diff --git a/src/portal/lib/src/cron-schedule/cron-schedule.component.html b/src/portal/lib/src/cron-schedule/cron-schedule.component.html index 315560e47..5c19753d9 100644 --- a/src/portal/lib/src/cron-schedule/cron-schedule.component.html +++ b/src/portal/lib/src/cron-schedule/cron-schedule.component.html @@ -17,7 +17,7 @@ {{ "SCHEDULE.CRON" | translate }} : {{ oriCron }} - diff --git a/src/portal/lib/src/cron-schedule/cron-schedule.component.ts b/src/portal/lib/src/cron-schedule/cron-schedule.component.ts index ba9abae5b..bf1e764ad 100644 --- a/src/portal/lib/src/cron-schedule/cron-schedule.component.ts +++ b/src/portal/lib/src/cron-schedule/cron-schedule.component.ts @@ -27,6 +27,7 @@ export class CronScheduleComponent implements OnChanges { @Input() originCron: OriginCron; @Input() labelEdit: string; @Input() labelCurrent: string; + @Input() disabled: boolean; dateInvalid: boolean; originScheduleType: string; oriCron: string; 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 c08c71e11..271c8c1d0 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 @@ -68,7 +68,13 @@ export class AddRuleComponent implements OnInit, OnDestroy { } set num(num) { - this.rule.params[this.template] = parseInt(num, 10); + if (num) { + num = num.trim(); + } + if (parseInt(num, 10) > 0) { + num = parseInt(num, 10); + } + this.rule.params[this.template] = num; } get repoSelect() { @@ -128,8 +134,8 @@ export class AddRuleComponent implements OnInit, OnDestroy { } canNotAdd(): boolean { - if (!this.isAdd) { - return compareValue(this.editRuleOrigin, this.rule); + if (!this.isAdd && compareValue(this.editRuleOrigin, this.rule)) { + return true; } if (!this.hasParam()) { return !(this.rule.template @@ -138,6 +144,7 @@ export class AddRuleComponent implements OnInit, OnDestroy { } else { return !(this.rule.template && this.rule.params[this.template] + && parseInt(this.rule.params[this.template], 10) >= 0 && this.rule.scope_selectors.repository[0].pattern && this.rule.tag_selectors[0].pattern); } diff --git a/src/portal/src/app/project/tag-retention/retention.ts b/src/portal/src/app/project/tag-retention/retention.ts index b2427751e..749c59f00 100644 --- a/src/portal/src/app/project/tag-retention/retention.ts +++ b/src/portal/src/app/project/tag-retention/retention.ts @@ -16,6 +16,7 @@ export class Retention { rules: Array; trigger: { kind: string; + references: object; settings: { cron: string; } @@ -31,8 +32,9 @@ export class Retention { this.algorithm = "or"; this.trigger = { kind: "Schedule", + references: {}, settings: { - cron: "0 0 0 * * *", + cron: "", } }; } 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 580b6a074..8c3f4e510 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 @@ -64,11 +64,11 @@
- +
-
+
@@ -174,7 +184,7 @@
+ [clrModalStaticBackdrop]="true" [clrModalClosable]="true"> + + + + +
\ No newline at end of file diff --git a/src/portal/src/app/project/tag-retention/tag-retention.component.scss b/src/portal/src/app/project/tag-retention/tag-retention.component.scss index abab3d670..1a0a4ce41 100644 --- a/src/portal/src/app/project/tag-retention/tag-retention.component.scss +++ b/src/portal/src/app/project/tag-retention/tag-retention.component.scss @@ -57,4 +57,7 @@ } .font-size-54 { font-size: .541667rem; +} +.padding-left-4 { + padding-left: 4px; } \ 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 f5fa9a10f..a39ec13c6 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 @@ -58,6 +58,8 @@ export class TagRetentionComponent implements OnInit { projectId: number; isRetentionRunOpened: boolean = false; isAbortedOpened: boolean = false; + isConfirmOpened: boolean = false; + cron: string; selectedItem: any = null; ruleIndex: number = -1; index: number = -1; @@ -84,8 +86,8 @@ export class TagRetentionComponent implements OnInit { } originCron(): OriginCron { let originCron: OriginCron = { - type: SCHEDULE_TYPE.DAILY, - cron: "0 0 0 * * *" + type: SCHEDULE_TYPE.NONE, + cron: "" }; originCron.cron = this.retention.trigger.settings.cron; if (originCron.cron === "") { @@ -118,6 +120,18 @@ export class TagRetentionComponent implements OnInit { this.getRetention(); this.getMetadata(); } + openConfirm(cron: string) { + if (cron) { + this.isConfirmOpened = true; + this.cron = cron; + } else { + this.updateCron(cron); + } + } + closeConfirm() { + this.isConfirmOpened = false; + this.updateCron(this.cron); + } updateCron(cron: string) { let retention: Retention = clone(this.retention); retention.trigger.settings.cron = cron; @@ -133,7 +147,7 @@ export class TagRetentionComponent implements OnInit { this.tagRetentionService.updateRetention(this.retentionId, retention).subscribe( response => { this.cronScheduleComponent.isEditMode = false; - this.retention = retention; + this.getRetention(); }, error => { this.errorHandler.error(error); }); @@ -169,15 +183,14 @@ export class TagRetentionComponent implements OnInit { this.addRuleComponent.isAdd = false; this.ruleIndex = -1; } - toggleDisable(index, isActionDisable) { + toggleDisable(index, isActionDisable) { let retention: Retention = clone(this.retention); retention.rules[index].disabled = isActionDisable; this.ruleIndex = -1; this.loadingRule = true; this.tagRetentionService.updateRetention(this.retentionId, retention).subscribe( response => { - this.loadingRule = false; - this.retention = retention; + this.getRetention(); }, error => { this.loadingRule = false; this.errorHandler.error(error); @@ -186,12 +199,15 @@ export class TagRetentionComponent implements OnInit { deleteRule(index) { let retention: Retention = clone(this.retention); retention.rules.splice(index, 1); + // if rules is empty, clear schedule. + if (retention.rules && retention.rules.length === 0) { + retention.trigger.settings.cron = ""; + } this.ruleIndex = -1; this.loadingRule = true; this.tagRetentionService.updateRetention(this.retentionId, retention).subscribe( response => { - this.loadingRule = false; - this.retention = retention; + this.getRetention(); }, error => { this.loadingRule = false; this.errorHandler.error(error); @@ -340,8 +356,7 @@ export class TagRetentionComponent implements OnInit { } else { this.tagRetentionService.updateRetention(this.retentionId, retention).subscribe( response => { - this.loadingRule = false; - this.retention = retention; + this.getRetention(); }, error => { this.loadingRule = false; this.errorHandler.error(error); @@ -352,8 +367,7 @@ export class TagRetentionComponent implements OnInit { retention.rules[this.editIndex] = rule; this.tagRetentionService.updateRetention(this.retentionId, retention).subscribe( response => { - this.retention = retention; - this.loadingRule = false; + this.getRetention(); }, error => { this.errorHandler.error(error); this.loadingRule = 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 0792fb622..76940c324 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 @@ -28,8 +28,8 @@ export class TagRetentionService { "latestPushedK": "RULE_NAME_3", "latestPulledN": "RULE_NAME_4", "always": "RULE_NAME_5", - "dayspl": "RULE_NAME_6", - "daysps": "RULE_NAME_7", + "nDaysSinceLastPull": "RULE_NAME_6", + "nDaysSinceLastPush": "RULE_NAME_7", "the images from the last # days": "RULE_TEMPLATE_1", "the most recent active # images": "RULE_TEMPLATE_2", "the most recently pushed # images": "RULE_TEMPLATE_3", diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index ae060f0f8..82eb7df78 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -1206,7 +1206,9 @@ "RULE_NAME_6": " the images pulled within the last {{number}} days", "RULE_NAME_7": " the images pushed within the last {{number}} days", "RULE_TEMPLATE_6": " the images pulled within the last # days", - "RULE_TEMPLATE_7": " the images pushed 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." } } diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index df102d442..2c9c5e02e 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -1203,7 +1203,9 @@ "RULE_NAME_6": " the images pulled within the last {{number}} days", "RULE_NAME_7": " the images pushed within the last {{number}} days", "RULE_TEMPLATE_6": " the images pulled within the last # days", - "RULE_TEMPLATE_7": " the images pushed 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." } } diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index ae3d5faa3..bd948d912 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -1175,7 +1175,9 @@ "RULE_NAME_6": " the images pulled within the last {{number}} days", "RULE_NAME_7": " the images pushed within the last {{number}} days", "RULE_TEMPLATE_6": " the images pulled within the last # days", - "RULE_TEMPLATE_7": " the images pushed 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." } } diff --git a/src/portal/src/i18n/lang/pt-br-lang.json b/src/portal/src/i18n/lang/pt-br-lang.json index 13e36487d..3ecec7b91 100644 --- a/src/portal/src/i18n/lang/pt-br-lang.json +++ b/src/portal/src/i18n/lang/pt-br-lang.json @@ -1200,7 +1200,9 @@ "RULE_NAME_6": " the images pulled within the last {{number}} days", "RULE_NAME_7": " the images pushed within the last {{number}} days", "RULE_TEMPLATE_6": " the images pulled within the last # days", - "RULE_TEMPLATE_7": " the images pushed 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." } diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index 2f4606fe9..313b23703 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -1202,7 +1202,9 @@ "RULE_NAME_6": "最近{{number}}天被拉取过的镜像", "RULE_NAME_7": "最近{{number}}天被推送过的镜像", "RULE_TEMPLATE_6": "最近#天被拉取过的镜像", - "RULE_TEMPLATE_7": "最近#天被推送过的镜像" + "RULE_TEMPLATE_7": "最近#天被推送过的镜像", + "SCHEDULE": "定时任务", + "SCHEDULE_WARNING": "执行保留策略将对该项目中的镜像产生反向影响,受影响的镜像tags将会被删除。" } }