1 import { Component, OnDestroy, OnInit } from '@angular/core';
3 import _ from 'lodash';
4 import { Observable, Subscription } from 'rxjs';
5 import { take } from 'rxjs/operators';
7 import { HealthService } from '~/app/shared/api/health.service';
8 import { OsdService } from '~/app/shared/api/osd.service';
9 import { PrometheusService } from '~/app/shared/api/prometheus.service';
10 import { Promqls as queries } from '~/app/shared/enum/dashboard-promqls.enum';
11 import { Icons } from '~/app/shared/enum/icons.enum';
12 import { DashboardDetails } from '~/app/shared/models/cd-details';
13 import { Permissions } from '~/app/shared/models/permissions';
14 import { AlertmanagerAlert } from '~/app/shared/models/prometheus-alerts';
15 import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
19 } from '~/app/shared/services/feature-toggles.service';
20 import { RefreshIntervalService } from '~/app/shared/services/refresh-interval.service';
21 import { SummaryService } from '~/app/shared/services/summary.service';
22 import { PrometheusListHelper } from '~/app/shared/helpers/prometheus-list-helper';
23 import { PrometheusAlertService } from '~/app/shared/services/prometheus-alert.service';
24 import { OrchestratorService } from '~/app/shared/api/orchestrator.service';
25 import { MgrModuleService } from '~/app/shared/api/mgr-module.service';
26 import { AlertClass } from '~/app/shared/enum/health-icon.enum';
29 selector: 'cd-dashboard-v3',
30 templateUrl: './dashboard-v3.component.html',
31 styleUrls: ['./dashboard-v3.component.scss']
33 export class DashboardV3Component extends PrometheusListHelper implements OnInit, OnDestroy {
34 detailsCardData: DashboardDetails = {};
35 osdSettingsService: any;
37 interval = new Subscription();
38 permissions: Permissions;
39 enabledFeature$: FeatureTogglesMap$;
43 healthData$: Observable<Object>;
44 prometheusAlerts$: Observable<AlertmanagerAlert[]>;
53 alertClass = AlertClass;
55 categoryPgAmount: Record<string, number> = {};
57 queriesResults: any = {
63 READCLIENTTHROUGHPUT: '',
64 WRITECLIENTTHROUGHPUT: '',
67 telemetryEnabled: boolean;
68 telemetryURL = 'https://telemetry-public.ceph.com/';
69 origin = window.location.origin;
72 private summaryService: SummaryService,
73 private orchestratorService: OrchestratorService,
74 private osdService: OsdService,
75 private authStorageService: AuthStorageService,
76 private featureToggles: FeatureTogglesService,
77 private healthService: HealthService,
78 public prometheusService: PrometheusService,
79 private mgrModuleService: MgrModuleService,
80 private refreshIntervalService: RefreshIntervalService,
81 public prometheusAlertService: PrometheusAlertService
83 super(prometheusService);
84 this.permissions = this.authStorageService.getPermissions();
85 this.enabledFeature$ = this.featureToggles.get();
90 this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
92 this.getCapacityCardData();
94 this.getPrometheusData(this.prometheusService.lastHourDateObject);
95 this.getDetailsCardData();
96 this.getTelemetryReport();
99 getTelemetryText(): string {
100 return this.telemetryEnabled
101 ? 'Cluster telemetry is active'
102 : 'Cluster telemetry is inactive. To Activate the Telemetry, \
103 click settings icon on top navigation bar and select \
104 Telemetry configration.';
107 this.interval.unsubscribe();
108 this.prometheusService.unsubscribe();
112 this.healthService.getMinimalHealth().subscribe((data: any) => {
113 this.healthData = data;
117 toggleAlertsWindow(type: AlertClass) {
118 this.alertType === type ? (this.alertType = null) : (this.alertType = type);
121 getDetailsCardData() {
122 this.healthService.getClusterFsid().subscribe((data: string) => {
123 this.detailsCardData.fsid = data;
125 this.orchestratorService.getName().subscribe((data: string) => {
126 this.detailsCardData.orchestrator = data;
128 this.summaryService.subscribe((summary) => {
129 const version = summary.version.replace('ceph version ', '').split(' ');
130 this.detailsCardData.cephVersion =
131 version[0] + ' ' + version.slice(2, version.length).join(' ');
135 getCapacityCardData() {
136 this.osdSettingsService = this.osdService
139 .subscribe((data: any) => {
140 this.osdSettings = data;
142 this.capacityService = this.healthService.getClusterCapacity().subscribe((data: any) => {
143 this.capacity = data;
147 public getPrometheusData(selectedTime: any) {
148 this.queriesResults = this.prometheusService.getPrometheusQueriesData(
155 private getTelemetryReport() {
156 this.mgrModuleService.getConfig('telemetry').subscribe((resp: any) => {
157 this.telemetryEnabled = resp?.enabled;
161 trackByFn(index: any) {