import { Component , EventEmitter , Input , OnDestroy , Output } from '@angular/core' ; import { RenderResult } from '../../../models/cmdb-render' ; import { NgbModal , NgbModalRef } from '@ng-bootstrap/ng-bootstrap' ; import { ObjectPreviewModalComponent } from '../../modals/object-preview-modal/object-preview-modal.component' ; import { ObjectDeleteModalComponent } from '../../modals/object-delete-modal/object-delete-modal.component' ; import { ReplaySubject } from 'rxjs' ; import { AccessControlList } from '../../../../acl/acl.types' ; @ Component ( { selector : 'cmdb-object-table-actions' , templateUrl : './object-table-actions.component.html' , styleUrls : [ './object-table-actions.component.scss' ] } ) export class ObjectTableActionsComponent implements OnDestroy { private private subscriber : ReplaySubject < void > = new ReplaySubject < void > ( ) ; /**
     * Public id of the object.
     */ @ Input ( ) public publicID : number ; /**
     * Rendered object
     */ @ Input ( ) public result : RenderResult ; /**
     * AccesContolList
     */ @ Input ( ) public acl : AccessControlList ; /**
     * Emitter when element was deleted.
     */ @ Output ( ) public deleteEmitter : EventEmitter < number > = new EventEmitter < number > ( ) ; private modalRef : NgbModalRef ; constructor ( private modalService ) { } /**
     * Open the preview modal.
     */ public openPreviewModal ( ) { this . modalRef = this . modalService . open ( ObjectPreviewModalComponent , { size : 'lg' } ) ; this . modalRef . componentInstance . renderResult = this . result ; } /**
     * Open the delete modal.
     */ public openDeleteModal ( ) { this . modalRef = this . modalService . open ( ObjectDeleteModalComponent , { size : 'lg' } ) ; this . modalRef . componentInstance . publicID = this . result . object_information . object_id ; this . modalRef . result . then ( ( response ) => { if ( ! isNaN ( + response ) ) { this . deleteEmitter . emit ( + response ) ; } } ) ; } public ngOnDestroy ( ) { this . subscriber . next ( ) ; this . subscriber . complete ( ) ; if ( this . modalRef ) { this . modalRef . close ( ) ; } } }