11<script setup>
22import { ref , computed } from ' vue'
33import { useRoute } from ' vue-router'
4+ import { useLocalStorage } from ' @vueuse/core'
5+ import { useMetricsStore } from " ~/stores/metrics.js"
46
57const sideBar = ref (true )
68const toggleSideBar = (value ) => { sideBar .value = value ?? ! sideBar .value }
@@ -10,6 +12,27 @@ const route = useRoute()
1012
1113// only show sidebar when *not* on the onboarding page
1214const showSidebar = computed (() => ! route .path .startsWith (' /onboarding' ))
15+
16+ const metricsStore = useMetricsStore ()
17+ const cpuWarnThreshold = useLocalStorage (' metrics.cpuWarnThreshold' , 85 )
18+ const memWarnThreshold = useLocalStorage (' metrics.memWarnThreshold' , 85 )
19+ const diskWarnThreshold = useLocalStorage (' metrics.diskWarnThreshold' , 90 )
20+
21+ const globalAlerts = computed (() => {
22+ const snapshot = metricsStore .latestSnapshot
23+ if (! snapshot? .system ) return []
24+ const list = []
25+ if (snapshot .system .cpu_percent != null && snapshot .system .cpu_percent >= cpuWarnThreshold .value ) {
26+ list .push (` CPU ${ snapshot .system .cpu_percent .toFixed (1 )} %` )
27+ }
28+ if (snapshot .system .mem ? .percent != null && snapshot .system .mem .percent >= memWarnThreshold .value ) {
29+ list .push (` Memory ${ snapshot .system .mem .percent .toFixed (1 )} %` )
30+ }
31+ if (snapshot .system .disk ? .percent != null && snapshot .system .disk .percent >= diskWarnThreshold .value ) {
32+ list .push (` Disk ${ snapshot .system .disk .percent .toFixed (1 )} %` )
33+ }
34+ return list
35+ })
1336< / script>
1437
1538< template>
@@ -32,8 +55,16 @@ const showSidebar = computed(() => !route.path.startsWith('/onboarding'))
3255 < / div>
3356
3457 <!-- Main Content -->
35- < div class = " flex-1 overflow-auto" >
36- < slot / >
58+ < div class = " flex-1 min-h-0 flex flex-col" >
59+ < div v- if = " globalAlerts.length" class = " px-4 md:px-8 pt-2" >
60+ < div class = " rounded border border-amber-600/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-200" >
61+ < span class = " font-semibold" > System alerts: < / span>
62+ < span class = " ml-2" > {{ globalAlerts .join (' · ' ) }}< / span>
63+ < / div>
64+ < / div>
65+ < div class = " flex-1 min-h-0 overflow-y-auto overflow-x-hidden" >
66+ < slot / >
67+ < / div>
3768 < / div>
3869 < / div>
3970 < / div>
0 commit comments