Added toggle for tag visibility

This commit is contained in:
Jasper Miller-Waugh
2021-10-29 18:19:24 +13:00
parent 24664cde2c
commit b32bfb3ff1
2 changed files with 44 additions and 5 deletions

View File

@@ -101,6 +101,10 @@ router.get("/api/status-page/config", async (_request, response) => {
config.statusPagePublished = true;
}
if (! config.statusPageTags) {
config.statusPageTags = "hidden";
}
if (! config.title) {
config.title = "Uptime Kuma";
}
@@ -143,11 +147,15 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request,
let list = await R.find("group", " public = 1 ORDER BY weight ");
for (let groupBean of list) {
let monitorGroup = await groupBean.toPublicJSON()
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]);
return {...monitor,tags: tags}
}))
console.log("\n\nsettings", await getSettings("statusPage"))
if ((await getSettings("statusPage")).statusPageTags=="visible") {
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]);
return {...monitor,tags: tags}
}))
}
publicGroupList.push(monitorGroup);
}