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.

47 lines
1.2 KiB

6 years ago
6 years ago
6 years ago
6 years ago
  1. const express = require("express")
  2. const router = express.Router()
  3. const {logHeaderApi, eventNames} = require("../../rpdata/api/LogHeader")
  4. const {charactersApi} = require("../../rpdata/api/Character")
  5. const {channelApi} = require("../../rpdata/api/Channel")
  6. const listTemplate = require("../../marko/page/logs/list.marko")
  7. router.get("/", async(req, res) => {
  8. const filter = {limit: 75}
  9. if (req.query.characters) {
  10. filter.characters = req.query.characters.split(",")
  11. filter.limit = 0
  12. }
  13. if (req.query.channels) {
  14. filter.channels = req.query.channels.split(",")
  15. filter.limit = 0
  16. }
  17. if (req.query.events) {
  18. filter.events = req.query.events.split(",")
  19. filter.limit = 0
  20. }
  21. if (req.query.search) {
  22. filter.search = req.query.search
  23. filter.limit = 0
  24. }
  25. if (req.query.limit) {
  26. filter.limit = parseInt(req.query.limit)
  27. }
  28. try {
  29. res.markoAsync(listTemplate, {
  30. filter: filter,
  31. logs: logHeaderApi.list(filter),
  32. characters: charactersApi.listHeaders(),
  33. channels: channelApi.list(),
  34. eventNames: logHeaderApi.eventNames(),
  35. selected: {index: true},
  36. })
  37. } catch(err) {
  38. console.error(err)
  39. }
  40. })
  41. module.exports = router