-
gateway.server-slave-config
@@ -178,6 +168,13 @@
+
+
+
+ {{ 'gateway.send-data-TB' | translate }}
+
+
+
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.scss b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.scss
deleted file mode 100644
index a464832202..0000000000
--- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.scss
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright © 2016-2024 The Thingsboard Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-$server-config-header-height: 132px;
-
-:host {
- .slave-content {
- height: calc(100% - #{$server-config-header-height});
- overflow: auto;
- }
-
- .slave-container {
- display: inherit;
- }
-}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts
index 2a8488a2d4..46771c6937 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts
@@ -43,7 +43,7 @@ import {
import { SharedModule } from '@shared/shared.module';
import { CommonModule } from '@angular/common';
import { Subject } from 'rxjs';
-import { startWith, takeUntil } from 'rxjs/operators';
+import { takeUntil } from 'rxjs/operators';
import { GatewayPortTooltipPipe } from '@home/components/widget/lib/gateway/pipes/gateway-port-tooltip.pipe';
import { ModbusSecurityConfigComponent } from '../modbus-security-config/modbus-security-config.component';
import { ModbusValuesComponent, } from '../modbus-values/modbus-values.component';
@@ -73,7 +73,6 @@ import { isEqual } from '@core/utils';
ModbusSecurityConfigComponent,
GatewayPortTooltipPipe,
],
- styleUrls: ['./modbus-slave-config.component.scss'],
})
export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validator, OnDestroy {
@@ -90,6 +89,7 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
readonly ModbusProtocolType = ModbusProtocolType;
readonly modbusBaudrates = ModbusBaudrates;
+ private isSlaveEnabled = false;
private readonly serialSpecificControlKeys = ['serialPort', 'baudrate'];
private readonly tcpUdpSpecificControlKeys = ['port', 'security', 'host'];
@@ -126,14 +126,9 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
this.observeValueChanges();
this.observeTypeChange();
- this.observeFormEnable();
this.observeShowSecurity();
}
- get isSlaveEnabled(): boolean {
- return this.slaveConfigFormGroup.get('sendDataToThingsBoard').value;
- }
-
get protocolType(): ModbusProtocolType {
return this.slaveConfigFormGroup.get('type').value;
}
@@ -160,7 +155,11 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
writeValue(slaveConfig: ModbusSlave): void {
this.showSecurityControl.patchValue(!!slaveConfig.security && !isEqual(slaveConfig.security, {}));
this.updateSlaveConfig(slaveConfig);
- this.updateFormEnableState(slaveConfig.sendDataToThingsBoard);
+ }
+
+ setDisabledState(isDisabled: boolean): void {
+ this.isSlaveEnabled = !isDisabled;
+ this.updateFormEnableState();
}
private observeValueChanges(): void {
@@ -180,7 +179,7 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
this.slaveConfigFormGroup.get('type').valueChanges
.pipe(takeUntil(this.destroy$))
.subscribe(type => {
- this.updateFormEnableState(this.isSlaveEnabled);
+ this.updateFormEnableState();
this.updateMethodType(type);
});
}
@@ -196,22 +195,15 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
}
}
- private observeFormEnable(): void {
- this.slaveConfigFormGroup.get('sendDataToThingsBoard').valueChanges
- .pipe(startWith(this.isSlaveEnabled), takeUntil(this.destroy$))
- .subscribe(value => this.updateFormEnableState(value));
- }
-
- private updateFormEnableState(enabled: boolean): void {
- if (enabled) {
+ private updateFormEnableState(): void {
+ if (this.isSlaveEnabled) {
this.slaveConfigFormGroup.enable({emitEvent: false});
this.showSecurityControl.enable({emitEvent: false});
} else {
this.slaveConfigFormGroup.disable({emitEvent: false});
this.showSecurityControl.disable({emitEvent: false});
- this.slaveConfigFormGroup.get('sendDataToThingsBoard').enable({emitEvent: false});
}
- this.updateEnablingByProtocol(this.protocolType);
+ this.updateEnablingByProtocol();
this.updateSecurityEnable(this.showSecurityControl.value);
}
@@ -229,9 +221,10 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
}
}
- private updateEnablingByProtocol(type: ModbusProtocolType): void {
- const enableKeys = type === ModbusProtocolType.Serial ? this.serialSpecificControlKeys : this.tcpUdpSpecificControlKeys;
- const disableKeys = type === ModbusProtocolType.Serial ? this.tcpUdpSpecificControlKeys : this.serialSpecificControlKeys;
+ private updateEnablingByProtocol(): void {
+ const isSerial = this.protocolType === ModbusProtocolType.Serial;
+ const enableKeys = isSerial ? this.serialSpecificControlKeys : this.tcpUdpSpecificControlKeys;
+ const disableKeys = isSerial ? this.tcpUdpSpecificControlKeys : this.serialSpecificControlKeys;
if (this.isSlaveEnabled) {
enableKeys.forEach(key => this.slaveConfigFormGroup.get(key)?.enable({ emitEvent: false }));