672d7bf6112de6a6a4986a0357f83a80f9c5c3ea
[src/xds/xds-agent.git] / webapp / src / app / alert / alert.component.ts
1 import { Component } from '@angular/core';
2 import { Observable } from 'rxjs';
3
4 import {AlertService, IAlert} from '../services/alert.service';
5
6 @Component({
7     selector: 'app-alert',
8     template: `
9         <div style="width:80%; margin-left:auto; margin-right:auto;" *ngFor="let alert of (alerts$ | async)">
10             <alert *ngIf="alert.show" [type]="alert.type" [dismissible]="alert.dismissible" [dismissOnTimeout]="alert.dismissTimeout"
11             (onClose)="onClose(alert)">
12                 <div style="text-align:center;" [innerHtml]="alert.msg"></div>
13             </alert>
14         </div>
15     `
16 })
17
18 export class AlertComponent {
19
20     alerts$: Observable<IAlert[]>;
21
22     constructor(private alertSvr: AlertService) {
23         this.alerts$ = this.alertSvr.alerts;
24     }
25
26     onClose(al) {
27         this.alertSvr.del(al);
28     }
29
30 }