UI: Refactoring LwM2M device profile setting; Delete unused translation

This commit is contained in:
Vladyslav_Prykhodko 2021-07-23 13:18:29 +03:00 committed by Andrew Shvayka
parent 25ac5f309c
commit 4d59d17141
4 changed files with 18 additions and 53 deletions

View File

@ -174,14 +174,9 @@
<!-- <div fxLayout="column">--> <!-- <div fxLayout="column">-->
<!-- <mat-form-field class="mat-block">--> <!-- <mat-form-field class="mat-block">-->
<!-- <mat-label>{{ 'device-profile.lwm2m.client-strategy-label' | translate }}</mat-label>--> <!-- <mat-label>{{ 'device-profile.lwm2m.client-strategy-label' | translate }}</mat-label>-->
<!-- <mat-select formControlName="clientOnlyObserveAfterConnect"--> <!-- <mat-select formControlName="clientOnlyObserveAfterConnect">-->
<!-- matTooltip="{{ 'device-profile.lwm2m.client-strategy-tip' | translate:--> <!-- <mat-option value=1>{{ 'device-profile.lwm2m.client-strategy-only-observe' | translate }}</mat-option>-->
<!-- { count: +lwm2mDeviceProfileFormGroup.get('clientOnlyObserveAfterConnect').value } }}"--> <!-- <mat-option value=2>{{ 'device-profile.lwm2m.client-strategy-read-all' | translate }}</mat-option>-->
<!-- matTooltipPosition="above">-->
<!-- <mat-option value=1>{{ 'device-profile.lwm2m.client-strategy-connect' | translate:-->
<!-- {count: 1} }}</mat-option>-->
<!-- <mat-option value=2>{{ 'device-profile.lwm2m.client-strategy-connect' | translate:-->
<!-- {count: 2} }}</mat-option>-->
<!-- </mat-select>--> <!-- </mat-select>-->
<!-- </mat-form-field>--> <!-- </mat-form-field>-->
<!-- </div>--> <!-- </div>-->
@ -194,13 +189,12 @@
</mat-tab> </mat-tab>
<mat-tab label="{{ 'device-profile.lwm2m.config-json-tab' | translate }}"> <mat-tab label="{{ 'device-profile.lwm2m.config-json-tab' | translate }}">
<ng-template matTabContent> <ng-template matTabContent>
<section [formGroup]="lwm2mDeviceConfigFormGroup" style="padding: 8px 0"> <section style="padding: 8px 0">
<tb-json-object-edit <tb-json-object-edit
readonly readonly
[required]="required"
[sort]="sortFunction" [sort]="sortFunction"
label="{{ 'device-profile.transport-type-lwm2m' | translate }}" label="{{ 'device-profile.transport-type-lwm2m' | translate }}"
formControlName="configurationJson"> [ngModel]="configurationValue">
</tb-json-object-edit> </tb-json-object-edit>
</section> </section>
</ng-template> </ng-template>

View File

