]>
Commit | Line | Data |
---|---|---|
1911f103 TL |
1 | import { Component, HostBinding, OnDestroy, OnInit } from '@angular/core'; |
2 | ||
3 | import { Subscription } from 'rxjs'; | |
11fdf7f2 | 4 | |
9f95a23c | 5 | import { Icons } from '../../../shared/enum/icons.enum'; |
11fdf7f2 TL |
6 | import { Permissions } from '../../../shared/models/permissions'; |
7 | import { AuthStorageService } from '../../../shared/services/auth-storage.service'; | |
8 | import { | |
9 | FeatureTogglesMap$, | |
10 | FeatureTogglesService | |
11 | } from '../../../shared/services/feature-toggles.service'; | |
12 | import { SummaryService } from '../../../shared/services/summary.service'; | |
13 | ||
14 | @Component({ | |
15 | selector: 'cd-navigation', | |
16 | templateUrl: './navigation.component.html', | |
17 | styleUrls: ['./navigation.component.scss'] | |
18 | }) | |
1911f103 | 19 | export class NavigationComponent implements OnInit, OnDestroy { |
9f95a23c TL |
20 | @HostBinding('class.isPwdDisplayed') isPwdDisplayed = false; |
21 | ||
11fdf7f2 | 22 | permissions: Permissions; |
9f95a23c | 23 | enabledFeature$: FeatureTogglesMap$; |
11fdf7f2 | 24 | summaryData: any; |
9f95a23c | 25 | icons = Icons; |
11fdf7f2 TL |
26 | |
27 | isCollapsed = true; | |
9f95a23c TL |
28 | showMenuSidebar = true; |
29 | displayedSubMenu = ''; | |
30 | ||
31 | simplebar = { | |
32 | autoHide: false | |
33 | }; | |
1911f103 | 34 | private subs = new Subscription(); |
11fdf7f2 TL |
35 | |
36 | constructor( | |
37 | private authStorageService: AuthStorageService, | |
11fdf7f2 TL |
38 | private summaryService: SummaryService, |
39 | private featureToggles: FeatureTogglesService | |
40 | ) { | |
41 | this.permissions = this.authStorageService.getPermissions(); | |
42 | this.enabledFeature$ = this.featureToggles.get(); | |
43 | } | |
44 | ||
45 | ngOnInit() { | |
1911f103 TL |
46 | this.subs.add( |
47 | this.summaryService.subscribe((data: any) => { | |
48 | if (!data) { | |
49 | return; | |
50 | } | |
51 | this.summaryData = data; | |
52 | }) | |
53 | ); | |
54 | this.subs.add( | |
55 | this.authStorageService.isPwdDisplayed$.subscribe((isDisplayed) => { | |
56 | this.isPwdDisplayed = isDisplayed; | |
57 | }) | |
58 | ); | |
59 | } | |
60 | ||
61 | ngOnDestroy(): void { | |
62 | this.subs.unsubscribe(); | |
11fdf7f2 TL |
63 | } |
64 | ||
65 | blockHealthColor() { | |
66 | if (this.summaryData && this.summaryData.rbd_mirroring) { | |
67 | if (this.summaryData.rbd_mirroring.errors > 0) { | |
68 | return { color: '#d9534f' }; | |
69 | } else if (this.summaryData.rbd_mirroring.warnings > 0) { | |
70 | return { color: '#f0ad4e' }; | |
71 | } | |
72 | } | |
9f95a23c TL |
73 | |
74 | return undefined; | |
75 | } | |
76 | ||
77 | toggleSubMenu(menu: string) { | |
78 | if (this.displayedSubMenu === menu) { | |
79 | this.displayedSubMenu = ''; | |
80 | } else { | |
81 | this.displayedSubMenu = menu; | |
82 | } | |
11fdf7f2 TL |
83 | } |
84 | } |