diff options
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/core/navigation/notifications/notifications.component.ts')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/core/navigation/notifications/notifications.component.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/notifications/notifications.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/notifications/notifications.component.ts new file mode 100644 index 000000000..89c6c4037 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/notifications/notifications.component.ts @@ -0,0 +1,47 @@ +import { Component, OnDestroy, OnInit } from '@angular/core'; + +import { Subscription } from 'rxjs'; + +import { Icons } from '~/app/shared/enum/icons.enum'; +import { CdNotification } from '~/app/shared/models/cd-notification'; +import { NotificationService } from '~/app/shared/services/notification.service'; +import { SummaryService } from '~/app/shared/services/summary.service'; + +@Component({ + selector: 'cd-notifications', + templateUrl: './notifications.component.html', + styleUrls: ['./notifications.component.scss'] +}) +export class NotificationsComponent implements OnInit, OnDestroy { + icons = Icons; + hasRunningTasks = false; + hasNotifications = false; + private subs = new Subscription(); + + constructor( + public notificationService: NotificationService, + private summaryService: SummaryService + ) {} + + ngOnInit() { + this.subs.add( + this.summaryService.subscribe((summary) => { + this.hasRunningTasks = summary.executing_tasks.length > 0; + }) + ); + + this.subs.add( + this.notificationService.data$.subscribe((notifications: CdNotification[]) => { + this.hasNotifications = notifications.length > 0; + }) + ); + } + + ngOnDestroy(): void { + this.subs.unsubscribe(); + } + + toggleSidebar() { + this.notificationService.toggleSidebar(); + } +} |