Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 1 | import Vue from 'vue'; |
| 2 | import VueRouter from 'vue-router'; |
| 3 | import store from '../store/index'; |
| 4 | import AppLayout from '../layouts/AppLayout.vue'; |
Yoshie Muranaka | 6173bc6 | 2020-06-16 12:39:07 -0700 | [diff] [blame] | 5 | import LoginLayout from '@/layouts/LoginLayout'; |
Sukanya Pandey | 96f69ca | 2020-05-20 15:32:57 +0530 | [diff] [blame] | 6 | import ConsoleLayout from '@/layouts/ConsoleLayout.vue'; |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 7 | import Overview from '@/views/Overview'; |
| 8 | import ProfileSettings from '@/views/ProfileSettings'; |
| 9 | import EventLogs from '@/views/Health/EventLogs'; |
| 10 | import HardwareStatus from '@/views/Health/HardwareStatus'; |
| 11 | import Sensors from '@/views/Health/Sensors'; |
| 12 | import Ldap from '@/views/AccessControl/Ldap'; |
| 13 | import LocalUserManagement from '@/views/AccessControl/LocalUserManagement'; |
| 14 | import SslCertificates from '@/views/AccessControl/SslCertificates'; |
| 15 | import DateTimeSettings from '@/views/Configuration/DateTimeSettings'; |
| 16 | import Firmware from '@/views/Configuration/Firmware'; |
| 17 | import Kvm from '@/views/Control/Kvm'; |
| 18 | import ManagePowerUsage from '@/views/Control/ManagePowerUsage'; |
| 19 | import NetworkSettings from '@/views/Configuration/NetworkSettings'; |
| 20 | import RebootBmc from '@/views/Control/RebootBmc'; |
| 21 | import ServerLed from '@/views/Control/ServerLed'; |
| 22 | import SerialOverLan from '@/views/Control/SerialOverLan'; |
| 23 | import ServerPowerOperations from '@/views/Control/ServerPowerOperations'; |
| 24 | import Unauthorized from '@/views/Unauthorized'; |
| 25 | import Login from '@/views/Login'; |
| 26 | import ChangePassword from '@/views/ChangePassword'; |
| 27 | import SerialOverLanConsole from '@/views/Control/SerialOverLan/SerialOverLanConsole'; |
| 28 | import KvmConsole from '@/views/Control/Kvm/KvmConsole'; |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 29 | |
| 30 | Vue.use(VueRouter); |
| 31 | |
Dixsie Wolmers | cbcd213 | 2020-01-30 20:58:37 -0600 | [diff] [blame] | 32 | // Meta title is translated using i18n in App.vue and PageTitle.Vue |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 33 | // Example meta: {title: 'appPageTitle.overview'} |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 34 | const routes = [ |
| 35 | { |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 36 | path: '/', |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 37 | meta: { |
| 38 | requiresAuth: true |
| 39 | }, |
| 40 | component: AppLayout, |
| 41 | children: [ |
| 42 | { |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 43 | path: '', |
Yoshie Muranaka | f2b3e6c | 2020-04-28 09:36:45 -0700 | [diff] [blame] | 44 | name: 'overview', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 45 | component: Overview, |
Derick Montague | c8636e5 | 2019-12-06 01:28:38 -0600 | [diff] [blame] | 46 | meta: { |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 47 | title: 'appPageTitle.overview' |
Derick Montague | c8636e5 | 2019-12-06 01:28:38 -0600 | [diff] [blame] | 48 | } |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 49 | }, |
| 50 | { |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 51 | path: '/profile-settings', |
| 52 | name: 'profile-settings', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 53 | component: ProfileSettings, |
Sukanya Pandey | b1f559f | 2020-04-28 20:18:28 +0530 | [diff] [blame] | 54 | meta: { |
| 55 | title: 'appPageTitle.profileSettings' |
| 56 | } |
| 57 | }, |
| 58 | { |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 59 | path: '/health/event-logs', |
| 60 | name: 'event-logs', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 61 | component: EventLogs, |
Yoshie Muranaka | 6f10234 | 2020-05-05 09:45:39 -0700 | [diff] [blame] | 62 | meta: { |
| 63 | title: 'appPageTitle.eventLogs' |
| 64 | } |
| 65 | }, |
| 66 | { |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 67 | path: '/health/hardware-status', |
| 68 | name: 'hardware-status', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 69 | component: HardwareStatus, |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 70 | meta: { |
| 71 | title: 'appPageTitle.hardwareStatus' |
| 72 | } |
| 73 | }, |
| 74 | { |
Yoshie Muranaka | 30abccb | 2020-03-11 12:44:24 -0700 | [diff] [blame] | 75 | path: '/health/sensors', |
Yoshie Muranaka | f2b3e6c | 2020-04-28 09:36:45 -0700 | [diff] [blame] | 76 | name: 'sensors', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 77 | component: Sensors, |
Yoshie Muranaka | 30abccb | 2020-03-11 12:44:24 -0700 | [diff] [blame] | 78 | meta: { |
| 79 | title: 'appPageTitle.sensors' |
| 80 | } |
| 81 | }, |
| 82 | { |
Yoshie Muranaka | c4e38ab | 2020-04-09 12:41:27 -0700 | [diff] [blame] | 83 | path: '/access-control/ldap', |
| 84 | name: 'ldap', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 85 | component: Ldap, |
Yoshie Muranaka | c4e38ab | 2020-04-09 12:41:27 -0700 | [diff] [blame] | 86 | meta: { |
| 87 | title: 'appPageTitle.ldap' |
| 88 | } |
| 89 | }, |
| 90 | { |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 91 | path: '/access-control/local-user-management', |
| 92 | name: 'local-users', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 93 | component: LocalUserManagement, |
Derick Montague | c8636e5 | 2019-12-06 01:28:38 -0600 | [diff] [blame] | 94 | meta: { |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 95 | title: 'appPageTitle.localUserManagement' |
Derick Montague | c8636e5 | 2019-12-06 01:28:38 -0600 | [diff] [blame] | 96 | } |
Derick Montague | 126eaab | 2019-12-23 13:33:52 -0600 | [diff] [blame] | 97 | }, |
| 98 | { |
Yoshie Muranaka | 3739381 | 2020-03-24 15:25:24 -0700 | [diff] [blame] | 99 | path: '/access-control/ssl-certificates', |
| 100 | name: 'ssl-certificates', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 101 | component: SslCertificates, |
Yoshie Muranaka | 3739381 | 2020-03-24 15:25:24 -0700 | [diff] [blame] | 102 | meta: { |
| 103 | title: 'appPageTitle.sslCertificates' |
| 104 | } |
| 105 | }, |
| 106 | { |
Dixsie Wolmers | 739e459 | 2020-06-05 07:00:06 -0500 | [diff] [blame] | 107 | path: '/configuration/date-time-settings', |
| 108 | name: 'date-time-settings', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 109 | component: DateTimeSettings, |
Dixsie Wolmers | 739e459 | 2020-06-05 07:00:06 -0500 | [diff] [blame] | 110 | meta: { |
| 111 | title: 'appPageTitle.dateTimeSettings' |
| 112 | } |
| 113 | }, |
| 114 | { |
Yoshie Muranaka | 92a0a4a | 2020-07-15 10:30:31 -0700 | [diff] [blame] | 115 | path: '/configuration/firmware', |
| 116 | name: 'firmware', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 117 | component: Firmware, |
Yoshie Muranaka | 92a0a4a | 2020-07-15 10:30:31 -0700 | [diff] [blame] | 118 | meta: { |
| 119 | title: 'appPageTitle.firmware' |
| 120 | } |
| 121 | }, |
| 122 | { |
Mateusz Gapski | 632de22 | 2020-07-09 09:21:33 +0200 | [diff] [blame] | 123 | path: '/control/kvm', |
| 124 | name: 'kvm', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 125 | component: Kvm, |
Mateusz Gapski | 632de22 | 2020-07-09 09:21:33 +0200 | [diff] [blame] | 126 | meta: { |
| 127 | title: 'appPageTitle.kvm' |
| 128 | } |
| 129 | }, |
| 130 | { |
Sukanya Pandey | 9055d98 | 2020-03-31 17:37:53 +0530 | [diff] [blame] | 131 | path: '/control/manage-power-usage', |
| 132 | name: 'manage-power-usage', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 133 | component: ManagePowerUsage, |
Sukanya Pandey | 9055d98 | 2020-03-31 17:37:53 +0530 | [diff] [blame] | 134 | meta: { |
| 135 | title: 'appPageTitle.managePowerUsage' |
| 136 | } |
| 137 | }, |
| 138 | { |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 139 | path: '/configuration/network-settings', |
| 140 | name: 'network-settings', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 141 | component: NetworkSettings, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 142 | meta: { |
| 143 | title: 'appPageTitle.networkSettings' |
| 144 | } |
| 145 | }, |
| 146 | { |
Yoshie Muranaka | c11d389 | 2020-02-19 08:07:40 -0800 | [diff] [blame] | 147 | path: '/control/reboot-bmc', |
| 148 | name: 'reboot-bmc', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 149 | component: RebootBmc, |
Yoshie Muranaka | c11d389 | 2020-02-19 08:07:40 -0800 | [diff] [blame] | 150 | meta: { |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 151 | title: 'appPageTitle.rebootBmc' |
Yoshie Muranaka | c11d389 | 2020-02-19 08:07:40 -0800 | [diff] [blame] | 152 | } |
| 153 | }, |
| 154 | { |
SurenNeware | 090c2d4 | 2020-04-01 14:07:27 +0530 | [diff] [blame] | 155 | path: '/control/server-led', |
| 156 | name: 'server-led', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 157 | component: ServerLed, |
SurenNeware | 090c2d4 | 2020-04-01 14:07:27 +0530 | [diff] [blame] | 158 | meta: { |
| 159 | title: 'appPageTitle.serverLed' |
| 160 | } |
| 161 | }, |
| 162 | { |
Sukanya Pandey | 96f69ca | 2020-05-20 15:32:57 +0530 | [diff] [blame] | 163 | path: '/control/serial-over-lan', |
| 164 | name: 'serial-over-lan', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 165 | component: SerialOverLan, |
Sukanya Pandey | 96f69ca | 2020-05-20 15:32:57 +0530 | [diff] [blame] | 166 | meta: { |
| 167 | title: 'appPageTitle.serialOverLan' |
| 168 | } |
| 169 | }, |
| 170 | { |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 171 | path: '/control/server-power-operations', |
| 172 | name: 'server-power-operations', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 173 | component: ServerPowerOperations, |
Yoshie Muranaka | fa1512b | 2020-02-25 15:54:07 -0800 | [diff] [blame] | 174 | meta: { |
| 175 | title: 'appPageTitle.serverPowerOperations' |
| 176 | } |
| 177 | }, |
| 178 | { |
Mateusz Gapski | 7510046 | 2020-07-30 11:01:29 +0200 | [diff] [blame^] | 179 | path: '/control/virtual-media', |
| 180 | name: 'virtual-media', |
| 181 | component: () => import('@/views/Control/VirtualMedia'), |
| 182 | meta: { |
| 183 | title: 'appPageTitle.virtualMedia' |
| 184 | } |
| 185 | }, |
| 186 | { |
Derick Montague | 126eaab | 2019-12-23 13:33:52 -0600 | [diff] [blame] | 187 | path: '/unauthorized', |
| 188 | name: 'unauthorized', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 189 | component: Unauthorized, |
Derick Montague | 126eaab | 2019-12-23 13:33:52 -0600 | [diff] [blame] | 190 | meta: { |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 191 | title: 'appPageTitle.unauthorized' |
Derick Montague | 126eaab | 2019-12-23 13:33:52 -0600 | [diff] [blame] | 192 | } |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 193 | } |
| 194 | ] |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 195 | }, |
| 196 | { |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 197 | path: '/login', |
Yoshie Muranaka | 6173bc6 | 2020-06-16 12:39:07 -0700 | [diff] [blame] | 198 | component: LoginLayout, |
| 199 | children: [ |
| 200 | { |
| 201 | path: '', |
| 202 | name: 'login', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 203 | component: Login, |
Yoshie Muranaka | 6173bc6 | 2020-06-16 12:39:07 -0700 | [diff] [blame] | 204 | meta: { |
| 205 | title: 'appPageTitle.login' |
| 206 | } |
Yoshie Muranaka | 3305857 | 2020-06-16 13:21:21 -0700 | [diff] [blame] | 207 | }, |
| 208 | { |
| 209 | path: '/change-password', |
| 210 | name: 'change-password', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 211 | component: ChangePassword, |
Yoshie Muranaka | 3305857 | 2020-06-16 13:21:21 -0700 | [diff] [blame] | 212 | meta: { |
Yoshie Muranaka | 2c98b09 | 2020-06-22 13:28:09 -0700 | [diff] [blame] | 213 | title: 'appPageTitle.changePassword', |
| 214 | requiresAuth: true |
Yoshie Muranaka | 3305857 | 2020-06-16 13:21:21 -0700 | [diff] [blame] | 215 | } |
Yoshie Muranaka | 6173bc6 | 2020-06-16 12:39:07 -0700 | [diff] [blame] | 216 | } |
| 217 | ] |
Sukanya Pandey | 96f69ca | 2020-05-20 15:32:57 +0530 | [diff] [blame] | 218 | }, |
| 219 | { |
| 220 | path: '/console', |
| 221 | component: ConsoleLayout, |
| 222 | meta: { |
| 223 | requiresAuth: true |
| 224 | }, |
| 225 | children: [ |
| 226 | { |
Mateusz Gapski | 632de22 | 2020-07-09 09:21:33 +0200 | [diff] [blame] | 227 | path: 'serial-over-lan-console', |
| 228 | name: 'serial-over-lan-console', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 229 | component: SerialOverLanConsole, |
Sukanya Pandey | 96f69ca | 2020-05-20 15:32:57 +0530 | [diff] [blame] | 230 | meta: { |
| 231 | title: 'appPageTitle.serialOverLan' |
| 232 | } |
Mateusz Gapski | 632de22 | 2020-07-09 09:21:33 +0200 | [diff] [blame] | 233 | }, |
| 234 | { |
| 235 | path: 'kvm', |
| 236 | name: 'kvm-console', |
Yoshie Muranaka | 2a7b5ac | 2020-08-17 13:25:00 -0700 | [diff] [blame] | 237 | component: KvmConsole, |
Mateusz Gapski | 632de22 | 2020-07-09 09:21:33 +0200 | [diff] [blame] | 238 | meta: { |
| 239 | title: 'appPageTitle.kvm' |
| 240 | } |
Sukanya Pandey | 96f69ca | 2020-05-20 15:32:57 +0530 | [diff] [blame] | 241 | } |
| 242 | ] |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 243 | } |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 244 | ]; |
| 245 | |
| 246 | const router = new VueRouter({ |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 247 | base: process.env.BASE_URL, |
| 248 | routes, |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 249 | linkExactActiveClass: 'nav-link--current' |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 250 | }); |
| 251 | |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 252 | router.beforeEach((to, from, next) => { |
| 253 | if (to.matched.some(record => record.meta.requiresAuth)) { |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 254 | if (store.getters['authentication/isLoggedIn']) { |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 255 | next(); |
| 256 | return; |
| 257 | } |
Derick Montague | fded0d1 | 2019-12-11 06:16:40 -0600 | [diff] [blame] | 258 | next('/login'); |
Derick Montague | e080a1a | 2019-12-04 16:30:08 -0600 | [diff] [blame] | 259 | } else { |
| 260 | next(); |
| 261 | } |
| 262 | }); |
| 263 | |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 264 | export default router; |