]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/services/refresh-interval.service.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / services / refresh-interval.service.ts
index 4cc846acdb9b43df25b1a7a3b054cd18d4e5b3d2..03aa3b8a56ad1f6cb86525f06c9df50a325c67f6 100644 (file)
@@ -1,10 +1,9 @@
-import { Injectable, OnDestroy } from '@angular/core';
+import { Injectable, NgZone, OnDestroy } from '@angular/core';
 
 import { BehaviorSubject, interval, Subscription } from 'rxjs';
 
-import { ServicesModule } from './services.module';
 @Injectable({
-  providedIn: ServicesModule
+  providedIn: 'root'
 })
 export class RefreshIntervalService implements OnDestroy {
   private intervalTime: number;
@@ -14,7 +13,7 @@ export class RefreshIntervalService implements OnDestroy {
   // Observable streams
   intervalData$ = this.intervalDataSource.asObservable();
 
-  constructor() {
+  constructor(private ngZone: NgZone) {
     const initialInterval = parseInt(sessionStorage.getItem('dashboard_interval'), 10) || 5000;
     this.setRefreshInterval(initialInterval);
   }
@@ -26,9 +25,13 @@ export class RefreshIntervalService implements OnDestroy {
     if (this.intervalSubscription) {
       this.intervalSubscription.unsubscribe();
     }
-    this.intervalSubscription = interval(this.intervalTime).subscribe(() =>
-      this.intervalDataSource.next(this.intervalTime)
-    );
+    this.ngZone.runOutsideAngular(() => {
+      this.intervalSubscription = interval(this.intervalTime).subscribe(() =>
+        this.ngZone.run(() => {
+          this.intervalDataSource.next(this.intervalTime);
+        })
+      );
+    });
   }
 
   getRefreshInterval() {