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.

56 lines
1.1 KiB

  1. const moment = require("moment")
  2. const {channelApi} = require("../../../../../rpdata/api/Channel")
  3. module.exports = class {
  4. onCreate(input) {
  5. this.state = {
  6. error: null,
  7. loading: false,
  8. values: {
  9. locationName: "",
  10. eventName: "",
  11. logged: false,
  12. }
  13. }
  14. }
  15. change(key, ev) {
  16. this.state.values = Object.assign({}, this.state.values, {[key]: ev.target.value})
  17. }
  18. onInput(input) {
  19. this.state.values = {
  20. eventName: input.channel.eventName,
  21. locationName: input.channel.locationName,
  22. logged: input.channel.logged,
  23. }
  24. }
  25. open() {
  26. }
  27. close() {
  28. this.emit("close")
  29. }
  30. save() {
  31. if (this.state.loading) {
  32. return
  33. }
  34. const input = Object.assign({name: this.input.channel.name}, this.state.values)
  35. this.state.loading = true
  36. channelApi.edit(input).then((res) => {
  37. this.emit("edited", res)
  38. this.emit("close")
  39. }).catch(errs => {
  40. console.warn("Failed to edit:", errs)
  41. this.state.error = "Failed to edit: " + errs[0].message
  42. }).then(() => {
  43. this.state.loading = false
  44. })
  45. }
  46. }