Add new parameter for GC page

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
AllForNothing 2020-03-09 17:33:10 +08:00
parent 75eb7a8c5a
commit de009f49fb
11 changed files with 81 additions and 20 deletions

View File

@ -1156,7 +1156,9 @@
"LATEST_JOBS": "Latest {{param}} Jobs",
"MSG_SUCCESS": "Garbage Collection Successful",
"MSG_SCHEDULE_SET": "Garbage Collection schedule has been set",
"MSG_SCHEDULE_RESET": "Garbage Collection schedule has been reset"
"MSG_SCHEDULE_RESET": "Garbage Collection schedule has been reset",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Delete Untagged Artifacts"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",

View File

@ -1153,7 +1153,9 @@
"LATEST_JOBS": "Latest {{param}} Jobs",
"MSG_SUCCESS": "Garbage Collection Successful",
"MSG_SCHEDULE_SET": "Garbage Collection schedule has been set",
"MSG_SCHEDULE_RESET": "Garbage Collection schedule has been reset"
"MSG_SCHEDULE_RESET": "Garbage Collection schedule has been reset",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Delete Untagged Artifacts"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",

View File

@ -1123,7 +1123,9 @@
"LATEST_JOBS": "Latest {{param}} Jobs",
"MSG_SUCCESS": "Garbage Collection Successful",
"MSG_SCHEDULE_SET": "Garbage Collection schedule has been set",
"MSG_SCHEDULE_RESET": "Garbage Collection schedule has been reset"
"MSG_SCHEDULE_RESET": "Garbage Collection schedule has been reset",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Delete Untagged Artifacts"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",

View File

@ -1151,7 +1151,9 @@
"LOG_DETAIL": "Detalhes de Log",
"MSG_SUCCESS": "Garbage Collection efetuado com sucesso",
"MSG_SCHEDULE_SET": "Agendamento de Garbage Collection efetuado",
"MSG_SCHEDULE_RESET": "Agendamento de Garbage Collection foi redefinido"
"MSG_SCHEDULE_RESET": "Agendamento de Garbage Collection foi redefinido",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Delete Untagged Artifacts"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",

View File

@ -1155,7 +1155,9 @@
"LATEST_JOBS": "Son {{param}} İşler",
"MSG_SUCCESS": "Çöp Toplama Başarılı",
"MSG_SCHEDULE_SET": "Çöp Toplama programı belirlendi",
"MSG_SCHEDULE_RESET": "Çöp Toplama programı sıfırlandı"
"MSG_SCHEDULE_RESET": "Çöp Toplama programı sıfırlandı",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Delete Untagged Artifacts"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",

View File

