Fix EI jobs count stopping too early
Change-Id: I5d9deb44be7c62f20f85e619a6f5017879de15b0
Issue-ID: NONRTRIC-565
Signed-off-by: maximesson <maxime.bonneau@est.tech>
diff --git a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts
index 43b3ad8..c0e437d 100644
--- a/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts
+++ b/webapp-frontend/src/app/ei-coordinator/jobs-list/jobs-list.component.ts
@@ -22,9 +22,9 @@
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 { 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";
@@ -108,24 +108,28 @@
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(
- 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(
- switchMap((value) => {
+ concatMap((value) => {
let pollCondition = value == 0 || this.checked;
return pollCondition ? refreshedJobs$ : EMPTY;
- })
+ }),
)
.subscribe();
}
@@ -167,6 +171,7 @@
stopPolling(checked) {
this.checked = checked;
this.polling$.next(this.jobs().length);
+ this.refreshDataClick();
}
compare(a: any, b: any, isAsc: boolean) {
@@ -217,10 +222,10 @@
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);
- });
-
+ });
+
this.jobsSubject$.next(jobList);
if (this.firstTime && jobList.length > 0) {
this.polling$.next(jobList.length);