Commit 28f5d9ed9eb95682dd7177f5214d3f91d31263c9

Authored by Volodymyr Babak
2 parents c05de7c9 79814877

Merge remote-tracking branch 'upstream/develop/3.3' into develop/3.3-edge

... ... @@ -148,7 +148,7 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService {
148 148 public void onRegistered(LeshanServer lwServer, Registration registration, Collection<Observation> previousObsersations) {
149 149 executorRegistered.submit(() -> {
150 150 try {
151   -// log.warn("[{}] [{{}] Client: create after Registration", registration.getEndpoint(), registration.getId());
  151 + log.warn("[{}] [{{}] Client: create after Registration", registration.getEndpoint(), registration.getId());
152 152 LwM2MClient lwM2MClient = lwM2mInMemorySecurityStore.updateInSessionsLwM2MClient(lwServer, registration);
153 153 if (lwM2MClient != null) {
154 154 lwM2MClient.setLwM2MTransportServiceImpl(this);
... ...
... ... @@ -51,6 +51,7 @@ import { TranslateService } from '@ngx-translate/core';
51 51 export class Lwm2mDeviceConfigServerComponent implements ControlValueAccessor {
52 52
53 53 private requiredValue: boolean;
  54 + private disabled = false;
54 55
55 56 valuePrev = null;
56 57 serverFormGroup: FormGroup;
... ... @@ -61,10 +62,6 @@ export class Lwm2mDeviceConfigServerComponent implements ControlValueAccessor {
61 62 lenMaxServerPublicKey = LEN_MAX_PUBLIC_KEY_RPK;
62 63 currentSecurityMode = null;
63 64
64   -
65   - @Input()
66   - disabled: boolean;
67   -
68 65 @Input()
69 66 bootstrapServerIs: boolean;
70 67
... ... @@ -142,7 +139,7 @@ export class Lwm2mDeviceConfigServerComponent implements ControlValueAccessor {
142 139 Validators.maxLength(this.lenMaxServerPublicKey)]);
143 140 }
144 141
145   - writeValue(value: any): void {
  142 + writeValue(value: ServerSecurityConfig): void {
146 143 if (value) {
147 144 this.updateValueFields(value);
148 145 }
... ...
... ... @@ -15,7 +15,7 @@
15 15 limitations under the License.
16 16
17 17 -->
18   -<section style="padding-bottom: 16px;" mat-dialog-content>
  18 +<section style="padding-bottom: 16px; margin: 0" mat-dialog-content>
19 19 <mat-tab-group dynamicHeight>
20 20 <mat-tab label="{{ 'device-profile.lwm2m.model-tab' | translate }}">
21 21 <ng-template matTabContent>
... ...
... ... @@ -21,16 +21,11 @@ import { Store } from '@ngrx/store';
21 21 import { AppState } from '@app/core/core.state';
22 22 import { coerceBooleanProperty } from '@angular/cdk/coercion';
23 23 import {
24   - ATTR,
  24 + INSTANCES, RESOURCES, OBSERVE_ATTR_TELEMETRY, OBSERVE, ATTRIBUTE, TELEMETRY, KEY_NAME,
25 25 getDefaultProfileConfig,
26   - Instance,
27   - KEY_NAME,
28 26 ObjectLwM2M,
29   - OBSERVE,
30   - OBSERVE_ATTR,
31 27 ProfileConfigModels,
32   - ResourceLwM2M,
33   - TELEMETRY
  28 + ModelValue
34 29 } from './profile-config.models';
35 30 import { DeviceProfileService } from '@core/http/device-profile.service';
36 31 import { deepClone, isDefinedAndNotNull, isUndefined } from '@core/utils';
... ... @@ -55,11 +50,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
55 50
56 51 lwm2mDeviceProfileFormGroup: FormGroup;
57 52 lwm2mDeviceConfigFormGroup: FormGroup;
58   - observeAttr = OBSERVE_ATTR;
59   - observe = OBSERVE;
60   - attribute = ATTR;
61   - telemetry = TELEMETRY;
62   - keyName = KEY_NAME;
63 53 bootstrapServers: string;
64 54 bootstrapServer: string;
65 55 lwm2mServer: string;
... ... @@ -122,7 +112,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
122 112 }
123 113 }
124 114
125   - writeValue(value: any | null): void {
  115 + writeValue(value: ProfileConfigModels | null): void {
126 116 this.configurationValue = (Object.keys(value).length === 0) ? getDefaultProfileConfig() : value;
127 117 this.lwm2mDeviceConfigFormGroup.patchValue({
128 118 configurationJson: this.configurationValue
... ... @@ -131,7 +121,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
131 121 }
132 122
133 123 private initWriteValue = (): void => {
134   - const modelValue = {objectIds: null, objectsList: []};
  124 + const modelValue = {objectIds: null, objectsList: []} as ModelValue;
135 125 modelValue.objectIds = this.getObjectsFromJsonAllConfig();
136 126 if (modelValue.objectIds !== null) {
137 127 const sortOrder = {
... ... @@ -149,11 +139,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
149 139 }
150 140 }
151 141
152   - private updateWriteValue = (value: any): void => {
153   - const objectsList = value.objectsList;
  142 + private updateWriteValue = (value: ModelValue): void => {
154 143 this.lwm2mDeviceProfileFormGroup.patchValue({
155 144 objectIds: value,
156   - observeAttrTelemetry: this.getObserveAttrTelemetryObjects(objectsList),
  145 + observeAttrTelemetry: this.getObserveAttrTelemetryObjects(value['objectsList']),
157 146 shortId: this.configurationValue.bootstrap.servers.shortId,
158 147 lifetime: this.configurationValue.bootstrap.servers.lifetime,
159 148 defaultMinPeriod: this.configurationValue.bootstrap.servers.defaultMinPeriod,
... ... @@ -199,22 +188,22 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
199 188
200 189 private getObserveAttrTelemetryObjects = (listObject: ObjectLwM2M[]): object => {
201 190 const clientObserveAttrTelemetry = listObject;
202   - if (this.configurationValue[this.observeAttr]) {
203   - const observeArray = this.configurationValue[this.observeAttr][this.observe];
204   - const attributeArray = this.configurationValue[this.observeAttr][this.attribute];
205   - const telemetryArray = this.configurationValue[this.observeAttr][this.telemetry];
206   - const keyNameJson = this.configurationValue[this.observeAttr][this.keyName];
  191 + if (this.configurationValue.observeAttr) {
  192 + const observeArray = this.configurationValue.observeAttr.observe;
  193 + const attributeArray = this.configurationValue.observeAttr.attribute;
  194 + const telemetryArray = this.configurationValue.observeAttr.telemetry;
  195 + const keyNameJson = this.configurationValue.observeAttr.keyName;
207 196 if (this.includesNotZeroInstance(attributeArray, telemetryArray)) {
208 197 this.addInstances(attributeArray, telemetryArray, clientObserveAttrTelemetry);
209 198 }
210 199 if (isDefinedAndNotNull(observeArray)) {
211   - this.updateObserveAttrTelemetryObjects(observeArray, clientObserveAttrTelemetry, 'observe');
  200 + this.updateObserveAttrTelemetryObjects(observeArray, clientObserveAttrTelemetry, OBSERVE);
212 201 }
213 202 if (isDefinedAndNotNull(attributeArray)) {
214   - this.updateObserveAttrTelemetryObjects(attributeArray, clientObserveAttrTelemetry, 'attribute');
  203 + this.updateObserveAttrTelemetryObjects(attributeArray, clientObserveAttrTelemetry, ATTRIBUTE);
215 204 }
216 205 if (isDefinedAndNotNull(telemetryArray)) {
217   - this.updateObserveAttrTelemetryObjects(telemetryArray, clientObserveAttrTelemetry, 'telemetry');
  206 + this.updateObserveAttrTelemetryObjects(telemetryArray, clientObserveAttrTelemetry, TELEMETRY);
218 207 }
219 208 if (isDefinedAndNotNull(keyNameJson)) {
220 209 this.updateKeyNameObjects(keyNameJson, clientObserveAttrTelemetry);
... ... @@ -273,74 +262,51 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
273 262 const telemetryArray: Array<string> = [];
274 263 const keyNameNew = {};
275 264 const observeJson: ObjectLwM2M[] = JSON.parse(JSON.stringify(val));
276   - const paths = new Set<string>();
277   - let pathObj;
278   - let pathInst;
279   - let pathRes;
280 265 observeJson.forEach(obj => {
281   - for (const [key, value] of Object.entries(obj)) {
282   - if (key === 'id') {
283   - pathObj = value;
284   - }
285   - if (key === 'instances') {
286   - const instancesJson = value as Instance[];
287   - if (instancesJson.length > 0) {
288   - instancesJson.forEach(instance => {
289   - for (const [instanceKey, instanceValue] of Object.entries(instance)) {
290   - if (instanceKey === 'id') {
291   - pathInst = instanceValue;
  266 + if (obj.hasOwnProperty(INSTANCES) && Array.isArray(obj.instances)) {
  267 + obj.instances.forEach(instance => {
  268 + if (instance.hasOwnProperty(RESOURCES) && Array.isArray(instance.resources)) {
  269 + instance.resources.forEach(resource => {
  270 + if (resource.attribute || resource.telemetry) {
  271 + let pathRes = `/${obj.id}/${instance.id}/${resource.id}`;
  272 + if (resource.observe) {
  273 + observeArray.push(pathRes);
  274 + }
  275 + if (resource.attribute) {
  276 + attributeArray.push(pathRes);
292 277 }
293   - if (instanceKey === 'resources') {
294   - const resourcesJson = instanceValue as ResourceLwM2M[];
295   - if (resourcesJson.length > 0) {
296   - resourcesJson.forEach(res => {
297   - for (const [resourceKey, value] of Object.entries(res)) {
298   - if (resourceKey === 'id') {
299   - pathRes = `/${pathObj}/${pathInst}/${value}`;
300   - } else if (resourceKey === 'observe' && value) {
301   - observeArray.push(pathRes);
302   - } else if (resourceKey === 'attribute' && value) {
303   - attributeArray.push(pathRes);
304   - paths.add(pathRes);
305   - } else if (resourceKey === 'telemetry' && value) {
306   - telemetryArray.push(pathRes);
307   - paths.add(pathRes);
308   - }
309   - else if (resourceKey === this.keyName && paths.has(pathRes)) {
310   - console.warn(pathRes, value);
311   - keyNameNew[pathRes] = value;
312   - }
313   - }
314   - });
315   - }
  278 + if (resource.telemetry) {
  279 + telemetryArray.push(pathRes);
316 280 }
  281 + keyNameNew[pathRes] = resource.keyName;
317 282 }
318   - });
  283 + })
319 284 }
320   - }
  285 + })
321 286 }
322 287 });
323   - if (isUndefined(this.configurationValue[this.observeAttr])) {
324   - this.configurationValue[this.observeAttr] = {
325   - [this.observe]: observeArray,
326   - [this.attribute]: attributeArray,
327   - [this.telemetry]: telemetryArray
  288 + if (isUndefined(this.configurationValue.observeAttr)) {
  289 + this.configurationValue.observeAttr = {
  290 + observe: observeArray,
  291 + attribute: attributeArray,
  292 + telemetry: telemetryArray,
  293 + keyName: this.sortObjectKeyPathJson(KEY_NAME, keyNameNew)
328 294 };
329 295 } else {
330   - this.configurationValue[this.observeAttr][this.observe] = observeArray;
331   - this.configurationValue[this.observeAttr][this.attribute] = attributeArray;
332   - this.configurationValue[this.observeAttr][this.telemetry] = telemetryArray;
  296 + this.configurationValue.observeAttr.observe = observeArray;
  297 + this.configurationValue.observeAttr.attribute = attributeArray;
  298 + this.configurationValue.observeAttr.telemetry = telemetryArray;
  299 + this.configurationValue.observeAttr.keyName = this.sortObjectKeyPathJson(KEY_NAME, keyNameNew);
333 300 }
334   - this.configurationValue[this.observeAttr][this.keyName] = this.sortObjectKeyPathJson('keyName', keyNameNew);
335 301 }
336 302
337 303 sortObjectKeyPathJson = (key: string, value: object): object => {
338   - if (key === 'keyName') {
  304 + if (key === KEY_NAME) {
339 305 return Object.keys(value).sort(this.sortPath).reduce((obj, keySort) => {
340 306 obj[keySort] = value[keySort];
341 307 return obj;
342 308 }, {});
343   - } else if (key === 'observe' || key === 'attribute' || key === 'telemetry') {
  309 + } else if (key === OBSERVE || key === ATTRIBUTE || key === TELEMETRY) {
344 310 return Object.values(value).sort(this.sortPath).reduce((arr, arrValue) => {
345 311 arr.push(arrValue);
346 312 return arr;
... ... @@ -359,19 +325,19 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
359 325
360 326 private getObjectsFromJsonAllConfig = (): number[] => {
361 327 const objectsIds = new Set<number>();
362   - if (this.configurationValue[this.observeAttr]) {
363   - if (this.configurationValue[this.observeAttr][this.observe]) {
364   - this.configurationValue[this.observeAttr][this.observe].forEach(obj => {
  328 + if (this.configurationValue.observeAttr) {
  329 + if (this.configurationValue.observeAttr.observe) {
  330 + this.configurationValue.observeAttr.observe.forEach(obj => {
365 331 objectsIds.add(Array.from(obj.substring(1).split('/'), Number)[0]);
366 332 });
367 333 }
368   - if (this.configurationValue[this.observeAttr][this.attribute]) {
369   - this.configurationValue[this.observeAttr][this.attribute].forEach(obj => {
  334 + if (this.configurationValue.observeAttr.attribute) {
  335 + this.configurationValue.observeAttr.attribute.forEach(obj => {
370 336 objectsIds.add(Array.from(obj.substring(1).split('/'), Number)[0]);
371 337 });
372 338 }
373   - if (this.configurationValue[this.observeAttr][this.telemetry]) {
374   - this.configurationValue[this.observeAttr][this.telemetry].forEach(obj => {
  339 + if (this.configurationValue.observeAttr.telemetry) {
  340 + this.configurationValue.observeAttr.telemetry.forEach(obj => {
375 341 objectsIds.add(Array.from(obj.substring(1).split('/'), Number)[0]);
376 342 });
377 343 }
... ... @@ -390,15 +356,15 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
390 356 }
391 357
392 358 removeObjectsList = (value: ObjectLwM2M): void => {
393   - const objectsOld = this.lwm2mDeviceProfileFormGroup.get('observeAttrTelemetry').value.clientLwM2M;
  359 + const objectsOld = this.lwm2mDeviceProfileFormGroup.get(OBSERVE_ATTR_TELEMETRY).value.clientLwM2M;
394 360 const isIdIndex = (element) => element.id === value.id;
395 361 const index = objectsOld.findIndex(isIdIndex);
396 362 if (index >= 0) {
397 363 objectsOld.splice(index, 1);
398 364 }
399   - this.removeObserveAttrTelemetryFromJson(this.observe, value.id);
400   - this.removeObserveAttrTelemetryFromJson(this.telemetry, value.id);
401   - this.removeObserveAttrTelemetryFromJson(this.attribute, value.id);
  365 + this.removeObserveAttrTelemetryFromJson(OBSERVE, value.id);
  366 + this.removeObserveAttrTelemetryFromJson(TELEMETRY, value.id);
  367 + this.removeObserveAttrTelemetryFromJson(ATTRIBUTE, value.id);
402 368 this.removeKeyNameFromJson(value.id);
403 369 this.updateObserveAttrTelemetryObjectFormGroup(objectsOld);
404 370 this.upDateJsonAllConfig();
... ... @@ -406,15 +372,15 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
406 372
407 373 private removeObserveAttrTelemetryFromJson = (observeAttrTel: string, id: number): void => {
408 374 const isIdIndex = (element) => element.startsWith(`/${id}`);
409   - let index = this.configurationValue[this.observeAttr][observeAttrTel].findIndex(isIdIndex);
  375 + let index = this.configurationValue.observeAttr[observeAttrTel].findIndex(isIdIndex);
410 376 while (index >= 0) {
411   - this.configurationValue[this.observeAttr][observeAttrTel].splice(index, 1);
412   - index = this.configurationValue[this.observeAttr][observeAttrTel].findIndex(isIdIndex, index);
  377 + this.configurationValue.observeAttr[observeAttrTel].splice(index, 1);
  378 + index = this.configurationValue.observeAttr[observeAttrTel].findIndex(isIdIndex, index);
413 379 }
414 380 }
415 381
416 382 private removeKeyNameFromJson = (id: number): void => {
417   - const keyNameJson = this.configurationValue[this.observeAttr][this.keyName];
  383 + const keyNameJson = this.configurationValue.observeAttr.keyName;
418 384 Object.keys(keyNameJson).forEach(key => {
419 385 if (key.startsWith(`/${id}`)) {
420 386 delete keyNameJson[key];
... ... @@ -423,17 +389,17 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
423 389 }
424 390
425 391 isPathInJson(path: string): boolean {
426   - let isPath = this.findPathInJson(path, this.attribute);
  392 + let isPath = this.findPathInJson(path, ATTRIBUTE);
427 393 if (!isPath) {
428   - isPath = this.findPathInJson(path, this.telemetry);
  394 + isPath = this.findPathInJson(path, TELEMETRY);
429 395 }
430 396 return !!isPath;
431 397 }
432 398
433 399 private findPathInJson = (path: string, side: string): string => {
434   - if (this.configurationValue[this.observeAttr]) {
435   - if (this.configurationValue[this.observeAttr][side]) {
436   - return this.configurationValue[this.observeAttr][side].find(
  400 + if (this.configurationValue.observeAttr) {
  401 + if (this.configurationValue.observeAttr[side]) {
  402 + return this.configurationValue.bootstrap[side].find(
437 403 pathJs => pathJs === path);
438 404 }
439 405 }
... ...
... ... @@ -25,7 +25,6 @@ import { DeviceProfileService } from '@core/http/device-profile.service';
25 25 @Component({
26 26 selector: 'tb-profile-lwm2m-object-add-instances-list',
27 27 templateUrl: './lwm2m-object-add-instances-list.component.html',
28   - styleUrls: [],
29 28 providers: [{
30 29 provide: NG_VALUE_ACCESSOR,
31 30 useExisting: forwardRef(() => Lwm2mObjectAddInstancesListComponent),
... ...
... ... @@ -30,8 +30,7 @@ export interface Lwm2mObjectAddInstancesData {
30 30
31 31 @Component({
32 32 selector: 'tb-lwm2m-object-add-instances',
33   - templateUrl: './lwm2m-object-add-instances.component.html',
34   - styleUrls: []
  33 + templateUrl: './lwm2m-object-add-instances.component.html'
35 34 })
36 35 export class Lwm2mObjectAddInstancesComponent extends DialogComponent<Lwm2mObjectAddInstancesComponent, object> implements OnInit {
37 36
... ...
... ... @@ -21,7 +21,7 @@ import { Store } from '@ngrx/store';
21 21 import { AppState } from '@core/core.state';
22 22 import { Observable } from 'rxjs';
23 23 import { filter, map, mergeMap, publishReplay, refCount, tap } from 'rxjs/operators';
24   -import { ObjectLwM2M } from './profile-config.models';
  24 +import { ModelValue, ObjectLwM2M } from './profile-config.models';
25 25 import { TranslateService } from '@ngx-translate/core';
26 26 import { DeviceProfileService } from '@core/http/device-profile.service';
27 27 import { Direction } from '@shared/models/page/sort-order';
... ... @@ -120,7 +120,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
120 120 }
121 121 }
122 122
123   - writeValue(value: any): void {
  123 + writeValue(value: ModelValue): void {
124 124 this.searchText = '';
125 125 if (isDefinedAndNotNull(value)) {
126 126 if (Array.isArray(value.objectIds)) {
... ... @@ -193,7 +193,6 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
193 193 return this.lw2mModels;
194 194 }
195 195
196   -
197 196 onFocus = (): void => {
198 197 if (!this.dirty) {
199 198 this.lwm2mListFormGroup.get('objectLwm2m').updateValueAndValidity({onlySelf: true, emitEvent: true});
... ...
... ... @@ -25,7 +25,6 @@ import { coerceBooleanProperty } from '@angular/cdk/coercion';
25 25 @Component({
26 26 selector: 'tb-profile-lwm2m-observe-attr-telemetry-resource',
27 27 templateUrl: './lwm2m-observe-attr-telemetry-resource.component.html',
28   - styleUrls: [],
29 28 providers: [
30 29 {
31 30 provide: NG_VALUE_ACCESSOR,
... ...
... ... @@ -28,7 +28,7 @@ import {
28 28 import { Store } from '@ngrx/store';
29 29 import { AppState } from '@core/core.state';
30 30 import { coerceBooleanProperty } from '@angular/cdk/coercion';
31   -import { Instance, ObjectLwM2M, ResourceLwM2M } from './profile-config.models';
  31 +import { CLIENT_LWM2M, Instance, INSTANCES, ObjectLwM2M, ResourceLwM2M, RESOURCES } from './profile-config.models';
32 32 import { deepClone, isDefinedAndNotNull, isEqual, isUndefined } from '@core/utils';
33 33 import { MatDialog } from '@angular/material/dialog';
34 34 import { TranslateService } from '@ngx-translate/core';
... ... @@ -78,7 +78,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor
78 78 private dialog: MatDialog,
79 79 public translate: TranslateService) {
80 80 this.observeAttrTelemetryFormGroup = this.fb.group({
81   - clientLwM2M: this.fb.array([])
  81 + [CLIENT_LWM2M]: this.fb.array([])
82 82 });
83 83 this.observeAttrTelemetryFormGroup.valueChanges.subscribe(value => {
84 84 if (isUndefined(this.disabled) || !this.disabled) {
... ... @@ -87,7 +87,8 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor
87 87 });
88 88 }
89 89
90   - private propagateChange = (v: any) => { };
  90 + private propagateChange = (v: any) => {
  91 + };
91 92
92 93 registerOnChange(fn: any): void {
93 94 this.propagateChange = fn;
... ... @@ -123,14 +124,14 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor
123 124 }
124 125 }
125 126
126   - writeValue(value: any): void {
  127 + writeValue(value: {}): void {
127 128 if (isDefinedAndNotNull(value)) {
128   - this.buildClientObjectsLwM2M(value.clientLwM2M);
  129 + this.buildClientObjectsLwM2M(value[CLIENT_LWM2M]);
129 130 }
130 131 }
131 132
132 133 private buildClientObjectsLwM2M = (objectsLwM2M: ObjectLwM2M []): void => {
133   - this.observeAttrTelemetryFormGroup.setControl('clientLwM2M',
  134 + this.observeAttrTelemetryFormGroup.setControl(CLIENT_LWM2M,
134 135 this.createObjectsLwM2M(objectsLwM2M)
135 136 );
136 137 }
... ... @@ -157,23 +158,23 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor
157 158 }
158 159
159 160 get clientLwM2MFormArray(): FormArray {
160   - return this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray;
  161 + return this.observeAttrTelemetryFormGroup.get(CLIENT_LWM2M) as FormArray;
161 162 }
162 163
163 164 instancesLwm2mFormArray = (objectLwM2M: AbstractControl): FormArray => {
164   - return objectLwM2M.get('instances') as FormArray;
  165 + return objectLwM2M.get(INSTANCES) as FormArray;
165 166 }
166 167
167 168 changeInstanceResourcesCheckBox = (value: boolean, instance: AbstractControl, type: string): void => {
168   - const resources = deepClone(instance.get('resources').value as ResourceLwM2M[]);
  169 + const resources = deepClone(instance.get(RESOURCES).value as ResourceLwM2M[]);
169 170 resources.forEach(resource => resource[type] = value);
170   - instance.get('resources').patchValue(resources);
  171 + instance.get(RESOURCES).patchValue(resources);
171 172 this.propagateChange(this.observeAttrTelemetryFormGroup.value);
172 173 }
173 174
174 175 private updateValidators = (): void => {
175   - this.observeAttrTelemetryFormGroup.get('clientLwM2M').setValidators(this.required ? Validators.required : []);
176   - this.observeAttrTelemetryFormGroup.get('clientLwM2M').updateValueAndValidity();
  176 + this.observeAttrTelemetryFormGroup.get(CLIENT_LWM2M).setValidators(this.required ? Validators.required : []);
  177 + this.observeAttrTelemetryFormGroup.get(CLIENT_LWM2M).updateValueAndValidity();
177 178 }
178 179
179 180 trackByParams = (index: number, element: any): number => {
... ... @@ -181,7 +182,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor
181 182 }
182 183
183 184 getIndeterminate = (instance: AbstractControl, type: string): boolean => {
184   - const resources = instance.get('resources').value as ResourceLwM2M[];
  185 + const resources = instance.get(RESOURCES).value as ResourceLwM2M[];
185 186 if (isDefinedAndNotNull(resources)) {
186 187 const checkedResource = resources.filter(resource => resource[type]);
187 188 return checkedResource.length !== 0 && checkedResource.length !== resources.length;
... ... @@ -190,7 +191,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor
190 191 }
191 192
192 193 getChecked = (instance: AbstractControl, type: string): boolean => {
193   - const resources = instance.get('resources').value as ResourceLwM2M[];
  194 + const resources = instance.get(RESOURCES).value as ResourceLwM2M[];
194 195 return isDefinedAndNotNull(resources) && resources.every(resource => resource[type]);
195 196 }
196 197
... ... @@ -239,10 +240,10 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor
239 240 }
240 241
241 242 private updateInstancesIds = (data: Lwm2mObjectAddInstancesData): void => {
242   - const objectLwM2MFormGroup = (this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray).controls
  243 + const objectLwM2MFormGroup = (this.observeAttrTelemetryFormGroup.get(CLIENT_LWM2M) as FormArray).controls
243 244 .find(e => e.value.id === data.objectId) as FormGroup;
244 245 const instancesArray = objectLwM2MFormGroup.value.instances as Instance [];
245   - const instancesFormArray = objectLwM2MFormGroup.get('instances') as FormArray;
  246 + const instancesFormArray = objectLwM2MFormGroup.get(INSTANCES) as FormArray;
246 247 const instance0 = deepClone(instancesFormArray.at(0).value as Instance);
247 248 instance0.resources.forEach(r => {
248 249 r.attribute = false;
... ...
... ... @@ -14,11 +14,16 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -export const OBSERVE_ATTR = 'observeAttr';
  17 +import { JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point';
  18 +
  19 +export const INSTANCES = 'instances';
  20 +export const RESOURCES = 'resources';
  21 +export const OBSERVE_ATTR_TELEMETRY = 'observeAttrTelemetry';
18 22 export const OBSERVE = 'observe';
19   -export const ATTR = 'attribute';
  23 +export const ATTRIBUTE = 'attribute';
20 24 export const TELEMETRY = 'telemetry';
21 25 export const KEY_NAME = 'keyName';
  26 +export const CLIENT_LWM2M = 'clientLwM2M';
22 27 export const DEFAULT_ID_SERVER = 123;
23 28 export const DEFAULT_ID_BOOTSTRAP = 111;
24 29 export const DEFAULT_HOST_NAME = 'localhost';
... ... @@ -53,6 +58,11 @@ export const SECURITY_CONFIG_MODE_NAMES = new Map<SECURITY_CONFIG_MODE, string>(
53 58 ]
54 59 );
55 60
  61 +export interface ModelValue {
  62 + objectIds: number[] | null,
  63 + objectsList: ObjectLwM2M[]
  64 +}
  65 +
56 66 export interface BootstrapServersSecurityConfig {
57 67 shortId: number;
58 68 lifetime: number;
... ... @@ -89,7 +99,7 @@ export interface ObservableAttributes {
89 99 observe: string[];
90 100 attribute: string[];
91 101 telemetry: string[];
92   - keyName: string[];
  102 + keyName: {};
93 103 }
94 104
95 105 export function getDefaultBootstrapServersSecurityConfig(): BootstrapServersSecurityConfig {
... ... @@ -138,7 +148,7 @@ export function getDefaultProfileConfig(hostname?: any): ProfileConfigModels {
138 148 observe: [],
139 149 attribute: [],
140 150 telemetry: [],
141   - keyName: []
  151 + keyName: {}
142 152 }
143 153 };
144 154 }
... ...