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.

40 lines
1.0 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: 0}
  9. if (req.query.characters) {
  10. filter.characters = req.query.characters.split(",")
  11. }
  12. if (req.query.channels) {
  13. filter.channels = req.query.channels.split(",")
  14. }
  15. if (req.query.events) {
  16. filter.events = req.query.events.split(",")
  17. }
  18. if (req.query.search) {
  19. filter.search = req.query.search
  20. }
  21. try {
  22. res.markoAsync(listTemplate, {
  23. filter: filter,
  24. logs: logHeaderApi.list(filter),
  25. characters: charactersApi.listHeaders(),
  26. channels: channelApi.list(),
  27. eventNames: logHeaderApi.eventNames(),
  28. selected: {index: true},
  29. })
  30. } catch(err) {
  31. console.error(err)
  32. }
  33. })
  34. module.exports = router