blob: 89c6c4037941be719b0ce01a5808ce1ca1bd2f0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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();
}
}
|