73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import { Component, EventEmitter, Input, OnChanges, OnInit, 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, OnInit {
|
|
dataSource: IHostingnode[];
|
|
tableDetail: IHostingnode;
|
|
//nestedContexts: IContextNode[]|any;
|
|
|
|
@Input() myCtx: IContextNode; //fetching event from parent
|
|
@Output() jsonEmitter = new EventEmitter<IHostingnode>();
|
|
|
|
constructor(private myServiceTable: ResourcesLoaderService, private myContextService: MockCtxloaderService) {
|
|
this.myCtx = {} as IContextNode;
|
|
this.tableDetail = {} as IHostingnode;
|
|
this.dataSource = [];
|
|
}
|
|
|
|
openJsonViewer(node: IHostingnode): void {
|
|
this.jsonEmitter.emit(node);
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
//TODO: qui prende il contesto-radice
|
|
/*
|
|
this.myContextService.getData().subscribe(res => {
|
|
this.nestedContexts = res;
|
|
//inizializzo il contesto alla radice
|
|
this.myCtx = this.nestedContexts[0];
|
|
|
|
});
|
|
*/
|
|
//const uid = this.myCtx.id;
|
|
// eslint-disable-next-line no-console
|
|
//console.log('---- UID DA PARENT X REST...' + uid);
|
|
|
|
//TODO: qui deve prendere i dati dal rest con l'ID passato dal contesto
|
|
|
|
this.myServiceTable.getHostingNodes().subscribe(res => {
|
|
this.dataSource = res;
|
|
});
|
|
}
|
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
|
// eslint-disable-next-line no-console
|
|
console.log('---NELLA ONCHANGES...' + this.myCtx.name);
|
|
for (const propName in changes) {
|
|
if (propName === 'myCtx') {
|
|
const param = changes[propName];
|
|
this.myCtx = <IContextNode>param.currentValue;
|
|
//controllo che l'oggetto non sia vuoto
|
|
if (Object.keys(this.myCtx).length !== 0) {
|
|
//mt qui va passato il parametro myCtx.id al rest
|
|
this.myServiceTable.getHostingNodes().subscribe(res => {
|
|
this.dataSource = res;
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|