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.

50 lines
915 B

  1. const {fileApi} = require("../../../../../rpdata/api/File")
  2. module.exports = class {
  3. onCreate(input) {
  4. this.state = {
  5. error: null,
  6. loading: false,
  7. values: {
  8. id: "",
  9. }
  10. }
  11. }
  12. onInput(input) {
  13. this.state.values = {
  14. id: input.file.id,
  15. }
  16. }
  17. change(key, ev) {
  18. this.state.values = Object.assign({}, this.state.values, {[key]: ev.target.value})
  19. }
  20. open() {
  21. }
  22. close() {
  23. this.emit("close")
  24. }
  25. doIt() {
  26. if (this.state.loading) {
  27. return
  28. }
  29. const input = Object.assign({}, this.state.values)
  30. this.state.loading = true
  31. fileApi.removeFile(input).then((res) => {
  32. this.emit("removed", res)
  33. this.emit("close")
  34. }).catch(errs => {
  35. console.warn("Failed to add:", errs)
  36. this.state.error = "Failed to add: " + JSON.stringify(errs)
  37. }).then(() => {
  38. this.state.loading = false
  39. })
  40. }
  41. }