blob: f3b8d8a331086f56cc841ed5520d2921cf14975f [file] [log] [blame]
Derick Montaguefded0d12019-12-11 06:16:40 -06001import Vue from 'vue';
2import VueRouter from 'vue-router';
3import store from '../store/index';
4import AppLayout from '../layouts/AppLayout.vue';
Yoshie Muranaka6173bc62020-06-16 12:39:07 -07005import LoginLayout from '@/layouts/LoginLayout';
Sukanya Pandey96f69ca2020-05-20 15:32:57 +05306import ConsoleLayout from '@/layouts/ConsoleLayout.vue';
Derick Montaguea2988f42020-01-17 13:46:30 -06007
8Vue.use(VueRouter);
9
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060010// Meta title is translated using i18n in App.vue and PageTitle.Vue
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -080011// Example meta: {title: 'appPageTitle.overview'}
Derick Montaguea2988f42020-01-17 13:46:30 -060012const routes = [
13 {
Derick Montaguefded0d12019-12-11 06:16:40 -060014 path: '/',
Derick Montaguee080a1a2019-12-04 16:30:08 -060015 meta: {
16 requiresAuth: true
17 },
18 component: AppLayout,
19 children: [
20 {
Derick Montaguefded0d12019-12-11 06:16:40 -060021 path: '',
Yoshie Muranakaf2b3e6c2020-04-28 09:36:45 -070022 name: 'overview',
Derick Montaguefded0d12019-12-11 06:16:40 -060023 component: () => import('@/views/Overview'),
Derick Montaguec8636e52019-12-06 01:28:38 -060024 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -080025 title: 'appPageTitle.overview'
Derick Montaguec8636e52019-12-06 01:28:38 -060026 }
Derick Montaguee080a1a2019-12-04 16:30:08 -060027 },
28 {
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053029 path: '/profile-settings',
30 name: 'profile-settings',
31 component: () => import('@/views/ProfileSettings'),
32 meta: {
33 title: 'appPageTitle.profileSettings'
34 }
35 },
36 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -070037 path: '/health/event-logs',
38 name: 'event-logs',
39 component: () => import('@/views/Health/EventLogs'),
40 meta: {
41 title: 'appPageTitle.eventLogs'
42 }
43 },
44 {
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070045 path: '/health/hardware-status',
46 name: 'hardware-status',
47 component: () => import('@/views/Health/HardwareStatus'),
48 meta: {
49 title: 'appPageTitle.hardwareStatus'
50 }
51 },
52 {
Yoshie Muranaka30abccb2020-03-11 12:44:24 -070053 path: '/health/sensors',
Yoshie Muranakaf2b3e6c2020-04-28 09:36:45 -070054 name: 'sensors',
Yoshie Muranaka30abccb2020-03-11 12:44:24 -070055 component: () => import('@/views/Health/Sensors'),
56 meta: {
57 title: 'appPageTitle.sensors'
58 }
59 },
60 {
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -070061 path: '/access-control/ldap',
62 name: 'ldap',
63 component: () => import('@/views/AccessControl/Ldap'),
64 meta: {
65 title: 'appPageTitle.ldap'
66 }
67 },
68 {
Derick Montaguefded0d12019-12-11 06:16:40 -060069 path: '/access-control/local-user-management',
70 name: 'local-users',
71 component: () => import('@/views/AccessControl/LocalUserManagement'),
Derick Montaguec8636e52019-12-06 01:28:38 -060072 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -080073 title: 'appPageTitle.localUserManagement'
Derick Montaguec8636e52019-12-06 01:28:38 -060074 }
Derick Montague126eaab2019-12-23 13:33:52 -060075 },
76 {
Yoshie Muranaka37393812020-03-24 15:25:24 -070077 path: '/access-control/ssl-certificates',
78 name: 'ssl-certificates',
79 component: () => import('@/views/AccessControl/SslCertificates'),
80 meta: {
81 title: 'appPageTitle.sslCertificates'
82 }
83 },
84 {
Dixsie Wolmers739e4592020-06-05 07:00:06 -050085 path: '/configuration/date-time-settings',
86 name: 'date-time-settings',
87 component: () => import('@/views/Configuration/DateTimeSettings'),
88 meta: {
89 title: 'appPageTitle.dateTimeSettings'
90 }
91 },
92 {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -070093 path: '/configuration/firmware',
94 name: 'firmware',
95 component: () => import('@/views/Configuration/Firmware'),
96 meta: {
97 title: 'appPageTitle.firmware'
98 }
99 },
100 {
Mateusz Gapski632de222020-07-09 09:21:33 +0200101 path: '/control/kvm',
102 name: 'kvm',
103 component: () => import('@/views/Control/Kvm'),
104 meta: {
105 title: 'appPageTitle.kvm'
106 }
107 },
108 {
Sukanya Pandey9055d982020-03-31 17:37:53 +0530109 path: '/control/manage-power-usage',
110 name: 'manage-power-usage',
111 component: () => import('@/views/Control/ManagePowerUsage'),
112 meta: {
113 title: 'appPageTitle.managePowerUsage'
114 }
115 },
116 {
Dixsie Wolmersbb81d552020-02-26 19:52:28 -0600117 path: '/configuration/network-settings',
118 name: 'network-settings',
119 component: () => import('@/views/Configuration/NetworkSettings'),
120 meta: {
121 title: 'appPageTitle.networkSettings'
122 }
123 },
124 {
Yoshie Muranakac11d3892020-02-19 08:07:40 -0800125 path: '/control/reboot-bmc',
126 name: 'reboot-bmc',
127 component: () => import('@/views/Control/RebootBmc'),
128 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -0800129 title: 'appPageTitle.rebootBmc'
Yoshie Muranakac11d3892020-02-19 08:07:40 -0800130 }
131 },
132 {
SurenNeware090c2d42020-04-01 14:07:27 +0530133 path: '/control/server-led',
134 name: 'server-led',
135 component: () => import('@/views/Control/ServerLed'),
136 meta: {
137 title: 'appPageTitle.serverLed'
138 }
139 },
140 {
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530141 path: '/control/serial-over-lan',
142 name: 'serial-over-lan',
143 component: () => import('@/views/Control/SerialOverLan'),
144 meta: {
145 title: 'appPageTitle.serialOverLan'
146 }
147 },
148 {
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800149 path: '/control/server-power-operations',
150 name: 'server-power-operations',
151 component: () => import('@/views/Control/ServerPowerOperations'),
152 meta: {
153 title: 'appPageTitle.serverPowerOperations'
154 }
155 },
156 {
Derick Montague126eaab2019-12-23 13:33:52 -0600157 path: '/unauthorized',
158 name: 'unauthorized',
159 component: () => import('@/views/Unauthorized'),
160 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -0800161 title: 'appPageTitle.unauthorized'
Derick Montague126eaab2019-12-23 13:33:52 -0600162 }
Derick Montaguee080a1a2019-12-04 16:30:08 -0600163 }
164 ]
Derick Montaguea2988f42020-01-17 13:46:30 -0600165 },
166 {
Derick Montaguefded0d12019-12-11 06:16:40 -0600167 path: '/login',
Yoshie Muranaka6173bc62020-06-16 12:39:07 -0700168 component: LoginLayout,
169 children: [
170 {
171 path: '',
172 name: 'login',
173 component: () => import('@/views/Login'),
174 meta: {
175 title: 'appPageTitle.login'
176 }
Yoshie Muranaka33058572020-06-16 13:21:21 -0700177 },
178 {
179 path: '/change-password',
180 name: 'change-password',
181 component: () => import('@/views/ChangePassword'),
182 meta: {
Yoshie Muranaka2c98b092020-06-22 13:28:09 -0700183 title: 'appPageTitle.changePassword',
184 requiresAuth: true
Yoshie Muranaka33058572020-06-16 13:21:21 -0700185 }
Yoshie Muranaka6173bc62020-06-16 12:39:07 -0700186 }
187 ]
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530188 },
189 {
190 path: '/console',
191 component: ConsoleLayout,
192 meta: {
193 requiresAuth: true
194 },
195 children: [
196 {
Mateusz Gapski632de222020-07-09 09:21:33 +0200197 path: 'serial-over-lan-console',
198 name: 'serial-over-lan-console',
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530199 component: () =>
200 import('@/views/Control/SerialOverLan/SerialOverLanConsole'),
201 meta: {
202 title: 'appPageTitle.serialOverLan'
203 }
Mateusz Gapski632de222020-07-09 09:21:33 +0200204 },
205 {
206 path: 'kvm',
207 name: 'kvm-console',
208 component: () => import('@/views/Control/Kvm/KvmConsole'),
209 meta: {
210 title: 'appPageTitle.kvm'
211 }
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530212 }
213 ]
Derick Montaguea2988f42020-01-17 13:46:30 -0600214 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600215];
216
217const router = new VueRouter({
Derick Montaguea2988f42020-01-17 13:46:30 -0600218 base: process.env.BASE_URL,
219 routes,
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800220 linkExactActiveClass: 'nav-link--current'
Derick Montaguea2988f42020-01-17 13:46:30 -0600221});
222
Derick Montaguee080a1a2019-12-04 16:30:08 -0600223router.beforeEach((to, from, next) => {
224 if (to.matched.some(record => record.meta.requiresAuth)) {
Derick Montaguefded0d12019-12-11 06:16:40 -0600225 if (store.getters['authentication/isLoggedIn']) {
Derick Montaguee080a1a2019-12-04 16:30:08 -0600226 next();
227 return;
228 }
Derick Montaguefded0d12019-12-11 06:16:40 -0600229 next('/login');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600230 } else {
231 next();
232 }
233});
234
Derick Montaguea2988f42020-01-17 13:46:30 -0600235export default router;