From 4768ad33ed29eb903988ef708716ef169a99806d Mon Sep 17 00:00:00 2001 From: FangyuanCheng Date: Thu, 25 Apr 2019 18:09:01 +0800 Subject: [PATCH] Get the number of execution status every 10s and refresh the task list Signed-off-by: FangyuanCheng --- .../replication-tasks.component.html | 1 + .../replication-tasks.component.ts | 42 ++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/portal/lib/src/replication/replication-tasks/replication-tasks.component.html b/src/portal/lib/src/replication/replication-tasks/replication-tasks.component.html index 920b4e084..055aecaa7 100644 --- a/src/portal/lib/src/replication/replication-tasks/replication-tasks.component.html +++ b/src/portal/lib/src/replication/replication-tasks/replication-tasks.component.html @@ -30,6 +30,7 @@
+
diff --git a/src/portal/lib/src/replication/replication-tasks/replication-tasks.component.ts b/src/portal/lib/src/replication/replication-tasks/replication-tasks.component.ts index df293a5da..633e8d1df 100644 --- a/src/portal/lib/src/replication/replication-tasks/replication-tasks.component.ts +++ b/src/portal/lib/src/replication/replication-tasks/replication-tasks.component.ts @@ -20,6 +20,7 @@ const taskStatus: any = { }) export class ReplicationTasksComponent implements OnInit, OnDestroy { isOpenFilterTag: boolean; + inProgress: boolean = false; currentPage: number = 1; selectedRow: []; pageSize: number = DEFAULT_PAGE_SIZE; @@ -54,10 +55,13 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy { } getExecutionDetail(): void { + this.inProgress = true; if (this.executionId) { this.replicationService.getExecutionById(this.executionId) + .pipe(finalize(() => (this.inProgress = false))) .subscribe(res => { this.executions = res.data; + this.clrLoadPage(); }, error => { this.errorHandler.error(error); @@ -65,6 +69,24 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy { } } + clrLoadPage(): void { + if (!this.timerDelay) { + this.timerDelay = timer(10000, 10000).subscribe(() => { + let count: number = 0; + if (this.executions['in_progress'] > 0) { + count++; + } + if (count > 0) { + this.getExecutionDetail(); + this.clrLoadTasks(); + } else { + this.timerDelay.unsubscribe(); + this.timerDelay = null; + } + }); + } + } + public get trigger(): string { return this.executions && this.executions['trigger'] ? this.executions['trigger'] @@ -128,26 +150,6 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy { .pipe(finalize(() => (this.loading = false))) .subscribe(res => { this.tasks = res; // Keep the data - if (!this.timerDelay) { - this.timerDelay = timer(10000, 10000).subscribe(() => { - let count: number = 0; - this.tasks.forEach(tasks => { - if ( - tasks.status.toLowerCase() === taskStatus.PENDING || - tasks.status.toLowerCase() === taskStatus.RUNNING || - tasks.status.toLowerCase() === taskStatus.SCHEDULED - ) { - count++; - } - }); - if (count > 0) { - this.clrLoadTasks(); - } else { - this.timerDelay.unsubscribe(); - this.timerDelay = null; - } - }); - } }, error => { this.errorHandler.error(error);