4
0

router.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import { createRouter, createWebHistory } from 'vue-router'
  2. import { Wrench01Icon } from '@hugeicons/core-free-icons'
  3. import { LeftToRightListDashIcon } from '@hugeicons/core-free-icons'
  4. import { CellsIcon } from '@hugeicons/core-free-icons'
  5. import { DashboardSquare01Icon } from '@hugeicons/core-free-icons'
  6. const routes = [
  7. {
  8. path: '/',
  9. name: 'Actions',
  10. component: () => import('./Dashboard.vue'),
  11. meta: { title: 'Actions', icon: DashboardSquare01Icon }
  12. },
  13. {
  14. path: '/dashboards/:title/:entityType?/:entityKey?',
  15. name: 'Dashboard',
  16. component: () => import('./Dashboard.vue'),
  17. props: true,
  18. meta: { title: 'Dashboard' }
  19. },
  20. {
  21. path: '/actionBinding/:bindingId/argumentForm',
  22. name: 'ActionBinding',
  23. component: () => import('./views/ArgumentForm.vue'),
  24. props: true,
  25. meta: { title: 'Action Binding' }
  26. },
  27. {
  28. path: '/logs',
  29. name: 'Logs',
  30. component: () => import('./views/LogsListView.vue'),
  31. meta: {
  32. title: 'Logs',
  33. icon: LeftToRightListDashIcon
  34. }
  35. },
  36. {
  37. path: '/logs/calendar',
  38. name: 'LogsCalendar',
  39. component: () => import('./views/LogsCalendarView.vue'),
  40. meta: {
  41. title: 'Logs Calendar',
  42. breadcrumb: [
  43. { name: "Logs", href: "/logs" },
  44. { name: "Calendar" },
  45. ]
  46. }
  47. },
  48. {
  49. path: '/entities',
  50. name: 'Entities',
  51. component: () => import('./views/EntitiesView.vue'),
  52. meta: {
  53. title: 'Entities',
  54. icon: CellsIcon
  55. }
  56. },
  57. {
  58. path: '/entity-details/:entityType/:entityKey',
  59. name: 'EntityDetails',
  60. component: () => import('./views/EntityDetailsView.vue'),
  61. props: true,
  62. meta: {
  63. title: 'OliveTin - Entity Details',
  64. breadcrumb: [
  65. { name: "Entities", href: "/entities" },
  66. { name: "Entity Details" }
  67. ]
  68. }
  69. },
  70. {
  71. path: '/logs/:executionTrackingId',
  72. name: 'Execution',
  73. component: () => import('./views/ExecutionView.vue'),
  74. props: true,
  75. meta: {
  76. title: 'Execution',
  77. breadcrumb: [
  78. { name: "Logs", href: "/logs" },
  79. { name: "Execution" },
  80. ]
  81. }
  82. },
  83. {
  84. path: '/action/:actionId',
  85. name: 'ActionDetails',
  86. component: () => import('./views/ActionDetailsView.vue'),
  87. props: true,
  88. meta: {
  89. title: 'Action Details',
  90. breadcrumb: [
  91. { name: "Actions", href: "/" },
  92. { name: "Action Details" },
  93. ]
  94. }
  95. },
  96. {
  97. path: '/diagnostics',
  98. name: 'Diagnostics',
  99. component: () => import('./views/DiagnosticsView.vue'),
  100. meta: {
  101. title: 'Diagnostics',
  102. icon: Wrench01Icon
  103. }
  104. },
  105. {
  106. path: '/login',
  107. name: 'Login',
  108. component: () => import('./views/LoginView.vue'),
  109. meta: { title: 'Login' }
  110. },
  111. {
  112. path: '/user',
  113. name: 'UserInformation',
  114. component: () => import('./views/UserControlPanel.vue'),
  115. meta: { title: 'User Information' }
  116. },
  117. {
  118. path: '/:pathMatch(.*)*',
  119. name: 'NotFound',
  120. component: () => import('./views/NotFoundView.vue'),
  121. meta: { title: 'Page Not Found' }
  122. }
  123. ]
  124. // Create router instance
  125. const router = createRouter({
  126. history: createWebHistory(),
  127. routes,
  128. scrollBehavior(to, from, savedPosition) {
  129. if (savedPosition) {
  130. return savedPosition
  131. } else {
  132. return { top: 0 }
  133. }
  134. }
  135. })
  136. // Navigation guard to update page title
  137. router.beforeEach((to, from, next) => {
  138. if (to.meta && to.meta.title) {
  139. const pageTitle = window.initResponse?.pageTitle || 'OliveTin'
  140. document.title = to.meta.title + " - " + pageTitle
  141. }
  142. next()
  143. })
  144. // Navigation guard for authentication (if needed)
  145. router.beforeEach((to, from, next) => {
  146. // Check if user is authenticated for protected routes
  147. const isAuthenticated = window.isAuthenticated || true // Default to true for now
  148. if (to.meta.requiresAuth && !isAuthenticated) {
  149. next('/login')
  150. } else {
  151. next()
  152. }
  153. })
  154. export default router