- this.eiSvc.getEIJobs()
- .pipe(
- catchError((her: HttpErrorResponse) => {
- this.notificationService.error('Failed to get EI jobs: ' + her.error);
- return of([]);
- }),
- finalize(() => this.loadingSubject.next(false))
- )
- .subscribe((instances: EIJob[]) => {
- this.rowCount = instances.length;
- this.eiJobSubject.next(instances);
- });
- }
-
- connect(): Observable<EIJob[]> {
- const dataMutations = [
- this.eiJobSubject.asObservable(),
- this.sort.sortChange
- ];
- return merge(...dataMutations).pipe(map(() => {
- return this.getSortedData([...this.eiJobSubject.getValue()]);
- }));
- }
-
- disconnect(): void {
- this.eiJobSubject.complete();
- this.loadingSubject.complete();
- }
-
- private getSortedData(data: EIJob[]) {
- if (!this.sort || !this.sort.active || this.sort.direction === '') {
- return data;
- }
-
- return data.sort((a, b) => {
- const isAsc = this.sort.direction === 'asc';
- switch (this.sort.active) {
- case 'ei_job_identity': return compare(a.ei_job_identity, b.ei_job_identity, isAsc);
- case 'owner': return compare(a.owner, b.owner, isAsc);
- case 'ei_type_identity': return compare(a.ei_type_identity, b.ei_type_identity, isAsc);
- default: return 0;
- }
+ this.jobs = [];
+ this.eiSvc.getProducerIds().pipe(
+ mergeMap(prodIds =>
+ forkJoin(prodIds.map(id => this.eiSvc.getJobsForProducer(id)))),
+ mergeMap(result => result),
+ finalize(() => this.loadingSubject.next(false))
+ ).subscribe(result => {
+ this.jobs = this.jobs.concat(result);
+ this.jobsSubject.next(this.jobs);