]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/notifications/notifications.component.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / core / navigation / notifications / notifications.component.ts
index d3dd47a13ef5e1dc6fc46b33b5db4d4894b33340..ec615cc4c1a4eb882655f0b4fa170897ec9c3bae 100644 (file)
@@ -1,58 +1,36 @@
-import { Component, NgZone, OnDestroy, OnInit } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
 
 import * as _ from 'lodash';
 
-import { CdNotification } from '../../../shared/models/cd-notification';
-import { AuthStorageService } from '../../../shared/services/auth-storage.service';
+import { Icons } from '../../../shared/enum/icons.enum';
 import { NotificationService } from '../../../shared/services/notification.service';
-import { PrometheusAlertService } from '../../../shared/services/prometheus-alert.service';
-import { PrometheusNotificationService } from '../../../shared/services/prometheus-notification.service';
+import { SummaryService } from '../../../shared/services/summary.service';
 
 @Component({
   selector: 'cd-notifications',
   templateUrl: './notifications.component.html',
   styleUrls: ['./notifications.component.scss']
 })
-export class NotificationsComponent implements OnInit, OnDestroy {
-  notifications: CdNotification[];
-  private interval: number;
+export class NotificationsComponent implements OnInit {
+  icons = Icons;
+
+  hasRunningTasks = false;
 
   constructor(
     public notificationService: NotificationService,
-    private prometheusNotificationService: PrometheusNotificationService,
-    private authStorageService: AuthStorageService,
-    private prometheusAlertService: PrometheusAlertService,
-    private ngZone: NgZone
-  ) {
-    this.notifications = [];
-  }
-
-  ngOnDestroy() {
-    window.clearInterval(this.interval);
-  }
+    private summaryService: SummaryService
+  ) {}
 
   ngOnInit() {
-    if (this.authStorageService.getPermissions().prometheus.read) {
-      this.triggerPrometheusAlerts();
-      this.ngZone.runOutsideAngular(() => {
-        this.interval = window.setInterval(() => {
-          this.ngZone.run(() => {
-            this.triggerPrometheusAlerts();
-          });
-        }, 5000);
-      });
-    }
-    this.notificationService.data$.subscribe((notifications: CdNotification[]) => {
-      this.notifications = _.orderBy(notifications, ['timestamp'], ['desc']);
+    this.summaryService.subscribe((data: any) => {
+      if (!data) {
+        return;
+      }
+      this.hasRunningTasks = data.executing_tasks.length > 0;
     });
   }
 
-  private triggerPrometheusAlerts() {
-    this.prometheusAlertService.refresh();
-    this.prometheusNotificationService.refresh();
-  }
-
-  removeAll() {
-    this.notificationService.removeAll();
+  toggleSidebar() {
+    this.notificationService.toggleSidebar();
   }
 }