aboutsummaryrefslogtreecommitdiffstats
path: root/src/angular/notifications/container/notifcontainer.component.ts
blob: d2f7ad1711a5646a30b196e56bcf95abc2584253 (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
import { Component, Input, Output, EventEmitter, OnInit } from "@angular/core";
import { NotificationSettings } from "../utilities/notification.config";
import { NotificationsService } from "../services/notifications.service";
import { template } from "./notifcontainer.component.html";

@Component({
    selector: "sdc-notification-container",
    template: template
})
export class NotificationContainerComponent implements OnInit {
    notifications: NotificationSettings[] = [];

    constructor(private notify: NotificationsService) {
    }

    public ngOnInit() {
        this.notify.subscribe((notif: NotificationSettings) => {
            this.notifications.push(notif);
        });
    }

    private onDestroyed = (event: any): void => {
        let index: number = this.notifications.indexOf(event);
        if (index !== -1) {
            this.notifications.splice(index, 1);
        }
    }

}