]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { NgModule } from '@angular/core'; |
2 | import { ActivatedRouteSnapshot, PreloadAllModules, RouterModule, Routes } from '@angular/router'; | |
3 | ||
4 | import * as _ from 'lodash'; | |
5 | ||
6 | import { CephfsListComponent } from './ceph/cephfs/cephfs-list/cephfs-list.component'; | |
7 | import { ConfigurationFormComponent } from './ceph/cluster/configuration/configuration-form/configuration-form.component'; | |
8 | import { ConfigurationComponent } from './ceph/cluster/configuration/configuration.component'; | |
9 | import { CrushmapComponent } from './ceph/cluster/crushmap/crushmap.component'; | |
10 | import { HostsComponent } from './ceph/cluster/hosts/hosts.component'; | |
11 | import { LogsComponent } from './ceph/cluster/logs/logs.component'; | |
12 | import { MgrModuleFormComponent } from './ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component'; | |
13 | import { MgrModuleListComponent } from './ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component'; | |
14 | import { MonitorComponent } from './ceph/cluster/monitor/monitor.component'; | |
15 | import { OsdListComponent } from './ceph/cluster/osd/osd-list/osd-list.component'; | |
16 | import { PrometheusListComponent } from './ceph/cluster/prometheus/prometheus-list/prometheus-list.component'; | |
17 | import { DashboardComponent } from './ceph/dashboard/dashboard/dashboard.component'; | |
18 | import { Nfs501Component } from './ceph/nfs/nfs-501/nfs-501.component'; | |
19 | import { NfsFormComponent } from './ceph/nfs/nfs-form/nfs-form.component'; | |
20 | import { NfsListComponent } from './ceph/nfs/nfs-list/nfs-list.component'; | |
21 | import { PerformanceCounterComponent } from './ceph/performance-counter/performance-counter/performance-counter.component'; | |
22 | import { LoginComponent } from './core/auth/login/login.component'; | |
23 | import { SsoNotFoundComponent } from './core/auth/sso/sso-not-found/sso-not-found.component'; | |
24 | import { ForbiddenComponent } from './core/forbidden/forbidden.component'; | |
25 | import { NotFoundComponent } from './core/not-found/not-found.component'; | |
26 | import { BreadcrumbsResolver, IBreadcrumb } from './shared/models/breadcrumbs'; | |
27 | import { AuthGuardService } from './shared/services/auth-guard.service'; | |
28 | import { FeatureTogglesGuardService } from './shared/services/feature-toggles-guard.service'; | |
29 | import { ModuleStatusGuardService } from './shared/services/module-status-guard.service'; | |
30 | ||
31 | export class PerformanceCounterBreadcrumbsResolver extends BreadcrumbsResolver { | |
32 | resolve(route: ActivatedRouteSnapshot) { | |
33 | const result: IBreadcrumb[] = []; | |
34 | ||
35 | const fromPath = route.queryParams.fromLink || null; | |
36 | let fromText = ''; | |
37 | switch (fromPath) { | |
38 | case '/monitor': | |
39 | fromText = 'Monitors'; | |
40 | break; | |
41 | case '/hosts': | |
42 | fromText = 'Hosts'; | |
43 | break; | |
44 | } | |
45 | result.push({ text: 'Cluster', path: null }); | |
46 | result.push({ text: fromText, path: fromPath }); | |
47 | result.push({ text: 'Performance Counters', path: '' }); | |
48 | ||
49 | return result; | |
50 | } | |
51 | } | |
52 | ||
53 | export class StartCaseBreadcrumbsResolver extends BreadcrumbsResolver { | |
54 | resolve(route: ActivatedRouteSnapshot) { | |
55 | const path = route.params.name; | |
56 | const text = _.startCase(path); | |
57 | return [{ text: text, path: path }]; | |
58 | } | |
59 | } | |
60 | ||
61 | const routes: Routes = [ | |
62 | // Dashboard | |
63 | { path: '', redirectTo: 'dashboard', pathMatch: 'full' }, | |
64 | { path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuardService] }, | |
65 | // Cluster | |
66 | { | |
67 | path: 'hosts', | |
68 | component: HostsComponent, | |
69 | canActivate: [AuthGuardService], | |
70 | data: { breadcrumbs: 'Cluster/Hosts' } | |
71 | }, | |
72 | { | |
73 | path: 'monitor', | |
74 | component: MonitorComponent, | |
75 | canActivate: [AuthGuardService], | |
76 | data: { breadcrumbs: 'Cluster/Monitors' } | |
77 | }, | |
78 | { | |
79 | path: 'osd', | |
80 | canActivate: [AuthGuardService], | |
81 | canActivateChild: [AuthGuardService], | |
82 | data: { breadcrumbs: 'Cluster/OSDs' }, | |
83 | children: [{ path: '', component: OsdListComponent }] | |
84 | }, | |
85 | { | |
86 | path: 'configuration', | |
87 | data: { breadcrumbs: 'Cluster/Configuration' }, | |
88 | children: [ | |
89 | { path: '', component: ConfigurationComponent }, | |
90 | { | |
91 | path: 'edit/:name', | |
92 | component: ConfigurationFormComponent, | |
93 | data: { breadcrumbs: 'Edit' } | |
94 | } | |
95 | ] | |
96 | }, | |
97 | { | |
98 | path: 'crush-map', | |
99 | component: CrushmapComponent, | |
100 | canActivate: [AuthGuardService], | |
101 | data: { breadcrumbs: 'Cluster/CRUSH map' } | |
102 | }, | |
103 | { | |
104 | path: 'logs', | |
105 | component: LogsComponent, | |
106 | canActivate: [AuthGuardService], | |
107 | data: { breadcrumbs: 'Cluster/Logs' } | |
108 | }, | |
109 | { | |
110 | path: 'alerts', | |
111 | component: PrometheusListComponent, | |
112 | canActivate: [AuthGuardService], | |
113 | data: { breadcrumbs: 'Cluster/Alerts' } | |
114 | }, | |
115 | { | |
116 | path: 'perf_counters/:type/:id', | |
117 | component: PerformanceCounterComponent, | |
118 | canActivate: [AuthGuardService], | |
119 | data: { | |
120 | breadcrumbs: PerformanceCounterBreadcrumbsResolver | |
121 | } | |
122 | }, | |
123 | // Mgr modules | |
124 | { | |
125 | path: 'mgr-modules', | |
126 | canActivate: [AuthGuardService], | |
127 | canActivateChild: [AuthGuardService], | |
128 | data: { breadcrumbs: 'Cluster/Manager modules' }, | |
129 | children: [ | |
130 | { | |
131 | path: '', | |
132 | component: MgrModuleListComponent | |
133 | }, | |
134 | { | |
135 | path: 'edit/:name', | |
136 | component: MgrModuleFormComponent, | |
137 | data: { | |
138 | breadcrumbs: StartCaseBreadcrumbsResolver | |
139 | } | |
140 | } | |
141 | ] | |
142 | }, | |
143 | // Pools | |
144 | { | |
145 | path: 'pool', | |
146 | canActivate: [AuthGuardService], | |
147 | canActivateChild: [AuthGuardService], | |
148 | data: { breadcrumbs: 'Pools' }, | |
149 | loadChildren: './ceph/pool/pool.module#RoutedPoolModule' | |
150 | }, | |
151 | // Block | |
152 | { | |
153 | path: 'block', | |
154 | canActivateChild: [AuthGuardService], | |
155 | canActivate: [AuthGuardService], | |
156 | data: { breadcrumbs: true, text: 'Block', path: null }, | |
157 | loadChildren: './ceph/block/block.module#RoutedBlockModule' | |
158 | }, | |
159 | // Filesystems | |
160 | { | |
161 | path: 'cephfs', | |
162 | component: CephfsListComponent, | |
163 | canActivate: [FeatureTogglesGuardService, AuthGuardService], | |
164 | data: { breadcrumbs: 'Filesystems' } | |
165 | }, | |
166 | // Object Gateway | |
167 | { | |
168 | path: 'rgw', | |
169 | canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService, AuthGuardService], | |
170 | data: { | |
171 | moduleStatusGuardConfig: { | |
172 | apiPath: 'rgw', | |
173 | redirectTo: 'rgw/501' | |
174 | }, | |
175 | breadcrumbs: true, | |
176 | text: 'Object Gateway', | |
177 | path: null | |
178 | }, | |
179 | loadChildren: './ceph/rgw/rgw.module#RoutedRgwModule' | |
180 | }, | |
181 | // Dashboard Settings | |
182 | { | |
183 | path: 'user-management', | |
184 | canActivate: [AuthGuardService], | |
185 | canActivateChild: [AuthGuardService], | |
186 | data: { breadcrumbs: 'User management', path: null }, | |
187 | loadChildren: './core/auth/auth.module#RoutedAuthModule' | |
188 | }, | |
189 | // NFS | |
190 | { | |
191 | path: 'nfs/501/:message', | |
192 | component: Nfs501Component, | |
193 | canActivate: [AuthGuardService], | |
194 | data: { breadcrumbs: 'NFS' } | |
195 | }, | |
196 | { | |
197 | path: 'nfs', | |
198 | canActivate: [AuthGuardService], | |
199 | canActivateChild: [AuthGuardService, ModuleStatusGuardService], | |
200 | data: { | |
201 | moduleStatusGuardConfig: { | |
202 | apiPath: 'nfs-ganesha', | |
203 | redirectTo: 'nfs/501' | |
204 | }, | |
205 | breadcrumbs: 'NFS' | |
206 | }, | |
207 | children: [ | |
208 | { path: '', component: NfsListComponent }, | |
209 | { path: 'add', component: NfsFormComponent, data: { breadcrumbs: 'Add' } }, | |
210 | { | |
211 | path: 'edit/:cluster_id/:export_id', | |
212 | component: NfsFormComponent, | |
213 | data: { breadcrumbs: 'Edit' } | |
214 | } | |
215 | ] | |
216 | }, | |
217 | // Single Sign-On (SSO) | |
218 | { path: 'sso/404', component: SsoNotFoundComponent }, | |
219 | // System | |
220 | { path: 'login', component: LoginComponent }, | |
221 | { path: 'logout', children: [] }, | |
222 | { path: '403', component: ForbiddenComponent }, | |
223 | { path: '404', component: NotFoundComponent }, | |
224 | { path: '**', redirectTo: '/404' } | |
225 | ]; | |
226 | ||
227 | @NgModule({ | |
228 | imports: [ | |
229 | RouterModule.forRoot(routes, { | |
230 | useHash: true, | |
231 | preloadingStrategy: PreloadAllModules | |
232 | }) | |
233 | ], | |
234 | exports: [RouterModule], | |
235 | providers: [StartCaseBreadcrumbsResolver, PerformanceCounterBreadcrumbsResolver] | |
236 | }) | |
237 | export class AppRoutingModule {} |