]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts
update sources to ceph Nautilus 14.2.1
[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';
10import { HostsComponent } from './ceph/cluster/hosts/hosts.component';
11import { LogsComponent } from './ceph/cluster/logs/logs.component';
12import { MgrModuleFormComponent } from './ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component';
13import { MgrModuleListComponent } from './ceph/cluster/mgr-modules/mgr-module-list/mgr-module-list.component';
14import { MonitorComponent } from './ceph/cluster/monitor/monitor.component';
15import { OsdListComponent } from './ceph/cluster/osd/osd-list/osd-list.component';
16import { PrometheusListComponent } from './ceph/cluster/prometheus/prometheus-list/prometheus-list.component';
17import { DashboardComponent } from './ceph/dashboard/dashboard/dashboard.component';
18import { Nfs501Component } from './ceph/nfs/nfs-501/nfs-501.component';
19import { NfsFormComponent } from './ceph/nfs/nfs-form/nfs-form.component';
20import { NfsListComponent } from './ceph/nfs/nfs-list/nfs-list.component';
21import { PerformanceCounterComponent } from './ceph/performance-counter/performance-counter/performance-counter.component';
22import { LoginComponent } from './core/auth/login/login.component';
23import { SsoNotFoundComponent } from './core/auth/sso/sso-not-found/sso-not-found.component';
24import { ForbiddenComponent } from './core/forbidden/forbidden.component';
25import { NotFoundComponent } from './core/not-found/not-found.component';
26import { BreadcrumbsResolver, IBreadcrumb } from './shared/models/breadcrumbs';
27import { AuthGuardService } from './shared/services/auth-guard.service';
28import { FeatureTogglesGuardService } from './shared/services/feature-toggles-guard.service';
29import { ModuleStatusGuardService } from './shared/services/module-status-guard.service';
30
31export class PerformanceCounterBreadcrumbsResolver extends BreadcrumbsResolver {
32 resolve(route: ActivatedRouteSnapshot) {
33 const result: IBreadcrumb[] = [];
34
35 const fromPath = route.queryParams.fromLink || null;
36 let fromText = '';
37 switch (fromPath) {
38 case '/monitor':
39 fromText = 'Monitors';
40 break;
41 case '/hosts':
42 fromText = 'Hosts';
43 break;
44 }
45 result.push({ text: 'Cluster', path: null });
46 result.push({ text: fromText, path: fromPath });
47 result.push({ text: 'Performance Counters', path: '' });
48
49 return result;
50 }
51}
52
53export class StartCaseBreadcrumbsResolver extends BreadcrumbsResolver {
54 resolve(route: ActivatedRouteSnapshot) {
55 const path = route.params.name;
56 const text = _.startCase(path);
57 return [{ text: text, path: path }];
58 }
59}
60
61const routes: Routes = [
62 // Dashboard
63 { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
64 { path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuardService] },
65 // Cluster
66 {
67 path: 'hosts',
68 component: HostsComponent,
69 canActivate: [AuthGuardService],
70 data: { breadcrumbs: 'Cluster/Hosts' }
71 },
72 {
73 path: 'monitor',
74 component: MonitorComponent,
75 canActivate: [AuthGuardService],
76 data: { breadcrumbs: 'Cluster/Monitors' }
77 },
78 {
79 path: 'osd',
80 canActivate: [AuthGuardService],
81 canActivateChild: [AuthGuardService],
82 data: { breadcrumbs: 'Cluster/OSDs' },
83 children: [{ path: '', component: OsdListComponent }]
84 },
85 {
86 path: 'configuration',
87 data: { breadcrumbs: 'Cluster/Configuration' },
88 children: [
89 { path: '', component: ConfigurationComponent },
90 {
91 path: 'edit/:name',
92 component: ConfigurationFormComponent,
93 data: { breadcrumbs: 'Edit' }
94 }
95 ]
96 },
97 {
98 path: 'crush-map',
99 component: CrushmapComponent,
100 canActivate: [AuthGuardService],
101 data: { breadcrumbs: 'Cluster/CRUSH map' }
102 },
103 {
104 path: 'logs',
105 component: LogsComponent,
106 canActivate: [AuthGuardService],
107 data: { breadcrumbs: 'Cluster/Logs' }
108 },
109 {
110 path: 'alerts',
111 component: PrometheusListComponent,
112 canActivate: [AuthGuardService],
113 data: { breadcrumbs: 'Cluster/Alerts' }
114 },
115 {
116 path: 'perf_counters/:type/:id',
117 component: PerformanceCounterComponent,
118 canActivate: [AuthGuardService],
119 data: {
120 breadcrumbs: PerformanceCounterBreadcrumbsResolver
121 }
122 },
123 // Mgr modules
124 {
125 path: 'mgr-modules',
126 canActivate: [AuthGuardService],
127 canActivateChild: [AuthGuardService],
128 data: { breadcrumbs: 'Cluster/Manager modules' },
129 children: [
130 {
131 path: '',
132 component: MgrModuleListComponent
133 },
134 {
135 path: 'edit/:name',
136 component: MgrModuleFormComponent,
137 data: {
138 breadcrumbs: StartCaseBreadcrumbsResolver
139 }
140 }
141 ]
142 },
143 // Pools
144 {
145 path: 'pool',
146 canActivate: [AuthGuardService],
147 canActivateChild: [AuthGuardService],
148 data: { breadcrumbs: 'Pools' },
149 loadChildren: './ceph/pool/pool.module#RoutedPoolModule'
150 },
151 // Block
152 {
153 path: 'block',
154 canActivateChild: [AuthGuardService],
155 canActivate: [AuthGuardService],
156 data: { breadcrumbs: true, text: 'Block', path: null },
157 loadChildren: './ceph/block/block.module#RoutedBlockModule'
158 },
159 // Filesystems
160 {
161 path: 'cephfs',
162 component: CephfsListComponent,
163 canActivate: [FeatureTogglesGuardService, AuthGuardService],
164 data: { breadcrumbs: 'Filesystems' }
165 },
166 // Object Gateway
167 {
168 path: 'rgw',
169 canActivateChild: [FeatureTogglesGuardService, ModuleStatusGuardService, AuthGuardService],
170 data: {
171 moduleStatusGuardConfig: {
172 apiPath: 'rgw',
173 redirectTo: 'rgw/501'
174 },
175 breadcrumbs: true,
176 text: 'Object Gateway',
177 path: null
178 },
179 loadChildren: './ceph/rgw/rgw.module#RoutedRgwModule'
180 },
181 // Dashboard Settings
182 {
183 path: 'user-management',
184 canActivate: [AuthGuardService],
185 canActivateChild: [AuthGuardService],
186 data: { breadcrumbs: 'User management', path: null },
187 loadChildren: './core/auth/auth.module#RoutedAuthModule'
188 },
189 // NFS
190 {
191 path: 'nfs/501/:message',
192 component: Nfs501Component,
193 canActivate: [AuthGuardService],
194 data: { breadcrumbs: 'NFS' }
195 },
196 {
197 path: 'nfs',
198 canActivate: [AuthGuardService],
199 canActivateChild: [AuthGuardService, ModuleStatusGuardService],
200 data: {
201 moduleStatusGuardConfig: {
202 apiPath: 'nfs-ganesha',
203 redirectTo: 'nfs/501'
204 },
205 breadcrumbs: 'NFS'
206 },
207 children: [
208 { path: '', component: NfsListComponent },
209 { path: 'add', component: NfsFormComponent, data: { breadcrumbs: 'Add' } },
210 {
211 path: 'edit/:cluster_id/:export_id',
212 component: NfsFormComponent,
213 data: { breadcrumbs: 'Edit' }
214 }
215 ]
216 },
217 // Single Sign-On (SSO)
218 { path: 'sso/404', component: SsoNotFoundComponent },
219 // System
220 { path: 'login', component: LoginComponent },
221 { path: 'logout', children: [] },
222 { path: '403', component: ForbiddenComponent },
223 { path: '404', component: NotFoundComponent },
224 { path: '**', redirectTo: '/404' }
225];
226
227@NgModule({
228 imports: [
229 RouterModule.forRoot(routes, {
230 useHash: true,
231 preloadingStrategy: PreloadAllModules
232 })
233 ],
234 exports: [RouterModule],
235 providers: [StartCaseBreadcrumbsResolver, PerformanceCounterBreadcrumbsResolver]
236})
237export class AppRoutingModule {}