aboutsummaryrefslogtreecommitdiffstats
path: root/webapp/src/app/app-alert/app-alert.component.ts
blob: e6fbd47b23121eeaa712c64c260a446a8f375d1f (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
import { Component, ViewEncapsulation } from '@angular/core';
import { Observable } from 'rxjs/Observable';

import { AlertService, IAlert } from '../services/alert.service';

@Component({
    selector: 'app-alert',
    template: `
  <div style="width:80%; margin-left:auto; margin-right:auto;"
   *ngFor="let alert of (alerts$ | async)">
      <alert *ngIf="alert.show" [type]="alert.type" [dismissible]="alert.dismissible" [dismissOnTimeout]="alert.dismissTimeout"
      (onClose)="onClose(alert)">
          <div style="text-align:center;" [innerHtml]="alert.msg"></div>
      </alert>
  </div>
`,
})

export class AppAlertComponent {

    alerts$: Observable<IAlert[]>;

    constructor(private alertSvr: AlertService) {
        this.alerts$ = this.alertSvr.alerts;
    }

    onClose(al) {
        this.alertSvr.del(al);
    }

}