mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-20 07:37:38 +01:00
Get the number of execution status every 10s and refresh the task list
Signed-off-by: FangyuanCheng <fangyuanc@vmware.com>
This commit is contained in:
parent
3296e2acae
commit
4768ad33ed
@ -30,6 +30,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<button class="btn btn-primary btn-sm" (click)="stopJob()"
|
<button class="btn btn-primary btn-sm" (click)="stopJob()"
|
||||||
[disabled]="stopOnGoing">{{'REPLICATION.STOPJOB' | translate}}</button>
|
[disabled]="stopOnGoing">{{'REPLICATION.STOPJOB' | translate}}</button>
|
||||||
|
<span class="spinner spinner-inline" [hidden]="inProgress === false"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -20,6 +20,7 @@ const taskStatus: any = {
|
|||||||
})
|
})
|
||||||
export class ReplicationTasksComponent implements OnInit, OnDestroy {
|
export class ReplicationTasksComponent implements OnInit, OnDestroy {
|
||||||
isOpenFilterTag: boolean;
|
isOpenFilterTag: boolean;
|
||||||
|
inProgress: boolean = false;
|
||||||
currentPage: number = 1;
|
currentPage: number = 1;
|
||||||
selectedRow: [];
|
selectedRow: [];
|
||||||
pageSize: number = DEFAULT_PAGE_SIZE;
|
pageSize: number = DEFAULT_PAGE_SIZE;
|
||||||
@ -54,10 +55,13 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getExecutionDetail(): void {
|
getExecutionDetail(): void {
|
||||||
|
this.inProgress = true;
|
||||||
if (this.executionId) {
|
if (this.executionId) {
|
||||||
this.replicationService.getExecutionById(this.executionId)
|
this.replicationService.getExecutionById(this.executionId)
|
||||||
|
.pipe(finalize(() => (this.inProgress = false)))
|
||||||
.subscribe(res => {
|
.subscribe(res => {
|
||||||
this.executions = res.data;
|
this.executions = res.data;
|
||||||
|
this.clrLoadPage();
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this.errorHandler.error(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 {
|
public get trigger(): string {
|
||||||
return this.executions && this.executions['trigger']
|
return this.executions && this.executions['trigger']
|
||||||
? this.executions['trigger']
|
? this.executions['trigger']
|
||||||
@ -128,26 +150,6 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(finalize(() => (this.loading = false)))
|
.pipe(finalize(() => (this.loading = false)))
|
||||||
.subscribe(res => {
|
.subscribe(res => {
|
||||||
this.tasks = res; // Keep the data
|
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 => {
|
error => {
|
||||||
this.errorHandler.error(error);
|
this.errorHandler.error(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user