diff --git a/frontend/index.html b/frontend/index.html index fbbf46b..df68c5c 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -3,6 +3,7 @@ + Key-IP Sentinel diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 950ad34..eb2443e 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -3,11 +3,15 @@ import { computed, onBeforeUnmount, onMounted, ref } from 'vue' import { useRoute, useRouter } from 'vue-router' import { clearAuthToken } from './api' +import { subscribeToAnnouncements } from './utils/liveRegion' const route = useRoute() const router = useRouter() const clockLabel = ref('') +const liveMessage = ref('') let clockTimer +let clearAnnouncementTimer +let unsubscribeAnnouncements = () => {} const navItems = [ { label: 'Dashboard', name: 'dashboard', icon: 'DataAnalysis' }, @@ -34,19 +38,34 @@ async function logout() { onMounted(() => { updateClock() clockTimer = window.setInterval(updateClock, 60000) + unsubscribeAnnouncements = subscribeToAnnouncements((message) => { + liveMessage.value = message + if (clearAnnouncementTimer) { + window.clearTimeout(clearAnnouncementTimer) + } + clearAnnouncementTimer = window.setTimeout(() => { + liveMessage.value = '' + }, 3000) + }) }) onBeforeUnmount(() => { if (clockTimer) { window.clearInterval(clockTimer) } + if (clearAnnouncementTimer) { + window.clearTimeout(clearAnnouncementTimer) + } + unsubscribeAnnouncements() })