]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts
import 15.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / rbd-mirroring.service.ts
index c1f069323be2480efcd39cd5380acb08679b7e95..6a378b359971a691d3f03be0de060f6a5edd3562 100644 (file)
@@ -2,8 +2,10 @@ import { HttpClient } from '@angular/common/http';
 import { Injectable } from '@angular/core';
 
 import { BehaviorSubject, Observable, Subscription } from 'rxjs';
+import { filter } from 'rxjs/operators';
 
 import { cdEncode, cdEncodeNot } from '../decorators/cd-encode';
+import { MirroringSummary } from '../models/mirroring-summary';
 import { TimerService } from '../services/timer.service';
 import { ApiModule } from './api.module';
 
@@ -14,7 +16,7 @@ import { ApiModule } from './api.module';
 export class RbdMirroringService {
   readonly REFRESH_INTERVAL = 30000;
   // Observable sources
-  private summaryDataSource = new BehaviorSubject(null);
+  private summaryDataSource = new BehaviorSubject<MirroringSummary>(null);
   // Observable streams
   summaryData$ = this.summaryDataSource.asObservable();
 
@@ -30,29 +32,25 @@ export class RbdMirroringService {
     return this.retrieveSummaryObservable().subscribe(this.retrieveSummaryObserver());
   }
 
-  private retrieveSummaryObservable(): Observable<Object> {
+  private retrieveSummaryObservable(): Observable<MirroringSummary> {
     return this.http.get('api/block/mirroring/summary');
   }
 
-  private retrieveSummaryObserver(): (data: any) => void {
+  private retrieveSummaryObserver(): (data: MirroringSummary) => void {
     return (data: any) => {
       this.summaryDataSource.next(data);
     };
   }
 
-  /**
-   * Returns the current value of summaryData
-   */
-  getCurrentSummary(): { [key: string]: any; executing_tasks: object[] } {
-    return this.summaryDataSource.getValue();
-  }
-
   /**
    * Subscribes to the summaryData,
    * which is updated periodically or when a new task is created.
    */
-  subscribeSummary(next: (summary: any) => void, error?: (error: any) => void): Subscription {
-    return this.summaryData$.subscribe(next, error);
+  subscribeSummary(
+    next: (summary: MirroringSummary) => void,
+    error?: (error: any) => void
+  ): Subscription {
+    return this.summaryData$.pipe(filter((value) => !!value)).subscribe(next, error);
   }
 
   getPool(poolName: string) {