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.
This commit is contained in:
Jasper Miller-Waugh 2021-11-01 13:23:46 +13:00
parent 4004926e64
commit 12ef9f39c5
No known key found for this signature in database
GPG key ID: 02A5F6F15443A805
2 changed files with 23 additions and 15 deletions

View file

@ -102,7 +102,7 @@ router.get("/api/status-page/config", async (_request, response) => {
} }
if (! config.statusPageTags) { if (! config.statusPageTags) {
config.statusPageTags = "hidden"; config.statusPageTags = false;
} }
if (! config.title) { if (! config.title) {
@ -144,15 +144,22 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request,
try { try {
await checkPublished(); await checkPublished();
const publicGroupList = []; 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) { for (let groupBean of list) {
let monitorGroup = await groupBean.toPublicJSON() let monitorGroup = await groupBean.toPublicJSON();
if ((await getSettings("statusPage")).statusPageTags=="visible") { if (tagsVisible) {
monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map( async (monitor)=>{ 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 // 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} return {...monitor,tags: tags}
})) }));
} }
publicGroupList.push(monitorGroup); publicGroupList.push(monitorGroup);

View file

@ -78,14 +78,15 @@
{{ $t("Switch to Dark Theme") }} {{ $t("Switch to Dark Theme") }}
</button> </button>
<button v-if="tagsVisible == 'hidden'" class="btn btn-secondary me-2" @click="changeTagsVisibilty('visible')"> <button class="btn btn-secondary me-2" @click="changeTagsVisibilty(!tagsVisible)">
<font-awesome-icon icon="eye" /> <template v-if="tagsVisible">
{{ $t("Show Tags") }} <font-awesome-icon icon="eye-slash" />
</button> {{ $t("Hide Tags") }}
</template>
<button v-if="tagsVisible == 'visible'" class="btn btn-secondary me-2" @click="changeTagsVisibilty('hidden')"> <template v-else>
<font-awesome-icon icon="eye-slash" /> <font-awesome-icon icon="eye" />
{{ $t("Hide Tags") }} {{ $t("Show Tags") }}
</template>
</button> </button>
</div> </div>
</div> </div>
@ -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 // We only include the tags if visible so we can reuse the logic to hide the tags on disable
return { return {
...monitor, ...monitor,
tags: newState==="visible" ? this.$root.monitorList[monitor.id].tags : [] tags: newState ? this.$root.monitorList[monitor.id].tags : []
} }
}) })
} }