Browse Source

Merge branch 'fix/3995-connector-form-update' of github.com:maxunbearable/thingsboard into improvement/gateway-dashboard

pull/11251/head
Vladyslav_Prykhodko 2 years ago
parent
commit
b4a7843779
  1. 11
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.ts
  2. 4
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/security-config/security-config.component.ts
  3. 12
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/server-config/server-config.component.ts
  4. 6
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/workers-config-control/workers-config-control.component.ts
  5. 1
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts

11
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/broker-config-control/broker-config-control.component.ts

@ -14,7 +14,7 @@
/// limitations under the License.
///
import { ChangeDetectionStrategy, Component, forwardRef, OnDestroy } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, forwardRef, OnDestroy } from '@angular/core';
import {
ControlValueAccessor,
FormBuilder,
@ -72,6 +72,7 @@ export class BrokerConfigControlComponent implements ControlValueAccessor, Valid
private destroy$ = new Subject<void>();
constructor(private fb: FormBuilder,
private cdr: ChangeDetectorRef,
private translate: TranslateService) {
this.brokerConfigFormGroup = this.fb.group({
name: ['', []],
@ -119,7 +120,13 @@ export class BrokerConfigControlComponent implements ControlValueAccessor, Valid
}
writeValue(brokerConfig: BrokerConfig): void {
this.brokerConfigFormGroup.patchValue(brokerConfig, {emitEvent: false});
const brokerConfigState = {
...brokerConfig,
version: brokerConfig.version || 5,
clientId: brokerConfig.clientId || 'tb_gw_' + generateSecret(5),
};
this.brokerConfigFormGroup.reset(brokerConfigState, {emitEvent: false});
this.cdr.markForCheck();
}
validate(): ValidationErrors | null {

4
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/security-config/security-config.component.ts

@ -16,6 +16,7 @@
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
forwardRef,
Input,
@ -87,7 +88,7 @@ export class SecurityConfigComponent implements ControlValueAccessor, OnInit, On
private destroy$ = new Subject<void>();
constructor(private fb: FormBuilder) {}
constructor(private fb: FormBuilder, private cdr: ChangeDetectorRef) {}
ngOnInit(): void {
this.securityFormGroup = this.fb.group({
@ -127,6 +128,7 @@ export class SecurityConfigComponent implements ControlValueAccessor, OnInit, On
}
this.securityFormGroup.reset(securityInfo, {emitEvent: false});
}
this.cdr.markForCheck();
}
validate(): ValidationErrors | null {

12
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/server-config/server-config.component.ts

@ -114,6 +114,16 @@ export class ServerConfigComponent implements ControlValueAccessor, Validator, O
}
writeValue(serverConfig: ServerConfig): void {
this.serverConfigFormGroup.patchValue(serverConfig, {emitEvent: false});
const { timeoutInMillis, scanPeriodInMillis, enableSubscriptions, subCheckPeriodInMillis, showMap, security } = serverConfig;
const serverConfigState = {
...serverConfig,
timeoutInMillis: timeoutInMillis || 1000,
scanPeriodInMillis: scanPeriodInMillis || 1000,
enableSubscriptions: enableSubscriptions || true,
subCheckPeriodInMillis: subCheckPeriodInMillis || 10,
showMap: showMap || false,
security: security || SecurityPolicy.BASIC128,
};
this.serverConfigFormGroup.reset(serverConfigState, {emitEvent: false});
}
}

6
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/workers-config-control/workers-config-control.component.ts

@ -95,7 +95,11 @@ export class WorkersConfigControlComponent implements OnDestroy, ControlValueAcc
}
writeValue(workersConfig: WorkersConfig): void {
this.workersConfigFormGroup.patchValue(workersConfig, {emitEvent: false});
const { maxNumberOfWorkers, maxMessageNumberPerWorker } = workersConfig;
this.workersConfigFormGroup.reset({
maxNumberOfWorkers: maxNumberOfWorkers || 100,
maxMessageNumberPerWorker: maxMessageNumberPerWorker || 10,
}, {emitEvent: false});
}
validate(): ValidationErrors | null {

1
ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts

@ -733,6 +733,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
case ConnectorType.MQTT:
case ConnectorType.OPCUA:
this.connectorForm.get('type').patchValue(connector.type, {emitValue: false, onlySelf: true});
this.connectorForm.get('basicConfig').setValue({}, {emitEvent: false});
setTimeout(() => {
this.connectorForm.patchValue({...connector, mode: connector.mode || ConnectorConfigurationModes.BASIC});

Loading…
Cancel
Save