diff options
Diffstat (limited to 'webapp/src/app/app-alert/app-alert.component.ts')
-rw-r--r-- | webapp/src/app/app-alert/app-alert.component.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/webapp/src/app/app-alert/app-alert.component.ts b/webapp/src/app/app-alert/app-alert.component.ts new file mode 100644 index 0000000..e6fbd47 --- /dev/null +++ b/webapp/src/app/app-alert/app-alert.component.ts @@ -0,0 +1,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); + } + +} |