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