Browse Source

Merge remote-tracking branch 'origin/lts-4.4' into internal-lts-4.4

pull/16844/head
Viacheslav Klimov 3 weeks ago
parent
commit
ce9c2837cb
Failed to extract signature
  1. 24
      ui-ngx/src/app/modules/home/components/converter/converter-test-dialog.component.ts
  2. 4
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/get-value-action-settings-panel.component.html
  3. 4
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/get-value-action-settings-panel.component.ts
  4. 4
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings-panel.component.html
  5. 4
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings-panel.component.ts
  6. 5
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings.component.ts
  7. 1
      ui-ngx/src/app/modules/home/components/widget/widget-container.component.scss
  8. 2
      ui-ngx/src/app/shared/models/converter.models.ts

24
ui-ngx/src/app/modules/home/components/converter/converter-test-dialog.component.ts

@ -153,7 +153,7 @@ export class ConverterTestDialogComponent extends DialogComponent<ConverterTestD
const debugIn = this.data.debugIn;
let contentType: ContentType;
let msgType: string;
let metadata: Record<string, string>;
let metadata: Record<string, unknown>;
let integrationMetadata: Record<string, any>;
if (debugIn) {
if (debugIn.inContentType) {
@ -161,12 +161,7 @@ export class ConverterTestDialogComponent extends DialogComponent<ConverterTestD
}
if (debugIn.inMetadata) {
try {
metadata = JSON.parse(debugIn.inMetadata);
Object.keys(metadata).forEach(function (key) {
if (isObject(metadata[key])) {
metadata[key] = JSON.stringify(metadata[key]);
}
});
metadata = this.stringifyMetadataValues(JSON.parse(debugIn.inMetadata));
} catch (e) { /* empty */ }
}
if (!this.isDecoder) {
@ -437,7 +432,7 @@ export class ConverterTestDialogComponent extends DialogComponent<ConverterTestD
).subscribe((value) => {
this.converterTestFormGroup.patchValue({
payload: value,
metadata: value.metadata
metadata: this.stringifyMetadataValues(value.metadata)
}, {emitEvent: false});
this.currentOriginalMsg.payload = msg.payload;
this.currentOriginalMsg.metadata = msg.metadata;
@ -446,9 +441,20 @@ export class ConverterTestDialogComponent extends DialogComponent<ConverterTestD
}
}
private stringifyMetadataValues(metadata: Record<string, unknown>): Record<string, unknown> {
if (!metadata) {
return metadata;
}
const result: Record<string, unknown> = {};
Object.keys(metadata).forEach((key) => {
result[key] = isObject(metadata[key]) ? JSON.stringify(metadata[key]) : metadata[key];
});
return result;
}
private testConverter(): Observable<TestConverterResult> {
if (this.checkInputParamErrors()) {
const metadata: Record<string, string> = this.converterTestFormGroup.get('metadata').value;
const metadata: Record<string, any> = {...this.converterTestFormGroup.get('metadata').value};
Object.keys(metadata).forEach(function (key) {
try {
metadata[key] = JSON.parse(metadata[key]);

4
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/get-value-action-settings-panel.component.html

@ -207,7 +207,7 @@
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<div class="tb-form-row space-between">
<div>{{ 'widgets.value-action.request-timeout-ms' | translate }}</div>
<div class="tb-required">{{ 'widgets.value-action.request-timeout-ms' | translate }}</div>
<mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
<input matInput formControlName="requestTimeout" type="number" required min="5000" step="1" placeholder="{{ 'widget-config.set' | translate }}">
@if (getValueSettingsFormGroup.get('executeRpc').get('requestTimeout').touched &&
@ -236,7 +236,7 @@
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<div class="tb-form-row space-between">
<div tb-hint-tooltip-icon="{{'widgets.value-action.persistent-polling-interval-hint' | translate}}">{{ 'widgets.value-action.persistent-polling-interval' | translate }}</div>
<div class="tb-required" tb-hint-tooltip-icon="{{'widgets.value-action.persistent-polling-interval-hint' | translate}}">{{ 'widgets.value-action.persistent-polling-interval' | translate }}</div>
<mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
<input matInput formControlName="persistentPollingInterval" type="number" required min="1000" placeholder="{{ 'widget-config.set' | translate }}">
@if (getValueSettingsFormGroup.get('executeRpc').get('persistentPollingInterval').touched &&

4
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/get-value-action-settings-panel.component.ts

@ -110,10 +110,10 @@ export class GetValueActionSettingsPanelComponent extends PageComponent implemen
defaultValue: [this.getValueSettings?.defaultValue, [Validators.required]],
executeRpc: this.fb.group({
method: [this.getValueSettings?.executeRpc?.method, [Validators.required]],
requestTimeout: [this.getValueSettings?.executeRpc?.requestTimeout, [Validators.required, Validators.min(5000)]],
requestTimeout: [this.getValueSettings?.executeRpc?.requestTimeout ?? 5000, [Validators.required, Validators.min(5000)]],
requestPersistent: [this.getValueSettings?.executeRpc?.requestPersistent, []],
persistentPollingInterval:
[this.getValueSettings?.executeRpc?.persistentPollingInterval, [Validators.required, Validators.min(1000)]],
[this.getValueSettings?.executeRpc?.persistentPollingInterval ?? 1000, [Validators.required, Validators.min(1000)]],
params: this.fb.group({
type: [this.getValueSettings?.executeRpc?.params?.type ?? RpcParamsType.NONE, [Validators.required]],
constantValue: [this.getValueSettings?.executeRpc?.params?.constantValue, [Validators.required]],

4
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings-panel.component.html

@ -139,7 +139,7 @@
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<div class="tb-form-row space-between">
<div>{{ 'widgets.value-action.request-timeout-ms' | translate }}</div>
<div class="tb-required">{{ 'widgets.value-action.request-timeout-ms' | translate }}</div>
<mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
<input matInput formControlName="requestTimeout" type="number" required min="5000" step="1" placeholder="{{ 'widget-config.set' | translate }}">
@if (setValueSettingsFormGroup.get('executeRpc').get('requestTimeout').touched &&
@ -168,7 +168,7 @@
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<div class="tb-form-row space-between">
<div tb-hint-tooltip-icon="{{'widgets.value-action.persistent-polling-interval-hint' | translate}}">{{ 'widgets.value-action.persistent-polling-interval' | translate }}</div>
<div class="tb-required" tb-hint-tooltip-icon="{{'widgets.value-action.persistent-polling-interval-hint' | translate}}">{{ 'widgets.value-action.persistent-polling-interval' | translate }}</div>
<mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
<input matInput formControlName="persistentPollingInterval" type="number" required min="1000" placeholder="{{ 'widget-config.set' | translate }}">
@if (setValueSettingsFormGroup.get('executeRpc').get('persistentPollingInterval').touched &&

4
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings-panel.component.ts

@ -89,10 +89,10 @@ export class SetValueActionSettingsPanelComponent extends PageComponent implemen
action: [this.setValueSettings?.action, []],
executeRpc: this.fb.group({
method: [this.setValueSettings?.executeRpc?.method, [Validators.required]],
requestTimeout: [this.setValueSettings?.executeRpc?.requestTimeout, [Validators.required, Validators.min(5000)]],
requestTimeout: [this.setValueSettings?.executeRpc?.requestTimeout ?? 5000, [Validators.required, Validators.min(5000)]],
requestPersistent: [this.setValueSettings?.executeRpc?.requestPersistent, []],
persistentPollingInterval:
[this.setValueSettings?.executeRpc?.persistentPollingInterval, [Validators.required, Validators.min(1000)]]
[this.setValueSettings?.executeRpc?.persistentPollingInterval ?? 1000, [Validators.required, Validators.min(1000)]]
}),
setAttribute: this.fb.group({
scope: [this.setValueSettings?.setAttribute?.scope, []],

5
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/set-value-action-settings.component.ts

@ -18,7 +18,7 @@ import { SetValueAction, SetValueSettings, ValueToDataType } from '@shared/model
import { TranslateService } from '@ngx-translate/core';
import { IAliasController } from '@core/api/widget-api.models';
import { TargetDevice, widgetType } from '@shared/models/widget.models';
import { isDefinedAndNotNull } from '@core/utils';
import { isDefinedAndNotNull, isObject } from '@core/utils';
import {
SetValueActionSettingsPanelComponent
} from '@home/components/widget/lib/settings/common/action/set-value-action-settings-panel.component';
@ -136,6 +136,9 @@ export class SetValueActionSettingsComponent implements OnInit, ControlValueAcce
break;
case ValueToDataType.CONSTANT:
value = this.modelValue.valueToData.constantValue;
if (isObject(value)) {
value = JSON.stringify(value);
}
break;
case ValueToDataType.FUNCTION:
value = 'f(value)';

1
ui-ngx/src/app/modules/home/components/widget/widget-container.component.scss

@ -27,6 +27,7 @@
div.tb-widget {
display: flex;
flex-direction: column;
isolation: isolate;
.tb-widget-header {
display: flex;
flex-direction: row;

2
ui-ngx/src/app/shared/models/converter.models.ts

@ -140,7 +140,7 @@ export interface ConvertedInputMsgParams {
export interface ConvertedInputMsgResult {
payload: any;
metadata: {[key: string]: string};
metadata: Record<string, unknown>;
contentType: ContentType;
stringContent?: string;
}

Loading…
Cancel
Save