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