]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Usage of 'BehaviorSubject' in summary
authorRicardo Marques <rimarques@suse.com>
Tue, 3 Jul 2018 09:05:30 +0000 (10:05 +0100)
committerRicardo Marques <rimarques@suse.com>
Wed, 4 Jul 2018 08:51:27 +0000 (09:51 +0100)
Signed-off-by: Ricardo Marques <rimarques@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts
src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation/navigation.component.ts
src/pybind/mgr/dashboard/frontend/src/app/core/navigation/task-manager/task-manager.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts

index d05fec8325f5495abb9165cdb77e33bfbee5afc8..17819e54a7fea1e34a8a6dd8c50a5547a386a621 100644 (file)
@@ -112,6 +112,9 @@ export class RbdListComponent implements OnInit, OnDestroy {
     ];
 
     this.summaryService.get().subscribe((resp: any) => {
+      if (!resp) {
+        return;
+      }
       this.loadImages(resp.executing_tasks);
       this.summaryDataSubscription = this.summaryService.summaryData$.subscribe((data: any) => {
         this.loadImages(data.executing_tasks);
index 10adf680618bcf42e9ed6624223306215992f00e..74a554a177ecf1460fd8c787120d34c223a00938 100644 (file)
@@ -17,6 +17,9 @@ export class DashboardHelpComponent implements OnInit {
 
   ngOnInit() {
     const subs = this.summaryService.summaryData$.subscribe((summary: any) => {
+      if (!summary) {
+        return;
+      }
       const releaseName = this.cephReleaseNamePipe.transform(summary.version);
       this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/mgr/dashboard/`;
       subs.unsubscribe();
index 9372e75d857679f1cb3cb92f05ef7b55441e3f0f..ec45878d86c73d602ce244c81224a8c3a9ec8c54 100644 (file)
@@ -23,6 +23,9 @@ export class NavigationComponent implements OnInit {
 
   ngOnInit() {
     this.summaryService.summaryData$.subscribe((data: any) => {
+      if (!data) {
+        return;
+      }
       this.summaryData = data;
     });
   }
index 0c07f881c4db15d16b889ef6cf70623d472efc2c..102628c136ad58148172a467c99251be59423b63 100644 (file)
@@ -23,6 +23,9 @@ export class TaskManagerComponent implements OnInit {
 
   ngOnInit() {
     this.summaryService.summaryData$.subscribe((data: any) => {
+      if (!data) {
+        return;
+      }
       this._handleTasks(data.executing_tasks, data.finished_tasks);
       this._setIcon(data.executing_tasks.length);
     });
index c2fafa201184a7165275ccfd406d4513b61193ef..6a03d06efda872092edfe6c0273c905a4ed9482f 100644 (file)
@@ -1,7 +1,7 @@
 import { HttpClient } from '@angular/common/http';
 import { Injectable, NgZone } from '@angular/core';
 
-import { Subject } from 'rxjs';
+import { BehaviorSubject } from 'rxjs';
 
 import { AuthStorageService } from './auth-storage.service';
 import { ServicesModule } from './services.module';
@@ -11,7 +11,7 @@ import { ServicesModule } from './services.module';
 })
 export class SummaryService {
   // Observable sources
-  private summaryDataSource = new Subject();
+  private summaryDataSource = new BehaviorSubject(null);
 
   // Observable streams
   summaryData$ = this.summaryDataSource.asObservable();
index 9eedf43e2ff8dcafb90f53e472cd50f785ffe14b..078d54747ca4f6d508ca43d72713219d8cbd1980 100644 (file)
@@ -28,6 +28,9 @@ export class TaskManagerService {
 
   constructor(summaryService: SummaryService) {
     summaryService.summaryData$.subscribe((data: any) => {
+      if (!data) {
+        return;
+      }
       const executingTasks = data.executing_tasks;
       const finishedTasks = data.finished_tasks;
       const newSubscriptions: Array<TaskSubscription> = [];