The frontend/UI server, written in JS using the MarkoJS library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
742 B

  1. const moment = require("moment")
  2. module.exports = class {
  3. onCreate(input) {
  4. this.state = {
  5. modal: null,
  6. deleted: false,
  7. date: moment(input.data.time).format("MMM D, YYYY"),
  8. }
  9. }
  10. onInput(input) {
  11. if (input && input.data) {
  12. this.state.date = moment(input.data.time).format("MMM D, YYYY")
  13. }
  14. }
  15. open(modal) {
  16. this.state.modal = modal
  17. }
  18. close() {
  19. this.state.modal = null
  20. }
  21. removed() {
  22. this.state.deleted = true
  23. this.emit("removed")
  24. }
  25. sizeString(bytes) {
  26. const order = Math.floor(Math.log2(bytes) / 10)
  27. const unit = ["B", "KB", "MB", "GB", "TB", "PB"][order]
  28. const number = bytes / Math.pow(2, (order)*10)
  29. return `${number.toFixed(2)} ${unit}`
  30. }
  31. }