Jasper Miller-Waugh
3 years ago
No known key found for this signature in database
GPG Key ID: 2A5F6F15443A805
2 changed files with
44 additions and
5 deletions
server/routers/api-router.js
src/pages/StatusPage.vue
@ -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 ( )
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 ) ;
}
@ -77,6 +77,16 @@
< font -awesome -icon icon = "save" / >
{ { $t ( "Switch to Dark Theme" ) } }
< / button >
< button v-if ="tagsVisible == 'hidden'" class="btn btn-secondary me-2" @click="changeTagsVisibilty('visible')" >
< font -awesome -icon icon = "eye" / >
{ { $t ( "Show Tags" ) } }
< / button >
< button v-if ="tagsVisible == 'visible'" class="btn btn-secondary me-2" @click="changeTagsVisibilty('hidden')" >
< font -awesome -icon icon = "eye-slash" / >
{ { $t ( "Hide Tags" ) } }
< / button >
< / div >
< / div >
@ -292,6 +302,10 @@ export default {
return this . config . statusPageTheme ;
} ,
tagsVisible ( ) {
return this . config . statusPageTags
} ,
logoClass ( ) {
if ( this . editMode ) {
return {
@ -472,6 +486,23 @@ export default {
changeTheme ( name ) {
this . config . statusPageTheme = name ;
} ,
changeTagsVisibilty ( newState ) {
this . config . statusPageTags = newState ;
/ / O n l o a d , i f t h e s t a t u s p a g e w i l l n o t i n c l u d e t a g s i f i t ' s n o t e n a b l e d f o r s e c u r i t y r e a s o n s
/ / W h i c h m e a n s i f w e e n a b l e t a g s , i t w o n ' t s h o w i n t h e U I u n t i l s a v e d
/ / S o w e h a v e t h i s t o e n h a n c e U X a n d l o a d i n t h e t a g s f r o m t h e a u t h e n t i c a t e d s o u r c e i n s t a n t l y
this . $root . publicGroupList = this . $root . publicGroupList . map ( ( group ) => {
return { ... group ,
monitorList : group . monitorList . map ( ( monitor ) => {
/ / W e o n l y i n c l u d e t h e t a g s i f v i s i b l e s o w e c a n r e u s e t h e l o g i c t o h i d e t h e t a g s o n d i s a b l e
return { ... monitor ,
tags : newState === "visible" ? this . $root . monitorList [ monitor . id ] . tags : [ ]
}
} )
}
} ) ;
} ,
/ * *
* Crop Success