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.

49 lines
942 B

  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. name: "",
  10. locationName: "",
  11. eventName: "",
  12. logged: false,
  13. }
  14. }
  15. }
  16. change(key, ev) {
  17. this.state.values = Object.assign({}, this.state.values, {[key]: ev.target.value})
  18. }
  19. open() {
  20. }
  21. close() {
  22. this.emit("close")
  23. }
  24. save() {
  25. if (this.state.loading) {
  26. return
  27. }
  28. const input = Object.assign({}, this.state.values)
  29. this.state.loading = true
  30. channelApi.add(input).then((res) => {
  31. this.emit("added", res)
  32. this.emit("close")
  33. }).catch(errs => {
  34. console.warn("Failed to add:", errs)
  35. this.state.error = "Failed to add: " + JSON.stringify(errs)
  36. }).then(() => {
  37. this.state.loading = false
  38. })
  39. }
  40. }