1
|
import {NgModule} from '@angular/core';
|
2
|
import {RouterModule, Routes} from '@angular/router';
|
3
|
import {LoginComponent} from './login/components/login.component';
|
4
|
import {DashboardComponent} from './dashboard/components/dashboard.component';
|
5
|
import {AuthGuard} from './auth/guards/auth.guard';
|
6
|
import {RoleGuard} from './auth/guards/role.guard';
|
7
|
import {AdministrationComponent} from './administration/components/administration.component';
|
8
|
import {SensorComponent} from './sensor/components/sensor.component';
|
9
|
import {UnitComponent} from './unit/components/unit.component';
|
10
|
|
11
|
const routes: Routes = [
|
12
|
{
|
13
|
path: '',
|
14
|
redirectTo: 'login',
|
15
|
pathMatch: 'full'
|
16
|
}, {
|
17
|
canActivate: [AuthGuard],
|
18
|
path: 'dashboard',
|
19
|
component: DashboardComponent,
|
20
|
pathMatch: 'full'
|
21
|
}, {
|
22
|
canActivate: [AuthGuard, RoleGuard],
|
23
|
path: 'dashboard/unit/:unitId/sensor/:sensorId',
|
24
|
component: SensorComponent,
|
25
|
pathMatch: 'full',
|
26
|
data: {
|
27
|
expectedRole: ['1', '0']
|
28
|
}
|
29
|
}, {
|
30
|
canActivate: [AuthGuard, RoleGuard],
|
31
|
path: 'dashboard/unit/:unitId',
|
32
|
component: UnitComponent,
|
33
|
pathMatch: 'full',
|
34
|
data: {
|
35
|
expectedRole: ['1', '0']
|
36
|
}
|
37
|
}, {
|
38
|
canActivate: [AuthGuard, RoleGuard],
|
39
|
path: 'administration',
|
40
|
component: AdministrationComponent,
|
41
|
pathMatch: 'full',
|
42
|
data: {
|
43
|
expectedRole: ['1']
|
44
|
}
|
45
|
},{
|
46
|
path: 'login',
|
47
|
component: LoginComponent,
|
48
|
pathMatch: 'full',
|
49
|
}
|
50
|
];
|
51
|
|
52
|
@NgModule({
|
53
|
imports: [RouterModule.forRoot(routes)],
|
54
|
exports: [RouterModule]
|
55
|
})
|
56
|
export class AppRoutingModule {
|
57
|
}
|