mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-17 07:45:24 +01:00
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:
commit
630fa48ac8
@ -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>
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user