From d8b917c09767d5cc21dbcf01c2af16a5724f91ae Mon Sep 17 00:00:00 2001 From: Meina Zhou Date: Fri, 21 Sep 2018 08:39:19 +0800 Subject: [PATCH] Modify some small issues in gc ui Signed-off-by: Meina Zhou --- .../src/app/config/gc/gc.component.html | 8 ++++---- .../src/app/config/gc/gc.component.scss | 9 +++++++++ src/portal/src/app/config/gc/gc.component.ts | 19 ++++++++++++------- src/portal/src/app/config/gc/gc.const.ts | 2 ++ .../src/app/config/gc/gc.viewmodel.factory.ts | 2 +- src/portal/src/i18n/lang/en-us-lang.json | 5 +++-- src/portal/src/i18n/lang/es-es-lang.json | 5 +++-- src/portal/src/i18n/lang/fr-fr-lang.json | 5 +++-- src/portal/src/i18n/lang/zh-cn-lang.json | 5 +++-- 9 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/portal/src/app/config/gc/gc.component.html b/src/portal/src/app/config/gc/gc.component.html index 3b228aa05..a0b900793 100644 --- a/src/portal/src/app/config/gc/gc.component.html +++ b/src/portal/src/app/config/gc/gc.component.html @@ -3,7 +3,7 @@ {{(originScheduleType ? 'SCHEDULE.'+ originScheduleType.toUpperCase(): "") | translate}} {{'GC.ON' | translate}} {{originWeekDay.text | translate}} {{'GC.AT' | translate}} {{originOffTime.text}} - +
@@ -27,7 +27,7 @@
- +
{{'GC.JOB_LIST' | translate}}
{{'GC.JOB_ID' | translate}} @@ -38,12 +38,12 @@ {{'DETAILS' | translate}} {{job.id }} - {{'SCHEDULE.'+ job.type.toUpperCase() | translate }} + {{(job.type ? 'SCHEDULE.'+ job.type.toUpperCase() : '') | translate }} {{job.status.toUpperCase() | translate}} {{job.createTime | date:'medium'}} {{job.updateTime | date:'medium'}} - {{'GC.LOG_DETAIL' | translate}} + {{'GC.LOG_DETAIL' | translate}} {{'GC.LATEST_JOBS' | translate :{param: jobs.length} }} diff --git a/src/portal/src/app/config/gc/gc.component.scss b/src/portal/src/app/config/gc/gc.component.scss index b1170b9f5..e9dbd0620 100644 --- a/src/portal/src/app/config/gc/gc.component.scss +++ b/src/portal/src/app/config/gc/gc.component.scss @@ -2,11 +2,20 @@ display: flex; align-items: center; margin:20px 0; +} + +.setting-wrapper { > * { margin-right:35px; } } +.normal-wrapper { + > * { + margin-right: 90px; + } +} + .gc-start-btn { width:150px; } diff --git a/src/portal/src/app/config/gc/gc.component.ts b/src/portal/src/app/config/gc/gc.component.ts index 378377aee..c35757bb6 100644 --- a/src/portal/src/app/config/gc/gc.component.ts +++ b/src/portal/src/app/config/gc/gc.component.ts @@ -3,9 +3,10 @@ import { TranslateService } from '@ngx-translate/core'; import { GcJobViewModel, WeekDay } from "./gcLog"; import { GcViewModelFactory } from "./gc.viewmodel.factory"; import { GcRepoService } from "./gc.service"; -import { WEEKDAYS, SCHEDULE_TYPE } from './gc.const'; +import { WEEKDAYS, SCHEDULE_TYPE, ONE_MINITUE} from './gc.const'; import { GcUtility } from './gc.utility'; import { ErrorHandler } from '@harbor/ui'; + @Component({ selector: 'gc-config', templateUrl: './gc.component.html', @@ -23,6 +24,7 @@ export class GcComponent implements OnInit { SCHEDULE_TYPE = SCHEDULE_TYPE; weekDay: WeekDay = WEEKDAYS[0]; dailyTime: string; + disableGC: boolean = false; constructor(private gcRepoService: GcRepoService, private gcViewModelFactory: GcViewModelFactory, @@ -80,6 +82,9 @@ export class GcComponent implements OnInit { } gcNow(): void { + this.disableGC = true; + setTimeout(() => {this.enableGc(); }, ONE_MINITUE); + this.gcRepoService.manualGc().subscribe(response => { this.translate.get('GC.MSG_SUCCESS').subscribe((res: string) => { this.errorHandler.info(res); @@ -90,6 +95,10 @@ export class GcComponent implements OnInit { }); } + private enableGc () { + this.disableGC = false; + } + scheduleGc(): void { let offTime = this.gcUtility.getOffTime(this.dailyTime); if (this.schedule) { @@ -103,9 +112,7 @@ export class GcComponent implements OnInit { this.isEditMode = false; this.getJobs(); }, error => { - this.translate.get('GC.MSG_ERROR').subscribe((res: string) => { - this.errorHandler.info(res); - }); + this.errorHandler.error(error); }); } else { this.gcRepoService.postScheduleGc(this.scheduleType, offTime, this.weekDay.value).subscribe(response => { @@ -125,9 +132,7 @@ export class GcComponent implements OnInit { this.isEditMode = false; this.getJobs(); }, error => { - this.translate.get('GC.MSG_ERROR').subscribe((res: string) => { - this.errorHandler.info(res); - }); + this.errorHandler.error(error); }); } } diff --git a/src/portal/src/app/config/gc/gc.const.ts b/src/portal/src/app/config/gc/gc.const.ts index 1c30a6d4c..4e43dfcab 100644 --- a/src/portal/src/app/config/gc/gc.const.ts +++ b/src/portal/src/app/config/gc/gc.const.ts @@ -14,6 +14,8 @@ export const SCHEDULE_TYPE = { WEEKLY: "Weekly" }; +export const ONE_MINITUE = 60000; + diff --git a/src/portal/src/app/config/gc/gc.viewmodel.factory.ts b/src/portal/src/app/config/gc/gc.viewmodel.factory.ts index 99b54e1d2..ba109ba75 100644 --- a/src/portal/src/app/config/gc/gc.viewmodel.factory.ts +++ b/src/portal/src/app/config/gc/gc.viewmodel.factory.ts @@ -11,7 +11,7 @@ export class GcViewModelFactory { let updateTime = new Date(job.update_time); gcViewModels.push({ id: job.id, - type: job.schedule.type, + type: job.schedule ? job.schedule.type : null, status: job.job_status, createTime: createTime, updateTime: updateTime, diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index f3f2f562a..df1d65ffb 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -818,6 +818,8 @@ "DETAILS":"Details", "PENDING":"Pending", "FINISHED":"Finished", + "STOPPED":"Stopped", + "ERROR":"Error", "SCHEDULE": { "NONE": "None", "DAILY": "Daily", @@ -836,8 +838,7 @@ "LOG_DETAIL":"Log Details", "MSG_SUCCESS":"Garbage Collection Successful", "MSG_SCHEDULE_SET":"Garbage Collection schedule has been set", - "MSG_SCHEDULE_RESET":"Garbage Collection schedule has been reset", - "MSG_ERROR":"Can not do Garbase Collection too often,please try again later." + "MSG_SCHEDULE_RESET":"Garbage Collection schedule has been reset" } } diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index f5ab6a557..522bd3239 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -815,6 +815,8 @@ "DETAILS":"Details", "PENDING":"Pending", "FINISHED":"Finished", + "STOPPED":"Stopped", + "ERROR":"Error", "SCHEDULE": { "NONE": "None", "DAILY": "Daily", @@ -833,7 +835,6 @@ "LOG_DETAIL":"Log Details", "MSG_SUCCESS":"Garbage Collection Successful", "MSG_SCHEDULE_SET":"Garbage Collection schedule has been set", - "MSG_SCHEDULE_RESET":"Garbage Collection schedule has been reset", - "MSG_ERROR":"Can not do Garbase Collection too often,please try again later." + "MSG_SCHEDULE_RESET":"Garbage Collection schedule has been reset" } } \ No newline at end of file diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index 513499ee6..6579d6cbe 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -778,6 +778,8 @@ "DETAILS":"Details", "PENDING":"Pending", "FINISHED":"Finished", + "STOPPED":"Stopped", + "ERROR":"Error", "SCHEDULE": { "NONE": "None", "DAILY": "Daily", @@ -796,7 +798,6 @@ "LOG_DETAIL":"Log Details", "MSG_SUCCESS":"Garbage Collection Successful", "MSG_SCHEDULE_SET":"Garbage Collection schedule has been set", - "MSG_SCHEDULE_RESET":"Garbage Collection schedule has been reset", - "MSG_ERROR":"Can not do Garbase Collection too often,please try again later." + "MSG_SCHEDULE_RESET":"Garbage Collection schedule has been reset" } } diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index 6d9d96686..f002b70fb 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -814,6 +814,8 @@ "DETAILS":"详情", "PENDING":"未开始", "FINISHED":"已完成", + "STOPPED":"已停止", + "ERROR":"错误", "SCHEDULE": { "NONE": "无", "DAILY": "每天", @@ -832,7 +834,6 @@ "LOG_DETAIL":"日志详情", "MSG_SUCCESS":"垃圾回收成功", "MSG_SCHEDULE_SET":"垃圾回收定时任务设置成功", - "MSG_SCHEDULE_RESET":"垃圾回收定时任务已被重置", - "MSG_ERROR":"您的垃圾回收请求提交过于频繁,请稍候重试" + "MSG_SCHEDULE_RESET":"垃圾回收定时任务已被重置" } } \ No newline at end of file