Skip to content

Router

File: apps/frontend/src/router/index.ts

The router uses createWebHashHistory (hash-based URLs, e.g. /#/dashboard). This avoids the need for server-side catch-all redirects when deployed as a static SPA on AWS Amplify.


Route Guard

router.beforeEach

Runs before every navigation:

ts
router.beforeEach((to, from, next) => {
  NProgress.start()
  if (to.meta.requiresAuth && !authStore.isAuthenticated) {
    next({ name: 'signin' })
  } else {
    next()
  }
})
  • Starts the NProgress loading bar
  • Checks meta.requiresAuth on the target route
  • Reads authStore.isAuthenticated (from persisted Pinia state)
  • Redirects unauthenticated users to /signin

router.afterEach

ts
router.afterEach((to) => {
  NProgress.done()
  document.title = to.meta.title ?? 'IoT Monitoring'
})

Route Definitions

Public Routes

Rendered inside the SignUpAndSignIn layout (centered card, no sidebar):

PathNameComponentDescription
/signupsignupviews/signup.vueRegistration form
/signinsigninviews/signin.vueLogin form
/404404views/newPages/404.vueNot found page

User Routes

Rendered inside the Home layout (sidebar + header). All have meta: { requiresAuth: true }.

PathNameComponent
/dashboarddashboardviews/dashboard.vue
/live-alertsliveAlertsviews/live-alerts.vue
/current-conditionscurrentConditionsviews/current-conditions.vue
/reportsreportsviews/reports.vue
/profileprofileviews/profile.vue
/settingssettingsviews/settings.vue
/storage-settingsstorage-settingsviews/storage-settings.vue
/notification-settingsnotification-settingsviews/notification-settings.vue
/recipient-settingsrecipient-settingsviews/recipient-settings.vue
/device-settingsdevice-settingsviews/device-settings.vue

Admin Routes

Also rendered inside the Home layout, prefixed with /admin. All have meta: { requiresAuth: true }.

PathNameComponent
/admin/devicesdevicesviews/admin/devices.vue
/admin/sensor-datasensorDataviews/admin/sensorData.vue
/admin/diagnostic-datadiagnosticDataviews/admin/diagnosticData.vue
/admin/usersusersviews/admin/users.vue
/admin/device-logsdeviceLogsviews/admin/deviceLogs.vue
/admin/raw-sensor-datarawSensorDataviews/admin/rawSensorData.vue

Lazy Loading

All routes are lazy-loaded via dynamic imports with webpack chunk names:

ts
{
  path: '/dashboard',
  name: 'dashboard',
  component: () => import(/* webpackChunkName: "dashboard" */ '@/views/dashboard.vue'),
  meta: { requiresAuth: true, title: 'Dashboard' }
}

This splits each view into a separate JS chunk and only loads the code when the route is first visited.


Layouts

SignUpAndSignIn layout

File: views/signUpAndSignIn.vue

Renders a centered card with a branded header (components/signUpAndSignInHeader.vue). Used for authentication pages.

Home layout

File: views/home.vue

The main authenticated shell:

  • Sidebar (components/sidebar.vue) — collapsible navigation
  • Header (components/header.vue) — user menu, notifications
  • Tab bar (components/tabs.vue) — open page tabs
  • <router-view> — current page content

If a user visits / (root), they are redirected to /dashboard (or /signin if not authenticated). A catch-all /:pathMatch(.*)* route redirects unmatched paths to /404.

Intecog Logistech IoT Monitoring Platform