1 import { Injectable, NgModule } from '@angular/core';
2 import { ActivatedRouteSnapshot, PreloadAllModules, RouterModule, Routes } from '@angular/router';
4 import _ from 'lodash';
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';
48 export class PerformanceCounterBreadcrumbsResolver extends BreadcrumbsResolver {
49 resolve(route: ActivatedRouteSnapshot) {
50 const result: IBreadcrumb[] = [];
52 const fromPath = route.queryParams.fromLink || null;
56 fromText = 'Monitors';
62 result.push({ text: 'Cluster', path: null });
63 result.push({ text: fromText, path: fromPath });
64 result.push({ text: 'Performance Counters', path: '' });
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 }];
79 const routes: Routes = [
81 { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
82 { path: 'api-docs', component: ApiDocsComponent },
85 component: WorkbenchLayoutComponent,
86 canActivate: [AuthGuardService, ChangePasswordGuardService],
87 canActivateChild: [AuthGuardService, ChangePasswordGuardService],
89 { path: 'dashboard', component: DashboardComponent },
90 { path: 'error', component: ErrorComponent },
94 path: 'expand-cluster',
95 component: CreateClusterComponent,
96 canActivate: [ModuleStatusGuardService],
98 moduleStatusGuardConfig: {
99 apiPath: 'orchestrator',
100 redirectTo: 'dashboard',
103 breadcrumbs: 'Expand Cluster'
108 component: HostsComponent,
109 data: { breadcrumbs: 'Cluster/Hosts' },
113 component: HostFormComponent,
120 component: MonitorComponent,
121 data: { breadcrumbs: 'Cluster/Monitors' }
125 component: ServicesComponent,
126 canActivate: [ModuleStatusGuardService],
128 moduleStatusGuardConfig: {
129 apiPath: 'orchestrator',
132 section_info: 'Orchestrator',
133 header: 'Orchestrator is not available'
135 breadcrumbs: 'Cluster/Services'
139 path: URLVerbs.CREATE,
140 component: ServiceFormComponent,
144 path: `${URLVerbs.EDIT}/:type/:name`,
145 component: ServiceFormComponent,
152 canActivate: [ModuleStatusGuardService],
153 component: InventoryComponent,
155 moduleStatusGuardConfig: {
156 apiPath: 'orchestrator',
159 section_info: 'Orchestrator',
160 header: 'Orchestrator is not available'
162 breadcrumbs: 'Cluster/Physical Disks'
167 data: { breadcrumbs: 'Cluster/OSDs' },
169 { path: '', component: OsdListComponent },
171 path: URLVerbs.CREATE,
172 component: OsdFormComponent,
173 data: { breadcrumbs: ActionLabels.CREATE }
178 path: 'configuration',
179 data: { breadcrumbs: 'Cluster/Configuration' },
181 { path: '', component: ConfigurationComponent },
184 component: ConfigurationFormComponent,
185 data: { breadcrumbs: ActionLabels.EDIT }
191 component: CrushmapComponent,
192 data: { breadcrumbs: 'Cluster/CRUSH map' }
196 component: LogsComponent,
197 data: { breadcrumbs: 'Cluster/Logs' }
201 component: TelemetryComponent,
202 data: { breadcrumbs: 'Telemetry configuration' }
206 data: { breadcrumbs: 'Cluster/Monitoring' },
208 { path: '', redirectTo: 'active-alerts', pathMatch: 'full' },
210 path: 'active-alerts',
211 data: { breadcrumbs: 'Active Alerts' },
212 component: ActiveAlertListComponent
216 data: { breadcrumbs: 'Alerts' },
217 component: RulesListComponent
221 data: { breadcrumbs: 'Silences' },
225 component: SilenceListComponent
228 path: URLVerbs.CREATE,
229 component: SilenceFormComponent,
230 data: { breadcrumbs: `${ActionLabels.CREATE} Silence` }
233 path: `${URLVerbs.CREATE}/:id`,
234 component: SilenceFormComponent,
235 data: { breadcrumbs: ActionLabels.CREATE }
238 path: `${URLVerbs.EDIT}/:id`,
239 component: SilenceFormComponent,
240 data: { breadcrumbs: ActionLabels.EDIT }
243 path: `${URLVerbs.RECREATE}/:id`,
244 component: SilenceFormComponent,
245 data: { breadcrumbs: ActionLabels.RECREATE }
252 path: 'perf_counters/:type/:id',
253 component: PerformanceCounterComponent,
255 breadcrumbs: PerformanceCounterBreadcrumbsResolver
261 data: { breadcrumbs: 'Cluster/Manager Modules' },
265 component: MgrModuleListComponent
269 component: MgrModuleFormComponent,
271 breadcrumbs: StartCaseBreadcrumbsResolver
279 data: { breadcrumbs: 'Pools' },
280 loadChildren: () => import('./ceph/pool/pool.module').then((m) => m.RoutedPoolModule)
285 data: { breadcrumbs: true, text: 'Block', path: null },
286 loadChildren: () => import('./ceph/block/block.module').then((m) => m.RoutedBlockModule)
291 component: CephfsListComponent,
292 canActivate: [FeatureTogglesGuardService],
293 data: { breadcrumbs: 'File Systems' }
298 canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService],
300 moduleStatusGuardConfig: {
304 section_info: 'Object Gateway',
305 header: 'The Object Gateway Service is not configured'
308 text: 'Object Gateway',
311 loadChildren: () => import('./ceph/rgw/rgw.module').then((m) => m.RoutedRgwModule)
313 // User/Role Management
315 path: 'user-management',
316 data: { breadcrumbs: 'User management', path: null },
317 loadChildren: () => import('./core/auth/auth.module').then((m) => m.RoutedAuthModule)
321 path: 'user-profile',
322 data: { breadcrumbs: 'User profile', path: null },
326 component: UserPasswordFormComponent,
327 canActivate: [NoSsoGuardService],
328 data: { breadcrumbs: ActionLabels.EDIT }
335 canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService],
337 moduleStatusGuardConfig: {
338 apiPath: 'nfs-ganesha',
340 section: 'nfs-ganesha',
341 section_info: 'NFS GANESHA',
342 header: 'NFS-Ganesha is not configured'
347 { path: '', component: NfsListComponent },
349 path: URLVerbs.CREATE,
350 component: NfsFormComponent,
351 data: { breadcrumbs: ActionLabels.CREATE }
354 path: `${URLVerbs.EDIT}/:cluster_id/:export_id`,
355 component: NfsFormComponent,
356 data: { breadcrumbs: ActionLabels.EDIT }
364 component: LoginLayoutComponent,
366 { path: 'login', component: LoginComponent },
368 path: 'login-change-password',
369 component: LoginPasswordFormComponent,
370 canActivate: [NoSsoGuardService]
376 component: BlankLayoutComponent,
377 children: [{ path: '**', redirectTo: '/error' }]
383 RouterModule.forRoot(routes, {
385 preloadingStrategy: PreloadAllModules,
386 relativeLinkResolution: 'legacy'
389 exports: [RouterModule],
390 providers: [StartCaseBreadcrumbsResolver, PerformanceCounterBreadcrumbsResolver]
392 export class AppRoutingModule {}