1 import { NgModule } from '@angular/core';
2 import { ActivatedRouteSnapshot, PreloadAllModules, RouterModule, Routes } from '@angular/router';
4 import * as _ 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 { CrushmapComponent } from './ceph/cluster/crushmap/crushmap.component';
10 import { HostFormComponent } from './ceph/cluster/hosts/host-form/host-form.component';
11 import { HostsComponent } from './ceph/cluster/hosts/hosts.component';
12 import { InventoryComponent } from './ceph/cluster/inventory/inventory.component';
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';
17 import { OsdFormComponent } from './ceph/cluster/osd/osd-form/osd-form.component';
18 import { OsdListComponent } from './ceph/cluster/osd/osd-list/osd-list.component';
19 import { MonitoringListComponent } from './ceph/cluster/prometheus/monitoring-list/monitoring-list.component';
20 import { SilenceFormComponent } from './ceph/cluster/prometheus/silence-form/silence-form.component';
21 import { ServicesComponent } from './ceph/cluster/services/services.component';
22 import { DashboardComponent } from './ceph/dashboard/dashboard/dashboard.component';
23 import { Nfs501Component } from './ceph/nfs/nfs-501/nfs-501.component';
24 import { NfsFormComponent } from './ceph/nfs/nfs-form/nfs-form.component';
25 import { NfsListComponent } from './ceph/nfs/nfs-list/nfs-list.component';
26 import { PerformanceCounterComponent } from './ceph/performance-counter/performance-counter/performance-counter.component';
27 import { LoginPasswordFormComponent } from './core/auth/login-password-form/login-password-form.component';
28 import { LoginComponent } from './core/auth/login/login.component';
29 import { SsoNotFoundComponent } from './core/auth/sso/sso-not-found/sso-not-found.component';
30 import { UserPasswordFormComponent } from './core/auth/user-password-form/user-password-form.component';
31 import { ForbiddenComponent } from './core/forbidden/forbidden.component';
32 import { BlankLayoutComponent } from './core/layouts/blank-layout/blank-layout.component';
33 import { LoginLayoutComponent } from './core/layouts/login-layout/login-layout.component';
34 import { WorkbenchLayoutComponent } from './core/layouts/workbench-layout/workbench-layout.component';
35 import { NotFoundComponent } from './core/not-found/not-found.component';
36 import { ActionLabels, URLVerbs } from './shared/constants/app.constants';
37 import { BreadcrumbsResolver, IBreadcrumb } from './shared/models/breadcrumbs';
38 import { AuthGuardService } from './shared/services/auth-guard.service';
39 import { ChangePasswordGuardService } from './shared/services/change-password-guard.service';
40 import { FeatureTogglesGuardService } from './shared/services/feature-toggles-guard.service';
41 import { ModuleStatusGuardService } from './shared/services/module-status-guard.service';
42 import { NoSsoGuardService } from './shared/services/no-sso-guard.service';
44 export class PerformanceCounterBreadcrumbsResolver extends BreadcrumbsResolver {
45 resolve(route: ActivatedRouteSnapshot) {
46 const result: IBreadcrumb[] = [];
48 const fromPath = route.queryParams.fromLink || null;
52 fromText = 'Monitors';
58 result.push({ text: 'Cluster', path: null });
59 result.push({ text: fromText, path: fromPath });
60 result.push({ text: 'Performance Counters', path: '' });
66 export class StartCaseBreadcrumbsResolver extends BreadcrumbsResolver {
67 resolve(route: ActivatedRouteSnapshot) {
68 const path = route.params.name;
69 const text = _.startCase(path);
70 return [{ text: text, path: path }];
74 const routes: Routes = [
76 { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
79 component: WorkbenchLayoutComponent,
80 canActivate: [AuthGuardService, ChangePasswordGuardService],
81 canActivateChild: [AuthGuardService, ChangePasswordGuardService],
83 { path: 'dashboard', component: DashboardComponent },
87 data: { breadcrumbs: 'Cluster/Hosts' },
89 { path: '', component: HostsComponent },
91 path: URLVerbs.CREATE,
92 component: HostFormComponent,
93 data: { breadcrumbs: ActionLabels.CREATE }
99 component: MonitorComponent,
100 data: { breadcrumbs: 'Cluster/Monitors' }
104 component: ServicesComponent,
105 data: { breadcrumbs: 'Cluster/Services' }
109 component: InventoryComponent,
110 data: { breadcrumbs: 'Cluster/Inventory' }
114 data: { breadcrumbs: 'Cluster/OSDs' },
116 { path: '', component: OsdListComponent },
118 path: URLVerbs.CREATE,
119 component: OsdFormComponent,
120 data: { breadcrumbs: ActionLabels.CREATE }
125 path: 'configuration',
126 data: { breadcrumbs: 'Cluster/Configuration' },
128 { path: '', component: ConfigurationComponent },
131 component: ConfigurationFormComponent,
132 data: { breadcrumbs: ActionLabels.EDIT }
138 component: CrushmapComponent,
139 data: { breadcrumbs: 'Cluster/CRUSH map' }
143 component: LogsComponent,
144 data: { breadcrumbs: 'Cluster/Logs' }
148 data: { breadcrumbs: 'Cluster/Monitoring' },
152 component: MonitoringListComponent
155 path: 'silence/' + URLVerbs.CREATE,
156 component: SilenceFormComponent,
157 data: { breadcrumbs: `${ActionLabels.CREATE} Silence` }
160 path: `silence/${URLVerbs.CREATE}/:id`,
161 component: SilenceFormComponent,
162 data: { breadcrumbs: ActionLabels.CREATE }
165 path: `silence/${URLVerbs.EDIT}/:id`,
166 component: SilenceFormComponent,
167 data: { breadcrumbs: ActionLabels.EDIT }
170 path: `silence/${URLVerbs.RECREATE}/:id`,
171 component: SilenceFormComponent,
172 data: { breadcrumbs: ActionLabels.RECREATE }
177 path: 'perf_counters/:type/:id',
178 component: PerformanceCounterComponent,
180 breadcrumbs: PerformanceCounterBreadcrumbsResolver
186 data: { breadcrumbs: 'Cluster/Manager modules' },
190 component: MgrModuleListComponent
194 component: MgrModuleFormComponent,
196 breadcrumbs: StartCaseBreadcrumbsResolver
204 data: { breadcrumbs: 'Pools' },
205 loadChildren: () => import('./ceph/pool/pool.module').then((m) => m.RoutedPoolModule)
210 data: { breadcrumbs: true, text: 'Block', path: null },
211 loadChildren: () => import('./ceph/block/block.module').then((m) => m.RoutedBlockModule)
216 component: CephfsListComponent,
217 canActivate: [FeatureTogglesGuardService],
218 data: { breadcrumbs: 'Filesystems' }
223 canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService],
225 moduleStatusGuardConfig: {
227 redirectTo: 'rgw/501'
230 text: 'Object Gateway',
233 loadChildren: () => import('./ceph/rgw/rgw.module').then((m) => m.RoutedRgwModule)
235 // User/Role Management
237 path: 'user-management',
238 data: { breadcrumbs: 'User management', path: null },
239 loadChildren: () => import('./core/auth/auth.module').then((m) => m.RoutedAuthModule)
243 path: 'user-profile',
244 data: { breadcrumbs: 'User profile', path: null },
248 component: UserPasswordFormComponent,
249 canActivate: [NoSsoGuardService],
250 data: { breadcrumbs: ActionLabels.EDIT }
256 path: 'nfs/501/:message',
257 component: Nfs501Component,
258 data: { breadcrumbs: 'NFS' }
262 canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService],
264 moduleStatusGuardConfig: {
265 apiPath: 'nfs-ganesha',
266 redirectTo: 'nfs/501'
271 { path: '', component: NfsListComponent },
273 path: URLVerbs.CREATE,
274 component: NfsFormComponent,
275 data: { breadcrumbs: ActionLabels.CREATE }
278 path: `${URLVerbs.EDIT}/:cluster_id/:export_id`,
279 component: NfsFormComponent,
280 data: { breadcrumbs: ActionLabels.EDIT }
288 component: LoginLayoutComponent,
290 { path: 'login', component: LoginComponent },
292 path: 'login-change-password',
293 component: LoginPasswordFormComponent,
294 canActivate: [NoSsoGuardService]
296 { path: 'logout', children: [] }
301 component: BlankLayoutComponent,
303 // Single Sign-On (SSO)
304 { path: 'sso/404', component: SsoNotFoundComponent },
306 { path: '403', component: ForbiddenComponent },
307 { path: '404', component: NotFoundComponent },
308 { path: '**', redirectTo: '/404' }
315 RouterModule.forRoot(routes, {
317 preloadingStrategy: PreloadAllModules
320 exports: [RouterModule],
321 providers: [StartCaseBreadcrumbsResolver, PerformanceCounterBreadcrumbsResolver]
323 export class AppRoutingModule {}