import { AfterContentInit, Component, Input, EventEmitter, Output, OnChanges, SimpleChanges } from '@angular/core'; import { Anim } from './animation'; import { TreeNode } from 'primeng/primeng'; @Component({ selector: 'of-discovery-result', templateUrl: './search-result.component.html', animations: Anim }) export class SearchResultComponent implements OnChanges { @Output() stop = new EventEmitter(); @Input() started: boolean; zoneNode: TreeNode[] = []; hostNode: TreeNode[] = []; constructor( ) { this.zoneNode.push({ label: 'zone', children: this.hostNode, expanded: true }); } ngOnChanges(changes: SimpleChanges): void { } onStop() { this.stop.emit(); } test() { } addHostNode() { const idx = Math.floor(Math.random() * (this.hostNode.length - 1)); this.hostNode.splice(idx, 0, { label: 'host', expanded: true, children: [] }); } addServiceNode() { const idx = Math.floor(Math.random() * (this.hostNode.length - 1)); this.hostNode[idx].children.push({ label: 'service', }); } }