Browse Source

Merge branch 'lts-4.4' into feature/ai-model-chat-by-ai

pull/16379/head
Kostenko Roman 1 month ago
committed by GitHub
parent
commit
b7f7c96969
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      common/data/src/main/java/org/thingsboard/server/common/data/wl/Palette.java
  2. 4
      common/data/src/main/java/org/thingsboard/server/common/data/wl/PaletteSettings.java
  3. 1
      ui-ngx/src/app/modules/home/components/integration/configuration/integration-configuration.component.html
  4. 37
      ui-ngx/src/app/modules/home/components/integration/configuration/kpn-integration-form/kpn-integration-form.component.html
  5. 57
      ui-ngx/src/app/modules/home/components/integration/configuration/kpn-integration-form/kpn-integration-form.component.ts
  6. 11
      ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.html
  7. 17
      ui-ngx/src/app/modules/home/components/integration/configuration/opc-ua-integration-form/opc-ua-subscription.component.ts
  8. 4
      ui-ngx/src/assets/locale/locale.constant-en_US.json
  9. 4
      ui-ngx/src/styles.scss

2
common/data/src/main/java/org/thingsboard/server/common/data/wl/Palette.java

@ -13,7 +13,7 @@ import java.util.Map;
@EqualsAndHashCode
public class Palette {
@Schema(description = "Name of the pre-defined palette, or 'custom'", example = "custom", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "Name of the pre-defined palette, or 'custom'", example = "custom")
private String type;
@JsonProperty("extends")

4
common/data/src/main/java/org/thingsboard/server/common/data/wl/PaletteSettings.java

@ -11,9 +11,9 @@ import org.thingsboard.server.common.data.StringUtils;
@Data
@EqualsAndHashCode
public class PaletteSettings {
@Schema(description = "Primary palette JSON", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "Primary palette JSON")
private Palette primaryPalette;
@Schema(description = "Accent palette JSON", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "Accent palette JSON")
private Palette accentPalette;
public PaletteSettings merge(PaletteSettings otherPaletteSettings) {

1
ui-ngx/src/app/modules/home/components/integration/configuration/integration-configuration.component.html

@ -54,6 +54,7 @@
@case (integrationTypes.KPN) {
<tb-kpn-integration-form formControlName="configuration"
[routingKey]="routingKey"
[isSetDownlink]="isSetDownlink"
[executeRemotelyTemplate]="executeRemotelyTemplate"
[genericAdditionalInfoTemplate]="genericAdditionalInfoTemplate"
[allowLocalNetwork]="allowLocalNetwork">

37
ui-ngx/src/app/modules/home/components/integration/configuration/kpn-integration-form/kpn-integration-form.component.html

@ -35,30 +35,19 @@
</button>
</div>
<mat-expansion-panel class="expansion-panel-setting" [expanded]="kpnIntegrationConfigForm.get('allowDownlink').value">
<mat-expansion-panel-header>
<mat-panel-title class="flex flex-col items-start justify-start gap-2">
<mat-slide-toggle formControlName="allowDownlink" (click)="$event.stopPropagation()">
{{ 'integration.allow-downlink' | translate }}
</mat-slide-toggle>
</mat-panel-title>
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<section class="expansion-panel-setting-content">
<fieldset class="fields-group">
<legend class="group-title" translate>integration.credentials</legend>
<div class="flex flex-col gt-xs:gap-2">
<tb-secret-key-input formControlName="apiId" class="mat-block flex-1" appearance="outline"
label="{{ 'integration.api-id' | translate }}">
</tb-secret-key-input>
<tb-secret-key-input formControlName="apiKey" class="mat-block flex-1" appearance="outline"
label="{{ 'integration.api-key' | translate }}">
</tb-secret-key-input>
</div>
</fieldset>
</section>
</ng-template>
</mat-expansion-panel>
@if (isSetDownlink) {
<fieldset class="fields-group">
<legend class="group-title" translate>integration.downlink-credentials</legend>
<div class="flex flex-col gt-xs:gap-2">
<tb-secret-key-input formControlName="apiId" class="mat-block flex-1" appearance="outline"
label="{{ 'integration.api-id' | translate }}">
</tb-secret-key-input>
<tb-secret-key-input formControlName="apiKey" class="mat-block flex-1" appearance="outline"
label="{{ 'integration.api-key' | translate }}">
</tb-secret-key-input>
</div>
</fieldset>
}
<mat-expansion-panel class="expansion-panel-setting"
[expanded]="kpnIntegrationConfigForm.get('enableSecurity').value">

57
ui-ngx/src/app/modules/home/components/integration/configuration/kpn-integration-form/kpn-integration-form.component.ts

@ -50,10 +50,24 @@ export class KpnIntegrationFormComponent extends IntegrationForm implements Cont
@Input()
routingKey: string;
@Input()
set isSetDownlink(value: boolean) {
if (this.isSetDownlinkValue !== value) {
this.isSetDownlinkValue = value;
this.updateCredentialsValidators();
}
}
get isSetDownlink(): boolean {
return this.isSetDownlinkValue;
}
private integrationType = IntegrationType.KPN;
private isSetDownlinkValue = false;
private propagateChangePending = false;
private propagateChange = (v: any) => { };
private validatorChange = () => { };
constructor(private fb: UntypedFormBuilder,
private store: Store<AppState>,
@ -75,20 +89,14 @@ export class KpnIntegrationFormComponent extends IntegrationForm implements Cont
}],
enableSecurity: [false],
headersFilter: [{}],
allowDownlink: [false],
apiId:[],
apiKey:[]
apiId: [],
apiKey: []
});
this.kpnIntegrationConfigForm.get('baseUrl').valueChanges.pipe(
takeUntil(this.destroy$)
).subscribe((value) => {
const httpEndpoint = integrationEndPointUrl(this.integrationType, value, this.routingKey);
this.kpnIntegrationConfigForm.get('httpEndpoint').patchValue(httpEndpoint);
});
this.kpnIntegrationConfigForm.get('allowDownlink').valueChanges.pipe(
takeUntil(this.destroy$)
).subscribe(() => {
this.updateEnableFields();
});
this.kpnIntegrationConfigForm.valueChanges.pipe(
takeUntil(this.destroy$)
@ -96,14 +104,12 @@ export class KpnIntegrationFormComponent extends IntegrationForm implements Cont
this.updateModels(this.kpnIntegrationConfigForm.getRawValue());
});
this.kpnIntegrationConfigForm.removeControl('replaceNoContentToOk', {emitEvent: false});
this.updateCredentialsValidators();
}
writeValue(value: KpnIntegration) {
if (isDefinedAndNotNull(value)) {
this.kpnIntegrationConfigForm.reset(value, {emitEvent: false});
if (!this.disabled) {
this.updateEnableFields();
}
} else {
this.propagateChangePending = true;
}
@ -121,13 +127,16 @@ export class KpnIntegrationFormComponent extends IntegrationForm implements Cont
registerOnTouched(fn: any) { }
registerOnValidatorChange(fn: () => void) {
this.validatorChange = fn;
}
setDisabledState(isDisabled: boolean) {
this.disabled = isDisabled;
if (isDisabled) {
this.kpnIntegrationConfigForm.disable({emitEvent: false});
} else {
this.kpnIntegrationConfigForm.enable({emitEvent: false});
this.updateEnableFields();
this.kpnIntegrationConfigForm.get('httpEndpoint').disable({emitEvent: false});
}
}
@ -154,22 +163,14 @@ export class KpnIntegrationFormComponent extends IntegrationForm implements Cont
this.propagateChange(value);
}
private updateEnableFields() {
const allowDownlink = this.kpnIntegrationConfigForm.get('allowDownlink').value;
if (allowDownlink) {
this.kpnIntegrationConfigForm.get('apiId').enable({emitEvent: false});
this.kpnIntegrationConfigForm.get('apiKey').enable({emitEvent: false});
this.kpnIntegrationConfigForm.get('apiId').setValidators(Validators.required);
this.kpnIntegrationConfigForm.get('apiKey').setValidators(Validators.required);
} else {
this.kpnIntegrationConfigForm.get('apiId').disable({emitEvent: false});
this.kpnIntegrationConfigForm.get('apiKey').disable({emitEvent: false});
this.kpnIntegrationConfigForm.get('apiId').clearValidators();
this.kpnIntegrationConfigForm.get('apiKey').clearValidators();
private updateCredentialsValidators() {
if (this.kpnIntegrationConfigForm) {
const validators = this.isSetDownlink ? [Validators.required] : [];
this.kpnIntegrationConfigForm.get('apiId').setValidators(validators);
this.kpnIntegrationConfigForm.get('apiKey').setValidators(validators);
this.kpnIntegrationConfigForm.get('apiId').updateValueAndValidity({emitEvent: false});
this.kpnIntegrationConfigForm.get('apiKey').updateValueAndValidity({emitEvent: false});
this.validatorChange();
}
this.kpnIntegrationConfigForm.get('apiId').updateValueAndValidity({emitEvent: false});
this.kpnIntegrationConfigForm.get('apiKey').updateValueAndValidity({emitEvent: false});
this.kpnIntegrationConfigForm.get('destinationSharedSecret').updateValueAndValidity({emitEvent: false});
}
}

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);
}

4
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -5580,6 +5580,7 @@
"credentials": "Credentials",
"credentials-type": "Credentials type",
"credentials-type-required": "Credentials type is required.",
"downlink-credentials": "Downlink credentials",
"username": "Username",
"username-required": "Username is required.",
"password": "Password",
@ -5786,6 +5787,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