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

46 lines
1.4 KiB
TypeScript
Raw Normal View History

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