diff --git a/ui-ngx/src/app/modules/home/components/home-components.module.ts b/ui-ngx/src/app/modules/home/components/home-components.module.ts
index 03124d7a65..876d7fe785 100644
--- a/ui-ngx/src/app/modules/home/components/home-components.module.ts
+++ b/ui-ngx/src/app/modules/home/components/home-components.module.ts
@@ -307,7 +307,6 @@ import { Lwm2mProfileComponentsModule } from '@home/components/profile/device/lw
EditAlarmDetailsDialogComponent,
DeviceProfileProvisionConfigurationComponent,
AlarmScheduleComponent,
- // Lwm2mProfileComponentsModule,
SmsProviderConfigurationComponent,
AwsSnsProviderConfigurationComponent,
TwilioSmsProviderConfigurationComponent
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts
index e02a4e7c3a..29589d2388 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts
@@ -15,19 +15,18 @@
///
import { Component, forwardRef, Inject, Input, OnInit } from '@angular/core';
-
-import {
- ControlValueAccessor,
- FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators
-} from '@angular/forms';
+import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
import {
- SECURITY_CONFIG_MODE,
- SECURITY_CONFIG_MODE_NAMES,
- ServerSecurityConfig,
+ DEFAULT_CLIENT_HOLD_OFF_TIME,
+ DEFAULT_ID_SERVER,
DEFAULT_PORT_BOOTSTRAP_NO_SEC,
DEFAULT_PORT_SERVER_NO_SEC,
- DEFAULT_CLIENT_HOLD_OFF_TIME,
- DEFAULT_ID_SERVER, LEN_MAX_PUBLIC_KEY_RPK, LEN_MAX_PUBLIC_KEY_X509, KEY_REGEXP_HEX_DEC
+ KEY_REGEXP_HEX_DEC,
+ LEN_MAX_PUBLIC_KEY_RPK,
+ LEN_MAX_PUBLIC_KEY_X509,
+ SECURITY_CONFIG_MODE,
+ SECURITY_CONFIG_MODE_NAMES,
+ ServerSecurityConfig
} from './profile-config.models';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
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 3eadd43c53..58eaff4fdc 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
@@ -46,50 +46,52 @@
{{ 'device-profile.lwm2m.servers' | translate | uppercase }}
-
-
+
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 b1f87568ad..ea7da72966 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,26 +14,23 @@
/// limitations under the License.
///
-import {
- DeviceProfileTransportConfiguration,
- DeviceTransportType
-} from '@shared/models/device.models';
-import {
- Component,
- forwardRef, Inject,
- Input,
- OnInit
-} from '@angular/core';
+import { DeviceProfileTransportConfiguration, DeviceTransportType } from '@shared/models/device.models';
+import { Component, forwardRef, Inject, Input, OnInit } from '@angular/core';
import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
import { Store } from '@ngrx/store';
import { AppState } from '@app/core/core.state';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import {
ATTR,
+ getDefaultProfileConfig,
+ Instance,
+ KEY_NAME,
+ ObjectLwM2M,
OBSERVE,
OBSERVE_ATTR,
- TELEMETRY,
- ObjectLwM2M, getDefaultProfileConfig, KEY_NAME, Instance, ProfileConfigModels, ResourceLwM2M
+ ProfileConfigModels,
+ ResourceLwM2M,
+ TELEMETRY
} from './profile-config.models';
import { DeviceProfileService } from '@core/http/device-profile.service';
import { deepClone, isUndefined } from '@core/utils';
@@ -50,7 +47,7 @@ import { isNotNullOrUndefined } from 'codelyzer/util/isNotNullOrUndefined';
multi: true
}]
})
-export class Lwm2mDeviceProfileTransportConfigurationComponent implements ControlValueAccessor, OnInit, Validators {
+export class Lwm2mDeviceProfileTransportConfigurationComponent implements ControlValueAccessor, Validators {
private configurationValue: ProfileConfigModels;
private requiredValue: boolean;
@@ -65,7 +62,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
bootstrapServers: string;
bootstrapServer: string;
lwm2mServer: string;
- sortFunction: {};
+ sortFunction: (key: string, value: object) => object;
get required(): boolean {
return this.requiredValue;
@@ -99,6 +96,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
this.updateModel();
}
});
+ this.sortFunction = this.sortObjectKeyPathJson;
}
registerOnChange(fn: any): void {
@@ -108,10 +106,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
registerOnTouched(fn: any): void {
}
- ngOnInit() {
- this.sortFunction = this.sortObjectKeyPathJson;
- }
-
setDisabledState(isDisabled: boolean): void {
this.disabled = isDisabled;
if (isDisabled) {
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances-list.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances-list.component.ts
index acbebca313..6e09a6d254 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances-list.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances-list.component.ts
@@ -49,7 +49,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service';
multi: true
}]
})
-export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccessor, OnInit, Validators {
+export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccessor {
private requiredValue: boolean;
private disabled = false as boolean;
@@ -103,12 +103,6 @@ export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccesso
registerOnTouched(fn: any): void {
}
- ngOnInit() {
- }
-
- ngAfterViewInit(): void {
- }
-
setDisabledState(isDisabled: boolean): void {
this.disabled = isDisabled;
if (isDisabled) {
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances.component.html
index 6dafeb6024..6c7706071f 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances.component.html
@@ -15,7 +15,7 @@
limitations under the License.
-->
-
-
-
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances.component.ts
index 64beea1bdb..57c7e3e2b5 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-add-instances.component.ts
@@ -35,7 +35,7 @@ export interface Lwm2mObjectAddInstancesData {
})
export class Lwm2mObjectAddInstancesComponent extends DialogComponent implements OnInit {
- jsonFormGroup: FormGroup;
+ instancesFormGroup: FormGroup;
submitted = false;
constructor(protected store: Store,
@@ -46,9 +46,8 @@ export class Lwm2mObjectAddInstancesComponent extends DialogComponent | null;
objectsList: Array = [];
filteredObjectsList: Observable>;
- disabled = false as boolean;
- searchText = '' as string;
+ disabled = false;
+ searchText = '';
get required(): boolean {
return this.requiredValue;
@@ -210,9 +196,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
direction: Direction.ASC
});
return this.deviceProfileService.getLwm2mObjectsPage(pageLink, {ignoreLoading: true}).pipe(
- map(pageData => {
- return pageData.data;
- })
+ map(pageData => pageData.data)
);
}
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry-resource.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry-resource.component.html
index 322fba8086..c406cfb17f 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry-resource.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry-resource.component.html
@@ -17,12 +17,10 @@
-->
-
-
-
-
-
+ *ngFor="let resourceLwM2M of resourceFormArray.controls; let i = index; trackBy: trackByParams">
+
+
+
device-profile.lwm2m.observe-label
@@ -72,10 +70,9 @@
{{ 'device-profile.lwm2m.key-name_label' | translate }}
-
{{ 'device-profile.lwm2m.key-name' | translate }}
{{ 'device-profile.lwm2m.required' | translate }}
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry-resource.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry-resource.component.ts
index 12eeaab029..8d3fa0c57b 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry-resource.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry-resource.component.ts
@@ -14,20 +14,12 @@
/// limitations under the License.
///
-import { Component, forwardRef, Input, OnInit } from '@angular/core';
-import {
- ControlValueAccessor,
- FormArray, FormBuilder,
- FormGroup,
- NG_VALUE_ACCESSOR, Validators
-} from '@angular/forms';
-import {
- CAMEL_CASE_REGEXP,
- ResourceLwM2M
-} from '@home/components/profile/device/lwm2m/profile-config.models';
+import { Component, forwardRef, Input } from '@angular/core';
+import { ControlValueAccessor, FormArray, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
+import { ResourceLwM2M } from '@home/components/profile/device/lwm2m/profile-config.models';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
-import { deepClone } from '@core/utils';
+import _ from 'lodash';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
@Component({
@@ -43,12 +35,12 @@ import { coerceBooleanProperty } from '@angular/cdk/coercion';
]
})
-export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueAccessor, OnInit, Validators {
+export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueAccessor {
private requiredValue: boolean;
resourceFormGroup: FormGroup;
- disabled = false as boolean;
+ disabled = false;
get required(): boolean {
return this.requiredValue;
@@ -61,9 +53,12 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
this.requiredValue = newVal;
}
}
+
constructor(private store: Store,
private fb: FormBuilder) {
- this.resourceFormGroup = this.fb.group({resources: this.fb.array([])});
+ this.resourceFormGroup = this.fb.group({
+ resources: this.fb.array([])
+ });
this.resourceFormGroup.valueChanges.subscribe(value => {
if (!this.disabled) {
this.propagateChangeState(value.resources);
@@ -71,9 +66,6 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
});
}
- ngOnInit(): void {
- }
-
registerOnTouched(fn: any): void {
}
@@ -85,10 +77,6 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
return this.resourceFormGroup.get('resources') as FormArray;
}
- resourceLwm2mFormArray = (instance: FormGroup): FormArray => {
- return instance.get('resources') as FormArray;
- }
-
setDisabledState(isDisabled: boolean): void {
this.disabled = isDisabled;
if (isDisabled) {
@@ -98,31 +86,16 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
}
}
- getDisabledState = (): boolean => {
- return this.disabled;
- }
-
- updateValueKeyName = (event: any, z: number): void => {
- this.resourceFormArray.at(z).patchValue( {keyName: this.keysToCamel(deepClone(event.target.value))} );
- }
-
- private keysToCamel = (o: any): string => {
- const val = o.split(' ');
- const playStore = [];
- val.forEach((item, k) => {
- item = item.replace(CAMEL_CASE_REGEXP, '');
- item = (k === 0) ? item.charAt(0).toLowerCase() + item.substr(1) : item.charAt(0).toUpperCase() + item.substr(1);
- playStore.push(item);
- });
- return playStore.join('');
+ updateValueKeyName = (event: Event, index: number): void => {
+ this.resourceFormArray.at(index).patchValue({keyName: _.camelCase((event.target as HTMLInputElement).value)});
}
- private createResourceLwM2M = (resourcesLwM2MJson: ResourceLwM2M []): void => {
- if (resourcesLwM2MJson.length === this.resourceFormArray.length) {
- this.resourceFormArray.patchValue(resourcesLwM2MJson, {emitEvent: false});
+ createResourceLwM2M(resourcesLwM2M: ResourceLwM2M[]): void {
+ if (resourcesLwM2M.length === this.resourceFormArray.length) {
+ this.resourceFormArray.patchValue(resourcesLwM2M, {emitEvent: false});
} else {
this.resourceFormArray.clear();
- resourcesLwM2MJson.forEach(resourceLwM2M => {
+ resourcesLwM2M.forEach(resourceLwM2M => {
this.resourceFormArray.push(this.fb.group({
id: resourceLwM2M.id,
name: resourceLwM2M.name,
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry.component.html
index ea3233f769..eb0e4bc88d 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry.component.html
@@ -19,7 +19,7 @@
@@ -34,8 +34,8 @@
-
-
+
+
+
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry.component.ts
index faed152a1b..11ffdf0fe5 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-observe-attr-telemetry.component.ts
@@ -15,7 +15,7 @@
///
-import { Component, forwardRef, Input, OnInit } from '@angular/core';
+import { Component, forwardRef, Input } from '@angular/core';
import {
AbstractControl,
ControlValueAccessor,
@@ -28,16 +28,8 @@ import {
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
-import {
- ATTR,
- Instance,
- ObjectLwM2M,
- OBSERVE,
- ResourceLwM2M,
- TELEMETRY
-} from './profile-config.models';
-import { isNotNullOrUndefined } from 'codelyzer/util/isNotNullOrUndefined';
-import { deepClone, isUndefined } from '@core/utils';
+import { Instance, ObjectLwM2M, ResourceLwM2M } from './profile-config.models';
+import { deepClone, isDefinedAndNotNull, isEqual, isUndefined } from '@core/utils';
import { MatDialog } from '@angular/material/dialog';
import { TranslateService } from '@ngx-translate/core';
import {
@@ -58,24 +50,17 @@ import {
]
})
-export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, OnInit, Validators {
+export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor {
private requiredValue: boolean;
valuePrev = null as any;
observeAttrTelemetryFormGroup: FormGroup;
- observe = OBSERVE as string;
- attribute = ATTR as string;
- telemetry = TELEMETRY as string;
get required(): boolean {
return this.requiredValue;
}
- @Input()
- disabled: boolean;
-
- // tslint:disable-next-line:adjacent-overload-signatures
@Input()
set required(value: boolean) {
const newVal = coerceBooleanProperty(value);
@@ -85,6 +70,9 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
}
}
+ @Input()
+ disabled: boolean;
+
constructor(private store: Store,
private fb: FormBuilder,
private dialog: MatDialog,
@@ -99,9 +87,6 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
});
}
- ngOnInit(): void {
- }
-
private propagateChange = (v: any) => { };
@@ -139,10 +124,6 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
}
}
- getDisabledState = (): boolean => {
- return this.disabled;
- }
-
writeValue(value: any): void {
this.buildClientObjectsLwM2M(value.clientLwM2M);
}
@@ -153,8 +134,8 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
);
}
- private createObjectsLwM2M = (objectsLwM2MJson: ObjectLwM2M []): FormArray => {
- return this.fb.array(objectsLwM2MJson.map((objectLwM2M) => {
+ private createObjectsLwM2M = (objectsLwM2M: ObjectLwM2M[]): FormArray => {
+ return this.fb.array(objectsLwM2M.map((objectLwM2M) => {
return this.fb.group({
id: objectLwM2M.id,
name: objectLwM2M.name,
@@ -165,20 +146,17 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
}));
}
- private createInstanceLwM2M = (instanceLwM2MJson: Instance []): FormArray => {
- return this.fb.array(instanceLwM2MJson.map((instanceLwM2M) => {
+ private createInstanceLwM2M = (instancesLwM2M: Instance[]): FormArray => {
+ return this.fb.array(instancesLwM2M.map((instanceLwM2M) => {
return this.fb.group({
id: instanceLwM2M.id,
- [this.observe]: {value: false, disabled: this.disabled},
- [this.attribute]: {value: false, disabled: this.disabled},
- [this.telemetry]: {value: false, disabled: this.disabled},
resources: {value: instanceLwM2M.resources, disabled: this.disabled}
});
}));
}
- clientLwM2MFormArray = (formGroup: FormGroup): FormArray => {
- return formGroup.get('clientLwM2M') as FormArray;
+ get clientLwM2MFormArray(): FormArray {
+ return this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray;
}
instancesLwm2mFormArray = (objectLwM2M: AbstractControl): FormArray => {
@@ -186,7 +164,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
}
changeInstanceResourcesCheckBox = (value: boolean, instance: AbstractControl, type: string): void => {
- const resources = instance.get('resources').value as ResourceLwM2M [];
+ const resources = instance.get('resources').value as ResourceLwM2M[];
resources.forEach(resource => resource[type] = value);
instance.get('resources').patchValue(resources);
this.propagateChange(this.observeAttrTelemetryFormGroup.value);
@@ -202,26 +180,18 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
}
getIndeterminate = (instance: AbstractControl, type: string): boolean => {
- const resources = instance.get('resources').value as ResourceLwM2M [];
- if (isNotNullOrUndefined(resources)) {
- const isType = (element) => element[type] === true;
- const checkedResource = resources.filter(isType);
- if (checkedResource.length === 0) { return false; }
- else if (checkedResource.length === resources.length) {
- instance.patchValue({[type]: true});
- return false;
- } else { return true; }
+ const resources = instance.get('resources').value as ResourceLwM2M[];
+ if (isDefinedAndNotNull(resources)) {
+ const checkedResource = resources.filter(resource => resource[type]);
+ return checkedResource.length !== 0 && checkedResource.length !== resources.length;
}
return false;
}
getChecked = (instance: AbstractControl, type: string): boolean => {
- const resources = instance.get('resources').value as ResourceLwM2M [];
- if (isNotNullOrUndefined(resources)) {
- return resources.some(resource => resource[type]);
- }
- return false;
+ const resources = instance.get('resources').value as ResourceLwM2M[];
+ return isDefinedAndNotNull(resources) && resources.every(resource => resource[type]);
}
getExpended = (objectLwM2M: AbstractControl): boolean => {
@@ -265,7 +235,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
}
}).afterClosed().subscribe(
(res: Lwm2mObjectAddInstancesData | undefined) => {
- if (isNotNullOrUndefined(res)) {
+ if (isDefinedAndNotNull(res)) {
this.updateInstancesIds(res);
}
}
@@ -278,43 +248,41 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
data.instancesIds.forEach(value => {
valueNew.add(value);
});
- const oldInstances = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M []).
- find(e => e.id === data.objectId).instances;
+ const oldInstances = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M [])
+ .find(e => e.id === data.objectId).instances;
oldInstances.forEach(inst => {
valueOld.add(inst.id);
});
- if (JSON.stringify(Array.from(valueOld)) !== JSON.stringify(Array.from(valueNew))) {
- const idsDel = this.diffBetweenSet(valueNew, this.deepCloneSet(valueOld));
- const idsAdd = this.diffBetweenSet(valueOld, this.deepCloneSet(valueNew));
+ if (!isEqual(valueOld, valueNew)) {
+ const idsDel = this.diffBetweenSet(valueOld, valueNew);
+ const idsAdd = this.diffBetweenSet(valueNew, valueOld);
if (idsAdd.size) {
this.addInstancesNew(data.objectId, idsAdd);
}
if (idsDel.size) {
- this.delInstances(data.objectId, idsDel);
+ this.deleteInstances(data.objectId, idsDel);
}
}
}
- private delInstances = (objectId: number, idsDel: Set): void => {
- let isIdIndex = (element) => element.id === objectId;
- const objectIndex = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M []).findIndex(isIdIndex);
+ private deleteInstances = (objectId: number, idsDel: Set): void => {
+ const objectIndex = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M[])
+ .findIndex(element => element.id === objectId);
idsDel.forEach(x => {
- isIdIndex = (element) => element.value.id === x;
const instancesFormArray = ((this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray)
- .controls[objectIndex].get('instances') as FormArray);
- const instanceIndex = instancesFormArray.controls.findIndex(isIdIndex);
+ .at(objectIndex).get('instances') as FormArray);
+ const instanceIndex = instancesFormArray.value.findIndex(element => element.id === x);
instancesFormArray.removeAt(instanceIndex);
});
}
private addInstancesNew = (objectId: number, idsAdd: Set): void => {
const instancesValue = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M [])
- .find(e => e.id === objectId).instances;
+ .find(objectLwM2M => objectLwM2M.id === objectId).instances;
const instancesFormArray = ((this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray).controls
.find(e => e.value.id === objectId).get('instances') as FormArray) as FormArray;
idsAdd.forEach(x => {
const instanceNew = deepClone(instancesValue[0]) as Instance;
- instanceNew.id = x;
instanceNew.resources.forEach(r => {
r.attribute = false;
r.telemetry = false;
@@ -322,28 +290,14 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
});
instancesFormArray.push(this.fb.group({
id: x,
- [this.observe]: {value: false, disabled: this.disabled},
- [this.attribute]: {value: false, disabled: this.disabled},
- [this.telemetry]: {value: false, disabled: this.disabled},
resources: {value: instanceNew.resources, disabled: this.disabled}
}));
});
(instancesFormArray.controls as FormGroup[]).sort((a, b) => a.value.id - b.value.id);
}
- private deepCloneSet = (oldSet: Set): Set => {
- const newSet = new Set();
- oldSet.forEach(p => {
- newSet.add(p);
- });
- return newSet;
- }
-
private diffBetweenSet = (firstSet: Set, secondSet: Set): Set => {
- firstSet.forEach(p => {
- secondSet.delete(p);
- });
- return secondSet;
+ return new Set([...Array.from(firstSet)].filter(x => !secondSet.has(x)));
}
private setInstancesIds = (instances: Instance []): Set => {
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/profile-config.models.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/profile-config.models.ts
index 1cbc1bdf03..681e2fa295 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/profile-config.models.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/profile-config.models.ts
@@ -33,7 +33,6 @@ export const DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT = 0;
export const LEN_MAX_PUBLIC_KEY_RPK = 182;
export const LEN_MAX_PUBLIC_KEY_X509 = 3000;
export const KEY_REGEXP_HEX_DEC = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/;
-export const CAMEL_CASE_REGEXP = /[-_&@.,*+!?^${}()|[\]\\]/g;
export const INSTANCES_ID_VALUE_MIN = 0;
export const INSTANCES_ID_VALUE_MAX = 65535;
@@ -82,12 +81,14 @@ interface BootstrapSecurityConfig {
export interface ProfileConfigModels {
bootstrap: BootstrapSecurityConfig;
- observeAttr: {
- observe: string [],
- attribute: string [],
- telemetry: string [],
- keyName: []
- };
+ observeAttr: ObservableAttributes;
+}
+
+export interface ObservableAttributes {
+ observe: string[];
+ attribute: string[];
+ telemetry: string[];
+ keyName: string[];
}
export function getDefaultBootstrapServersSecurityConfig(): BootstrapServersSecurityConfig {
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-form.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-form.component.html
index 19f6b87471..8340857d8d 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-form.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-form.component.html
@@ -35,7 +35,7 @@
required
>
- profile-tab
+
{{'gateway.security-type' | translate }}
diff --git a/ui-ngx/src/app/shared/components/json-object-edit.component.ts b/ui-ngx/src/app/shared/components/json-object-edit.component.ts
index c1b1e4ab06..61861bc6f6 100644
--- a/ui-ngx/src/app/shared/components/json-object-edit.component.ts
+++ b/ui-ngx/src/app/shared/components/json-object-edit.component.ts
@@ -61,8 +61,7 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va
@Input() editorStyle: { [klass: string]: any };
- // tslint:disable-next-line:ban-types
- @Input() sort: Function;
+ @Input() sort: (key: string, value: any) => any;
private requiredValue: boolean;
@@ -227,10 +226,9 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va
try {
if (this.modelValue) {
- this.contentValue = JSON.stringify(this.modelValue, isUndefined(this.sort) ? null :
- // tslint:disable-next-line:no-shadowed-variable
- (key, value) => {
- return this.sort(key, value);
+ this.contentValue = JSON.stringify(this.modelValue, isUndefined(this.sort) ? undefined :
+ (key, objectValue) => {
+ return this.sort(key, objectValue);
}, 2);
this.objectValid = true;
} else {
diff --git a/ui-ngx/src/app/shared/models/device.models.ts b/ui-ngx/src/app/shared/models/device.models.ts
index 0f07cadd36..4ff9fadbba 100644
--- a/ui-ngx/src/app/shared/models/device.models.ts
+++ b/ui-ngx/src/app/shared/models/device.models.ts
@@ -454,8 +454,6 @@ export interface DeviceCredentials extends BaseData {
credentialsType: DeviceCredentialsType;
credentialsId: string;
credentialsValue: string;
- credentialsLwKey: string;
- credentialsLwValue: string;
}
export interface DeviceCredentialMQTTBasic {