Browse Source

Added Path format hint and whitespace/trailing-dot warnings for subscription tags (#16477)

* Added Path format hint and whitespace/trailing-dot warnings for subscription tags

* PR comments fixes
pull/16508/head
Maksym Tsymbarov 1 month ago
committed by GitHub
parent
commit
47b56e7f59
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 11
      ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.html
  2. 17
      ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.ts
  3. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  4. 4
      ui-ngx/src/styles.scss

11
ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.html

@ -7,6 +7,7 @@
<section [formGroup]="opcSubscriptionForm">
<fieldset class="fields-group">
<legend class="group-title" translate>integration.subscription-tags</legend>
<div class="tb-hint !p-0 mb-2" translate>integration.opc-ua-path-hint</div>
<div class="flex flex-col gap-2">
@for (subscriptionTag of opcSubscriptionArrayControls; track subscriptionTag; let i = $index) {
<div class="flex flex-1 flex-row items-center justify-start gap-2"
@ -18,6 +19,16 @@
<mat-form-field appearance="outline" class="mat-block flex-1" subscriptSizing="dynamic">
<mat-label translate>integration.path</mat-label>
<input matInput required formControlName="path">
@let warning = pathWarning(subscriptionTag.get('path').value);
@if (warning) {
<mat-icon matSuffix
matTooltipPosition="above"
matTooltipClass="tb-warning-tooltip"
[matTooltip]="warning"
class="tb-warning">
warning
</mat-icon>
}
</mat-form-field>
<mat-checkbox [aria-label]="'integration.required' | translate" formControlName="required">
{{ 'integration.required' | translate }}

17
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<void>();
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);
}

3
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",

4
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 {

Loading…
Cancel
Save