router.js 4.3 KB

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