feature: Degraded Operations Visibility
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { canAccessOps, defaultRouteForRole, isDashboardRole, roleCanAccessRoute } from '@/composables/roleAccess'
|
||||
|
||||
const CLINICAL = ['NURSE', 'PHYSICIAN', 'ADMIN']
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@@ -16,37 +19,67 @@ const routes = [
|
||||
path: '/ward',
|
||||
name: 'WardDashboard',
|
||||
component: () => import('@/views/WardDashboard.vue'),
|
||||
meta: { title: 'Virtual Ward', layout: 'default' },
|
||||
meta: { title: 'Virtual Ward', layout: 'default', allowedRoles: CLINICAL },
|
||||
},
|
||||
{
|
||||
path: '/departments',
|
||||
name: 'DepartmentOverview',
|
||||
component: () => import('@/views/DepartmentOverviewView.vue'),
|
||||
meta: { title: 'Department Overview', layout: 'default' },
|
||||
meta: { title: 'Department Overview', layout: 'default', allowedRoles: CLINICAL },
|
||||
},
|
||||
{
|
||||
path: '/patients/:encounterId',
|
||||
name: 'PatientDetail',
|
||||
component: () => import('@/views/PatientDetail.vue'),
|
||||
meta: { title: 'Patient Detail', layout: 'default' },
|
||||
meta: { title: 'Patient Detail', layout: 'default', allowedRoles: CLINICAL },
|
||||
},
|
||||
{
|
||||
path: '/alerts',
|
||||
name: 'AlertCenter',
|
||||
component: () => import('@/views/AlertCenter.vue'),
|
||||
meta: { title: 'Alert Center', layout: 'default' },
|
||||
meta: { title: 'Alert Center', layout: 'default', allowedRoles: CLINICAL },
|
||||
},
|
||||
{
|
||||
path: '/sepsis',
|
||||
name: 'SepsisBoard',
|
||||
component: () => import('@/views/SepsisBoardView.vue'),
|
||||
meta: { title: 'Sepsis Bundle Board', layout: 'default' },
|
||||
meta: { title: 'Sepsis Bundle Board', layout: 'default', allowedRoles: CLINICAL },
|
||||
},
|
||||
{
|
||||
path: '/feedback',
|
||||
name: 'FeedbackSummary',
|
||||
component: () => import('@/views/FeedbackSummary.vue'),
|
||||
meta: { title: 'Feedback Summary', layout: 'default' },
|
||||
meta: { title: 'Feedback Summary', layout: 'default', allowedRoles: ['PHYSICIAN', 'ADMIN'] },
|
||||
},
|
||||
{
|
||||
path: '/admin/thresholds',
|
||||
name: 'ThresholdManagement',
|
||||
component: () => import('@/views/ThresholdManagementView.vue'),
|
||||
meta: { title: 'Alert Thresholds', layout: 'default', allowedRoles: ['ADMIN'] },
|
||||
},
|
||||
{
|
||||
path: '/admin/users',
|
||||
name: 'UserManagement',
|
||||
component: () => import('@/views/UserManagementView.vue'),
|
||||
meta: { title: 'User Management', layout: 'default', allowedRoles: ['ADMIN'] },
|
||||
},
|
||||
{
|
||||
path: '/admin/audit',
|
||||
name: 'AuditLog',
|
||||
component: () => import('@/views/AuditLogView.vue'),
|
||||
meta: { title: 'Audit Logs', layout: 'default', allowedRoles: ['ADMIN'] },
|
||||
},
|
||||
{
|
||||
path: '/admin/reconciliation',
|
||||
name: 'Reconciliation',
|
||||
component: () => import('@/views/ReconciliationView.vue'),
|
||||
meta: { title: 'Data Quality', layout: 'default', allowedRoles: CLINICAL },
|
||||
},
|
||||
{
|
||||
path: '/operations/gateways',
|
||||
name: 'GatewayOperations',
|
||||
component: () => import('@/views/GatewayOperations.vue'),
|
||||
meta: { title: 'Gateway Operations', layout: 'default', opsRoute: true },
|
||||
},
|
||||
]
|
||||
|
||||
@@ -62,8 +95,14 @@ router.beforeEach((to) => {
|
||||
if (!to.meta.public && !auth.isAuthenticated) {
|
||||
return { path: '/login', query: { redirect: to.fullPath } }
|
||||
}
|
||||
if (to.path === '/login' && auth.isAuthenticated) {
|
||||
return { path: '/ward' }
|
||||
if (to.path === '/login' && auth.isAuthenticated && isDashboardRole(auth.role)) {
|
||||
return { path: defaultRouteForRole(auth.role) }
|
||||
}
|
||||
if (!to.meta.public && auth.isAuthenticated && to.meta.opsRoute && !canAccessOps(auth.role)) {
|
||||
return { path: defaultRouteForRole(auth.role) }
|
||||
}
|
||||
if (!to.meta.public && auth.isAuthenticated && !roleCanAccessRoute(auth.role, to.meta)) {
|
||||
return { path: defaultRouteForRole(auth.role) }
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user