349 lines
9.5 KiB
TypeScript
349 lines
9.5 KiB
TypeScript
|
|
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: '/home',
|
|
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
|
|
},
|
|
]
|
|
})
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
// redirect to login page if not logged in and trying to access a restricted page
|
|
const auth = useAuthStore();
|
|
|
|
// if to is not found, redirect to 404
|
|
if (to.matched.length === 0) {
|
|
if (to.path === '/') {
|
|
if (auth.isLoggedIn) {
|
|
next('/home')
|
|
} else {
|
|
next('/login')
|
|
}
|
|
} else {
|
|
next('/404')
|
|
}
|
|
} else {
|
|
// if to is not login and user is not logged in, redirect to login
|
|
if (auth.isLoggedIn) {
|
|
// if to is login and user is logged in, redirect to home
|
|
if (to.path === '/login') {
|
|
next('/home')
|
|
} else {
|
|
next()
|
|
}
|
|
} else {
|
|
// if to is 404, redirect to 404
|
|
if (to.path !== '/404' && to.path !== '/login') {
|
|
next('/login')
|
|
} else {
|
|
next()
|
|
}
|
|
}
|
|
}
|
|
|
|
})
|
|
|
|
export default router
|