From 4d59d17141e8bd84d2bc9a422b4c529e84dc7327 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Fri, 23 Jul 2021 13:18:29 +0300 Subject: [PATCH] UI: Refactoring LwM2M device profile setting; Delete unused translation --- ...ile-transport-configuration.component.html | 16 +++----- ...ofile-transport-configuration.component.ts | 37 +++---------------- .../assets/locale/locale.constant-cs_CZ.json | 13 +++---- .../assets/locale/locale.constant-en_US.json | 5 +-- 4 files changed, 18 insertions(+), 53 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html index 834071dfb4..cfbd1f304e 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html @@ -174,14 +174,9 @@ - - - - - - - - + + + @@ -194,13 +189,12 @@ -
+
+ [ngModel]="configurationValue">
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts index 0934a9b6e2..a6e57abe4f 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts @@ -14,7 +14,6 @@ /// limitations under the License. /// -import { DeviceProfileTransportConfiguration } from '@shared/models/device.models'; import { Component, forwardRef, Input, OnDestroy } from '@angular/core'; import { ControlValueAccessor, @@ -76,7 +75,6 @@ import { takeUntil } from 'rxjs/operators'; }) export class Lwm2mDeviceProfileTransportConfigurationComponent implements ControlValueAccessor, Validator, OnDestroy { - private configurationValue: Lwm2mProfileConfigModels; private requiredValue: boolean; private disabled = false; private destroy$ = new Subject(); @@ -84,7 +82,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro bindingModeTypes = Object.values(BingingMode); bindingModeTypeNamesMap = BingingModeTranslationsMap; lwm2mDeviceProfileFormGroup: FormGroup; - lwm2mDeviceConfigFormGroup: FormGroup; + configurationValue: Lwm2mProfileConfigModels; sortFunction: (key: string, value: object) => object; get required(): boolean { @@ -128,9 +126,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro compositeOperationsSupport: [false] }) }); - this.lwm2mDeviceConfigFormGroup = this.fb.group({ - configurationJson: [null, Validators.required] - }); this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.fwUpdateStrategy').valueChanges.pipe( takeUntil(this.destroy$) ).subscribe((fwStrategy) => { @@ -158,11 +153,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro ).subscribe((value) => { this.updateDeviceProfileValue(value); }); - this.lwm2mDeviceConfigFormGroup.valueChanges.pipe( - takeUntil(this.destroy$) - ).subscribe(() => { - this.updateModel(); - }); this.sortFunction = this.sortObjectKeyPathJson; } @@ -182,10 +172,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro this.disabled = isDisabled; if (isDisabled) { this.lwm2mDeviceProfileFormGroup.disable({emitEvent: false}); - this.lwm2mDeviceConfigFormGroup.disable({emitEvent: false}); } else { this.lwm2mDeviceProfileFormGroup.enable({emitEvent: false}); - this.lwm2mDeviceConfigFormGroup.enable({emitEvent: false}); this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.powerMode').updateValueAndValidity({onlySelf: true}); this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.fwUpdateStrategy').updateValueAndValidity({onlySelf: true}); this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.swUpdateStrategy').updateValueAndValidity({onlySelf: true}); @@ -196,9 +184,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro if (isDefinedAndNotNull(value) && (value?.clientLwM2mSettings || value?.observeAttr || value?.bootstrap)) { this.configurationValue = value; const defaultFormSettings = !(value.observeAttr.attribute.length && value.observeAttr.telemetry.length); - this.lwm2mDeviceConfigFormGroup.patchValue({ - configurationJson: this.configurationValue - }, {emitEvent: defaultFormSettings}); if (defaultFormSettings) { await this.defaultProfileConfig(); } @@ -227,9 +212,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro this.configurationValue.bootstrap.bootstrapServer = bootstrap; this.configurationValue.bootstrap.lwm2mServer = lwm2m; - this.lwm2mDeviceConfigFormGroup.patchValue({ - configurationJson: this.configurationValue - }, {emitEvent: false}); this.lwm2mDeviceProfileFormGroup.patchValue({ bootstrap: this.configurationValue.bootstrap }, {emitEvent: false}); @@ -265,6 +247,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro swUpdateResource: this.configurationValue.clientLwM2mSettings.swUpdateResource || '', powerMode: this.configurationValue.clientLwM2mSettings.powerMode || PowerMode.DRX, edrxCycle: this.configurationValue.clientLwM2mSettings.edrxCycle || 0, + pagingTransmissionWindow: this.configurationValue.clientLwM2mSettings.pagingTransmissionWindow || 0, + psmActivityTimer: this.configurationValue.clientLwM2mSettings.psmActivityTimer || 0, compositeOperationsSupport: this.configurationValue.clientLwM2mSettings.compositeOperationsSupport || false } }, @@ -277,9 +261,9 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro } private updateModel = (): void => { - let configuration: DeviceProfileTransportConfiguration = null; - if (this.lwm2mDeviceConfigFormGroup.valid && this.lwm2mDeviceProfileFormGroup.valid) { - configuration = this.lwm2mDeviceConfigFormGroup.value.configurationJson; + let configuration: Lwm2mProfileConfigModels = null; + if (this.lwm2mDeviceProfileFormGroup.valid) { + configuration = this.configurationValue; } this.propagateChange(configuration); } @@ -299,7 +283,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro this.configurationValue.bootstrap.lwm2mServer = config.bootstrap.lwm2mServer; this.configurationValue.bootstrap.servers = config.bootstrap.servers; this.configurationValue.clientLwM2mSettings = config.clientLwM2mSettings; - this.upDateJsonAllConfig(); this.updateModel(); } @@ -327,7 +310,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro } if (isDefinedAndNotNull(keyNameJson)) { this.configurationValue.observeAttr.keyName = this.validateKeyNameObjects(keyNameJson, attributeArray, telemetryArray); - this.upDateJsonAllConfig(); this.updateKeyNameObjects(objectLwM2MS); } } @@ -513,12 +495,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro return (objectsIds.size > 0) ? Array.from(objectsIds) : []; } - private upDateJsonAllConfig = (): void => { - this.lwm2mDeviceConfigFormGroup.patchValue({ - configurationJson: this.configurationValue - }, {emitEvent: false}); - } - addObjectsList = (value: ObjectLwM2M[]): void => { this.updateObserveAttrTelemetryObjectFormGroup(value); } @@ -536,7 +512,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro this.removeKeyNameFromJson(value.keyId); this.removeAttributesFromJson(value.keyId); this.updateObserveAttrTelemetryObjectFormGroup(objectsOld); - this.upDateJsonAllConfig(); } private removeObserveAttrTelemetryFromJson = (observeAttrTel: string, keyId: string): void => { diff --git a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json index 35892cfede..3b96068406 100644 --- a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json +++ b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json @@ -1236,14 +1236,12 @@ "object-list": "SEznam objektů", "object-list-empty": "Žádné objekty nebyly vybrány.", "no-objects-matching": "Žádné objekty odpovídající '{{object}}' nebyly nalezeny.", - "valid-id-instance-no-min": "Instance číslo '{{instance}}' nebyla validována. Mininimální hodnota='{{min}}'", - "valid-id-instance-no-max": "Instance číslo '{{instance}}' nebyla validována. Maximální hodnota='{{max}}'", - "valid-id-instance": "Instance číslo '{{instance}}' nebyla validována. { count, plural, 1 {Maximální hodnota='{{max}}'} 2 {Minimální hodnota='{{min}}'} other {Musí být pouze číslo} }", "model-tab": "LWM2M model", "add-new-instances": "Přidat nové instance", "instances-list": "Seznam instancí", - "instances-input": "Vstupní hodnota Id instance", - "instances-input-holder": "Vstupní číslo instance...", + "instances-list-required": "Seznam instancí je povinný", + "instance-id-pattern": "Instance číslo musí být kladné číslo.", + "instance-id-max": "Maximální instance číslo hodnota {{max}}.", "instance": "Instance", "resource-label": "Název zdroje #ID", "observe-label": "Pozorování", @@ -1266,7 +1264,6 @@ "view-attribute": "Zobrazit atribut", "remove-attribute": "Odebrat atribut", "mode": "Režim konfigurace bezpečnosti", - "pattern_hex_dec": "{ count, plural, 0 {musí být v hexadecimálním formátu} other {musí být # znaků} }", "servers": "Servery", "short-id": "Krátké ID", "short-id-required": "Krátké ID je povinné.", @@ -1316,8 +1313,8 @@ "others-tab": "Ostatní nastavení", "client-strategy": "Strategie klienta při připojování", "client-strategy-label": "Strategie", - "client-strategy-connect": "{ count, plural, 1 {1: Klientovi je odeslán pouze observe požadavek po úvodním spojení} other {2: Načti všechny zdroje a observer požadavky na klienta po registraci} }", - "client-strategy-tip": "{ count, plural, 1 {Strategie 1: Po úvodním spojení LWM2M klienta, server odešle požadavek Observe zdrojů klientovi, přičemž tyto zdroje existující na straně LWM2M klienta jsou v profilu zařízení označeny jako pozorování.} other {Strategie 2: Po registraci, je klientovi odeslán požadavek na načtení hodnotu všech zdrojů všech objektů, které LWM2M klient má,\n poté: server odešle požadavek observe zdrojů klientovi, přičemž tyto zdroje existující na straně klienta, jsou v profilu zařízení označeny jako pozorování.} }", + "client-strategy-only-observe": "Klientovi je odeslán pouze observe požadavek po úvodním spojení", + "client-strategy-read-all": "Načti všechny zdroje a observer požadavky na klienta po registraci", "fw-update": "Aktualizace firmware", "fw-update-strategy": "Strategie aktualizace firmware", "fw-update-strategy-data": "Odeslat (push) aktualizaci firmware jako binární soubor pomocí Object 19 a Resource 0 (Data)", diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index c7c9a8302e..3ed1c81632 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1273,7 +1273,6 @@ "view-attribute": "View attribute", "remove-attribute": "Remove attribute", "mode": "Security config mode", - "pattern_hex_dec": "{ count, plural, 0 {must be hex decimal format} other {must be # characters} }", "servers": "Servers", "short-id": "Short ID", "short-id-required": "Short ID is required.", @@ -1323,8 +1322,8 @@ "others-tab": "Other settings", "client-strategy": "Client strategy when connecting", "client-strategy-label": "Strategy", - "client-strategy-connect": "{ count, plural, 1 {1: Only Observe Request to the client after the initial connection} other {2: Read All Resources & Observe Request to the client after registration} }", - "client-strategy-tip": "{ count, plural, 1 {Strategy 1: After the initial connection of the LWM2M Client, the server sends Observe resources Request to the client, those resources that are marked as observation in the Device profile and which exist on the LWM2M client.} other {Strategy 2: After the registration, request the client to read all the resource values for all objects that the LWM2M client has,\n then execute: the server sends Observe resources Request to the client, those resources that are marked as observation in the Device profile and which exist on the LWM2M client.} }", + "client-strategy-only-observe": "Only Observe Request to the client after the initial connection", + "client-strategy-read-all": "Read All Resources & Observe Request to the client after registration", "fw-update": "Firmware update", "fw-update-strategy": "Firmware update strategy", "fw-update-strategy-data": "Push firmware update as binary file using Object 19 and Resource 0 (Data)",