mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 10:45:45 +01:00
Add server paging to tag-retention sub task list
Signed-off-by: sshijun <sshijun@vmware.com>
This commit is contained in:
parent
285d3e1e5c
commit
bbf61a11e3
@ -124,7 +124,7 @@
|
||||
(click)="openDetail(i,execution.id)">{{execution.start_time|date:'medium'}}</clr-dg-cell>
|
||||
<clr-dg-cell class="hand" (click)="openDetail(i,execution.id)">{{execution.duration}}</clr-dg-cell>
|
||||
<clr-dg-row-detail *ngIf="index===i">
|
||||
<clr-datagrid [clrDgLoading]="loadingHistories" class="w-100">
|
||||
<clr-datagrid (clrDgRefresh)="loadLog()" [clrDgLoading]="loadingHistories" class="w-100">
|
||||
<clr-dg-column>{{'TAG_RETENTION.REPOSITORY' | translate}}</clr-dg-column>
|
||||
<clr-dg-column>{{'TAG_RETENTION.STATUS' | translate}}</clr-dg-column>
|
||||
<clr-dg-column>{{'TAG_RETENTION.RETAINED' | translate}}/{{'TAG_RETENTION.TOTAL' | translate}}</clr-dg-column>
|
||||
@ -134,7 +134,7 @@
|
||||
<clr-dg-placeholder>
|
||||
{{'TAG_RETENTION.NO_HISTORY' | translate}}
|
||||
</clr-dg-placeholder>
|
||||
<clr-dg-row *clrDgItems="let task of historyList" [clrDgItem]="task">
|
||||
<clr-dg-row *ngFor="let task of historyList" [clrDgItem]="task">
|
||||
<clr-dg-cell>{{task.repository}}</clr-dg-cell>
|
||||
<clr-dg-cell>{{task.status}}</clr-dg-cell>
|
||||
<clr-dg-cell>{{task.retained}}/{{task.total}}</clr-dg-cell>
|
||||
@ -150,7 +150,7 @@
|
||||
{{innerPagination.lastItem + 1 }} {{'ROBOT_ACCOUNT.OF' |
|
||||
translate}} </span>
|
||||
{{innerPagination.totalItems }} {{'ROBOT_ACCOUNT.ITEMS' | translate}}
|
||||
<clr-dg-pagination #innerPagination [clrDgPageSize]="5"></clr-dg-pagination>
|
||||
<clr-dg-pagination [clrDgTotalItems]="totalLogCount" [(clrDgPage)]="currentLogPage" #innerPagination [clrDgPageSize]="logPageSize"></clr-dg-pagination>
|
||||
</clr-dg-footer>
|
||||
</clr-datagrid>
|
||||
</clr-dg-row-detail>
|
||||
|
@ -68,6 +68,7 @@ export class TagRetentionComponent implements OnInit {
|
||||
retention: Retention = new Retention();
|
||||
editIndex: number;
|
||||
executionList = [];
|
||||
executionId: number;
|
||||
historyList = [];
|
||||
loadingExecutions: boolean = true;
|
||||
loadingHistories: boolean = true;
|
||||
@ -76,6 +77,10 @@ export class TagRetentionComponent implements OnInit {
|
||||
currentPage: number = 1;
|
||||
pageSize: number = 10;
|
||||
totalCount: number = 0;
|
||||
currentLogPage: number = 1;
|
||||
totalLogCount: number = 0;
|
||||
logPageSize: number = 5;
|
||||
isDetailOpened: boolean = false;
|
||||
@ViewChild('cronScheduleComponent', {static: false})
|
||||
cronScheduleComponent: CronScheduleComponent;
|
||||
@ViewChild('addRule', {static: false}) addRuleComponent: AddRuleComponent;
|
||||
@ -255,7 +260,7 @@ export class TagRetentionComponent implements OnInit {
|
||||
this.tagRetentionService.getRunNowList(this.retentionId, this.currentPage, this.pageSize)
|
||||
.pipe(finalize(() => this.loadingExecutions = false))
|
||||
.subscribe(
|
||||
response => {
|
||||
(response: any) => {
|
||||
// Get total count
|
||||
if (response.headers) {
|
||||
let xHeader: string = response.headers.get("x-total-count");
|
||||
@ -322,22 +327,36 @@ export class TagRetentionComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
loadLog() {
|
||||
if (this.isDetailOpened) {
|
||||
this.loadingHistories = true;
|
||||
this.tagRetentionService.getExecutionHistory(this.retentionId, this.executionId, this.currentLogPage, this.logPageSize)
|
||||
.pipe(finalize(() => this.loadingHistories = false))
|
||||
.subscribe(
|
||||
(response: any) => {
|
||||
// Get total count
|
||||
if (response.headers) {
|
||||
let xHeader: string = response.headers.get("x-total-count");
|
||||
if (xHeader) {
|
||||
this.totalLogCount = parseInt(xHeader, 0);
|
||||
}
|
||||
}
|
||||
this.historyList = response.body as Array<any>;
|
||||
TagRetentionComponent.calculateDuration(this.historyList);
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
openDetail(index, executionId) {
|
||||
if (this.index !== index) {
|
||||
this.index = index;
|
||||
this.historyList = [];
|
||||
this.loadingHistories = true;
|
||||
this.tagRetentionService.getExecutionHistory(this.retentionId, executionId)
|
||||
.pipe(finalize(() => this.loadingHistories = false))
|
||||
.subscribe(
|
||||
res => {
|
||||
this.historyList = res;
|
||||
TagRetentionComponent.calculateDuration(this.historyList);
|
||||
}, error => {
|
||||
this.errorHandler.error(error);
|
||||
});
|
||||
this.executionId = executionId;
|
||||
this.isDetailOpened = true;
|
||||
} else {
|
||||
this.index = -1;
|
||||
this.isDetailOpened = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,9 +117,13 @@ export class TagRetentionService {
|
||||
.pipe(catchError(error => observableThrowError(error)), );
|
||||
}
|
||||
|
||||
getExecutionHistory(retentionId, executionId) {
|
||||
return this.http.get(`/api/retentions/${retentionId}/executions/${executionId}/tasks`)
|
||||
.pipe(map(response => response as Array<any>))
|
||||
getExecutionHistory(retentionId, executionId, page: number, pageSize: number) {
|
||||
let params = new HttpParams();
|
||||
if (page && pageSize) {
|
||||
params = params.set('page', page + '').set('page_size', pageSize + '');
|
||||
}
|
||||
return this.http.get<HttpResponse<Array<any>>>(`/api/retentions/${retentionId}/executions/${executionId}/tasks`,
|
||||
buildHttpRequestOptionsWithObserveResponse(params))
|
||||
.pipe(catchError(error => observableThrowError(error)));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user