refactoring
This commit is contained in:
parent
2ff3d0bafc
commit
2837edbbd1
@ -34,7 +34,7 @@
|
||||
</tb-toggle-select>
|
||||
</div>
|
||||
<div class="tb-form-panel no-border no-padding padding-top">
|
||||
<div *ngIf="this.slaveConfigFormGroup.get('type').value !== ModbusProtocolType.Serial"
|
||||
<div *ngIf="protocolType !== ModbusProtocolType.Serial"
|
||||
class="tb-form-row column-xs"
|
||||
fxLayoutAlign="space-between center"
|
||||
>
|
||||
@ -54,7 +54,7 @@
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="this.slaveConfigFormGroup.get('type').value !== ModbusProtocolType.Serial else serialPort"
|
||||
<div *ngIf="protocolType !== ModbusProtocolType.Serial else serialPort"
|
||||
class="tb-form-row column-xs"
|
||||
fxLayoutAlign="space-between center"
|
||||
>
|
||||
@ -102,7 +102,7 @@
|
||||
<div class="tb-flex no-gap">
|
||||
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
|
||||
<mat-select formControlName="method">
|
||||
<mat-option *ngFor="let method of slaveConfigFormGroup.get('type').value === ModbusProtocolType.Serial ? modbusSerialMethodTypes : modbusMethodTypes"
|
||||
<mat-option *ngFor="let method of protocolType === ModbusProtocolType.Serial ? modbusSerialMethodTypes : modbusMethodTypes"
|
||||
[value]="method">{{ ModbusMethodLabelsMap.get(method) }}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
@ -168,7 +168,7 @@
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="this.slaveConfigFormGroup.get('type').value === ModbusProtocolType.Serial" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
|
||||
<div *ngIf="protocolType === ModbusProtocolType.Serial" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
|
||||
<div class="fixed-title-width" translate>gateway.baudrate</div>
|
||||
<div class="tb-flex no-gap">
|
||||
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
|
||||
@ -196,7 +196,7 @@
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="this.slaveConfigFormGroup.get('type').value !== ModbusProtocolType.Serial" class="tb-form-panel stroked tb-slide-toggle">
|
||||
<div *ngIf="protocolType !== ModbusProtocolType.Serial" class="tb-form-panel stroked tb-slide-toggle">
|
||||
<mat-expansion-panel class="tb-settings" [expanded]="showSecurityControl.value">
|
||||
<mat-expansion-panel-header fxLayout="row wrap">
|
||||
<mat-panel-title>
|
||||
|
||||
@ -134,6 +134,10 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
|
||||
return this.slaveConfigFormGroup.get('sendDataToThingsBoard').value;
|
||||
}
|
||||
|
||||
get protocolType(): ModbusProtocolType {
|
||||
return this.slaveConfigFormGroup.get('type').value;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
@ -207,7 +211,7 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
|
||||
this.showSecurityControl.disable({emitEvent: false});
|
||||
this.slaveConfigFormGroup.get('sendDataToThingsBoard').enable({emitEvent: false});
|
||||
}
|
||||
this.updateEnablingByProtocol(this.slaveConfigFormGroup.get('type').value);
|
||||
this.updateEnablingByProtocol(this.protocolType);
|
||||
this.updateSecurityEnable(this.showSecurityControl.value);
|
||||
}
|
||||
|
||||
@ -218,7 +222,7 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
|
||||
}
|
||||
|
||||
private updateSecurityEnable(securityEnabled: boolean): void {
|
||||
if (securityEnabled && this.isSlaveEnabled) {
|
||||
if (securityEnabled && this.isSlaveEnabled && this.protocolType !== ModbusProtocolType.Serial) {
|
||||
this.slaveConfigFormGroup.get('security').enable({emitEvent: false});
|
||||
} else {
|
||||
this.slaveConfigFormGroup.get('security').disable({emitEvent: false});
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
</tb-toggle-select>
|
||||
</div>
|
||||
<div class="tb-form-panel no-border no-padding padding-top">
|
||||
<div *ngIf="this.slaveConfigFormGroup.get('type').value !== ModbusProtocolType.Serial"
|
||||
<div *ngIf="protocolType !== ModbusProtocolType.Serial"
|
||||
class="tb-form-row column-xs"
|
||||
fxLayoutAlign="space-between center"
|
||||
>
|
||||
@ -73,7 +73,7 @@
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="this.slaveConfigFormGroup.get('type').value !== ModbusProtocolType.Serial else serialPort"
|
||||
<div *ngIf="protocolType !== ModbusProtocolType.Serial else serialPort"
|
||||
class="tb-form-row column-xs"
|
||||
fxLayoutAlign="space-between center"
|
||||
>
|
||||
@ -122,14 +122,14 @@
|
||||
<div class="tb-flex no-gap">
|
||||
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
|
||||
<mat-select formControlName="method">
|
||||
<mat-option *ngFor="let method of slaveConfigFormGroup.get('type').value === ModbusProtocolType.Serial ? modbusSerialMethodTypes : modbusMethodTypes"
|
||||
<mat-option *ngFor="let method of protocolType === ModbusProtocolType.Serial ? modbusSerialMethodTypes : modbusMethodTypes"
|
||||
[value]="method">{{ ModbusMethodLabelsMap.get(method) }}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ng-container *ngIf="this.slaveConfigFormGroup.get('type').value === ModbusProtocolType.Serial">
|
||||
<ng-container *ngIf="protocolType === ModbusProtocolType.Serial">
|
||||
<div class="tb-form-row column-xs" fxLayoutAlign="space-between center">
|
||||
<div class="fixed-title-width" translate>gateway.baudrate</div>
|
||||
<div class="tb-flex no-gap">
|
||||
@ -260,7 +260,7 @@
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="this.slaveConfigFormGroup.get('type').value !== ModbusProtocolType.Serial" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
|
||||
<div *ngIf="protocolType !== ModbusProtocolType.Serial" class="tb-form-row column-xs" fxLayoutAlign="space-between center">
|
||||
<div class="fixed-title-width" translate>gateway.word-order</div>
|
||||
<div class="tb-flex no-gap">
|
||||
<mat-form-field class="tb-flex no-gap" appearance="outline" subscriptSizing="dynamic">
|
||||
@ -270,7 +270,7 @@
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="this.slaveConfigFormGroup.get('type').value !== ModbusProtocolType.Serial" class="tb-form-panel stroked tb-slide-toggle">
|
||||
<div *ngIf="protocolType !== ModbusProtocolType.Serial" class="tb-form-panel stroked tb-slide-toggle">
|
||||
<mat-expansion-panel class="tb-settings" [expanded]="showSecurityControl.value">
|
||||
<mat-expansion-panel-header fxLayout="row wrap">
|
||||
<mat-panel-title>
|
||||
@ -356,7 +356,7 @@
|
||||
<button mat-raised-button color="primary"
|
||||
(click)="add()"
|
||||
[disabled]="slaveConfigFormGroup.invalid || !slaveConfigFormGroup.dirty">
|
||||
{{ this.data.buttonTitle | translate }}
|
||||
{{ data.buttonTitle | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -128,6 +128,10 @@ export class ModbusSlaveDialogComponent extends DialogComponent<ModbusSlaveDialo
|
||||
this.showSecurityControl.patchValue(!!this.data.value.security && !isEqual(this.data.value.security, {}));
|
||||
}
|
||||
|
||||
get protocolType(): ModbusProtocolType {
|
||||
return this.slaveConfigFormGroup.get('type').value;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
@ -236,7 +240,7 @@ export class ModbusSlaveDialogComponent extends DialogComponent<ModbusSlaveDialo
|
||||
}
|
||||
|
||||
private updateSecurityEnabling(isEnabled: boolean): void {
|
||||
if (isEnabled) {
|
||||
if (isEnabled && this.protocolType !== ModbusProtocolType.Serial) {
|
||||
this.slaveConfigFormGroup.get('security').enable({emitEvent: false});
|
||||
} else {
|
||||
this.slaveConfigFormGroup.get('security').disable({emitEvent: false});
|
||||
|
||||
@ -200,7 +200,7 @@
|
||||
"timeseries": [
|
||||
{
|
||||
"address": 2,
|
||||
"type": "int",
|
||||
"type": "8int",
|
||||
"tag": "smm",
|
||||
"objectsCount": 1,
|
||||
"value": "12334"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user