Change-Id: Ie847cedb77131aa0db902972895018a5c8b20fc8
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Issue-ID: NONRTRIC-389
export class EIJobDataSource {
export class EIJobDataSource {
- private eiJobsSubject = new BehaviorSubject<EIJob[]>([]);
+ private jobs: Array<EIJob> = [];
public eiJobs(): EIJob[] {
public eiJobs(): EIJob[] {
- return this.eiJobsSubject.value;
}
private loadingSubject = new BehaviorSubject<boolean>(false);
}
private loadingSubject = new BehaviorSubject<boolean>(false);
loadJobs() {
this.loadingSubject.next(true);
loadJobs() {
this.loadingSubject.next(true);
this.eiSvc.getProducerIds()
.subscribe((producerIds: string[]) => {
producerIds.forEach(id => {
this.getJobsForProducer(id);
});
});
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);
}
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);
- }
export class EIProducerDataSource {
export class EIProducerDataSource {
- private producerSubject = new BehaviorSubject<EIProducer[]>([]);
+ private producers: Array<EIProducer> = [];
public eiProducers(): EIProducer[] {
public eiProducers(): EIProducer[] {
- return this.producerSubject.value;
}
private loadingSubject = new BehaviorSubject<boolean>(false);
}
private loadingSubject = new BehaviorSubject<boolean>(false);
loadProducers() {
this.loadingSubject.next(true);
loadProducers() {
this.loadingSubject.next(true);
- let producers: Array<EIProducer> = [];
this.eiSvc.getProducerIds()
.subscribe((prodIds: string[]) => {
console.log("ProducerIds: " + prodIds);
this.eiSvc.getProducerIds()
.subscribe((prodIds: string[]) => {
console.log("ProducerIds: " + prodIds);
this.eiSvc.getProducerStatus(id).subscribe(prodStatus => {
eiProducer.status = prodStatus.opState.toString();
});
this.eiSvc.getProducerStatus(id).subscribe(prodStatus => {
eiProducer.status = prodStatus.opState.toString();
});
- this.addProducerToSubject(eiProducer);
- producers.push(eiProducer);
+ this.producers.push(eiProducer);
- this.rowCount = this.producerSubject.value.length;
+ this.rowCount = this.producers.length;
-
- private addProducerToSubject(producer: EIProducer) {
- const currentValue = this.producerSubject.value;
- const updatedValue = [...currentValue, producer];
- this.producerSubject.next(updatedValue);
- }
}
\ No newline at end of file
}
\ No newline at end of file