blob: 5db985cdacfd0f55ce22c278ddf86f81aa34cda8 [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';
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -07007import Overview from '@/views/Overview';
8import ProfileSettings from '@/views/ProfileSettings';
9import EventLogs from '@/views/Health/EventLogs';
10import HardwareStatus from '@/views/Health/HardwareStatus';
11import Sensors from '@/views/Health/Sensors';
12import Ldap from '@/views/AccessControl/Ldap';
13import LocalUserManagement from '@/views/AccessControl/LocalUserManagement';
14import SslCertificates from '@/views/AccessControl/SslCertificates';
15import DateTimeSettings from '@/views/Configuration/DateTimeSettings';
16import Firmware from '@/views/Configuration/Firmware';
17import Kvm from '@/views/Control/Kvm';
18import ManagePowerUsage from '@/views/Control/ManagePowerUsage';
19import NetworkSettings from '@/views/Configuration/NetworkSettings';
20import RebootBmc from '@/views/Control/RebootBmc';
21import ServerLed from '@/views/Control/ServerLed';
22import SerialOverLan from '@/views/Control/SerialOverLan';
23import ServerPowerOperations from '@/views/Control/ServerPowerOperations';
24import Unauthorized from '@/views/Unauthorized';
25import Login from '@/views/Login';
26import ChangePassword from '@/views/ChangePassword';
27import SerialOverLanConsole from '@/views/Control/SerialOverLan/SerialOverLanConsole';
28import KvmConsole from '@/views/Control/Kvm/KvmConsole';
Derick Montaguea2988f42020-01-17 13:46:30 -060029
30Vue.use(VueRouter);
31
Dixsie Wolmerscbcd2132020-01-30 20:58:37 -060032// Meta title is translated using i18n in App.vue and PageTitle.Vue
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -080033// Example meta: {title: 'appPageTitle.overview'}
Derick Montaguea2988f42020-01-17 13:46:30 -060034const routes = [
35 {
Derick Montaguefded0d12019-12-11 06:16:40 -060036 path: '/',
Derick Montaguee080a1a2019-12-04 16:30:08 -060037 meta: {
38 requiresAuth: true
39 },
40 component: AppLayout,
41 children: [
42 {
Derick Montaguefded0d12019-12-11 06:16:40 -060043 path: '',
Yoshie Muranakaf2b3e6c2020-04-28 09:36:45 -070044 name: 'overview',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -070045 component: Overview,
Derick Montaguec8636e52019-12-06 01:28:38 -060046 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -080047 title: 'appPageTitle.overview'
Derick Montaguec8636e52019-12-06 01:28:38 -060048 }
Derick Montaguee080a1a2019-12-04 16:30:08 -060049 },
50 {
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053051 path: '/profile-settings',
52 name: 'profile-settings',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -070053 component: ProfileSettings,
Sukanya Pandeyb1f559f2020-04-28 20:18:28 +053054 meta: {
55 title: 'appPageTitle.profileSettings'
56 }
57 },
58 {
Yoshie Muranaka6f102342020-05-05 09:45:39 -070059 path: '/health/event-logs',
60 name: 'event-logs',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -070061 component: EventLogs,
Yoshie Muranaka6f102342020-05-05 09:45:39 -070062 meta: {
63 title: 'appPageTitle.eventLogs'
64 }
65 },
66 {
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070067 path: '/health/hardware-status',
68 name: 'hardware-status',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -070069 component: HardwareStatus,
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070070 meta: {
71 title: 'appPageTitle.hardwareStatus'
72 }
73 },
74 {
Yoshie Muranaka30abccb2020-03-11 12:44:24 -070075 path: '/health/sensors',
Yoshie Muranakaf2b3e6c2020-04-28 09:36:45 -070076 name: 'sensors',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -070077 component: Sensors,
Yoshie Muranaka30abccb2020-03-11 12:44:24 -070078 meta: {
79 title: 'appPageTitle.sensors'
80 }
81 },
82 {
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -070083 path: '/access-control/ldap',
84 name: 'ldap',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -070085 component: Ldap,
Yoshie Muranakac4e38ab2020-04-09 12:41:27 -070086 meta: {
87 title: 'appPageTitle.ldap'
88 }
89 },
90 {
Derick Montaguefded0d12019-12-11 06:16:40 -060091 path: '/access-control/local-user-management',
92 name: 'local-users',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -070093 component: LocalUserManagement,
Derick Montaguec8636e52019-12-06 01:28:38 -060094 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -080095 title: 'appPageTitle.localUserManagement'
Derick Montaguec8636e52019-12-06 01:28:38 -060096 }
Derick Montague126eaab2019-12-23 13:33:52 -060097 },
98 {
Yoshie Muranaka37393812020-03-24 15:25:24 -070099 path: '/access-control/ssl-certificates',
100 name: 'ssl-certificates',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700101 component: SslCertificates,
Yoshie Muranaka37393812020-03-24 15:25:24 -0700102 meta: {
103 title: 'appPageTitle.sslCertificates'
104 }
105 },
106 {
Dixsie Wolmers739e4592020-06-05 07:00:06 -0500107 path: '/configuration/date-time-settings',
108 name: 'date-time-settings',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700109 component: DateTimeSettings,
Dixsie Wolmers739e4592020-06-05 07:00:06 -0500110 meta: {
111 title: 'appPageTitle.dateTimeSettings'
112 }
113 },
114 {
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700115 path: '/configuration/firmware',
116 name: 'firmware',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700117 component: Firmware,
Yoshie Muranaka92a0a4a2020-07-15 10:30:31 -0700118 meta: {
119 title: 'appPageTitle.firmware'
120 }
121 },
122 {
Mateusz Gapski632de222020-07-09 09:21:33 +0200123 path: '/control/kvm',
124 name: 'kvm',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700125 component: Kvm,
Mateusz Gapski632de222020-07-09 09:21:33 +0200126 meta: {
127 title: 'appPageTitle.kvm'
128 }
129 },
130 {
Sukanya Pandey9055d982020-03-31 17:37:53 +0530131 path: '/control/manage-power-usage',
132 name: 'manage-power-usage',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700133 component: ManagePowerUsage,
Sukanya Pandey9055d982020-03-31 17:37:53 +0530134 meta: {
135 title: 'appPageTitle.managePowerUsage'
136 }
137 },
138 {
Dixsie Wolmersbb81d552020-02-26 19:52:28 -0600139 path: '/configuration/network-settings',
140 name: 'network-settings',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700141 component: NetworkSettings,
Dixsie Wolmersbb81d552020-02-26 19:52:28 -0600142 meta: {
143 title: 'appPageTitle.networkSettings'
144 }
145 },
146 {
Yoshie Muranakac11d3892020-02-19 08:07:40 -0800147 path: '/control/reboot-bmc',
148 name: 'reboot-bmc',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700149 component: RebootBmc,
Yoshie Muranakac11d3892020-02-19 08:07:40 -0800150 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -0800151 title: 'appPageTitle.rebootBmc'
Yoshie Muranakac11d3892020-02-19 08:07:40 -0800152 }
153 },
154 {
SurenNeware090c2d42020-04-01 14:07:27 +0530155 path: '/control/server-led',
156 name: 'server-led',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700157 component: ServerLed,
SurenNeware090c2d42020-04-01 14:07:27 +0530158 meta: {
159 title: 'appPageTitle.serverLed'
160 }
161 },
162 {
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530163 path: '/control/serial-over-lan',
164 name: 'serial-over-lan',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700165 component: SerialOverLan,
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530166 meta: {
167 title: 'appPageTitle.serialOverLan'
168 }
169 },
170 {
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800171 path: '/control/server-power-operations',
172 name: 'server-power-operations',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700173 component: ServerPowerOperations,
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800174 meta: {
175 title: 'appPageTitle.serverPowerOperations'
176 }
177 },
178 {
Mateusz Gapski75100462020-07-30 11:01:29 +0200179 path: '/control/virtual-media',
180 name: 'virtual-media',
181 component: () => import('@/views/Control/VirtualMedia'),
182 meta: {
183 title: 'appPageTitle.virtualMedia'
184 }
185 },
186 {
Derick Montague126eaab2019-12-23 13:33:52 -0600187 path: '/unauthorized',
188 name: 'unauthorized',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700189 component: Unauthorized,
Derick Montague126eaab2019-12-23 13:33:52 -0600190 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -0800191 title: 'appPageTitle.unauthorized'
Derick Montague126eaab2019-12-23 13:33:52 -0600192 }
Derick Montaguee080a1a2019-12-04 16:30:08 -0600193 }
194 ]
Derick Montaguea2988f42020-01-17 13:46:30 -0600195 },
196 {
Derick Montaguefded0d12019-12-11 06:16:40 -0600197 path: '/login',
Yoshie Muranaka6173bc62020-06-16 12:39:07 -0700198 component: LoginLayout,
199 children: [
200 {
201 path: '',
202 name: 'login',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700203 component: Login,
Yoshie Muranaka6173bc62020-06-16 12:39:07 -0700204 meta: {
205 title: 'appPageTitle.login'
206 }
Yoshie Muranaka33058572020-06-16 13:21:21 -0700207 },
208 {
209 path: '/change-password',
210 name: 'change-password',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700211 component: ChangePassword,
Yoshie Muranaka33058572020-06-16 13:21:21 -0700212 meta: {
Yoshie Muranaka2c98b092020-06-22 13:28:09 -0700213 title: 'appPageTitle.changePassword',
214 requiresAuth: true
Yoshie Muranaka33058572020-06-16 13:21:21 -0700215 }
Yoshie Muranaka6173bc62020-06-16 12:39:07 -0700216 }
217 ]
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530218 },
219 {
220 path: '/console',
221 component: ConsoleLayout,
222 meta: {
223 requiresAuth: true
224 },
225 children: [
226 {
Mateusz Gapski632de222020-07-09 09:21:33 +0200227 path: 'serial-over-lan-console',
228 name: 'serial-over-lan-console',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700229 component: SerialOverLanConsole,
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530230 meta: {
231 title: 'appPageTitle.serialOverLan'
232 }
Mateusz Gapski632de222020-07-09 09:21:33 +0200233 },
234 {
235 path: 'kvm',
236 name: 'kvm-console',
Yoshie Muranaka2a7b5ac2020-08-17 13:25:00 -0700237 component: KvmConsole,
Mateusz Gapski632de222020-07-09 09:21:33 +0200238 meta: {
239 title: 'appPageTitle.kvm'
240 }
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530241 }
242 ]
Derick Montaguea2988f42020-01-17 13:46:30 -0600243 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600244];
245
246const router = new VueRouter({
Derick Montaguea2988f42020-01-17 13:46:30 -0600247 base: process.env.BASE_URL,
248 routes,
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800249 linkExactActiveClass: 'nav-link--current'
Derick Montaguea2988f42020-01-17 13:46:30 -0600250});
251
Derick Montaguee080a1a2019-12-04 16:30:08 -0600252router.beforeEach((to, from, next) => {
253 if (to.matched.some(record => record.meta.requiresAuth)) {
Derick Montaguefded0d12019-12-11 06:16:40 -0600254 if (store.getters['authentication/isLoggedIn']) {
Derick Montaguee080a1a2019-12-04 16:30:08 -0600255 next();
256 return;
257 }
Derick Montaguefded0d12019-12-11 06:16:40 -0600258 next('/login');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600259 } else {
260 next();
261 }
262});
263
Derick Montaguea2988f42020-01-17 13:46:30 -0600264export default router;