From de009f49fbf0b545de6fb19183a3777fc78ac480 Mon Sep 17 00:00:00 2001 From: AllForNothing Date: Mon, 9 Mar 2020 17:33:10 +0800 Subject: [PATCH] Add new parameter for GC page Signed-off-by: AllForNothing --- src/portal/src/i18n/lang/en-us-lang.json | 4 +++- src/portal/src/i18n/lang/es-es-lang.json | 4 +++- src/portal/src/i18n/lang/fr-fr-lang.json | 4 +++- src/portal/src/i18n/lang/pt-br-lang.json | 4 +++- src/portal/src/i18n/lang/tr-tr-lang.json | 4 +++- src/portal/src/i18n/lang/zh-cn-lang.json | 4 +++- .../components/config/gc/gc.component.html | 16 ++++++++++++-- .../components/config/gc/gc.component.scss | 9 ++++++-- .../lib/components/config/gc/gc.component.ts | 21 +++++++++++++------ .../src/lib/components/config/gc/gc.const.ts | 14 +++++++++++++ .../lib/components/config/gc/gc.service.ts | 17 +++++++++++---- 11 files changed, 81 insertions(+), 20 deletions(-) diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index 065d3bc652..49e243b3ed 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -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", diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index 47a1a3d53e..0a6aae648a 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -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", diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index 8e33f5312c..d6f944db3b 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -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", diff --git a/src/portal/src/i18n/lang/pt-br-lang.json b/src/portal/src/i18n/lang/pt-br-lang.json index aebbd34dc7..921260c047 100644 --- a/src/portal/src/i18n/lang/pt-br-lang.json +++ b/src/portal/src/i18n/lang/pt-br-lang.json @@ -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", diff --git a/src/portal/src/i18n/lang/tr-tr-lang.json b/src/portal/src/i18n/lang/tr-tr-lang.json index 750f366c56..2851e02ce0 100644 --- a/src/portal/src/i18n/lang/tr-tr-lang.json +++ b/src/portal/src/i18n/lang/tr-tr-lang.json @@ -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", diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index f35b0692d6..95f46d095b 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -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 拷贝成功", diff --git a/src/portal/src/lib/components/config/gc/gc.component.html b/src/portal/src/lib/components/config/gc/gc.component.html index a86edd8fe8..7aa4c76d7a 100644 --- a/src/portal/src/lib/components/config/gc/gc.component.html +++ b/src/portal/src/lib/components/config/gc/gc.component.html @@ -1,4 +1,16 @@ +
+ + + + + + + +
- - + +
diff --git a/src/portal/src/lib/components/config/gc/gc.component.scss b/src/portal/src/lib/components/config/gc/gc.component.scss index 55c10060df..6eafa7694b 100644 --- a/src/portal/src/lib/components/config/gc/gc.component.scss +++ b/src/portal/src/lib/components/config/gc/gc.component.scss @@ -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; } \ No newline at end of file diff --git a/src/portal/src/lib/components/config/gc/gc.component.ts b/src/portal/src/lib/components/config/gc/gc.component.ts index e0193ba85f..2ab43f2023 100644 --- a/src/portal/src/lib/components/config/gc/gc.component.ts +++ b/src/portal/src/lib/components/config/gc/gc.component.ts @@ -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 = []; - 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(); @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); diff --git a/src/portal/src/lib/components/config/gc/gc.const.ts b/src/portal/src/lib/components/config/gc/gc.const.ts index 2407b098cd..121d40b4cd 100644 --- a/src/portal/src/lib/components/config/gc/gc.const.ts +++ b/src/portal/src/lib/components/config/gc/gc.const.ts @@ -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; +} + diff --git a/src/portal/src/lib/components/config/gc/gc.service.ts b/src/portal/src/lib/components/config/gc/gc.service.ts index 070a8418c2..9569095489 100644 --- a/src/portal/src/lib/components/config/gc/gc.service.ts +++ b/src/portal/src/lib/components/config/gc/gc.service.ts @@ -14,10 +14,13 @@ export class GcRepoService { private errorHandler: ErrorHandler) { } - public manualGc(): Observable { - let param = { + public manualGc(shouldDeleteUntagged: boolean): Observable { + 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 { + public postScheduleGc(shouldDeleteUntagged: boolean, type, cron): Observable { let param = { "schedule": { "type": type, "cron": cron, + }, + parameters: { + delete_untagged: shouldDeleteUntagged } }; return this.gcApiRepository.postSchedule(param); } - public putScheduleGc(type, cron): Observable { + public putScheduleGc(shouldDeleteUntagged, type, cron): Observable { let param = { "schedule": { "type": type, "cron": cron, + }, + parameters: { + delete_untagged: shouldDeleteUntagged } };