Merge pull request #7517 from pureshine/loading-num

Get the number of execution status every 10s and refresh the task list
This commit is contained in:
Mia ZHOU 2019-04-28 14:22:36 +08:00 committed by GitHub
commit 630fa48ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 20 deletions

View File

@ -30,6 +30,7 @@
<div>
<button class="btn btn-primary btn-sm" (click)="stopJob()"
[disabled]="stopOnGoing">{{'REPLICATION.STOPJOB' | translate}}</button>
<span class="spinner spinner-inline" [hidden]="inProgress === false"></span>
</div>
</div>
</div>

View File

@ -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);