From f597b8910079b6d3898ca4aae4386a11c0bf732b Mon Sep 17 00:00:00 2001 From: AllForNothing Date: Thu, 29 Aug 2019 17:40:39 +0800 Subject: [PATCH] fix UI bug for tag-retention and project-quota Signed-off-by: AllForNothing --- .../project-quotas.component.html | 4 +- .../project-quotas.component.scss | 6 +-- .../add-rule/add-rule.component.ts | 6 +-- .../tag-retention.component.html | 11 ++++-- .../tag-retention/tag-retention.component.ts | 37 ++++++++++++------- .../tag-retention/tag-retention.service.ts | 6 ++- src/portal/src/i18n/lang/en-us-lang.json | 7 +++- src/portal/src/i18n/lang/es-es-lang.json | 7 +++- src/portal/src/i18n/lang/fr-fr-lang.json | 7 +++- src/portal/src/i18n/lang/pt-br-lang.json | 7 +++- src/portal/src/i18n/lang/tr-tr-lang.json | 7 +++- src/portal/src/i18n/lang/zh-cn-lang.json | 7 +++- 12 files changed, 73 insertions(+), 39 deletions(-) diff --git a/src/portal/lib/src/config/project-quotas/project-quotas.component.html b/src/portal/lib/src/config/project-quotas/project-quotas.component.html index 22af1333d..4f4928ef8 100644 --- a/src/portal/lib/src/config/project-quotas/project-quotas.component.html +++ b/src/portal/lib/src/config/project-quotas/project-quotas.component.html @@ -32,7 +32,7 @@ - {{quota?.ref?.name}} + {{quota?.ref?.name}} {{quota?.ref?.owner_name}}
@@ -76,4 +76,4 @@
- \ No newline at end of file + diff --git a/src/portal/lib/src/config/project-quotas/project-quotas.component.scss b/src/portal/lib/src/config/project-quotas/project-quotas.component.scss index eeb09db91..ea5a1b9f4 100644 --- a/src/portal/lib/src/config/project-quotas/project-quotas.component.scss +++ b/src/portal/lib/src/config/project-quotas/project-quotas.component.scss @@ -4,11 +4,11 @@ .default-quota-text { display: flex; justify-content: space-between; - min-width: 13rem; + min-width: 14rem; .num-count { display: inline-block; - min-width: 2rem; + min-width: 3rem; } } } @@ -39,4 +39,4 @@ .refresh-div { margin-top: auto; cursor: pointer; -} \ No newline at end of file +} diff --git a/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.ts b/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.ts index f8cb51bd9..b0eba339b 100644 --- a/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.ts +++ b/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.ts @@ -157,6 +157,7 @@ export class AddRuleComponent implements OnInit, OnDestroy { return !(this.rule.template && this.rule.params[this.template] && parseInt(this.rule.params[this.template], 10) >= 0 + && parseInt(this.rule.params[this.template], 10) < MAX && this.rule.scope_selectors.repository[0].pattern && this.rule.scope_selectors.repository[0].pattern.replace(/[{}]/g, "") && this.rule.tag_selectors[0].pattern @@ -187,11 +188,6 @@ export class AddRuleComponent implements OnInit, OnDestroy { this.inlineAlert.showInlineError(INVALID_RULE); return; } - if (this.hasParam() - && (this.rule.params[this.template] <= 0 || this.rule.params[this.template] > MAX)) { - this.inlineAlert.showInlineError(ILLEGAL_RULE); - return; - } if (this.isExistingRule()) { this.inlineAlert.showInlineError(EXISTING_RULE); return; diff --git a/src/portal/src/app/project/tag-retention/tag-retention.component.html b/src/portal/src/app/project/tag-retention/tag-retention.component.html index d044a2dd6..649c4b7b2 100644 --- a/src/portal/src/app/project/tag-retention/tag-retention.component.html +++ b/src/portal/src/app/project/tag-retention/tag-retention.component.html @@ -95,6 +95,9 @@ {{'TAG_RETENTION.DRY_RUN' | translate}} + + {{'TAG_RETENTION.EXECUTION_TYPE' | translate}} + {{'TAG_RETENTION.START_TIME' | translate}} @@ -113,7 +116,9 @@ {{execution.dry_run ? 'YES' : 'NO'}} {{execution.start_time|date:'short'}} + (click)="openDetail(i,execution.id)">{{execution.Trigger}}
+ {{execution.start_time|date:'medium'}} {{execution.duration}} @@ -130,7 +135,7 @@ {{task.repository}} {{task.status}} {{task.retained}}/{{task.total}} - {{task.start_time|date:'short'}} + {{task.start_time|date:'medium'}} {{task.duration}} {{'TAG_RETENTION.LOG' | translate}} @@ -215,4 +220,4 @@ -
\ No newline at end of file +
diff --git a/src/portal/src/app/project/tag-retention/tag-retention.component.ts b/src/portal/src/app/project/tag-retention/tag-retention.component.ts index 9b8bd342d..d424646fb 100644 --- a/src/portal/src/app/project/tag-retention/tag-retention.component.ts +++ b/src/portal/src/app/project/tag-retention/tag-retention.component.ts @@ -268,19 +268,21 @@ export class TagRetentionComponent implements OnInit { static calculateDuration(arr: Array) { if (arr && arr.length > 0) { for (let i = 0; i < arr.length; i++) { - let duration = new Date(arr[i].end_time).getTime() - new Date(arr[i].start_time).getTime(); - let min = Math.floor(duration / MIN); - let sec = Math.floor((duration % MIN) / SEC); - arr[i]['duration'] = ""; - if ((min || sec) && duration > 0) { - if (min) { - arr[i]['duration'] += '' + min + MIN_STR; + if (arr[i].end_time && arr[i].start_time) { + let duration = new Date(arr[i].end_time).getTime() - new Date(arr[i].start_time).getTime(); + let min = Math.floor(duration / MIN); + let sec = Math.floor((duration % MIN) / SEC); + arr[i]['duration'] = ""; + if ((min || sec) && duration > 0) { + if (min) { + arr[i]['duration'] += '' + min + MIN_STR; + } + if (sec) { + arr[i]['duration'] += '' + sec + SEC_STR; + } + } else { + arr[i]['duration'] = "0"; } - if (sec) { - arr[i]['duration'] += '' + sec + SEC_STR; - } - } else if ( min === 0 && sec === 0 && duration > 0) { - arr[i]['duration'] = "0"; } else { arr[i]['duration'] = "N/A"; } @@ -353,6 +355,9 @@ export class TagRetentionComponent implements OnInit { this.addRuleComponent.close(); this.addRuleComponent.onGoing = false; }, error => { + if (error && error.error && error.error.message) { + error = this.tagRetentionService.getI18nKey(error.error.message); + } this.addRuleComponent.inlineAlert.showInlineError(error); this.loadingRule = false; this.addRuleComponent.onGoing = false; @@ -366,7 +371,10 @@ export class TagRetentionComponent implements OnInit { }, error => { this.loadingRule = false; this.addRuleComponent.onGoing = false; - this.addRuleComponent.inlineAlert.showInlineError(error); + if (error && error.error && error.error.message) { + error = this.tagRetentionService.getI18nKey(error.error.message); + } + this.addRuleComponent.inlineAlert.showInlineError(error); }); } } else { @@ -378,6 +386,9 @@ export class TagRetentionComponent implements OnInit { this.addRuleComponent.close(); this.addRuleComponent.onGoing = false; }, error => { + if (error && error.error && error.error.message) { + error = this.tagRetentionService.getI18nKey(error.error.message); + } this.addRuleComponent.inlineAlert.showInlineError(error); this.loadingRule = false; this.addRuleComponent.onGoing = false; diff --git a/src/portal/src/app/project/tag-retention/tag-retention.service.ts b/src/portal/src/app/project/tag-retention/tag-retention.service.ts index 76940c324..424eab091 100644 --- a/src/portal/src/app/project/tag-retention/tag-retention.service.ts +++ b/src/portal/src/app/project/tag-retention/tag-retention.service.ts @@ -45,7 +45,11 @@ export class TagRetentionService { "COUNT": "UNIT_COUNT", "DAYS": "UNIT_DAY", "none": "NONE", - "nothing": "NONE" + "nothing": "NONE", + "Parameters nDaysSinceLastPull is too large": "DAYS_LARGE", + "Parameters nDaysSinceLastPush is too large": "DAYS_LARGE", + "Parameters latestPushedK is too large": "COUNT_LARGE", + "Parameters latestPulledN is too large": "COUNT_LARGE" }; constructor( diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index 7c7b0d4f0..a7ebff8d6 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -1210,10 +1210,13 @@ "RULE_TEMPLATE_6": " the images pulled within the last # days", "RULE_TEMPLATE_7": " the images pushed within the last # days", "SCHEDULE": "Schedule", - "SCHEDULE_WARNING": "Executing the retention policy can have adverse effects to the images in this project and affected image tags will be deleted.", + "SCHEDULE_WARNING": "Executing retention policy results in the irreversible effect of deleting images from the Harbor project. Please double check all policies before scheduling.", "EXISTING_RULE": "Existing rule", "ILLEGAL_RULE": "Illegal rule", - "INVALID_RULE": "Invalid rule" + "INVALID_RULE": "Invalid rule", + "COUNT_LARGE": "Parameter \"COUNT\" is too large", + "DAYS_LARGE": "Parameter \"DAYS\" is too large", + "EXECUTION_TYPE": "Execution Type" } } diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index 5cbec84da..4dbe53fe2 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -1207,10 +1207,13 @@ "RULE_TEMPLATE_6": " the images pulled within the last # days", "RULE_TEMPLATE_7": " the images pushed within the last # days", "SCHEDULE": "Schedule", - "SCHEDULE_WARNING": "Executing the retention policy can have adverse effects to the images in this project and affected image tags will be deleted.", + "SCHEDULE_WARNING": "Executing retention policy results in the irreversible effect of deleting images from the Harbor project. Please double check all policies before scheduling.", "EXISTING_RULE": "Existing rule", "ILLEGAL_RULE": "Illegal rule", - "INVALID_RULE": "Invalid rule" + "INVALID_RULE": "Invalid rule", + "COUNT_LARGE": "Parameter \"COUNT\" is too large", + "DAYS_LARGE": "Parameter \"DAYS\" is too large", + "EXECUTION_TYPE": "Execution Type" } } diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index 95b6f1174..2bfa02040 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -1179,10 +1179,13 @@ "RULE_TEMPLATE_6": " the images pulled within the last # days", "RULE_TEMPLATE_7": " the images pushed within the last # days", "SCHEDULE": "Schedule", - "SCHEDULE_WARNING": "Executing the retention policy can have adverse effects to the images in this project and affected image tags will be deleted.", + "SCHEDULE_WARNING": "Executing retention policy results in the irreversible effect of deleting images from the Harbor project. Please double check all policies before scheduling.", "EXISTING_RULE": "Existing rule", "ILLEGAL_RULE": "Illegal rule", - "INVALID_RULE": "Invalid rule" + "INVALID_RULE": "Invalid rule", + "COUNT_LARGE": "Parameter \"COUNT\" is too large", + "DAYS_LARGE": "Parameter \"DAYS\" is too large", + "EXECUTION_TYPE": "Execution Type" } } diff --git a/src/portal/src/i18n/lang/pt-br-lang.json b/src/portal/src/i18n/lang/pt-br-lang.json index b2141062a..eb5e7d447 100644 --- a/src/portal/src/i18n/lang/pt-br-lang.json +++ b/src/portal/src/i18n/lang/pt-br-lang.json @@ -1204,10 +1204,13 @@ "RULE_TEMPLATE_6": " the images pulled within the last # days", "RULE_TEMPLATE_7": " the images pushed within the last # days", "SCHEDULE": "Schedule", - "SCHEDULE_WARNING": "Executing the retention policy can have adverse effects to the images in this project and affected image tags will be deleted.", + "SCHEDULE_WARNING": "Executing retention policy results in the irreversible effect of deleting images from the Harbor project. Please double check all policies before scheduling.", "EXISTING_RULE": "Existing rule", "ILLEGAL_RULE": "Illegal rule", - "INVALID_RULE": "Invalid rule" + "INVALID_RULE": "Invalid rule", + "COUNT_LARGE": "Parameter \"COUNT\" is too large", + "DAYS_LARGE": "Parameter \"DAYS\" is too large", + "EXECUTION_TYPE": "Execution Type" } diff --git a/src/portal/src/i18n/lang/tr-tr-lang.json b/src/portal/src/i18n/lang/tr-tr-lang.json index 2be6d22af..39e518e10 100644 --- a/src/portal/src/i18n/lang/tr-tr-lang.json +++ b/src/portal/src/i18n/lang/tr-tr-lang.json @@ -1210,10 +1210,13 @@ "RULE_TEMPLATE_6": " imajlar son # gün içinde imdirilmiş", "RULE_TEMPLATE_7": " imajlar son # gün içinde yüklendi.", "SCHEDULE": "Program", - "SCHEDULE_WARNING": "Tutma ilkesinin yürütülmesinin bu projedeki görüntüler üzerinde olumsuz etkileri olabilir ve etkilenen imajların etiketleri silinecektir.", + "SCHEDULE_WARNING": "Executing retention policy results in the irreversible effect of deleting images from the Harbor project. Please double check all policies before scheduling.", "EXISTING_RULE": "Existing rule", "ILLEGAL_RULE": "Illegal rule", - "INVALID_RULE": "Invalid rule" + "INVALID_RULE": "Invalid rule", + "COUNT_LARGE": "Parameter \"COUNT\" is too large", + "DAYS_LARGE": "Parameter \"DAYS\" is too large", + "EXECUTION_TYPE": "Execution Type" } } diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index 8ac3c8f77..b0dfec37c 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -1206,10 +1206,13 @@ "RULE_TEMPLATE_6": "最近#天被拉取过的镜像", "RULE_TEMPLATE_7": "最近#天被推送过的镜像", "SCHEDULE": "定时任务", - "SCHEDULE_WARNING": "执行保留策略将对该项目中的镜像产生反向影响,受影响的镜像tags将会被删除。", + "SCHEDULE_WARNING": "执行保留策略会将会删除受影响的镜像,且不可恢复。请在制定定时任务前仔细检查所有保留规则。", "EXISTING_RULE": "规则已存在", "ILLEGAL_RULE": "规则不合法", - "INVALID_RULE": "无效规则" + "INVALID_RULE": "无效规则", + "COUNT_LARGE": "参数“个数”太大", + "DAYS_LARGE": "参数“天数”太大", + "EXECUTION_TYPE": "执行类型" } }