first commit
This commit is contained in:
348
src/router/index.ts
Normal file
348
src/router/index.ts
Normal file
@ -0,0 +1,348 @@
|
||||
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import HomeView from '@/views/HomeView.vue'
|
||||
import LoginView from '@/views/LoginView.vue'
|
||||
import NotFoundView from '@/views/NotFoundView.vue'
|
||||
import MenuSample from '@/components/Menus/MenuSample.vue'
|
||||
import AktifIndividual from '@/components/Menus/DaftarTransaksi/AktifIndividual.vue'
|
||||
import HomeEmptyView from '@/components/HomeEmpty.vue'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
linkActiveClass: 'active',
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
'meta': { requiresAuth: true },
|
||||
component: HomeView,
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'Home Page',
|
||||
component: HomeEmptyView,
|
||||
},
|
||||
{
|
||||
path: 'daftar-transaksi',
|
||||
name: 'Daftar Transaksi',
|
||||
children: [
|
||||
{
|
||||
path: 'aktif-individual',
|
||||
name: 'Transaksi Aktif Individual',
|
||||
component: AktifIndividual,
|
||||
},
|
||||
{
|
||||
path: 'aktif-pln-mobile',
|
||||
name: 'Transaksi Aktif PLN Mobile',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'periksa-return-order',
|
||||
name: 'Transaksi Aktif Periksa dan Return Order',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'aktif-tm',
|
||||
name: 'Transaksi Aktif TM',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'aktif-historis',
|
||||
name: 'Transaksi Aktif Historis',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-alih-unit',
|
||||
name: 'Monitoring Alih Unit',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-all',
|
||||
name: 'Monitoring All',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-tiket',
|
||||
name: 'Monitoring Tiket',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-history',
|
||||
name: 'Monitoring History',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-aktif',
|
||||
name: 'Monitoring Aktif',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-close-cc',
|
||||
name: 'Monitoring Close CC',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-log-autodispatch',
|
||||
name: 'Monitoring Log AutoDispatch',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-perlu-diperhatikan',
|
||||
name: 'Monitoring yang Perlu Diperhatikan',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-log-break-regu',
|
||||
name: 'Monitoring Log Break Regu',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'monitoring-log-alih-regu',
|
||||
name: 'Monitoring Log Alih Regu',
|
||||
component: MenuSample,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'administration',
|
||||
name: 'Administration',
|
||||
children: [
|
||||
{
|
||||
path: 'audit-trails',
|
||||
name: 'Audit Trails',
|
||||
children: [
|
||||
{
|
||||
path: 'log-login',
|
||||
name: 'Log Login',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'log-aktivity',
|
||||
name: 'Log Aktivity',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'log-error',
|
||||
name: 'Log Error',
|
||||
component: MenuSample,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'task-management',
|
||||
name: 'Task Management',
|
||||
children: [
|
||||
{
|
||||
path: 'menu-management',
|
||||
name: 'Menu Management',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'system-parameter',
|
||||
name: 'System Parameter',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'ubah-profile-manager',
|
||||
name: 'Ubah Profile Manager',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'security-projek',
|
||||
name: 'Security Projek',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'user-role-manager',
|
||||
name: 'User Role Manager',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'menu-authorization',
|
||||
name: 'Menu Authorization',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'workflow-designer',
|
||||
name: 'Workflow Designer',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'apkt-news',
|
||||
name: 'APKT News',
|
||||
component: MenuSample,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'master-borderless',
|
||||
name: 'Master Borderless',
|
||||
children: [
|
||||
{
|
||||
path: 'zone-borderless',
|
||||
name: 'Zone Borderless',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'user-zone-borderless',
|
||||
name: 'User Zone Borderless',
|
||||
component: MenuSample,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'master-yantek',
|
||||
name: 'Master Yantek',
|
||||
children: [
|
||||
{
|
||||
path: 'unit',
|
||||
name: 'Unit',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'unit-jaringan',
|
||||
name: 'Unit Jaringan',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'unit-pelayanan',
|
||||
name: 'Unit Pelayanan',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'regu-yantek',
|
||||
name: 'Regu Yantek',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'gardu-induk',
|
||||
name: 'Gardu Induk',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'gardu-penyulang-tm',
|
||||
name: 'Gardu Penyulang TM',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'gardu-distribusi',
|
||||
name: 'Gardu Distribusi',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'group-gangguan',
|
||||
name: 'Group Gangguan',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'wilayah-yantek',
|
||||
name: 'Wilayah Yantek',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'material',
|
||||
name: 'Material',
|
||||
component: MenuSample,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'transaksi',
|
||||
name: 'Transaksi',
|
||||
children: [
|
||||
{
|
||||
path: 'gangguan-dan-keluhan',
|
||||
name: 'Gangguan dan Keluhan',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'gangguan-tegangan-menengah',
|
||||
name: 'Gangguan Tegangan Menengah',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'pemadaman-terencana',
|
||||
name: 'Pemadaman Terencana',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'aplikasi-off-line',
|
||||
name: 'Aplikasi Off-Line',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'penugasan-khusus',
|
||||
name: 'Penugasan Khusus',
|
||||
component: MenuSample,
|
||||
},
|
||||
{
|
||||
path: 'mutasi-pengaduan',
|
||||
name: 'Mutasi Pengaduan',
|
||||
component: MenuSample,
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: LoginView
|
||||
},
|
||||
{
|
||||
path: '/logout',
|
||||
name: 'Logout',
|
||||
beforeEnter(to, from, next) {
|
||||
const auth = useAuthStore();
|
||||
auth.logout();
|
||||
next('/login');
|
||||
},
|
||||
redirect: '/logout'
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
name: 'Not Found',
|
||||
component: NotFoundView
|
||||
},
|
||||
{
|
||||
path: '/profile',
|
||||
name: 'Profile',
|
||||
redirect: '/404',
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
name: 'Settings',
|
||||
redirect: '/404',
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
router.beforeEach((to, _from) => {
|
||||
// redirect to login page if not logged in and trying to access a restricted page
|
||||
const publicPages = ['/login'];
|
||||
const authRequired = !publicPages.includes(to.path);
|
||||
const auth = useAuthStore();
|
||||
|
||||
// if to is not found, redirect to 404
|
||||
if (to.matched.length === 0) {
|
||||
return '/404';
|
||||
} else {
|
||||
// if to is not login and user is not logged in, redirect to login
|
||||
if (!auth.isLoggedIn) {
|
||||
// if to is 404, redirect to 404
|
||||
if (to.path !== '/404' && to.path !== '/login') {
|
||||
return '/login';
|
||||
}
|
||||
} else {
|
||||
// if to is login and user is logged in, redirect to home
|
||||
if (to.path === '/login') {
|
||||
return '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
export default router
|
Reference in New Issue
Block a user