+ dataSubscription(): Subscription {
+ const jobsInfo$ = this.consumerService.getJobIds().pipe(
+ tap((_) => {
+ this.jobList = [] as Job[];
+ }),
+ mergeMap((jobIds) =>
+ forkJoin(jobIds.map((jobId) => {
+ return forkJoin([
+ of(jobId).pipe(
+ catchError(err => {
+ return of([-1]);
+ })
+ ),
+ 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);
+ this.jobsSubject$.next(this.jobList);
+ })
+ );
+
+ const whenToRefresh$ = of('').pipe(
+ delay(10000),
+ tap((_) => this.refresh$.next('')),
+ skip(1),
+ );
+
+ const poll$ = concat(jobsInfo$, whenToRefresh$);
+
+ const refreshedJobs$ = this.refresh$.pipe(
+ tap((_) => {
+ this.loadingSubject$.next(true);
+ }),
+ concatMap((_) => this.checked ? poll$ : jobsInfo$),
+ map((response) => this.extractJobs(response))
+ );
+
+ return this.polling$
+ .pipe(
+ concatMap((value) => {
+ let pollCondition = value == 0 || this.checked;
+ return pollCondition ? refreshedJobs$ : EMPTY;
+ })
+ )
+ .subscribe();
+ }
+
+ ngOnDestroy() {
+ this.subscription.unsubscribe();
+ }
+
+ clearFilter() {
+ this.jobForm.get("jobId").setValue("");
+ this.jobForm.get("typeId").setValue("");
+ this.jobForm.get("owner").setValue("");
+ this.jobForm.get("targetUri").setValue("");
+ this.jobForm.get("prodIds").setValue("");
+ this.jobForm.get("status").setValue("");
+ }
+