]>
Commit | Line | Data |
---|---|---|
f67539c2 | 1 | import { Injectable, NgModule } from '@angular/core'; |
11fdf7f2 TL |
2 | import { ActivatedRouteSnapshot, PreloadAllModules, RouterModule, Routes } from '@angular/router'; |
3 | ||
f67539c2 | 4 | import _ from 'lodash'; |
11fdf7f2 TL |
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'; | |
9f95a23c | 10 | import { HostFormComponent } from './ceph/cluster/hosts/host-form/host-form.component'; |
11fdf7f2 | 11 | import { HostsComponent } from './ceph/cluster/hosts/hosts.component'; |
9f95a23c | 12 | import { InventoryComponent } from './ceph/cluster/inventory/inventory.component'; |
11fdf7f2 TL |
13 | import { LogsComponent } from './ceph/cluster/logs/logs.component'; |
14 | import { MgrModuleFormComponent } from './ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component'; | |
15 | import { MgrModuleListComponent } from './ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component'; | |
16 | import { MonitorComponent } from './ceph/cluster/monitor/monitor.component'; | |
9f95a23c | 17 | import { OsdFormComponent } from './ceph/cluster/osd/osd-form/osd-form.component'; |
11fdf7f2 | 18 | import { OsdListComponent } from './ceph/cluster/osd/osd-list/osd-list.component'; |
f67539c2 TL |
19 | import { ActiveAlertListComponent } from './ceph/cluster/prometheus/active-alert-list/active-alert-list.component'; |
20 | import { RulesListComponent } from './ceph/cluster/prometheus/rules-list/rules-list.component'; | |
494da23a | 21 | import { SilenceFormComponent } from './ceph/cluster/prometheus/silence-form/silence-form.component'; |
f67539c2 | 22 | import { SilenceListComponent } from './ceph/cluster/prometheus/silence-list/silence-list.component'; |
adb31ebb | 23 | import { ServiceFormComponent } from './ceph/cluster/services/service-form/service-form.component'; |
9f95a23c | 24 | import { ServicesComponent } from './ceph/cluster/services/services.component'; |
e306af50 | 25 | import { TelemetryComponent } from './ceph/cluster/telemetry/telemetry.component'; |
11fdf7f2 | 26 | import { DashboardComponent } from './ceph/dashboard/dashboard/dashboard.component'; |
11fdf7f2 TL |
27 | import { NfsFormComponent } from './ceph/nfs/nfs-form/nfs-form.component'; |
28 | import { NfsListComponent } from './ceph/nfs/nfs-list/nfs-list.component'; | |
29 | import { PerformanceCounterComponent } from './ceph/performance-counter/performance-counter/performance-counter.component'; | |
9f95a23c | 30 | import { LoginPasswordFormComponent } from './core/auth/login-password-form/login-password-form.component'; |
11fdf7f2 | 31 | import { LoginComponent } from './core/auth/login/login.component'; |
9f95a23c | 32 | import { UserPasswordFormComponent } from './core/auth/user-password-form/user-password-form.component'; |
f67539c2 | 33 | import { ErrorComponent } from './core/error/error.component'; |
9f95a23c TL |
34 | import { BlankLayoutComponent } from './core/layouts/blank-layout/blank-layout.component'; |
35 | import { LoginLayoutComponent } from './core/layouts/login-layout/login-layout.component'; | |
36 | import { WorkbenchLayoutComponent } from './core/layouts/workbench-layout/workbench-layout.component'; | |
494da23a | 37 | import { ActionLabels, URLVerbs } from './shared/constants/app.constants'; |
11fdf7f2 TL |
38 | import { BreadcrumbsResolver, IBreadcrumb } from './shared/models/breadcrumbs'; |
39 | import { AuthGuardService } from './shared/services/auth-guard.service'; | |
9f95a23c | 40 | import { ChangePasswordGuardService } from './shared/services/change-password-guard.service'; |
11fdf7f2 TL |
41 | import { FeatureTogglesGuardService } from './shared/services/feature-toggles-guard.service'; |
42 | import { ModuleStatusGuardService } from './shared/services/module-status-guard.service'; | |
9f95a23c | 43 | import { NoSsoGuardService } from './shared/services/no-sso-guard.service'; |
11fdf7f2 | 44 | |
f67539c2 | 45 | @Injectable() |
11fdf7f2 TL |
46 | export class PerformanceCounterBreadcrumbsResolver extends BreadcrumbsResolver { |
47 | resolve(route: ActivatedRouteSnapshot) { | |
48 | const result: IBreadcrumb[] = []; | |
49 | ||
50 | const fromPath = route.queryParams.fromLink || null; | |
51 | let fromText = ''; | |
52 | switch (fromPath) { | |
53 | case '/monitor': | |
54 | fromText = 'Monitors'; | |
55 | break; | |
56 | case '/hosts': | |
57 | fromText = 'Hosts'; | |
58 | break; | |
59 | } | |
60 | result.push({ text: 'Cluster', path: null }); | |
61 | result.push({ text: fromText, path: fromPath }); | |
62 | result.push({ text: 'Performance Counters', path: '' }); | |
63 | ||
64 | return result; | |
65 | } | |
66 | } | |
67 | ||
f67539c2 | 68 | @Injectable() |
11fdf7f2 TL |
69 | export class StartCaseBreadcrumbsResolver extends BreadcrumbsResolver { |
70 | resolve(route: ActivatedRouteSnapshot) { | |
71 | const path = route.params.name; | |
72 | const text = _.startCase(path); | |
e306af50 | 73 | return [{ text: `${text}/Edit`, path: path }]; |
11fdf7f2 TL |
74 | } |
75 | } | |
76 | ||
77 | const routes: Routes = [ | |
78 | // Dashboard | |
79 | { path: '', redirectTo: 'dashboard', pathMatch: 'full' }, | |
11fdf7f2 | 80 | { |
9f95a23c TL |
81 | path: '', |
82 | component: WorkbenchLayoutComponent, | |
83 | canActivate: [AuthGuardService, ChangePasswordGuardService], | |
84 | canActivateChild: [AuthGuardService, ChangePasswordGuardService], | |
11fdf7f2 | 85 | children: [ |
9f95a23c | 86 | { path: 'dashboard', component: DashboardComponent }, |
f67539c2 TL |
87 | { path: 'error', component: ErrorComponent }, |
88 | ||
9f95a23c | 89 | // Cluster |
11fdf7f2 | 90 | { |
9f95a23c TL |
91 | path: 'hosts', |
92 | data: { breadcrumbs: 'Cluster/Hosts' }, | |
93 | children: [ | |
94 | { path: '', component: HostsComponent }, | |
95 | { | |
96 | path: URLVerbs.CREATE, | |
97 | component: HostFormComponent, | |
98 | data: { breadcrumbs: ActionLabels.CREATE } | |
99 | } | |
100 | ] | |
101 | }, | |
494da23a | 102 | { |
9f95a23c TL |
103 | path: 'monitor', |
104 | component: MonitorComponent, | |
105 | data: { breadcrumbs: 'Cluster/Monitors' } | |
494da23a TL |
106 | }, |
107 | { | |
9f95a23c | 108 | path: 'services', |
f67539c2 TL |
109 | canActivateChild: [ModuleStatusGuardService], |
110 | data: { | |
111 | moduleStatusGuardConfig: { | |
112 | apiPath: 'orchestrator', | |
113 | redirectTo: 'error', | |
114 | section: 'orch', | |
115 | section_info: 'Orchestrator', | |
116 | header: 'Orchestrator is not available' | |
117 | }, | |
118 | breadcrumbs: 'Cluster/Services' | |
119 | }, | |
adb31ebb TL |
120 | children: [ |
121 | { path: '', component: ServicesComponent }, | |
122 | { | |
123 | path: URLVerbs.CREATE, | |
124 | component: ServiceFormComponent, | |
125 | data: { breadcrumbs: ActionLabels.CREATE } | |
126 | } | |
127 | ] | |
494da23a TL |
128 | }, |
129 | { | |
9f95a23c | 130 | path: 'inventory', |
f67539c2 | 131 | canActivate: [ModuleStatusGuardService], |
9f95a23c | 132 | component: InventoryComponent, |
f67539c2 TL |
133 | data: { |
134 | moduleStatusGuardConfig: { | |
135 | apiPath: 'orchestrator', | |
136 | redirectTo: 'error', | |
137 | section: 'orch', | |
138 | section_info: 'Orchestrator', | |
139 | header: 'Orchestrator is not available' | |
140 | }, | |
141 | breadcrumbs: 'Cluster/Inventory' | |
142 | } | |
494da23a TL |
143 | }, |
144 | { | |
9f95a23c TL |
145 | path: 'osd', |
146 | data: { breadcrumbs: 'Cluster/OSDs' }, | |
147 | children: [ | |
148 | { path: '', component: OsdListComponent }, | |
149 | { | |
150 | path: URLVerbs.CREATE, | |
151 | component: OsdFormComponent, | |
152 | data: { breadcrumbs: ActionLabels.CREATE } | |
153 | } | |
154 | ] | |
155 | }, | |
156 | { | |
157 | path: 'configuration', | |
158 | data: { breadcrumbs: 'Cluster/Configuration' }, | |
159 | children: [ | |
160 | { path: '', component: ConfigurationComponent }, | |
161 | { | |
162 | path: 'edit/:name', | |
163 | component: ConfigurationFormComponent, | |
164 | data: { breadcrumbs: ActionLabels.EDIT } | |
165 | } | |
166 | ] | |
167 | }, | |
168 | { | |
169 | path: 'crush-map', | |
170 | component: CrushmapComponent, | |
171 | data: { breadcrumbs: 'Cluster/CRUSH map' } | |
172 | }, | |
173 | { | |
174 | path: 'logs', | |
175 | component: LogsComponent, | |
176 | data: { breadcrumbs: 'Cluster/Logs' } | |
177 | }, | |
e306af50 TL |
178 | { |
179 | path: 'telemetry', | |
180 | component: TelemetryComponent, | |
181 | data: { breadcrumbs: 'Telemetry configuration' } | |
182 | }, | |
11fdf7f2 | 183 | { |
9f95a23c TL |
184 | path: 'monitoring', |
185 | data: { breadcrumbs: 'Cluster/Monitoring' }, | |
186 | children: [ | |
f67539c2 | 187 | { path: '', redirectTo: 'active-alerts', pathMatch: 'full' }, |
9f95a23c | 188 | { |
f67539c2 TL |
189 | path: 'active-alerts', |
190 | data: { breadcrumbs: 'Active Alerts' }, | |
191 | component: ActiveAlertListComponent | |
9f95a23c TL |
192 | }, |
193 | { | |
f67539c2 TL |
194 | path: 'alerts', |
195 | data: { breadcrumbs: 'Alerts' }, | |
196 | component: RulesListComponent | |
9f95a23c TL |
197 | }, |
198 | { | |
f67539c2 TL |
199 | path: 'silences', |
200 | data: { breadcrumbs: 'Silences' }, | |
201 | children: [ | |
202 | { | |
203 | path: '', | |
204 | component: SilenceListComponent | |
205 | }, | |
206 | { | |
207 | path: URLVerbs.CREATE, | |
208 | component: SilenceFormComponent, | |
209 | data: { breadcrumbs: `${ActionLabels.CREATE} Silence` } | |
210 | }, | |
211 | { | |
212 | path: `${URLVerbs.CREATE}/:id`, | |
213 | component: SilenceFormComponent, | |
214 | data: { breadcrumbs: ActionLabels.CREATE } | |
215 | }, | |
216 | { | |
217 | path: `${URLVerbs.EDIT}/:id`, | |
218 | component: SilenceFormComponent, | |
219 | data: { breadcrumbs: ActionLabels.EDIT } | |
220 | }, | |
221 | { | |
222 | path: `${URLVerbs.RECREATE}/:id`, | |
223 | component: SilenceFormComponent, | |
224 | data: { breadcrumbs: ActionLabels.RECREATE } | |
225 | } | |
226 | ] | |
9f95a23c TL |
227 | } |
228 | ] | |
11fdf7f2 TL |
229 | }, |
230 | { | |
9f95a23c TL |
231 | path: 'perf_counters/:type/:id', |
232 | component: PerformanceCounterComponent, | |
11fdf7f2 | 233 | data: { |
9f95a23c | 234 | breadcrumbs: PerformanceCounterBreadcrumbsResolver |
11fdf7f2 | 235 | } |
9f95a23c TL |
236 | }, |
237 | // Mgr modules | |
238 | { | |
239 | path: 'mgr-modules', | |
f91f0fd5 | 240 | data: { breadcrumbs: 'Cluster/Manager Modules' }, |
9f95a23c TL |
241 | children: [ |
242 | { | |
243 | path: '', | |
244 | component: MgrModuleListComponent | |
245 | }, | |
246 | { | |
247 | path: 'edit/:name', | |
248 | component: MgrModuleFormComponent, | |
249 | data: { | |
250 | breadcrumbs: StartCaseBreadcrumbsResolver | |
251 | } | |
252 | } | |
253 | ] | |
254 | }, | |
255 | // Pools | |
256 | { | |
257 | path: 'pool', | |
258 | data: { breadcrumbs: 'Pools' }, | |
259 | loadChildren: () => import('./ceph/pool/pool.module').then((m) => m.RoutedPoolModule) | |
260 | }, | |
261 | // Block | |
262 | { | |
263 | path: 'block', | |
264 | data: { breadcrumbs: true, text: 'Block', path: null }, | |
265 | loadChildren: () => import('./ceph/block/block.module').then((m) => m.RoutedBlockModule) | |
266 | }, | |
b3b6e05e | 267 | // File Systems |
9f95a23c TL |
268 | { |
269 | path: 'cephfs', | |
270 | component: CephfsListComponent, | |
271 | canActivate: [FeatureTogglesGuardService], | |
b3b6e05e | 272 | data: { breadcrumbs: 'File Systems' } |
9f95a23c TL |
273 | }, |
274 | // Object Gateway | |
275 | { | |
276 | path: 'rgw', | |
277 | canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService], | |
278 | data: { | |
279 | moduleStatusGuardConfig: { | |
280 | apiPath: 'rgw', | |
f67539c2 TL |
281 | redirectTo: 'error', |
282 | section: 'rgw', | |
283 | section_info: 'Object Gateway', | |
284 | header: 'The Object Gateway Service is not configured' | |
9f95a23c TL |
285 | }, |
286 | breadcrumbs: true, | |
287 | text: 'Object Gateway', | |
288 | path: null | |
289 | }, | |
290 | loadChildren: () => import('./ceph/rgw/rgw.module').then((m) => m.RoutedRgwModule) | |
291 | }, | |
292 | // User/Role Management | |
293 | { | |
294 | path: 'user-management', | |
295 | data: { breadcrumbs: 'User management', path: null }, | |
296 | loadChildren: () => import('./core/auth/auth.module').then((m) => m.RoutedAuthModule) | |
297 | }, | |
298 | // User Profile | |
299 | { | |
300 | path: 'user-profile', | |
301 | data: { breadcrumbs: 'User profile', path: null }, | |
302 | children: [ | |
303 | { | |
304 | path: URLVerbs.EDIT, | |
305 | component: UserPasswordFormComponent, | |
306 | canActivate: [NoSsoGuardService], | |
307 | data: { breadcrumbs: ActionLabels.EDIT } | |
308 | } | |
309 | ] | |
310 | }, | |
311 | // NFS | |
9f95a23c TL |
312 | { |
313 | path: 'nfs', | |
314 | canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService], | |
315 | data: { | |
316 | moduleStatusGuardConfig: { | |
317 | apiPath: 'nfs-ganesha', | |
f67539c2 TL |
318 | redirectTo: 'error', |
319 | section: 'nfs-ganesha', | |
320 | section_info: 'NFS GANESHA', | |
321 | header: 'NFS-Ganesha is not configured' | |
9f95a23c TL |
322 | }, |
323 | breadcrumbs: 'NFS' | |
324 | }, | |
325 | children: [ | |
326 | { path: '', component: NfsListComponent }, | |
327 | { | |
328 | path: URLVerbs.CREATE, | |
329 | component: NfsFormComponent, | |
330 | data: { breadcrumbs: ActionLabels.CREATE } | |
331 | }, | |
332 | { | |
333 | path: `${URLVerbs.EDIT}/:cluster_id/:export_id`, | |
334 | component: NfsFormComponent, | |
335 | data: { breadcrumbs: ActionLabels.EDIT } | |
336 | } | |
337 | ] | |
11fdf7f2 TL |
338 | } |
339 | ] | |
340 | }, | |
11fdf7f2 | 341 | { |
9f95a23c TL |
342 | path: '', |
343 | component: LoginLayoutComponent, | |
11fdf7f2 | 344 | children: [ |
9f95a23c | 345 | { path: 'login', component: LoginComponent }, |
11fdf7f2 | 346 | { |
9f95a23c TL |
347 | path: 'login-change-password', |
348 | component: LoginPasswordFormComponent, | |
349 | canActivate: [NoSsoGuardService] | |
e306af50 | 350 | } |
11fdf7f2 TL |
351 | ] |
352 | }, | |
9f95a23c TL |
353 | { |
354 | path: '', | |
355 | component: BlankLayoutComponent, | |
f67539c2 | 356 | children: [{ path: '**', redirectTo: '/error' }] |
9f95a23c | 357 | } |
11fdf7f2 TL |
358 | ]; |
359 | ||
360 | @NgModule({ | |
361 | imports: [ | |
362 | RouterModule.forRoot(routes, { | |
363 | useHash: true, | |
364 | preloadingStrategy: PreloadAllModules | |
365 | }) | |
366 | ], | |
367 | exports: [RouterModule], | |
368 | providers: [StartCaseBreadcrumbsResolver, PerformanceCounterBreadcrumbsResolver] | |
369 | }) | |
370 | export class AppRoutingModule {} |