diff --git a/ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.html b/ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.html index a6c3ef4d83..106be2e479 100644 --- a/ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.html +++ b/ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.html @@ -7,6 +7,7 @@
integration.subscription-tags +
integration.opc-ua-path-hint
@for (subscriptionTag of opcSubscriptionArrayControls; track subscriptionTag; let i = $index) {
integration.path + @let warning = pathWarning(subscriptionTag.get('path').value); + @if (warning) { + + warning + + } {{ 'integration.required' | translate }} diff --git a/ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.ts b/ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.ts index ef97b4cc26..2cd8b0b383 100644 --- a/ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.ts +++ b/ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.ts @@ -16,6 +16,7 @@ import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { isDefinedAndNotNull } from '@core/utils'; import { OpcUaSubscription } from '@shared/models/integration.models'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'tb-opc-ua-subscription', @@ -43,7 +44,8 @@ export class OpcUaSubscriptionComponent implements ControlValueAccessor, Validat private destroy$ = new Subject(); private propagateChange = (v: any) => { }; - constructor(private fb: UntypedFormBuilder) { + constructor(private fb: UntypedFormBuilder, + private translate: TranslateService) { this.opcSubscriptionForm = this.fb.group({ subscription: this.fb.array([], Validators.required) }); @@ -121,6 +123,19 @@ export class OpcUaSubscriptionComponent implements ControlValueAccessor, Validat ); } + pathWarning(path: string): string { + const warnings: string[] = []; + if (path?.length) { + if (/^\s|\s$/.test(path)) { + warnings.push(this.translate.instant('integration.opc-ua-path-whitespace-warning')); + } + if (path.endsWith('.')) { + warnings.push(this.translate.instant('integration.opc-ua-path-trailing-dot-warning')); + } + } + return warnings.join(' '); + } + removeSubscriptionTag(index: number) { this.opcSubscriptionArray.removeAt(index); } 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 0a52b2ebf5..a000ee8696 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -5784,6 +5784,9 @@ "add-subscription-tag-prompt": "Please add subscription tag", "key": "Key", "path": "Path", + "opc-ua-path-hint": "Path must match a node under the device node: its BrowseName without the namespace prefix (e.g. MySwitch, not 2:MySwitch), or, if the node's string NodeId contains the device name, the part of the NodeId after the device name and separator (e.g. for NodeId ns=2;s=Device1.MySwitch, Path is MySwitch).", + "opc-ua-path-whitespace-warning": "Path starts or ends with a space. It will match only if the node name has the same spaces.", + "opc-ua-path-trailing-dot-warning": "Path ends with a dot. It will match only if the node name ends with a dot.", "required": "Required", "integration-key": "Integration key", "copy-integration-key": "Copy integration key", diff --git a/ui-ngx/src/styles.scss b/ui-ngx/src/styles.scss index 7c3f8526c0..7df150e010 100644 --- a/ui-ngx/src/styles.scss +++ b/ui-ngx/src/styles.scss @@ -542,6 +542,10 @@ pre.tb-highlight { &.tb-error { color: rgb(221, 44, 0); } + &.tb-warning { + color: rgb(199, 106, 0); + pointer-events: auto; + } } .mat-mdc-tooltip {