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