member_webapp/@overflow/shared/ui/component/error-message.component.ts
crusader ea812f6e54 ing
2018-05-30 19:00:46 +09:00

35 lines
851 B
TypeScript

import { Component, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core';
import { Message } from 'primeng/primeng';
@Component({
selector: 'of-error-message',
templateUrl: './error-message.component.html',
})
export class ErrorMessageComponent implements OnInit, OnChanges {
@Input() error: any;
@Input() closeAfter: number;
@Input() closable: boolean;
msgs: Message[] = [];
constructor(
) {
}
ngOnInit() {
}
ngOnChanges(changes: SimpleChanges) {
if (changes['error'].currentValue) {
const detail = ' (' + this.error.response.code + ')';
this.msgs = [];
this.msgs.push({ severity: 'error', summary: 'Sorry. An Error has occurred.', detail: detail });
if (this.closeAfter) {
setTimeout(() => {
this.msgs = [];
}, this.closeAfter * 1000);
}
}
}
}