]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts
import quincy beta 17.1.0
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / app-routing.module.ts
CommitLineData
f67539c2 1import { Injectable, NgModule } from '@angular/core';
11fdf7f2
TL
2import { ActivatedRouteSnapshot, PreloadAllModules, RouterModule, Routes } from '@angular/router';
3
f67539c2 4import _ from 'lodash';
11fdf7f2
TL
5
6import { CephfsListComponent } from './ceph/cephfs/cephfs-list/cephfs-list.component';
7import { ConfigurationFormComponent } from './ceph/cluster/configuration/configuration-form/configuration-form.component';
8import { ConfigurationComponent } from './ceph/cluster/configuration/configuration.component';
a4b75251 9import { CreateClusterComponent } from './ceph/cluster/create-cluster/create-cluster.component';
11fdf7f2 10import { CrushmapComponent } from './ceph/cluster/crushmap/crushmap.component';
9f95a23c 11import { HostFormComponent } from './ceph/cluster/hosts/host-form/host-form.component';
11fdf7f2 12import { HostsComponent } from './ceph/cluster/hosts/hosts.component';
9f95a23c 13import { InventoryComponent } from './ceph/cluster/inventory/inventory.component';
11fdf7f2
TL
14import { LogsComponent } from './ceph/cluster/logs/logs.component';
15import { MgrModuleFormComponent } from './ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component';
16import { MgrModuleListComponent } from './ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component';
17import { MonitorComponent } from './ceph/cluster/monitor/monitor.component';
9f95a23c 18import { OsdFormComponent } from './ceph/cluster/osd/osd-form/osd-form.component';
11fdf7f2 19import { OsdListComponent } from './ceph/cluster/osd/osd-list/osd-list.component';
f67539c2
TL
20import { ActiveAlertListComponent } from './ceph/cluster/prometheus/active-alert-list/active-alert-list.component';
21import { RulesListComponent } from './ceph/cluster/prometheus/rules-list/rules-list.component';
494da23a 22import { SilenceFormComponent } from './ceph/cluster/prometheus/silence-form/silence-form.component';
f67539c2 23import { SilenceListComponent } from './ceph/cluster/prometheus/silence-list/silence-list.component';
adb31ebb 24import { ServiceFormComponent } from './ceph/cluster/services/service-form/service-form.component';
9f95a23c 25import { ServicesComponent } from './ceph/cluster/services/services.component';
e306af50 26import { TelemetryComponent } from './ceph/cluster/telemetry/telemetry.component';
11fdf7f2 27import { DashboardComponent } from './ceph/dashboard/dashboard/dashboard.component';
11fdf7f2
TL
28import { NfsFormComponent } from './ceph/nfs/nfs-form/nfs-form.component';
29import { NfsListComponent } from './ceph/nfs/nfs-list/nfs-list.component';
30import { PerformanceCounterComponent } from './ceph/performance-counter/performance-counter/performance-counter.component';
9f95a23c 31import { LoginPasswordFormComponent } from './core/auth/login-password-form/login-password-form.component';
11fdf7f2 32import { LoginComponent } from './core/auth/login/login.component';
9f95a23c 33import { UserPasswordFormComponent } from './core/auth/user-password-form/user-password-form.component';
f67539c2 34import { ErrorComponent } from './core/error/error.component';
9f95a23c
TL
35import { BlankLayoutComponent } from './core/layouts/blank-layout/blank-layout.component';
36import { LoginLayoutComponent } from './core/layouts/login-layout/login-layout.component';
37import { WorkbenchLayoutComponent } from './core/layouts/workbench-layout/workbench-layout.component';
20effc67 38import { ApiDocsComponent } from './core/navigation/api-docs/api-docs.component';
494da23a 39import { ActionLabels, URLVerbs } from './shared/constants/app.constants';
11fdf7f2
TL
40import { BreadcrumbsResolver, IBreadcrumb } from './shared/models/breadcrumbs';
41import { AuthGuardService } from './shared/services/auth-guard.service';
9f95a23c 42import { ChangePasswordGuardService } from './shared/services/change-password-guard.service';
11fdf7f2
TL
43import { FeatureTogglesGuardService } from './shared/services/feature-toggles-guard.service';
44import { ModuleStatusGuardService } from './shared/services/module-status-guard.service';
9f95a23c 45import { NoSsoGuardService } from './shared/services/no-sso-guard.service';
11fdf7f2 46
f67539c2 47@Injectable()
11fdf7f2
TL
48export 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
f67539c2 70@Injectable()
11fdf7f2
TL
71export class StartCaseBreadcrumbsResolver extends BreadcrumbsResolver {
72 resolve(route: ActivatedRouteSnapshot) {
73 const path = route.params.name;
74 const text = _.startCase(path);
e306af50 75 return [{ text: `${text}/Edit`, path: path }];
11fdf7f2
TL
76 }
77}
78
79const routes: Routes = [
80 // Dashboard
81 { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
20effc67 82 { path: 'api-docs', component: ApiDocsComponent },
11fdf7f2 83 {
9f95a23c
TL
84 path: '',
85 component: WorkbenchLayoutComponent,
86 canActivate: [AuthGuardService, ChangePasswordGuardService],
87 canActivateChild: [AuthGuardService, ChangePasswordGuardService],
11fdf7f2 88 children: [
9f95a23c 89 { path: 'dashboard', component: DashboardComponent },
f67539c2
TL
90 { path: 'error', component: ErrorComponent },
91
9f95a23c 92 // Cluster
a4b75251
TL
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 },
11fdf7f2 106 {
9f95a23c 107 path: 'hosts',
a4b75251 108 component: HostsComponent,
9f95a23c
TL
109 data: { breadcrumbs: 'Cluster/Hosts' },
110 children: [
9f95a23c 111 {
a4b75251 112 path: URLVerbs.ADD,
9f95a23c 113 component: HostFormComponent,
a4b75251 114 outlet: 'modal'
9f95a23c
TL
115 }
116 ]
117 },
494da23a 118 {
9f95a23c
TL
119 path: 'monitor',
120 component: MonitorComponent,
121 data: { breadcrumbs: 'Cluster/Monitors' }
494da23a
TL
122 },
123 {
9f95a23c 124 path: 'services',
a4b75251
TL
125 component: ServicesComponent,
126 canActivate: [ModuleStatusGuardService],
f67539c2
TL
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 },
adb31ebb 137 children: [
adb31ebb
TL
138 {
139 path: URLVerbs.CREATE,
140 component: ServiceFormComponent,
a4b75251
TL
141 outlet: 'modal'
142 },
143 {
144 path: `${URLVerbs.EDIT}/:type/:name`,
145 component: ServiceFormComponent,
146 outlet: 'modal'
adb31ebb
TL
147 }
148 ]
494da23a
TL
149 },
150 {
9f95a23c 151 path: 'inventory',
f67539c2 152 canActivate: [ModuleStatusGuardService],
9f95a23c 153 component: InventoryComponent,
f67539c2
TL
154 data: {
155 moduleStatusGuardConfig: {
156 apiPath: 'orchestrator',
157 redirectTo: 'error',
158 section: 'orch',
159 section_info: 'Orchestrator',
160 header: 'Orchestrator is not available'
161 },
522d829b 162 breadcrumbs: 'Cluster/Physical Disks'
f67539c2 163 }
494da23a
TL
164 },
165 {
9f95a23c
TL
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 },
e306af50
TL
199 {
200 path: 'telemetry',
201 component: TelemetryComponent,
202 data: { breadcrumbs: 'Telemetry configuration' }
203 },
11fdf7f2 204 {
9f95a23c
TL
205 path: 'monitoring',
206 data: { breadcrumbs: 'Cluster/Monitoring' },
207 children: [
f67539c2 208 { path: '', redirectTo: 'active-alerts', pathMatch: 'full' },
9f95a23c 209 {
f67539c2
TL
210 path: 'active-alerts',
211 data: { breadcrumbs: 'Active Alerts' },
212 component: ActiveAlertListComponent
9f95a23c
TL
213 },
214 {
f67539c2
TL
215 path: 'alerts',
216 data: { breadcrumbs: 'Alerts' },
217 component: RulesListComponent
9f95a23c
TL
218 },
219 {
f67539c2
TL
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 ]
9f95a23c
TL
248 }
249 ]
11fdf7f2
TL
250 },
251 {
9f95a23c
TL
252 path: 'perf_counters/:type/:id',
253 component: PerformanceCounterComponent,
11fdf7f2 254 data: {
9f95a23c 255 breadcrumbs: PerformanceCounterBreadcrumbsResolver
11fdf7f2 256 }
9f95a23c
TL
257 },
258 // Mgr modules
259 {
260 path: 'mgr-modules',
f91f0fd5 261 data: { breadcrumbs: 'Cluster/Manager Modules' },
9f95a23c
TL
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 },
b3b6e05e 288 // File Systems
9f95a23c
TL
289 {
290 path: 'cephfs',
291 component: CephfsListComponent,
292 canActivate: [FeatureTogglesGuardService],
b3b6e05e 293 data: { breadcrumbs: 'File Systems' }
9f95a23c
TL
294 },
295 // Object Gateway
296 {
297 path: 'rgw',
298 canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService],
299 data: {
300 moduleStatusGuardConfig: {
301 apiPath: 'rgw',
f67539c2
TL
302 redirectTo: 'error',
303 section: 'rgw',
304 section_info: 'Object Gateway',
305 header: 'The Object Gateway Service is not configured'
9f95a23c
TL
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
9f95a23c
TL
333 {
334 path: 'nfs',
335 canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService],
336 data: {
337 moduleStatusGuardConfig: {
338 apiPath: 'nfs-ganesha',
f67539c2
TL
339 redirectTo: 'error',
340 section: 'nfs-ganesha',
341 section_info: 'NFS GANESHA',
342 header: 'NFS-Ganesha is not configured'
9f95a23c
TL
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 ]
11fdf7f2
TL
359 }
360 ]
361 },
11fdf7f2 362 {
9f95a23c
TL
363 path: '',
364 component: LoginLayoutComponent,
11fdf7f2 365 children: [
9f95a23c 366 { path: 'login', component: LoginComponent },
11fdf7f2 367 {
9f95a23c
TL
368 path: 'login-change-password',
369 component: LoginPasswordFormComponent,
370 canActivate: [NoSsoGuardService]
e306af50 371 }
11fdf7f2
TL
372 ]
373 },
9f95a23c
TL
374 {
375 path: '',
376 component: BlankLayoutComponent,
f67539c2 377 children: [{ path: '**', redirectTo: '/error' }]
9f95a23c 378 }
11fdf7f2
TL
379];
380
381@NgModule({
382 imports: [
383 RouterModule.forRoot(routes, {
384 useHash: true,
a4b75251
TL
385 preloadingStrategy: PreloadAllModules,
386 relativeLinkResolution: 'legacy'
11fdf7f2
TL
387 })
388 ],
389 exports: [RouterModule],
390 providers: [StartCaseBreadcrumbsResolver, PerformanceCounterBreadcrumbsResolver]
391})
392export class AppRoutingModule {}