blob: 0da37fa8e91e94808d7b9ed86be6b8bda044617d [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 {
Sukanya Pandey9055d982020-03-31 17:37:53 +053093 path: '/control/manage-power-usage',
94 name: 'manage-power-usage',
95 component: () => import('@/views/Control/ManagePowerUsage'),
96 meta: {
97 title: 'appPageTitle.managePowerUsage'
98 }
99 },
100 {
Dixsie Wolmersbb81d552020-02-26 19:52:28 -0600101 path: '/configuration/network-settings',
102 name: 'network-settings',
103 component: () => import('@/views/Configuration/NetworkSettings'),
104 meta: {
105 title: 'appPageTitle.networkSettings'
106 }
107 },
108 {
Yoshie Muranakac11d3892020-02-19 08:07:40 -0800109 path: '/control/reboot-bmc',
110 name: 'reboot-bmc',
111 component: () => import('@/views/Control/RebootBmc'),
112 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -0800113 title: 'appPageTitle.rebootBmc'
Yoshie Muranakac11d3892020-02-19 08:07:40 -0800114 }
115 },
116 {
SurenNeware090c2d42020-04-01 14:07:27 +0530117 path: '/control/server-led',
118 name: 'server-led',
119 component: () => import('@/views/Control/ServerLed'),
120 meta: {
121 title: 'appPageTitle.serverLed'
122 }
123 },
124 {
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530125 path: '/control/serial-over-lan',
126 name: 'serial-over-lan',
127 component: () => import('@/views/Control/SerialOverLan'),
128 meta: {
129 title: 'appPageTitle.serialOverLan'
130 }
131 },
132 {
Yoshie Muranakafa1512b2020-02-25 15:54:07 -0800133 path: '/control/server-power-operations',
134 name: 'server-power-operations',
135 component: () => import('@/views/Control/ServerPowerOperations'),
136 meta: {
137 title: 'appPageTitle.serverPowerOperations'
138 }
139 },
140 {
Derick Montague126eaab2019-12-23 13:33:52 -0600141 path: '/unauthorized',
142 name: 'unauthorized',
143 component: () => import('@/views/Unauthorized'),
144 meta: {
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -0800145 title: 'appPageTitle.unauthorized'
Derick Montague126eaab2019-12-23 13:33:52 -0600146 }
Derick Montaguee080a1a2019-12-04 16:30:08 -0600147 }
148 ]
Derick Montaguea2988f42020-01-17 13:46:30 -0600149 },
150 {
Derick Montaguefded0d12019-12-11 06:16:40 -0600151 path: '/login',
Yoshie Muranaka6173bc62020-06-16 12:39:07 -0700152 component: LoginLayout,
153 children: [
154 {
155 path: '',
156 name: 'login',
157 component: () => import('@/views/Login'),
158 meta: {
159 title: 'appPageTitle.login'
160 }
Yoshie Muranaka33058572020-06-16 13:21:21 -0700161 },
162 {
163 path: '/change-password',
164 name: 'change-password',
165 component: () => import('@/views/ChangePassword'),
166 meta: {
Yoshie Muranaka2c98b092020-06-22 13:28:09 -0700167 title: 'appPageTitle.changePassword',
168 requiresAuth: true
Yoshie Muranaka33058572020-06-16 13:21:21 -0700169 }
Yoshie Muranaka6173bc62020-06-16 12:39:07 -0700170 }
171 ]
Sukanya Pandey96f69ca2020-05-20 15:32:57 +0530172 },
173 {
174 path: '/console',
175 component: ConsoleLayout,
176 meta: {
177 requiresAuth: true
178 },
179 children: [
180 {
181 path: '/console/serial-over-lan-console',
182 name: 'serial-over-lan',
183 component: () =>
184 import('@/views/Control/SerialOverLan/SerialOverLanConsole'),
185 meta: {
186 title: 'appPageTitle.serialOverLan'
187 }
188 }
189 ]
Derick Montaguea2988f42020-01-17 13:46:30 -0600190 }
Derick Montaguea2988f42020-01-17 13:46:30 -0600191];
192
193const router = new VueRouter({
Derick Montaguea2988f42020-01-17 13:46:30 -0600194 base: process.env.BASE_URL,
195 routes,
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800196 linkExactActiveClass: 'nav-link--current'
Derick Montaguea2988f42020-01-17 13:46:30 -0600197});
198
Derick Montaguee080a1a2019-12-04 16:30:08 -0600199router.beforeEach((to, from, next) => {
200 if (to.matched.some(record => record.meta.requiresAuth)) {
Derick Montaguefded0d12019-12-11 06:16:40 -0600201 if (store.getters['authentication/isLoggedIn']) {
Derick Montaguee080a1a2019-12-04 16:30:08 -0600202 next();
203 return;
204 }
Derick Montaguefded0d12019-12-11 06:16:40 -0600205 next('/login');
Derick Montaguee080a1a2019-12-04 16:30:08 -0600206 } else {
207 next();
208 }
209});
210
Derick Montaguea2988f42020-01-17 13:46:30 -0600211export default router;