main
ts 152 lines 3.24 KB
Raw
1 import type { FormType } from "@/components/auth/types"
2 import { createRouter, createWebHistory } from "vue-router"
3 import { RouteRole } from "@/types/auth"
4 import { Layout } from "@/types/theme"
5 import { authCheck } from "@/utils/auth"
6 import AuthPage from "@/views/Auth.vue"
7 import Overview from "@/views/Overview.vue"
8
9 const router = createRouter({
10 history: createWebHistory(import.meta.env.BASE_URL),
11 routes: [
12 {
13 path: "/",
14 redirect: "/overview"
15 },
16 {
17 path: "/overview",
18 name: "Overview",
19 component: Overview,
20 meta: { title: "Overview", auth: true, roles: RouteRole.All }
21 },
22 {
23 path: "/alerts",
24 meta: {
25 auth: true,
26 roles: RouteRole.All
27 },
28 children: [
29 {
30 path: "",
31 name: "AlertsList",
32 component: () => import("@/views/Alerts/List.vue"),
33 meta: { title: "Alerts" }
34 },
35 {
36 path: ":id",
37 name: "AlertDetails",
38 component: () => import("@/views/Alerts/Details.vue"),
39 meta: { title: "Alert Details", skipPin: true }
40 }
41 ]
42 },
43 {
44 path: "/cases",
45 meta: {
46 auth: true,
47 roles: RouteRole.All
48 },
49 children: [
50 {
51 path: "",
52 name: "CasesList",
53 component: () => import("@/views/Cases/List.vue"),
54 meta: { title: "Cases" }
55 },
56 {
57 path: ":id",
58 name: "CaseDetails",
59 component: () => import("@/views/Cases/Details.vue"),
60 meta: { title: "Case Details", skipPin: true }
61 }
62 ]
63 },
64 {
65 path: "/agents",
66 meta: {
67 auth: true,
68 roles: RouteRole.All
69 },
70 children: [
71 {
72 path: "",
73 name: "AgentsList",
74 component: () => import("@/views/Agents/List.vue"),
75 meta: { title: "Agents" }
76 },
77 {
78 path: ":id",
79 name: "AgentDetails",
80 component: () => import("@/views/Agents/Details.vue"),
81 meta: { title: "Agent Details", skipPin: true }
82 }
83 ]
84 },
85 {
86 path: "/event-search",
87 name: "EventSearch",
88 component: () => import("@/views/EventSearch.vue"),
89 meta: { title: "Event Search", auth: true, roles: RouteRole.All }
90 },
91 {
92 path: "/dashboards",
93 meta: {
94 auth: true,
95 roles: RouteRole.All
96 },
97 children: [
98 {
99 path: "",
100 name: "DashboardsList",
101 component: () => import("@/views/Dashboards/List.vue"),
102 meta: { title: "Dashboards" }
103 },
104 {
105 path: ":id",
106 name: "DashboardView",
107 component: () => import("@/views/Dashboards/Overview.vue"),
108 meta: { title: "Dashboard Details", skipPin: true }
109 }
110 ]
111 },
112
113 {
114 path: "/profile",
115 name: "Profile",
116 component: () => import("@/views/Profile.vue"),
117 meta: { title: "Profile", auth: true, roles: RouteRole.All }
118 },
119 {
120 path: "/login",
121 name: "Login",
122 component: AuthPage,
123 props: { formType: "signin" as FormType },
124 meta: {
125 title: "Login",
126 theme: { layout: Layout.Blank, boxed: { enabled: false }, padded: { enabled: false } },
127 checkAuth: true,
128 skipPin: true
129 }
130 },
131 {
132 path: "/logout",
133 name: "Logout",
134 redirect: "/login"
135 },
136 {
137 path: "/:pathMatch(.*)*",
138 name: "NotFound",
139 component: () => import("@/views/NotFound.vue"),
140 meta: {
141 theme: { layout: Layout.Blank, boxed: { enabled: false }, padded: { enabled: false } },
142 skipPin: true
143 }
144 }
145 ]
146 })
147
148 router.beforeEach(route => {
149 return authCheck(route)
150 })
151
152 export default router