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