X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fei-coordinator%2Fei-job.datasource.ts;h=ef9e478d458b38e70ef2884236dc8792ab9986a3;hb=a3e0f85eff3e8203612c547045e11f8d83639df1;hp=9e048b6b2c2e618c705e41e0e911f8260a3873f3;hpb=94225563a68aecb49e713eb8508fb278682cec08;p=portal%2Fnonrtric-controlpanel.git diff --git a/webapp-frontend/src/app/ei-coordinator/ei-job.datasource.ts b/webapp-frontend/src/app/ei-coordinator/ei-job.datasource.ts index 9e048b6..ef9e478 100644 --- a/webapp-frontend/src/app/ei-coordinator/ei-job.datasource.ts +++ b/webapp-frontend/src/app/ei-coordinator/ei-job.datasource.ts @@ -36,7 +36,7 @@ import { NotificationService } from '../services/ui/notification.service'; export class EIJobDataSource extends MatTableDataSource { - private eiJobSubject = new BehaviorSubject([]); + eiJobsSubject = new BehaviorSubject([]); private loadingSubject = new BehaviorSubject(false); @@ -50,9 +50,9 @@ export class EIJobDataSource extends MatTableDataSource { super(); } - loadTable() { + getJobs() { this.loadingSubject.next(true); - this.eiSvc.getEIJobs() + this.eiSvc.getProducerIds() .pipe( catchError((her: HttpErrorResponse) => { this.notificationService.error('Failed to get EI jobs: ' + her.error); @@ -60,18 +60,33 @@ export class EIJobDataSource extends MatTableDataSource { }), finalize(() => this.loadingSubject.next(false)) ) - .subscribe((instances: EIJob[]) => { - this.rowCount = instances.length; - this.eiJobSubject.next(instances); + .subscribe((producerIds: string[]) => { + producerIds.forEach(id => { + this.getJobsForProducer(id); + }); }); } + private getJobsForProducer(id: string) { + console.log('Getting jobs for producer ID: ', id); + this.eiSvc.getJobsForProducer(id).subscribe(jobs => { + this.addJobsToSubject(jobs); + this.rowCount = this.eiJobsSubject.getValue().length; + }); + } + + private addJobsToSubject(jobs: EIJob[]) { + const currentValue = this.eiJobsSubject.value; + const updatedValue = [...currentValue, ...jobs]; + this.eiJobsSubject.next(updatedValue); + } + connect(): BehaviorSubject { - return this.eiJobSubject; + return this.eiJobsSubject; } disconnect(): void { - this.eiJobSubject.complete(); + this.eiJobsSubject.complete(); this.loadingSubject.complete(); } }