feature: Simulation Control Center (Dashboard)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useSimulationStore } from '@/stores/simulation'
|
||||
import { canAccessOps, defaultRouteForRole, isDashboardRole, roleCanAccessRoute } from '@/composables/roleAccess'
|
||||
|
||||
const CLINICAL = ['NURSE', 'PHYSICIAN', 'ADMIN']
|
||||
@@ -45,6 +46,12 @@ const routes = [
|
||||
component: () => import('@/views/SepsisBoardView.vue'),
|
||||
meta: { title: 'Sepsis Bundle Board', layout: 'default', allowedRoles: CLINICAL },
|
||||
},
|
||||
{
|
||||
path: '/simulation',
|
||||
name: 'SimulationControl',
|
||||
component: () => import('@/views/SimulationControlView.vue'),
|
||||
meta: { title: 'Simulation', layout: 'default', allowedRoles: CLINICAL, requiresSimulation: true },
|
||||
},
|
||||
{
|
||||
path: '/admin/thresholds',
|
||||
name: 'ThresholdManagement',
|
||||
@@ -92,7 +99,7 @@ const router = createRouter({
|
||||
routes,
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
router.beforeEach(async (to) => {
|
||||
document.title = `${to.meta.title ?? 'VigilCare'} — VigilCare`
|
||||
|
||||
const auth = useAuthStore()
|
||||
@@ -108,6 +115,15 @@ router.beforeEach((to) => {
|
||||
if (!to.meta.public && auth.isAuthenticated && !roleCanAccessRoute(auth.role, to.meta)) {
|
||||
return { path: defaultRouteForRole(auth.role) }
|
||||
}
|
||||
if (to.meta.requiresSimulation && auth.isAuthenticated) {
|
||||
const simulation = useSimulationStore()
|
||||
if (!simulation.enabled) {
|
||||
await simulation.loadConfig()
|
||||
}
|
||||
if (!simulation.enabled) {
|
||||
return { path: '/ward' }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user