isdashboard/src/main/webapp/app/tab-items/list-screen.component.ts

73 lines
2.4 KiB
TypeScript
Raw Normal View History

2023-09-07 17:13:39 +02:00
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
2023-09-01 22:27:00 +02:00
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],
})
2023-09-07 17:13:39 +02:00
export class ListScreenComponent implements OnChanges, OnInit {
2023-09-01 22:27:00 +02:00
dataSource: IHostingnode[];
tableDetail: IHostingnode;
2023-09-07 17:13:39 +02:00
//nestedContexts: IContextNode[]|any;
2023-09-01 22:27:00 +02:00
@Input() myCtx: IContextNode; //fetching event from parent
@Output() jsonEmitter = new EventEmitter<IHostingnode>();
2023-09-07 17:13:39 +02:00
constructor(private myServiceTable: ResourcesLoaderService, private myContextService: MockCtxloaderService) {
2023-09-01 22:27:00 +02:00
this.myCtx = {} as IContextNode;
this.tableDetail = {} as IHostingnode;
this.dataSource = [];
}
openJsonViewer(node: IHostingnode): void {
this.jsonEmitter.emit(node);
}
2023-09-07 17:13:39 +02:00
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];
});
*/
2023-09-08 14:06:17 +02:00
//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
2023-09-07 17:13:39 +02:00
this.myServiceTable.getHostingNodes().subscribe(res => {
this.dataSource = res;
});
}
2023-09-01 22:27:00 +02:00
ngOnChanges(changes: SimpleChanges): void {
2023-09-08 14:06:17 +02:00
// eslint-disable-next-line no-console
console.log('---NELLA ONCHANGES...' + this.myCtx.name);
2023-09-01 22:27:00 +02:00
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;
});
}
}
}
}
}