| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- import { createRouter, createWebHistory } from 'vue-router'
- import Dashboard from './Dashboard.vue'
- import { Wrench01Icon, LeftToRightListDashIcon, CellsIcon, DashboardSquare01Icon } from '@hugeicons/core-free-icons'
- const routes = [
- {
- path: '/',
- name: 'Actions',
- component: Dashboard,
- meta: { title: 'Actions', icon: DashboardSquare01Icon }
- },
- {
- path: '/dashboards/:title/:entityType?/:entityKey?',
- name: 'Dashboard',
- component: Dashboard,
- props: true,
- meta: { title: 'Dashboard' }
- },
- {
- path: '/actionBinding/:bindingId/argumentForm',
- name: 'ActionBinding',
- component: () => import('./views/ArgumentForm.vue'),
- props: true,
- meta: { title: 'Action Binding' }
- },
- {
- path: '/logs',
- name: 'Logs',
- component: () => import('./views/LogsListView.vue'),
- meta: {
- title: 'Logs',
- icon: LeftToRightListDashIcon
- }
- },
- {
- path: '/logs/calendar',
- name: 'LogsCalendar',
- component: () => import('./views/LogsCalendarView.vue'),
- meta: {
- title: 'Logs Calendar',
- keepOnQueryChange: true,
- breadcrumbs: () => [
- { name: 'Logs', to: { name: 'Logs' } },
- { name: 'Calendar' }
- ]
- }
- },
- {
- path: '/logs/queue',
- name: 'LogsQueue',
- component: () => import('./views/LogsQueueView.vue'),
- meta: {
- title: 'Execution Queue',
- breadcrumbs: () => [
- { name: 'Logs', to: { name: 'Logs' } },
- { name: 'Queue' }
- ]
- }
- },
- {
- path: '/entities',
- name: 'Entities',
- component: () => import('./views/EntitiesView.vue'),
- meta: {
- title: 'Entities',
- icon: CellsIcon
- }
- },
- {
- path: '/entity-details/:entityType/:entityKey',
- name: 'EntityDetails',
- component: () => import('./views/EntityDetailsView.vue'),
- props: true,
- meta: {
- title: 'OliveTin - Entity Details',
- breadcrumbs: () => [
- { name: 'Entities', to: { name: 'Entities' } },
- { name: 'Entity Details' }
- ]
- }
- },
- {
- path: '/logs/:executionTrackingId',
- name: 'Execution',
- component: () => import('./views/ExecutionView.vue'),
- props: true,
- meta: {
- title: 'Execution',
- breadcrumbs: () => [
- { name: 'Logs', to: { name: 'Logs' } },
- { name: 'Execution' }
- ]
- }
- },
- {
- path: '/action/:actionId',
- name: 'ActionDetails',
- component: () => import('./views/ActionDetailsView.vue'),
- props: true,
- meta: {
- title: 'Action Details',
- breadcrumbs: () => [
- { name: 'Actions', to: { name: 'Actions' } },
- { name: 'Action Details' }
- ]
- }
- },
- {
- path: '/action/:actionId/actionexecconditions',
- name: 'ActionExecConditions',
- component: () => import('./views/ActionExecConditionsView.vue'),
- props: true,
- meta: {
- title: 'Execution conditions',
- breadcrumbs: () => [
- { name: 'Actions', to: { name: 'Actions' } },
- { name: 'Execution conditions' }
- ]
- }
- },
- {
- path: '/diagnostics',
- name: 'Diagnostics',
- component: () => import('./views/DiagnosticsView.vue'),
- meta: {
- title: 'Diagnostics',
- icon: Wrench01Icon
- }
- },
- {
- path: '/login',
- name: 'Login',
- component: () => import('./views/LoginView.vue'),
- meta: { title: 'Login' }
- },
- {
- path: '/user',
- name: 'UserInformation',
- component: () => import('./views/UserControlPanel.vue'),
- meta: { title: 'User Information' }
- },
- {
- path: '/:pathMatch(.*)*',
- name: 'NotFound',
- component: () => import('./views/NotFoundView.vue'),
- meta: { title: 'Page Not Found' }
- }
- ]
- // Create router instance
- const router = createRouter({
- history: createWebHistory(),
- routes,
- scrollBehavior (to, from, savedPosition) {
- if (savedPosition) {
- return savedPosition
- } else {
- return { top: 0 }
- }
- }
- })
- // Navigation guard to update page title
- router.beforeEach((to) => {
- if (to.meta && to.meta.title) {
- const pageTitle = window.initResponse?.pageTitle || 'OliveTin'
- document.title = to.meta.title + ' - ' + pageTitle
- }
- })
- // Navigation guard for authentication (if needed)
- router.beforeEach((to) => {
- if (window.initResponse?.loginRequired && to.name !== 'Login') {
- return '/login'
- }
- const isAuthenticated = window.isAuthenticated ?? false
- if (to.meta.requiresAuth && !isAuthenticated) {
- return '/login'
- }
- })
- export default router
|