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