Change-Id: I5d9deb44be7c62f20f85e619a6f5017879de15b0
Issue-ID: NONRTRIC-565
Signed-off-by: maximesson <maxime.bonneau@est.tech>
import { MatPaginator } from "@angular/material/paginator";
import { Sort } from "@angular/material/sort";
import { MatTableDataSource } from "@angular/material/table";
import { MatPaginator } from "@angular/material/paginator";
import { Sort } from "@angular/material/sort";
import { MatTableDataSource } from "@angular/material/table";
-import { EMPTY, forkJoin, of, Subscription, timer } from "rxjs";
+import { EMPTY, forkJoin, of, pipe, Subscription, concat } from "rxjs";
import { BehaviorSubject } from "rxjs/BehaviorSubject";
import { BehaviorSubject } from "rxjs/BehaviorSubject";
-import { mergeMap, finalize, map, tap, switchMap } from "rxjs/operators";
+import { mergeMap, finalize, map, tap, concatMap, delay, skip } from "rxjs/operators";
import { ConsumerService } from "@services/ei/consumer.service";
import { UiService } from "@services/ui/ui.service";
import { ConsumerService } from "@services/ei/consumer.service";
import { UiService } from "@services/ui/ui.service";
finalize(() => this.loadingSubject$.next(false))
);
finalize(() => this.loadingSubject$.next(false))
);
+ const whenToRefresh$ = of('').pipe(
+ delay(10000),
+ tap((_) => this.refresh$.next('')),
+ skip(1),
+ );
+
+ const poll$ = concat(jobsInfo$, whenToRefresh$);
+
const refreshedJobs$ = this.refresh$.pipe(
const refreshedJobs$ = this.refresh$.pipe(
- switchMap((_) =>
- timer(0, 10000).pipe(
- tap((_) => {
- this.loadingSubject$.next(true);
- }),
- switchMap((_) => jobsInfo$),
- map((response) => this.extractJobs(response))
- )
- )
+ tap((_) => {
+ this.loadingSubject$.next(true);
+ }),
+ concatMap((_) => this.checked ? poll$ : jobsInfo$),
+ map((response) => this.extractJobs(response))
);
return this.polling$
.pipe(
);
return this.polling$
.pipe(
let pollCondition = value == 0 || this.checked;
return pollCondition ? refreshedJobs$ : EMPTY;
let pollCondition = value == 0 || this.checked;
return pollCondition ? refreshedJobs$ : EMPTY;
stopPolling(checked) {
this.checked = checked;
this.polling$.next(this.jobs().length);
stopPolling(checked) {
this.checked = checked;
this.polling$.next(this.jobs().length);
+ this.refreshDataClick();
}
compare(a: any, b: any, isAsc: boolean) {
}
compare(a: any, b: any, isAsc: boolean) {
jobObj.owner = element[1].job_owner;
jobObj.targetUri = element[1].job_result_uri;
jobObj.typeId = element[1].info_type_id;
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"];
+ jobObj.prodIds = (element[2].producers) ? element[2].producers : ["No Producers"];
jobList = jobList.concat(jobObj);
jobList = jobList.concat(jobObj);
this.jobsSubject$.next(jobList);
if (this.firstTime && jobList.length > 0) {
this.polling$.next(jobList.length);
this.jobsSubject$.next(jobList);
if (this.firstTime && jobList.length > 0) {
this.polling$.next(jobList.length);