|
1 | 1 | import { NgModule } from '@angular/core'; |
2 | 2 | import { RouterModule, Routes } from '@angular/router'; |
3 | 3 | import { BmsDebugPageComponent } from 'src/pages/bms-debug-page/bms-debug-page.component'; |
| 4 | +import { BmsSegmentViewComponent } from 'src/pages/bms-debug-page/bms-segment-view/bms-segment-view.component'; |
4 | 5 | import { CameraPageComponent } from 'src/pages/camera-page/camera-page.component'; |
5 | 6 | import ChargingPageComponent from 'src/pages/charging-page/charging-page.component'; |
6 | 7 | import FaultPageComponent from 'src/pages/fault-page/fault-page.component'; |
7 | 8 | import GraphPageComponent from 'src/pages/graph-page/graph-page.component'; |
8 | 9 | import LandingPageComponent from 'src/pages/landing-page/landing-page.component'; |
9 | 10 | import MapComponent from 'src/pages/map/map.component'; |
| 11 | +import { Segment } from 'src/utils/bms.utils'; |
10 | 12 |
|
| 13 | +const landingRoute = () => `/landing`; |
| 14 | +const graphRoute = () => `/graph`; |
| 15 | +const mapRoute = () => `/map`; |
| 16 | +const chargingRoute = () => `/charging`; |
| 17 | +const bmsRoute = () => `/bms`; |
| 18 | +const bmsSegmentViewRoute = (id: Segment) => `/bms/segment/${id + 1}`; |
| 19 | +const cameraRoute = () => `/camera`; |
| 20 | +const faultsRoute = () => `/faults`; |
| 21 | +const faultsGraphRoute = () => `/faults/fault-graph`; |
| 22 | + |
| 23 | +export const appRoutes = { |
| 24 | + landingRoute, |
| 25 | + graphRoute, |
| 26 | + mapRoute, |
| 27 | + chargingRoute, |
| 28 | + bmsRoute, |
| 29 | + bmsSegmentViewRoute, |
| 30 | + cameraRoute, |
| 31 | + faultsRoute, |
| 32 | + faultsGraphRoute |
| 33 | +}; |
| 34 | + |
| 35 | +// Routes should be defined carefully in accordance with the appRoutes |
11 | 36 | const routes: Routes = [ |
12 | 37 | { path: 'landing', component: LandingPageComponent }, |
13 | 38 | { path: 'graph', component: GraphPageComponent }, |
14 | | - { path: '', redirectTo: '/landing', pathMatch: 'full' }, |
| 39 | + { path: '', redirectTo: appRoutes.landingRoute(), pathMatch: 'full' }, |
15 | 40 | { path: 'map', component: MapComponent }, |
16 | 41 | { path: 'charging', component: ChargingPageComponent }, |
17 | 42 | { path: 'bms', component: BmsDebugPageComponent }, |
| 43 | + // NOTE: paramaterized routes should be even more carefully defined in accordance with the appRoutes |
| 44 | + { path: 'bms/segment/:id', component: BmsSegmentViewComponent }, |
18 | 45 | { path: 'faults', component: FaultPageComponent }, |
19 | 46 | { path: 'faults/fault-graph', component: GraphPageComponent }, |
20 | 47 | { path: 'camera', component: CameraPageComponent } |
|
0 commit comments