member_webapp/@overflow/noauth-probe/component/noauth-probe-list.component.ts
crusader 869fcf4e72 ing
2018-05-28 14:41:56 +09:00

43 lines
1.4 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-probe-list',
templateUrl: './noauth-probe-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: () => {
}
});
}
}