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