import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; import { IContextNode } from 'app/services/i-context-node'; import { MockCtxloaderService } from 'app/services/mock-ctxloader.service'; import { IHostingnode } from 'app/services/i-hostinngnode'; import { ResourcesLoaderService } from 'app/services/resources-loader.service'; import { SharedModule } from 'app/shared/shared.module'; @Component({ standalone: true, imports: [SharedModule], selector: 'jhi-list-screen', templateUrl: './list-screen.component.html', styleUrls: ['./list-screen.component.scss'], providers: [MockCtxloaderService, ResourcesLoaderService], }) export class ListScreenComponent implements OnChanges { dataSource: IHostingnode[]; //fetchedRawData?: string; tableDetail: IHostingnode; @Input() myCtx: IContextNode; //fetching event from parent @Output() jsonEmitter = new EventEmitter(); constructor(private myServiceTable: ResourcesLoaderService) { this.myCtx = {} as IContextNode; this.tableDetail = {} as IHostingnode; this.dataSource = []; //this.currentCtxId = ""; } openJsonViewer(node: IHostingnode): void { this.jsonEmitter.emit(node); } ngOnChanges(changes: SimpleChanges): void { for (const propName in changes) { if (propName === 'myCtx') { const param = changes[propName]; this.myCtx = param.currentValue; //controllo che l'oggetto non sia vuoto if (Object.keys(this.myCtx).length !== 0) { // eslint-disable-next-line no-console //console.log('+++++++CONTESTO PRESO DAL PARENT...' + this.myCtx.name); //mt qui va passato il parametro myCtx.id al rest this.myServiceTable.getHostingNodes().subscribe(res => { this.dataSource = res; }); } } } } }