@ -1152,7 +1152,9 @@
"LATEST_JOBS": "最新的 {{param}} 个任务",
"MSG_SUCCESS": "垃圾回收成功",
"MSG_SCHEDULE_SET": "垃圾回收定时任务设置成功",
"MSG_SCHEDULE_RESET": "垃圾回收定时任务已被重置"
"MSG_SCHEDULE_RESET": "垃圾回收定时任务已被重置",
"PARAMETERS": "参数",
"DELETE_UNTAGGED": "删除无 Tag 的 Artifacts"
},
"RETAG": {
"MSG_SUCCESS": "Artifact 拷贝成功",

View File

@ -1,4 +1,16 @@
<form class="clr-form clr-form-horizontal">
<clr-checkbox-container>
<label class="parameters">{{'GC.PARAMETERS' | translate}}</label>
<clr-checkbox-wrapper>
<input type="checkbox" clrCheckbox name="delete_untagged" id="delete_untagged"
[(ngModel)]="shouldDeleteUntagged"/>
<label for="delete_untagged">{{'GC.DELETE_UNTAGGED' | translate}}</label>
</clr-checkbox-wrapper>
</clr-checkbox-container>
</form>
<div class="cron-selection">
<cron-selection [labelCurrent]="getLabelCurrent" #CronScheduleComponent [labelEdit]='getText' [originCron]='originCron' (inputvalue)="scheduleGc($event)"></cron-selection>
<button class="btn btn-outline gc-start-btn" (click)="gcNow()" [disabled]="disableGC">{{'GC.GC_NOW' | translate}}</button>
<cron-selection [labelCurrent]="getLabelCurrent" #CronScheduleComponent [labelEdit]='getText'
[originCron]='originCron' (inputvalue)="scheduleGc($event)"></cron-selection>
<button class="btn btn-outline gc-start-btn" (click)="gcNow()"
[disabled]="disableGC">{{'GC.GC_NOW' | translate}}</button>
</div>

View File

@ -1,10 +1,15 @@
.cron-selection {
margin-top: 20px;
padding-left: 0.25rem;
display: flex;
align-items: center;
}
.gc-start-btn {
width:150px;
margin-top: 47px;
margin-top: 41px;
}
.parameters {
font-size: 0.541667rem !important;
width: 200px !important;
font-weight: 400 !important;
}

View File

@ -13,7 +13,7 @@ import { GcRepoService } from "./gc.service";
import {
SCHEDULE_TYPE_NONE,
ONE_MINITUE,
THREE_SECONDS
THREE_SECONDS, GCSchedule
} from "./gc.const";
import { ErrorHandler } from "../../../utils/error-handler";
import { CronScheduleComponent } from "../../cron-schedule/cron-schedule.component";
@ -26,7 +26,7 @@ import { finalize } from "rxjs/operators";
})
export class GcComponent implements OnInit {
jobs: Array<GcJobViewModel> = [];
schedule: any;
schedule: GCSchedule = {};
originCron: OriginCron;
disableGC: boolean = false;
getText = 'CONFIG.GC';
@ -34,6 +34,7 @@ export class GcComponent implements OnInit {
@Output() loadingGcStatus = new EventEmitter<boolean>();
@ViewChild(CronScheduleComponent, {static: false})
CronScheduleComponent: CronScheduleComponent;
shouldDeleteUntagged: boolean;
constructor(
private gcRepoService: GcRepoService,
private gcViewModelFactory: GcViewModelFactory,
@ -61,7 +62,7 @@ export class GcComponent implements OnInit {
});
}
public initSchedule(schedule: any) {
public initSchedule(schedule: GCSchedule) {
if (schedule && schedule.schedule !== null) {
this.schedule = schedule;
this.originCron = this.schedule.schedule;
@ -71,6 +72,11 @@ export class GcComponent implements OnInit {
cron: ''
};
}
if (schedule && schedule.job_parameters) {
this.shouldDeleteUntagged = JSON.parse(schedule.job_parameters).delete_untagged;
} else {
this.shouldDeleteUntagged = false;
}
}
getJobs() {
@ -85,7 +91,7 @@ export class GcComponent implements OnInit {
this.enableGc();
}, ONE_MINITUE);
this.gcRepoService.manualGc().subscribe(
this.gcRepoService.manualGc(this.shouldDeleteUntagged).subscribe(
response => {
this.translate.get("GC.MSG_SUCCESS").subscribe((res: string) => {
this.errorHandler.info(res);
@ -108,13 +114,16 @@ export class GcComponent implements OnInit {
cron: cron
}
};
if (!cron) {
this.shouldDeleteUntagged = false;
}
this.getJobs();
}
scheduleGc(cron: string) {
let schedule = this.schedule;
if (schedule && schedule.schedule && schedule.schedule.type !== SCHEDULE_TYPE_NONE) {
this.gcRepoService.putScheduleGc(this.CronScheduleComponent.scheduleType, cron).subscribe(
this.gcRepoService.putScheduleGc(this.shouldDeleteUntagged, this.CronScheduleComponent.scheduleType, cron).subscribe(
response => {
this.translate
.get("GC.MSG_SCHEDULE_RESET")
@ -129,7 +138,7 @@ export class GcComponent implements OnInit {
}
);
} else {
this.gcRepoService.postScheduleGc(this.CronScheduleComponent.scheduleType, cron).subscribe(
this.gcRepoService.postScheduleGc(this.shouldDeleteUntagged, this.CronScheduleComponent.scheduleType, cron).subscribe(
response => {
this.translate.get("GC.MSG_SCHEDULE_SET").subscribe((res) => {
this.errorHandler.info(res);

View File

@ -1,3 +1,4 @@
import { OriginCron } from "../../../services";
export const SCHEDULE_TYPE_NONE = "None";
@ -5,6 +6,19 @@ export const SCHEDULE_TYPE_NONE = "None";
export const ONE_MINITUE = 60000;
export const THREE_SECONDS = 3000;
export interface GCSchedule {
schedule?: OriginCron;
parameters?: {[key: string]: any};
id?: number;
job_name?: string;
job_kind?: string;
job_parameters?: string;
job_status?: string;
deleted?: boolean;
creation_time?: Date;
update_time?: Date;
}

View File

@ -14,10 +14,13 @@ export class GcRepoService {
private errorHandler: ErrorHandler) {
}
public manualGc(): Observable <any> {
let param = {
public manualGc(shouldDeleteUntagged: boolean): Observable<any> {
const param = {
"schedule": {
"type": "Manual"
},
parameters: {
delete_untagged: shouldDeleteUntagged
}
};
return this.gcApiRepository.postSchedule(param);
@ -35,22 +38,28 @@ export class GcRepoService {
return this.gcApiRepository.getSchedule();
}
public postScheduleGc(type, cron): Observable <any> {
public postScheduleGc(shouldDeleteUntagged: boolean, type, cron): Observable <any> {
let param = {
"schedule": {
"type": type,
"cron": cron,
},
parameters: {
delete_untagged: shouldDeleteUntagged
}
};
return this.gcApiRepository.postSchedule(param);
}
public putScheduleGc(type, cron): Observable <any> {
public putScheduleGc(shouldDeleteUntagged, type, cron): Observable <any> {
let param = {
"schedule": {
"type": type,
"cron": cron,
},
parameters: {
delete_untagged: shouldDeleteUntagged
}
};