@ -14,7 +14,6 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { DeviceProfileTransportConfiguration } from '@shared/models/device.models';
import { Component, forwardRef, Input, OnDestroy } from '@angular/core'; import { Component, forwardRef, Input, OnDestroy } from '@angular/core';
import { import {
ControlValueAccessor, ControlValueAccessor,
@ -76,7 +75,6 @@ import { takeUntil } from 'rxjs/operators';
}) })
export class Lwm2mDeviceProfileTransportConfigurationComponent implements ControlValueAccessor, Validator, OnDestroy { export class Lwm2mDeviceProfileTransportConfigurationComponent implements ControlValueAccessor, Validator, OnDestroy {
private configurationValue: Lwm2mProfileConfigModels;
private requiredValue: boolean; private requiredValue: boolean;
private disabled = false; private disabled = false;
private destroy$ = new Subject(); private destroy$ = new Subject();
@ -84,7 +82,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
bindingModeTypes = Object.values(BingingMode); bindingModeTypes = Object.values(BingingMode);
bindingModeTypeNamesMap = BingingModeTranslationsMap; bindingModeTypeNamesMap = BingingModeTranslationsMap;
lwm2mDeviceProfileFormGroup: FormGroup; lwm2mDeviceProfileFormGroup: FormGroup;
lwm2mDeviceConfigFormGroup: FormGroup; configurationValue: Lwm2mProfileConfigModels;
sortFunction: (key: string, value: object) => object; sortFunction: (key: string, value: object) => object;
get required(): boolean { get required(): boolean {
@ -128,9 +126,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
compositeOperationsSupport: [false] compositeOperationsSupport: [false]
}) })
}); });
this.lwm2mDeviceConfigFormGroup = this.fb.group({
configurationJson: [null, Validators.required]
});
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.fwUpdateStrategy').valueChanges.pipe( this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.fwUpdateStrategy').valueChanges.pipe(
takeUntil(this.destroy$) takeUntil(this.destroy$)
).subscribe((fwStrategy) => { ).subscribe((fwStrategy) => {
@ -158,11 +153,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
).subscribe((value) => { ).subscribe((value) => {
this.updateDeviceProfileValue(value); this.updateDeviceProfileValue(value);
}); });
this.lwm2mDeviceConfigFormGroup.valueChanges.pipe(
takeUntil(this.destroy$)
).subscribe(() => {
this.updateModel();
});
this.sortFunction = this.sortObjectKeyPathJson; this.sortFunction = this.sortObjectKeyPathJson;
} }
@ -182,10 +172,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
this.disabled = isDisabled; this.disabled = isDisabled;
if (isDisabled) { if (isDisabled) {
this.lwm2mDeviceProfileFormGroup.disable({emitEvent: false}); this.lwm2mDeviceProfileFormGroup.disable({emitEvent: false});
this.lwm2mDeviceConfigFormGroup.disable({emitEvent: false});
} else { } else {
this.lwm2mDeviceProfileFormGroup.enable({emitEvent: false}); this.lwm2mDeviceProfileFormGroup.enable({emitEvent: false});
this.lwm2mDeviceConfigFormGroup.enable({emitEvent: false});
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.powerMode').updateValueAndValidity({onlySelf: true}); this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.powerMode').updateValueAndValidity({onlySelf: true});
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.fwUpdateStrategy').updateValueAndValidity({onlySelf: true}); this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.fwUpdateStrategy').updateValueAndValidity({onlySelf: true});
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.swUpdateStrategy').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)) { if (isDefinedAndNotNull(value) && (value?.clientLwM2mSettings || value?.observeAttr || value?.bootstrap)) {
this.configurationValue = value; this.configurationValue = value;
const defaultFormSettings = !(value.observeAttr.attribute.length && value.observeAttr.telemetry.length); const defaultFormSettings = !(value.observeAttr.attribute.length && value.observeAttr.telemetry.length);
this.lwm2mDeviceConfigFormGroup.patchValue({
configurationJson: this.configurationValue
}, {emitEvent: defaultFormSettings});
if (defaultFormSettings) { if (defaultFormSettings) {
await this.defaultProfileConfig(); await this.defaultProfileConfig();
} }
@ -227,9 +212,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
this.configurationValue.bootstrap.bootstrapServer = bootstrap; this.configurationValue.bootstrap.bootstrapServer = bootstrap;
this.configurationValue.bootstrap.lwm2mServer = lwm2m; this.configurationValue.bootstrap.lwm2mServer = lwm2m;
this.lwm2mDeviceConfigFormGroup.patchValue({
configurationJson: this.configurationValue
}, {emitEvent: false});
this.lwm2mDeviceProfileFormGroup.patchValue({ this.lwm2mDeviceProfileFormGroup.patchValue({
bootstrap: this.configurationValue.bootstrap bootstrap: this.configurationValue.bootstrap
}, {emitEvent: false}); }, {emitEvent: false});
@ -265,6 +247,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
swUpdateResource: this.configurationValue.clientLwM2mSettings.swUpdateResource || '', swUpdateResource: this.configurationValue.clientLwM2mSettings.swUpdateResource || '',
powerMode: this.configurationValue.clientLwM2mSettings.powerMode || PowerMode.DRX, powerMode: this.configurationValue.clientLwM2mSettings.powerMode || PowerMode.DRX,
edrxCycle: this.configurationValue.clientLwM2mSettings.edrxCycle || 0, edrxCycle: this.configurationValue.clientLwM2mSettings.edrxCycle || 0,
pagingTransmissionWindow: this.configurationValue.clientLwM2mSettings.pagingTransmissionWindow || 0,
psmActivityTimer: this.configurationValue.clientLwM2mSettings.psmActivityTimer || 0,
compositeOperationsSupport: this.configurationValue.clientLwM2mSettings.compositeOperationsSupport || false compositeOperationsSupport: this.configurationValue.clientLwM2mSettings.compositeOperationsSupport || false
} }
}, },
@ -277,9 +261,9 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
} }
private updateModel = (): void => { private updateModel = (): void => {
let configuration: DeviceProfileTransportConfiguration = null; let configuration: Lwm2mProfileConfigModels = null;
if (this.lwm2mDeviceConfigFormGroup.valid && this.lwm2mDeviceProfileFormGroup.valid) { if (this.lwm2mDeviceProfileFormGroup.valid) {
configuration = this.lwm2mDeviceConfigFormGroup.value.configurationJson; configuration = this.configurationValue;
} }
this.propagateChange(configuration); this.propagateChange(configuration);
} }
@ -299,7 +283,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
this.configurationValue.bootstrap.lwm2mServer = config.bootstrap.lwm2mServer; this.configurationValue.bootstrap.lwm2mServer = config.bootstrap.lwm2mServer;
this.configurationValue.bootstrap.servers = config.bootstrap.servers; this.configurationValue.bootstrap.servers = config.bootstrap.servers;
this.configurationValue.clientLwM2mSettings = config.clientLwM2mSettings; this.configurationValue.clientLwM2mSettings = config.clientLwM2mSettings;
this.upDateJsonAllConfig();
this.updateModel(); this.updateModel();
} }
@ -327,7 +310,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
} }
if (isDefinedAndNotNull(keyNameJson)) { if (isDefinedAndNotNull(keyNameJson)) {
this.configurationValue.observeAttr.keyName = this.validateKeyNameObjects(keyNameJson, attributeArray, telemetryArray); this.configurationValue.observeAttr.keyName = this.validateKeyNameObjects(keyNameJson, attributeArray, telemetryArray);
this.upDateJsonAllConfig();
this.updateKeyNameObjects(objectLwM2MS); this.updateKeyNameObjects(objectLwM2MS);
} }
} }
@ -513,12 +495,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
return (objectsIds.size > 0) ? Array.from(objectsIds) : []; return (objectsIds.size > 0) ? Array.from(objectsIds) : [];
} }
private upDateJsonAllConfig = (): void => {
this.lwm2mDeviceConfigFormGroup.patchValue({
configurationJson: this.configurationValue
}, {emitEvent: false});
}
addObjectsList = (value: ObjectLwM2M[]): void => { addObjectsList = (value: ObjectLwM2M[]): void => {
this.updateObserveAttrTelemetryObjectFormGroup(value); this.updateObserveAttrTelemetryObjectFormGroup(value);
} }
@ -536,7 +512,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
this.removeKeyNameFromJson(value.keyId); this.removeKeyNameFromJson(value.keyId);
this.removeAttributesFromJson(value.keyId); this.removeAttributesFromJson(value.keyId);
this.updateObserveAttrTelemetryObjectFormGroup(objectsOld); this.updateObserveAttrTelemetryObjectFormGroup(objectsOld);
this.upDateJsonAllConfig();
} }
private removeObserveAttrTelemetryFromJson = (observeAttrTel: string, keyId: string): void => { private removeObserveAttrTelemetryFromJson = (observeAttrTel: string, keyId: string): void => {

View File

@ -1236,14 +1236,12 @@
"object-list": "SEznam objektů", "object-list": "SEznam objektů",
"object-list-empty": "Žádné objekty nebyly vybrány.", "object-list-empty": "Žádné objekty nebyly vybrány.",
"no-objects-matching": "Žádné objekty odpovídající '{{object}}' nebyly nalezeny.", "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", "model-tab": "LWM2M model",
"add-new-instances": "Přidat nové instance", "add-new-instances": "Přidat nové instance",
"instances-list": "Seznam instancí", "instances-list": "Seznam instancí",
"instances-input": "Vstupní hodnota Id instance", "instances-list-required": "Seznam instancí je povinný",
"instances-input-holder": "Vstupní číslo instance...", "instance-id-pattern": "Instance číslo musí být kladné číslo.",
"instance-id-max": "Maximální instance číslo hodnota {{max}}.",
"instance": "Instance", "instance": "Instance",
"resource-label": "Název zdroje #ID", "resource-label": "Název zdroje #ID",
"observe-label": "Pozorování", "observe-label": "Pozorování",
@ -1266,7 +1264,6 @@
"view-attribute": "Zobrazit atribut", "view-attribute": "Zobrazit atribut",
"remove-attribute": "Odebrat atribut", "remove-attribute": "Odebrat atribut",
"mode": "Režim konfigurace bezpečnosti", "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", "servers": "Servery",
"short-id": "Krátké ID", "short-id": "Krátké ID",
"short-id-required": "Krátké ID je povinné.", "short-id-required": "Krátké ID je povinné.",
@ -1316,8 +1313,8 @@
"others-tab": "Ostatní nastavení", "others-tab": "Ostatní nastavení",
"client-strategy": "Strategie klienta při připojování", "client-strategy": "Strategie klienta při připojování",
"client-strategy-label": "Strategie", "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-only-observe": "Klientovi je odeslán pouze observe požadavek po úvodním spojení",
"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-read-all": "Načti všechny zdroje a observer požadavky na klienta po registraci",
"fw-update": "Aktualizace firmware", "fw-update": "Aktualizace firmware",
"fw-update-strategy": "Strategie 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)", "fw-update-strategy-data": "Odeslat (push) aktualizaci firmware jako binární soubor pomocí Object 19 a Resource 0 (Data)",

View File

@ -1273,7 +1273,6 @@
"view-attribute": "View attribute", "view-attribute": "View attribute",
"remove-attribute": "Remove attribute", "remove-attribute": "Remove attribute",
"mode": "Security config mode", "mode": "Security config mode",
"pattern_hex_dec": "{ count, plural, 0 {must be hex decimal format} other {must be # characters} }",
"servers": "Servers", "servers": "Servers",
"short-id": "Short ID", "short-id": "Short ID",
"short-id-required": "Short ID is required.", "short-id-required": "Short ID is required.",
@ -1323,8 +1322,8 @@
"others-tab": "Other settings", "others-tab": "Other settings",
"client-strategy": "Client strategy when connecting", "client-strategy": "Client strategy when connecting",
"client-strategy-label": "Strategy", "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-only-observe": "Only Observe Request to the client after the initial connection",
"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-read-all": "Read All Resources & Observe Request to the client after registration",
"fw-update": "Firmware update", "fw-update": "Firmware update",
"fw-update-strategy": "Firmware update strategy", "fw-update-strategy": "Firmware update strategy",
"fw-update-strategy-data": "Push firmware update as binary file using Object 19 and Resource 0 (Data)", "fw-update-strategy-data": "Push firmware update as binary file using Object 19 and Resource 0 (Data)",