Commit 1fac07ed5eeb7325729a52cd22d4af6199d5d990
Merge branch 'master' of github.com:thingsboard/thingsboard
Showing
3 changed files
with
16 additions
and
7 deletions
... | ... | @@ -23,6 +23,7 @@ import { |
23 | 23 | BINDING_MODE, |
24 | 24 | BINDING_MODE_NAMES, |
25 | 25 | getDefaultProfileConfig, |
26 | + Instance, | |
26 | 27 | INSTANCES, |
27 | 28 | KEY_NAME, |
28 | 29 | Lwm2mProfileConfigModels, |
... | ... | @@ -37,6 +38,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service'; |
37 | 38 | import { deepClone, isDefinedAndNotNull, isEmpty, isUndefined } from '@core/utils'; |
38 | 39 | import { JsonArray, JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point'; |
39 | 40 | import { Direction } from '@shared/models/page/sort-order'; |
41 | +import _ from 'lodash'; | |
40 | 42 | |
41 | 43 | @Component({ |
42 | 44 | selector: 'tb-profile-lwm2m-device-transport-configuration', |
... | ... | @@ -230,24 +232,30 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
230 | 232 | const isNotZeroInstanceId = (instance) => !instance.includes('/0/'); |
231 | 233 | return attribute.some(isNotZeroInstanceId) || telemetry.some(isNotZeroInstanceId); |
232 | 234 | } |
233 | - | |
234 | 235 | private addInstances = (attribute: string[], telemetry: string[], clientObserveAttrTelemetry: ObjectLwM2M[]): void => { |
235 | 236 | const instancesPath = attribute.concat(telemetry) |
236 | 237 | .filter(instance => !instance.includes('/0/')) |
237 | 238 | .map(instance => instance.slice(1, instance.lastIndexOf('/'))) |
238 | 239 | .sort(this.sortPath); |
239 | - | |
240 | 240 | new Set(instancesPath).forEach(path => { |
241 | 241 | const pathParameter = Array.from(path.split('/'), String); |
242 | 242 | const objectLwM2M = clientObserveAttrTelemetry.find(x => x.keyId === pathParameter[0]); |
243 | 243 | if (objectLwM2M) { |
244 | - const instance = deepClone(objectLwM2M.instances[0]); | |
245 | - instance.id = +pathParameter[1]; | |
244 | + const instance = this.updateInInstanceKeyName (objectLwM2M.instances[0], +pathParameter[1]); | |
246 | 245 | objectLwM2M.instances.push(instance); |
247 | 246 | } |
248 | 247 | }); |
249 | 248 | } |
250 | 249 | |
250 | + private updateInInstanceKeyName = (instance: Instance, instanceId: number): Instance => { | |
251 | + const instanceUpdate = deepClone(instance); | |
252 | + instanceUpdate.id = instanceId; | |
253 | + instanceUpdate.resources.forEach(resource => { | |
254 | + resource.keyName = _.camelCase(resource.name + instanceUpdate.id); | |
255 | + }) | |
256 | + return instanceUpdate; | |
257 | + } | |
258 | + | |
251 | 259 | private updateObserveAttrTelemetryObjects = (parameters: string[], objectLwM2MS: ObjectLwM2M[], |
252 | 260 | nameParameter: string): void => { |
253 | 261 | parameters.forEach(parameter => { | ... | ... |
... | ... | @@ -45,6 +45,7 @@ import { |
45 | 45 | Lwm2mObjectAddInstancesData, |
46 | 46 | Lwm2mObjectAddInstancesDialogComponent |
47 | 47 | } from '@home/components/profile/device/lwm2m/lwm2m-object-add-instances-dialog.component'; |
48 | +import _ from 'lodash'; | |
48 | 49 | |
49 | 50 | @Component({ |
50 | 51 | selector: 'tb-profile-lwm2m-observe-attr-telemetry', |
... | ... | @@ -261,7 +262,6 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor |
261 | 262 | r.attribute = false; |
262 | 263 | r.telemetry = false; |
263 | 264 | r.observe = false; |
264 | - r.keyName = {}; | |
265 | 265 | r.attributeLwm2m = {}; |
266 | 266 | }); |
267 | 267 | const valueOld = this.instancesToSetId(instancesArray); |
... | ... | @@ -280,7 +280,8 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor |
280 | 280 | private addInstancesNew = (idsAdd: Set<number>, objectLwM2MFormGroup: FormGroup, instancesFormArray: FormArray, |
281 | 281 | instanceNew: Instance): void => { |
282 | 282 | idsAdd.forEach(x => { |
283 | - this.pushInstance(instancesFormArray, x, instanceNew); | |
283 | + instanceNew.resources.forEach(resource => {resource.keyName = _.camelCase(resource.name + x);}); | |
284 | + this.pushInstance(instancesFormArray, x, deepClone(instanceNew as Instance)); | |
284 | 285 | }); |
285 | 286 | (instancesFormArray.controls as FormGroup[]).sort((a, b) => a.value.id - b.value.id); |
286 | 287 | } | ... | ... |