]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/notifications/notifications.component.ts
import 15.2.2 octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / core / navigation / notifications / notifications.component.ts
index ec615cc4c1a4eb882655f0b4fa170897ec9c3bae..aaedd546eff48a33d20136f97958840d2c3b9df8 100644 (file)
@@ -1,6 +1,6 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnDestroy, OnInit } from '@angular/core';
 
-import * as _ from 'lodash';
+import { Subscription } from 'rxjs';
 
 import { Icons } from '../../../shared/enum/icons.enum';
 import { NotificationService } from '../../../shared/services/notification.service';
@@ -11,10 +11,10 @@ import { SummaryService } from '../../../shared/services/summary.service';
   templateUrl: './notifications.component.html',
   styleUrls: ['./notifications.component.scss']
 })
-export class NotificationsComponent implements OnInit {
+export class NotificationsComponent implements OnInit, OnDestroy {
   icons = Icons;
-
   hasRunningTasks = false;
+  private subs = new Subscription();
 
   constructor(
     public notificationService: NotificationService,
@@ -22,12 +22,18 @@ export class NotificationsComponent implements OnInit {
   ) {}
 
   ngOnInit() {
-    this.summaryService.subscribe((data: any) => {
-      if (!data) {
-        return;
-      }
-      this.hasRunningTasks = data.executing_tasks.length > 0;
-    });
+    this.subs.add(
+      this.summaryService.subscribe((data: any) => {
+        if (!data) {
+          return;
+        }
+        this.hasRunningTasks = data.executing_tasks.length > 0;
+      })
+    );
+  }
+
+  ngOnDestroy(): void {
+    this.subs.unsubscribe();
   }
 
   toggleSidebar() {