import _ from 'lodash';
import { Observable, Subscription } from 'rxjs';
import { take } from 'rxjs/operators';
-import moment from 'moment';
import { HealthService } from '~/app/shared/api/health.service';
import { OsdService } from '~/app/shared/api/osd.service';
};
telemetryEnabled: boolean;
telemetryURL = 'https://telemetry-public.ceph.com/';
- timerGetPrometheusDataSub: Subscription;
- timerTime = 30000;
- readonly lastHourDateObject = {
- start: moment().unix() - 3600,
- end: moment().unix(),
- step: 14
- };
origin = window.location.origin;
constructor(
this.getHealth();
this.getCapacityCardData();
});
- this.getPrometheusData(this.lastHourDateObject);
+ this.getPrometheusData(this.prometheusService.lastHourDateObject);
this.getDetailsCardData();
this.getTelemetryReport();
}
}
ngOnDestroy() {
this.interval.unsubscribe();
- if (this.timerGetPrometheusDataSub) {
- this.timerGetPrometheusDataSub.unsubscribe();
- }
+ this.prometheusService.unsubscribe();
}
getHealth() {
this.ZoneSUb.unsubscribe();
this.BucketSub.unsubscribe();
this.HealthSub.unsubscribe();
- if (this.timerGetPrometheusDataSub) {
- this.timerGetPrometheusDataSub.unsubscribe();
- }
+ this.prometheusService.unsubscribe();
}
getPrometheusData(selectedTime: any) {
constructor(private http: HttpClient) {}
+ unsubscribe() {
+ if (this.timerGetPrometheusDataSub) {
+ this.timerGetPrometheusDataSub.unsubscribe();
+ }
+ }
+
getPrometheusData(params: any): any {
return this.http.get<any>(`${this.baseURL}/data`, { params });
}