member_webapp/@overflow/noauth-probe/component/noauth-probe-list.component.ts
2018-05-30 14:24:19 +09:00

41 lines
1.2 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';
@Component({
selector: 'of-noauth-probe-list',
templateUrl: './noauth-probe-list.component.html',
providers: [ConfirmationService]
})
export class NoAuthProbeListComponent {
@Input() noauthProbes: NoAuthProbe[];
@Input() pending: boolean;
@Input() error: any;
@Output() accept = new EventEmitter<NoAuthProbe>();
@Output() deny = new EventEmitter<NoAuthProbe>();
constructor(
private confirmationService: ConfirmationService,
) {
}
onAcceptOrDeny(isAccept: boolean, selected: NoAuthProbe) {
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: () => {
}
});
}
}