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=bf3c867f8420e8bcb1c1a2551bc8b72cef7f9e34;hb=ad70d4114bbfc5dbf20fd1a8151095d89610c759;hp=64c948c158eafe3302c68055d01d7a51342d7496;hpb=b38d7384f7ef6571895d6d0cf89791749c33f783;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 64c948c..bf3c867 100644 --- a/webapp-frontend/src/app/ei-coordinator/ei-job.datasource.ts +++ b/webapp-frontend/src/app/ei-coordinator/ei-job.datasource.ts @@ -19,7 +19,6 @@ */ import { Injectable } from '@angular/core'; -import { MatTableDataSource } from '@angular/material'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; @@ -30,9 +29,13 @@ import { EIService } from '../services/ei/ei.service'; providedIn: 'root' }) -export class EIJobDataSource extends MatTableDataSource { +export class EIJobDataSource { - eiJobsSubject = new BehaviorSubject([]); + private jobs: Array = []; + + public eiJobs(): EIJob[] { + return this.jobs; + } private loadingSubject = new BehaviorSubject(false); @@ -42,39 +45,25 @@ export class EIJobDataSource extends MatTableDataSource { constructor( private eiSvc: EIService) { - super(); } - getJobs() { + loadJobs() { this.loadingSubject.next(true); + this.jobs = []; this.eiSvc.getProducerIds() .subscribe((producerIds: string[]) => { producerIds.forEach(id => { this.getJobsForProducer(id); }); }); + this.rowCount = this.jobs.length; } 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; + this.eiSvc.getJobsForProducer(id) + .subscribe(producerJobs => { + this.jobs = this.jobs.concat(producerJobs); }); } - - private addJobsToSubject(jobs: EIJob[]) { - const currentValue = this.eiJobsSubject.value; - const updatedValue = [...currentValue, ...jobs]; - this.eiJobsSubject.next(updatedValue); - } - - connect(): BehaviorSubject { - return this.eiJobsSubject; - } - - disconnect(): void { - this.eiJobsSubject.complete(); - this.loadingSubject.complete(); - } }