@@ -2,12 +2,14 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
22
33import _ from 'lodash' ;
44import { BehaviorSubject , EMPTY , Observable , Subject , Subscription , of } from 'rxjs' ;
5- import { catchError , exhaustMap , switchMap , take , takeUntil } from 'rxjs/operators' ;
5+ import { catchError , exhaustMap , switchMap , takeUntil } from 'rxjs/operators' ;
66
77import { 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' ;
8+ import { PrometheusService , PromqlGuageMetric } from '~/app/shared/api/prometheus.service' ;
9+ import {
10+ CapacityCardQueries ,
11+ UtilizationCardQueries
12+ } from '~/app/shared/enum/dashboard-promqls.enum' ;
1113import { Icons } from '~/app/shared/enum/icons.enum' ;
1214import { DashboardDetails } from '~/app/shared/models/cd-details' ;
1315import { Permissions } from '~/app/shared/models/permissions' ;
@@ -26,7 +28,6 @@ import { MgrModuleService } from '~/app/shared/api/mgr-module.service';
2628import { AlertClass } from '~/app/shared/enum/health-icon.enum' ;
2729import { HardwareService } from '~/app/shared/api/hardware.service' ;
2830import { SettingsService } from '~/app/shared/api/settings.service' ;
29- import { OsdSettings } from '~/app/shared/models/osd-settings' ;
3031import {
3132 IscsiMap ,
3233 MdsMap ,
@@ -36,15 +37,23 @@ import {
3637 PgStatus
3738} from '~/app/shared/models/health.interface' ;
3839
40+ type CapacityCardData = {
41+ osdNearfull : number ;
42+ osdFull : number ;
43+ } ;
44+
3945@Component ( {
4046 selector : 'cd-dashboard-v3' ,
4147 templateUrl : './dashboard-v3.component.html' ,
4248 styleUrls : [ './dashboard-v3.component.scss' ]
4349} )
4450export class DashboardV3Component extends PrometheusListHelper implements OnInit , OnDestroy {
4551 detailsCardData : DashboardDetails = { } ;
46- osdSettingsService : any ;
47- osdSettings = new OsdSettings ( ) ;
52+ capacityCardData : CapacityCardData = {
53+ osdNearfull : null ,
54+ osdFull : null
55+ } ;
56+ interval = new Subscription ( ) ;
4857 permissions : Permissions ;
4958 enabledFeature$ : FeatureTogglesMap$ ;
5059 color : string ;
@@ -102,7 +111,6 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
102111 constructor (
103112 private summaryService : SummaryService ,
104113 private orchestratorService : OrchestratorService ,
105- private osdService : OsdService ,
106114 private authStorageService : AuthStorageService ,
107115 private featureToggles : FeatureTogglesService ,
108116 private healthService : HealthService ,
@@ -121,7 +129,6 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
121129 ngOnInit ( ) {
122130 super . ngOnInit ( ) ;
123131 if ( this . permissions . configOpt . read ) {
124- this . getOsdSettings ( ) ;
125132 this . isHardwareEnabled$ = this . getHardwareConfig ( ) ;
126133 this . hardwareSummary$ = this . hardwareSubject . pipe (
127134 switchMap ( ( ) =>
@@ -148,6 +155,7 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
148155 this . getPrometheusData ( this . prometheusService . lastHourDateObject ) ;
149156 this . getDetailsCardData ( ) ;
150157 this . getTelemetryReport ( ) ;
158+ this . getCapacityCardData ( ) ;
151159 this . prometheusAlertService . getAlerts ( true ) ;
152160 }
153161
@@ -185,23 +193,38 @@ export class DashboardV3Component extends PrometheusListHelper implements OnInit
185193 ) ;
186194 }
187195
188- private getOsdSettings ( ) {
189- this . osdSettingsService = this . osdService
190- . getOsdSettings ( )
191- . pipe ( take ( 1 ) )
192- . subscribe ( ( data : OsdSettings ) => {
193- this . osdSettings = data ;
194- } ) ;
195- }
196-
197196 public getPrometheusData ( selectedTime : any ) {
198- this . queriesResults = this . prometheusService . getPrometheusQueriesData (
197+ this . queriesResults = this . prometheusService . getRangeQueriesData (
199198 selectedTime ,
200- queries ,
199+ UtilizationCardQueries ,
201200 this . queriesResults
202201 ) ;
203202 }
204203
204+ getCapacityQueryValues ( data : PromqlGuageMetric [ 'result' ] ) {
205+ let osdFull = null ;
206+ let osdNearfull = null ;
207+ if ( data ?. [ 0 ] ?. metric ?. [ '__name__' ] === CapacityCardQueries . OSD_FULL ) {
208+ osdFull = data [ 0 ] ?. value ?. [ 1 ] ;
209+ osdNearfull = data [ 1 ] ?. value ?. [ 1 ] ;
210+ } else {
211+ osdFull = data ?. [ 1 ] ?. value ?. [ 1 ] ;
212+ osdNearfull = data ?. [ 0 ] ?. value ?. [ 1 ] ;
213+ }
214+ return [ osdFull , osdNearfull ] ;
215+ }
216+
217+ getCapacityCardData ( ) {
218+ const CAPACITY_QUERY = `{__name__=~"${ CapacityCardQueries . OSD_FULL } |${ CapacityCardQueries . OSD_NEARFULL } "}` ;
219+ this . prometheusService
220+ . getGaugeQueryData ( CAPACITY_QUERY )
221+ . subscribe ( ( data : PromqlGuageMetric ) => {
222+ const [ osdFull , osdNearfull ] = this . getCapacityQueryValues ( data ?. result ) ;
223+ this . capacityCardData . osdFull = this . prometheusService . formatGuageMetric ( osdFull ) ;
224+ this . capacityCardData . osdNearfull = this . prometheusService . formatGuageMetric ( osdNearfull ) ;
225+ } ) ;
226+ }
227+
205228 private getTelemetryReport ( ) {
206229 this . healthService . getTelemetryStatus ( ) . subscribe ( ( enabled : boolean ) => {
207230 this . telemetryEnabled = enabled ;
0 commit comments