Improve cron validator for replication rule (#17069)

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
Shijun Sun 2022-06-28 14:41:55 +08:00 committed by GitHub
parent acb0c09bd6
commit 25d3583d36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 39 additions and 25 deletions

View File

@ -654,13 +654,15 @@
name="targetCron"
id="targetCron"
required
pattern="^0\s(?!(\*\s)).+$"
class="form-control cron-input clr-input"
formControlName="cron" />
</div>
<clr-control-error
*ngIf="cronInputShouldShowError()">
{{
'TOOLTIP.CRON_REQUIRED' | translate
'REPLICATION.CRON_ERROR_TIP'
| translate
}}
</clr-control-error>
</div>

View File

@ -710,22 +710,26 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
return filtersArray;
}
cronInputShouldShowError(): boolean {
return (
this.ruleForm &&
this.ruleForm.get('trigger') &&
this.ruleForm.get('trigger').get('trigger_settings') &&
this.ruleForm.get('trigger').get('trigger_settings').get('cron') &&
(this.ruleForm.get('trigger').get('trigger_settings').get('cron')
.touched ||
this.ruleForm.get('trigger').get('trigger_settings').get('cron')
.dirty) &&
this.ruleForm.get('trigger').get('trigger_settings').get('cron')
.value &&
!cronRegex(
this.ruleForm.get('trigger').get('trigger_settings').get('cron')
.value
)
);
if (
this.ruleForm?.get('trigger')?.get('trigger_settings')?.get('cron')
?.touched ||
this.ruleForm?.get('trigger')?.get('trigger_settings')?.get('cron')
?.dirty
) {
return (
this.ruleForm
?.get('trigger')
?.get('trigger_settings')
?.get('cron')?.invalid ||
!cronRegex(
this.ruleForm
.get('trigger')
.get('trigger_settings')
.get('cron').value
)
);
}
return false;
}
stickLabel(value, index) {
value.select = !value.select;

View File

@ -658,7 +658,8 @@
"BANDWIDTH_ERROR_TIP": "Bitte -1 oder einen Integer-Wert größer als 0 eingeben",
"BANDWIDTH_TOOLTIP": "Legt die maximale Netzwerkbandbreite für jede Ausführung fest. Bitte auf die Anzahl der parallelen Ausführungen achten. Für umbegrenzte Bandbreite, bitte -1 eingeben",
"UNLIMITED": "Unbegrenzt",
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}"
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}",
"CRON_ERROR_TIP": "Field is required and \"*\" is not allowed for the \"Minutes\" field"
},
"DESTINATION": {
"NEW_ENDPOINT": "Neuer Endpunkt",

View File

@ -658,7 +658,8 @@
"BANDWIDTH_ERROR_TIP": "Please enter -1 or an integer greater than 0",
"BANDWIDTH_TOOLTIP": "Set the maximum network bandwidth for each execution. Please pay attention to the number of concurrent executions. For unlimited bandwidth, please enter -1",
"UNLIMITED": "Unlimited",
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}"
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}",
"CRON_ERROR_TIP": "Field is required and \"*\" is not allowed for the \"Minutes\" field"
},
"DESTINATION": {
"NEW_ENDPOINT": "New Endpoint",

View File

@ -660,7 +660,8 @@
"BANDWIDTH_ERROR_TIP": "Please enter -1 or an integer greater than 0",
"BANDWIDTH_TOOLTIP": "Set the maximum network bandwidth for each execution. Please pay attention to the number of concurrent executions. For unlimited bandwidth, please enter -1",
"UNLIMITED": "Unlimited",
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}"
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}",
"CRON_ERROR_TIP": "Field is required and \"*\" is not allowed for the \"Minutes\" field"
},
"DESTINATION": {
"NEW_ENDPOINT": "Nuevo Endpoint",

View File

@ -648,7 +648,8 @@
"BANDWIDTH_ERROR_TIP": "Veuillez saisir -1 ou un nombre entier supérieur à 0",
"BANDWIDTH_TOOLTIP": "Définissez la bande passante réseau maximale pour chaque exécution. Veuillez faire attention au nombre d'exécutions simultanées. Pour une bande passante illimitée, veuillez entrer -1",
"UNLIMITED": "Illimitée",
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}"
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}",
"CRON_ERROR_TIP": "Field is required and \"*\" is not allowed for the \"Minutes\" field"
},
"DESTINATION": {
"NEW_ENDPOINT": "Nouveau Endpoint",

View File

@ -658,7 +658,8 @@
"BANDWIDTH_ERROR_TIP": "Informe um número inteiro maior que 0 (zero) ou -1",
"BANDWIDTH_TOOLTIP": "Informe o limite de banda para cada execução. Tome cuidado e observe a relação com o número de execuções simultâneas. Para remover qualquer limite, informe -1",
"UNLIMITED": "Ilimitado",
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}"
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}",
"CRON_ERROR_TIP": "Field is required and \"*\"is not allowed for the \"Minutes\" field"
},
"DESTINATION": {
"NEW_ENDPOINT": "Novo Endereço",

View File

@ -658,7 +658,8 @@
"BANDWIDTH_ERROR_TIP": "Please enter -1 or an integer greater than 0",
"BANDWIDTH_TOOLTIP": "Set the maximum network bandwidth for each execution. Please pay attention to the number of concurrent executions. For unlimited bandwidth, please enter -1",
"UNLIMITED": "Unlimited",
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}"
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}",
"CRON_ERROR_TIP": "Field is required and \"*\" is not allowed for the \"Minutes\" field"
},
"DESTINATION": {
"NEW_ENDPOINT": "Yeni Uç Nokta",

View File

@ -660,7 +660,8 @@
"BANDWIDTH_ERROR_TIP": "请输入-1或者大于0的整数",
"BANDWIDTH_TOOLTIP": "设置执行该条同步规则时的最大网络带宽。实际总带宽需要考虑并发执行的情况。如无需限制,请输入-1",
"UNLIMITED": "无限制",
"UNREACHABLE_SOURCE_REGISTRY": "连接源仓库失败,在编辑此规则前请先确保源仓库可用: {{error}}"
"UNREACHABLE_SOURCE_REGISTRY": "连接源仓库失败,在编辑此规则前请先确保源仓库可用: {{error}}",
"CRON_ERROR_TIP": "此项必填且\"分钟\"项不能为\"*\""
},
"DESTINATION": {
"NEW_ENDPOINT": "新建目标",

View File

@ -655,7 +655,8 @@
"BANDWIDTH_ERROR_TIP": "Please enter -1 or an integer greater than 0",
"BANDWIDTH_TOOLTIP": "Set the maximum network bandwidth for each execution. Please pay attention to the number of concurrent executions. For unlimited bandwidth, please enter -1",
"UNLIMITED": "Unlimited",
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}"
"UNREACHABLE_SOURCE_REGISTRY": "Failed to connect to the source registry, please make sure the source registry is available before editing this rule: {{error}}",
"CRON_ERROR_TIP": "Field is required and \"*\" is not allowed for the \"Minutes\" field"
},
"DESTINATION":{
"NEW_ENDPOINT": "新建目標",