1import Vue from 'vue'; 2import VueRouter from 'vue-router'; 3import store from '../store/index'; 4import AppLayout from '../layouts/AppLayout.vue'; 5 6Vue.use(VueRouter); 7 8// Meta title is translated using i18n in App.vue and PageTitle.Vue 9// Example meta: {title: 'appPageTitle.overview'} 10const routes = [ 11 { 12 path: '/', 13 meta: { 14 requiresAuth: true 15 }, 16 component: AppLayout, 17 children: [ 18 { 19 path: '', 20 name: 'overview', 21 component: () => import('@/views/Overview'), 22 meta: { 23 title: 'appPageTitle.overview' 24 } 25 }, 26 { 27 path: '/health/event-logs', 28 name: 'event-logs', 29 component: () => import('@/views/Health/EventLogs'), 30 meta: { 31 title: 'appPageTitle.eventLogs' 32 } 33 }, 34 { 35 path: '/health/sensors', 36 name: 'sensors', 37 component: () => import('@/views/Health/Sensors'), 38 meta: { 39 title: 'appPageTitle.sensors' 40 } 41 }, 42 { 43 path: '/access-control/ldap', 44 name: 'ldap', 45 component: () => import('@/views/AccessControl/Ldap'), 46 meta: { 47 title: 'appPageTitle.ldap' 48 } 49 }, 50 { 51 path: '/access-control/local-user-management', 52 name: 'local-users', 53 component: () => import('@/views/AccessControl/LocalUserManagement'), 54 meta: { 55 title: 'appPageTitle.localUserManagement' 56 } 57 }, 58 { 59 path: '/access-control/ssl-certificates', 60 name: 'ssl-certificates', 61 component: () => import('@/views/AccessControl/SslCertificates'), 62 meta: { 63 title: 'appPageTitle.sslCertificates' 64 } 65 }, 66 { 67 path: '/control/manage-power-usage', 68 name: 'manage-power-usage', 69 component: () => import('@/views/Control/ManagePowerUsage'), 70 meta: { 71 title: 'appPageTitle.managePowerUsage' 72 } 73 }, 74 { 75 path: '/control/reboot-bmc', 76 name: 'reboot-bmc', 77 component: () => import('@/views/Control/RebootBmc'), 78 meta: { 79 title: 'appPageTitle.rebootBmc' 80 } 81 }, 82 { 83 path: '/control/server-led', 84 name: 'server-led', 85 component: () => import('@/views/Control/ServerLed'), 86 meta: { 87 title: 'appPageTitle.serverLed' 88 } 89 }, 90 { 91 path: '/control/server-power-operations', 92 name: 'server-power-operations', 93 component: () => import('@/views/Control/ServerPowerOperations'), 94 meta: { 95 title: 'appPageTitle.serverPowerOperations' 96 } 97 }, 98 { 99 path: '/unauthorized', 100 name: 'unauthorized', 101 component: () => import('@/views/Unauthorized'), 102 meta: { 103 title: 'appPageTitle.unauthorized' 104 } 105 } 106 ] 107 }, 108 { 109 path: '/login', 110 name: 'login', 111 component: () => import('@/views/Login'), 112 meta: { 113 title: 'appPageTitle.login' 114 } 115 } 116]; 117 118const router = new VueRouter({ 119 base: process.env.BASE_URL, 120 routes, 121 linkExactActiveClass: 'nav-link--current' 122}); 123 124router.beforeEach((to, from, next) => { 125 if (to.matched.some(record => record.meta.requiresAuth)) { 126 if (store.getters['authentication/isLoggedIn']) { 127 next(); 128 return; 129 } 130 next('/login'); 131 } else { 132 next(); 133 } 134}); 135 136export default router; 137