import { MatPaginator } from "@angular/material/paginator";
import { Sort } from "@angular/material/sort";
import { MatTableDataSource } from "@angular/material/table";
-import { EMPTY, forkJoin, of, pipe, Subscription, concat } from "rxjs";
+import { EMPTY, forkJoin, of, pipe, Subscription, concat, Observable } from "rxjs";
import { BehaviorSubject } from "rxjs/BehaviorSubject";
-import { mergeMap, finalize, map, tap, concatMap, delay, skip } from "rxjs/operators";
+import { mergeMap, finalize, map, tap, concatMap, delay, skip, catchError } from "rxjs/operators";
import { ConsumerService } from "@services/ei/consumer.service";
import { UiService } from "@services/ui/ui.service";
subscription: Subscription;
checked: boolean = false;
firstTime: boolean = true;
+ jobList: Job[] = [];
constructor(private consumerService: ConsumerService, private ui: UiService) {
this.jobForm = new FormGroup({
dataSubscription(): Subscription {
const jobsInfo$ = this.consumerService.getJobIds().pipe(
+ tap((_) => {
+ this.jobList = [] as Job[];
+ }),
mergeMap((jobIds) =>
forkJoin(jobIds.map((jobId) => {
return forkJoin([
of(jobId),
- this.consumerService.getJobInfo(jobId),
- this.consumerService.getConsumerStatus(jobId)
+ this.consumerService.getJobInfo(jobId).pipe(
+ catchError(err => {
+ return of([-1]);
+ })),
+ this.consumerService.getConsumerStatus(jobId).pipe(
+ catchError(err => {
+ return of([-1]);
+ })),
])
}))
),
- finalize(() => this.loadingSubject$.next(false))
+ finalize(() => {
+ this.loadingSubject$.next(false);
+ this.jobsSubject$.next(this.jobList);
+ })
+
);
const whenToRefresh$ = of('').pipe(
concatMap((value) => {
let pollCondition = value == 0 || this.checked;
return pollCondition ? refreshedJobs$ : EMPTY;
- }),
+ })
)
.subscribe();
}
}
isArrayIncluding(data: string[], filter: string): boolean {
- if(!data)
+ if (!data)
return true;
for (let i = 0; i < data.length; i++) {
return this.isDataIncluding(data[i], filter);
private extractJobs(res: any) {
this.clearFilter();
- let jobList = [];
res.forEach(element => {
- let jobObj = <Job>{};
- jobObj.jobId = element[0];
- jobObj.owner = element[1].job_owner;
- jobObj.targetUri = element[1].job_result_uri;
- jobObj.typeId = element[1].info_type_id;
- jobObj.prodIds = (element[2].producers) ? element[2].producers : ["No Producers"];
- jobList = jobList.concat(jobObj);
+ if(element[1] != -1 && element[2] != -1){
+ let jobObj = <Job>{};
+ jobObj.jobId = element[0];
+ jobObj.owner = element[1].job_owner;
+ jobObj.targetUri = element[1].job_result_uri;
+ jobObj.typeId = element[1].info_type_id;
+ jobObj.prodIds = (element[2].producers) ? element[2].producers : ["No Producers"];
+ this.jobList = this.jobList.concat(jobObj);
+ }
});
- this.jobsSubject$.next(jobList);
- if (this.firstTime && jobList.length > 0) {
- this.polling$.next(jobList.length);
+ if (this.firstTime && this.jobList.length > 0) {
+ this.polling$.next(this.jobList.length);
this.firstTime = false;
}
- return jobList;
+ return this.jobList;
}
refreshDataClick() {
this.refresh$.next("");
}
+
+ hasJobs(): boolean {
+ return this.jobs().length > 0;
+ }
+
}