From f1804f2fb27e58e13181471397618ec9a07eb174 Mon Sep 17 00:00:00 2001 From: Maksym Dudnik Date: Wed, 11 Oct 2023 13:02:51 +0300 Subject: [PATCH 1/2] command whitespaces hotfix --- .../widget/lib/gateway/gateway-configuration.component.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.ts index c4e1257e64..ef4e946579 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.ts @@ -409,9 +409,14 @@ export class GatewayConfigurationComponent implements OnInit { const commandsFormArray = this.commandFormArray(); const commandFormGroup = this.fb.group({ attributeOnGateway: [command.attributeOnGateway || null, [Validators.required, Validators.pattern(/^[^.\s]+$/)]], - command: [command.command || null, [Validators.required, Validators.pattern(/^[^.\s]+$/)]], + command: [command.command || null, [Validators.required]], timeout: [command.timeout || null, [Validators.required, Validators.min(1), Validators.pattern(/^-?[0-9]+$/), Validators.pattern(/^[^.\s]+$/)]], }); + commandFormGroup.get('command').valueChanges.subscribe(value=>{ + if (value && !(value as String).trim().length) { + commandFormGroup.get('command').setValue("", {emitEvent: false}); + } + }) commandsFormArray.push(commandFormGroup); } From bc20ba7c83da88dadafac0c80439fe34bf42aa9b Mon Sep 17 00:00:00 2001 From: Maksym Dudnik Date: Wed, 11 Oct 2023 16:42:45 +0300 Subject: [PATCH 2/2] command whitespaces hotfix regex solution --- .../lib/gateway/gateway-configuration.component.html | 3 +++ .../widget/lib/gateway/gateway-configuration.component.ts | 7 +------ ui-ngx/src/assets/locale/locale.constant-en_US.json | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.html index b5b995e4d8..7ddf0c8cd9 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.html @@ -586,6 +586,9 @@ {{ 'gateway.statistics.command-required' | translate }} + + {{ 'gateway.statistics.command-pattern' | translate }} + info_outlined diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.ts index ef4e946579..1df76f2716 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-configuration.component.ts @@ -409,14 +409,9 @@ export class GatewayConfigurationComponent implements OnInit { const commandsFormArray = this.commandFormArray(); const commandFormGroup = this.fb.group({ attributeOnGateway: [command.attributeOnGateway || null, [Validators.required, Validators.pattern(/^[^.\s]+$/)]], - command: [command.command || null, [Validators.required]], + command: [command.command || null, [Validators.required, Validators.pattern(/^(?=\S).*\S$/)]], timeout: [command.timeout || null, [Validators.required, Validators.min(1), Validators.pattern(/^-?[0-9]+$/), Validators.pattern(/^[^.\s]+$/)]], }); - commandFormGroup.get('command').valueChanges.subscribe(value=>{ - if (value && !(value as String).trim().length) { - commandFormGroup.get('command').setValue("", {emitEvent: false}); - } - }) commandsFormArray.push(commandFormGroup); } diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 876fb19afb..47528369bb 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -2783,6 +2783,7 @@ "attribute-name-required": "Attribute name is required", "command": "Command", "command-required": "Command is required", + "command-pattern": "Command is not valid", "remove": "Remove command" }, "storage": "Storage",