member_webapp/@overflow/noauth-probe/component/noauth-probe-list.component.ts

46 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-05-18 17:49:13 +09:00
import { Component, Input, Output, EventEmitter, AfterContentInit } from '@angular/core';
2018-05-02 17:09:39 +09:00
import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
2018-04-11 17:41:38 +09:00
import { ConfirmationService, Message } from 'primeng/primeng';
import { MessageService } from 'primeng/components/common/messageservice';
2018-04-24 14:31:20 +09:00
2018-04-11 15:20:23 +09:00
@Component({
2018-05-28 14:41:56 +09:00
selector: 'of-noauth-probe-list',
templateUrl: './noauth-probe-list.component.html',
2018-04-11 17:41:38 +09:00
providers: [ConfirmationService, MessageService]
2018-04-11 15:20:23 +09:00
})
2018-05-18 20:29:16 +09:00
export class NoAuthProbeListComponent {
2018-05-18 17:49:13 +09:00
@Input() noauthProbes: NoAuthProbe[];
2018-05-28 17:58:10 +09:00
@Input() pending: boolean;
@Input() error: any;
2018-05-18 17:49:13 +09:00
@Output() accept = new EventEmitter<NoAuthProbe>();
@Output() deny = new EventEmitter<NoAuthProbe>();
2018-04-11 17:41:38 +09:00
msgs: Message[];
2018-04-06 20:02:18 +09:00
2018-04-11 15:20:23 +09:00
constructor(
2018-04-11 17:41:38 +09:00
private confirmationService: ConfirmationService,
private messageService: MessageService
2018-04-11 15:20:23 +09:00
) {
}
2018-04-06 20:02:18 +09:00
2018-04-24 14:47:03 +09:00
onAcceptOrDeny(isAccept: boolean, selected: NoAuthProbe) {
console.log(selected);
2018-04-11 17:41:38 +09:00
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: () => {
2018-05-18 17:49:13 +09:00
isAccept ? this.accept.emit(selected) : this.deny.emit(selected);
2018-04-11 17:41:38 +09:00
},
reject: () => {
}
});
}
2018-04-11 15:20:23 +09:00
}