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