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";
-import { EmptyObservable } from 'rxjs/observable/EmptyObservable';
export interface Job {
jobId: string;
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([
}))
),
finalize(() => {
- this.loadingSubject$.next(false)
+ this.loadingSubject$.next(false);
+ this.jobsSubject$.next(this.jobList);
})
);
concatMap((value) => {
let pollCondition = value == 0 || this.checked;
return pollCondition ? refreshedJobs$ : EMPTY;
- }),
+ })
)
.subscribe();
}
private extractJobs(res: any) {
this.clearFilter();
- let jobList = [];
res.forEach(element => {
if(element[1] != -1 && element[2] != -1){
let jobObj = <Job>{};
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);
+ 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;
+ }
+
}