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(); @Output() deny = new EventEmitter(); 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: () => { } }); } }