4
0

router.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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: '/action/:actionId/actionexecconditions',
  98. name: 'ActionExecConditions',
  99. component: () => import('./views/ActionExecConditionsView.vue'),
  100. props: true,
  101. meta: {
  102. title: 'Execution conditions',
  103. breadcrumb: [
  104. { name: "Actions", href: "/" },
  105. { name: "Execution conditions" },
  106. ]
  107. }
  108. },
  109. {
  110. path: '/diagnostics',
  111. name: 'Diagnostics',
  112. component: () => import('./views/DiagnosticsView.vue'),
  113. meta: {
  114. title: 'Diagnostics',
  115. icon: Wrench01Icon
  116. }
  117. },
  118. {
  119. path: '/login',
  120. name: 'Login',
  121. component: () => import('./views/LoginView.vue'),
  122. meta: { title: 'Login' }
  123. },
  124. {
  125. path: '/user',
  126. name: 'UserInformation',
  127. component: () => import('./views/UserControlPanel.vue'),
  128. meta: { title: 'User Information' }
  129. },
  130. {
  131. path: '/:pathMatch(.*)*',
  132. name: 'NotFound',
  133. component: () => import('./views/NotFoundView.vue'),
  134. meta: { title: 'Page Not Found' }
  135. }
  136. ]
  137. // Create router instance
  138. const router = createRouter({
  139. history: createWebHistory(),
  140. routes,
  141. scrollBehavior(to, from, savedPosition) {
  142. if (savedPosition) {
  143. return savedPosition
  144. } else {
  145. return { top: 0 }
  146. }
  147. }
  148. })
  149. // Navigation guard to update page title
  150. router.beforeEach((to, from, next) => {
  151. if (to.meta && to.meta.title) {
  152. const pageTitle = window.initResponse?.pageTitle || 'OliveTin'
  153. document.title = to.meta.title + " - " + pageTitle
  154. }
  155. next()
  156. })
  157. // Navigation guard for authentication (if needed)
  158. router.beforeEach((to, from, next) => {
  159. // Check if user is authenticated for protected routes
  160. const isAuthenticated = window.isAuthenticated || true // Default to true for now
  161. if (to.meta.requiresAuth && !isAuthenticated) {
  162. next('/login')
  163. } else {
  164. next()
  165. }
  166. })
  167. export default router