member_webapp/@overflow/noauth/component/list/list.component.ts
crusader d59d9379f9 ing
2018-05-24 15:44:13 +09:00

43 lines
1.3 KiB
TypeScript

import { Component, Input, Output, EventEmitter, AfterContentInit } from '@angular/core';
import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
import { ConfirmationService, Message } from 'primeng/primeng';
import { MessageService } from 'primeng/components/common/messageservice';
@Component({
selector: 'of-noauth-list',
templateUrl: './list.component.html',
providers: [ConfirmationService, MessageService]
})
export class NoAuthProbeListComponent {
@Input() noauthProbes: NoAuthProbe[];
@Output() accept = new EventEmitter<NoAuthProbe>();
@Output() deny = new EventEmitter<NoAuthProbe>();
msgs: Message[];
constructor(
private confirmationService: ConfirmationService,
private messageService: MessageService
) {
}
onAcceptOrDeny(isAccept: boolean, selected: NoAuthProbe) {
console.log(selected);
this.msgs = [];
const title = isAccept ?
'Are you sure to accept this Probe?' : 'Are you sure to deny this Probe';
const message = isAccept ?
'Start collecting data as a Probe.' : 'It will be permanently deleted.';
this.confirmationService.confirm({
header: title,
message: message,
icon: isAccept ? 'fa-check' : 'fa fa-trash',
accept: () => {
isAccept ? this.accept.emit(selected) : this.deny.emit(selected);
},
reject: () => {
}
});
}
}