2 * ============LICENSE_START=======================================================
4 * ================================================================================
6 *=================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
22 * This component is to display the notification.
28 import { Component, OnInit } from "@angular/core";
32 } from "src/app/core/models/toastr-notification.model";
33 import { ToastrNotificationService } from "src/app/core/services/toastr-notification.service";
36 selector: "app-toastr-notification",
37 templateUrl: "./toastr-notification.component.html",
38 styleUrls: ["./toastr-notification.component.css"]
40 export class ToastrNotificationComponent implements OnInit {
41 notifications: Notification[] = [];
43 constructor(public _notificationService: ToastrNotificationService) {}
46 this._notificationService.getAlert().subscribe((alert: Notification) => {
47 this.notifications = [];
49 this.notifications = [];
52 this.notifications.push(alert);
54 this.notifications = this.notifications.filter(x => x !== alert);
59 removeNotification(notification: Notification) {
60 this.notifications = this.notifications.filter(x => x !== notification);
64 Set css class for Alert -- Called from alert component
66 cssClass(notification: Notification) {
70 switch (notification.type) {
71 case NotificationType.Success:
72 return "toast-success";
73 case NotificationType.Error:
75 case NotificationType.Info:
77 case NotificationType.Warning:
78 return "toast-warning";