From 12ef9f39c51fac03f5a18ba4182a9a81328c662f Mon Sep 17 00:00:00 2001 From: Jasper Miller-Waugh Date: Mon, 1 Nov 2021 13:23:46 +1300 Subject: [PATCH] Merged buttons, cleaned up SS tag retrieval and made tagsVisible a bool. Also to note: due to the transition of tagsVisible this breaks compatibility with the previous commits, delete the tagsVisible setting in the database to fix. --- server/routers/api-router.js | 19 +++++++++++++------ src/pages/StatusPage.vue | 19 ++++++++++--------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index a5d1245..30f6a82 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -102,7 +102,7 @@ router.get("/api/status-page/config", async (_request, response) => { } if (! config.statusPageTags) { - config.statusPageTags = "hidden"; + config.statusPageTags = false; } if (! config.title) { @@ -144,15 +144,22 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request, try { await checkPublished(); const publicGroupList = []; - let list = await R.find("group", " public = 1 ORDER BY weight "); + const tagsVisible = (await getSettings("statusPage")).statusPageTags; + const list = await R.find("group", " public = 1 ORDER BY weight "); for (let groupBean of list) { - let monitorGroup = await groupBean.toPublicJSON() - if ((await getSettings("statusPage")).statusPageTags=="visible") { + let monitorGroup = await groupBean.toPublicJSON(); + if (tagsVisible) { monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map( async (monitor)=>{ // Includes tags as an array in response, allows for tags to be displayed on public status page - let tags = await R.getAll("SELECT mt.monitor_id,mt.value, tag.name, tag.color FROM monitor_tag mt JOIN tag ON mt.tag_id = tag.id WHERE mt.monitor_id = ?", [monitor.id]); + const tags = await R.getAll( + `SELECT monitor_tag.monitor_id, monitor_tag.value, tag.name, tag.color + FROM monitor_tag + JOIN tag + ON monitor_tag.tag_id = tag.id + WHERE monitor_tag.monitor_id = ?`, [monitor.id] + ); return {...monitor,tags: tags} - })) + })); } publicGroupList.push(monitorGroup); diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index 06be161..1320f09 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -78,14 +78,15 @@ {{ $t("Switch to Dark Theme") }} - - - @@ -499,7 +500,7 @@ export default { // We only include the tags if visible so we can reuse the logic to hide the tags on disable return { ...monitor, - tags: newState==="visible" ? this.$root.monitorList[monitor.id].tags : [] + tags: newState ? this.$root.monitorList[monitor.id].tags : [] } }) }