-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.vue
More file actions
93 lines (79 loc) · 2.46 KB
/
app.vue
File metadata and controls
93 lines (79 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<script setup>
import { useProcessesStore } from "~/stores/processes.js";
import { useLogsStore } from "~/stores/logs.js";
import { useMetricsStore } from "~/stores/metrics.js";
import { useStatusStore } from "~/stores/status.js";
import { useAuthStore } from "~/stores/auth.js";
import axios from "axios";
const processesStore = useProcessesStore()
const logsStore = useLogsStore()
const metricsStore = useMetricsStore()
const statusStore = useStatusStore()
const authStore = useAuthStore()
const route = useRoute()
const metricsPollMs = 15000
let metricsRefreshTimer = null
const refreshMetricsSnapshot = async () => {
try {
const response = await axios.get('/api/metrics')
if (response?.data) {
metricsStore.latestSnapshot = response.data
}
} catch (err) {
console.warn('Failed to load metrics snapshot in app.vue:', err)
}
}
onMounted(async () => {
// Note: Auth initialization is handled by the middleware, not here
// Only load app data if we're authenticated and past the setup/login flow
// Don't load data if:
// 1. We're on the setup page (no users exist yet)
// 2. We're on the login page (not authenticated yet)
// 3. Auth is enabled but user isn't authenticated
const isAuthPage = route.path === '/setup' || route.path === '/login'
if (isAuthPage) {
console.log('Skipping data load on auth page:', route.path)
return
}
// If auth is enabled, wait until user is authenticated
if (authStore.isAuthEnabled && !authStore.isAuthenticated) {
console.log('Skipping data load - auth required but not authenticated')
return
}
try {
await processesStore.getProcesses()
} catch (err) {
console.warn('Failed to load processes in app.vue:', err)
}
try {
await logsStore.getAllLogs()
} catch (err) {
console.warn('Failed to load logs in app.vue:', err)
}
// Keep app-level alert context without a global metrics websocket.
await refreshMetricsSnapshot()
if (!metricsRefreshTimer) {
metricsRefreshTimer = setInterval(() => {
refreshMetricsSnapshot()
}, metricsPollMs)
}
// Keep service status live across all pages.
statusStore.resume({ interval: 2, health: true })
});
onBeforeUnmount(() => {
if (metricsRefreshTimer) {
clearInterval(metricsRefreshTimer)
metricsRefreshTimer = null
}
})
watchEffect(() => {
useHead({
titleTemplate: `${processesStore.projectName} Dashboard`,
});
});
</script>
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>