|
@@ -23,6 +23,7 @@ import { |
|
@@ -23,6 +23,7 @@ import { |
23
|
BINDING_MODE,
|
23
|
BINDING_MODE,
|
24
|
BINDING_MODE_NAMES,
|
24
|
BINDING_MODE_NAMES,
|
25
|
getDefaultProfileConfig,
|
25
|
getDefaultProfileConfig,
|
|
|
26
|
+ Instance,
|
26
|
INSTANCES,
|
27
|
INSTANCES,
|
27
|
KEY_NAME,
|
28
|
KEY_NAME,
|
28
|
Lwm2mProfileConfigModels,
|
29
|
Lwm2mProfileConfigModels,
|
|
@@ -37,6 +38,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service'; |
|
@@ -37,6 +38,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service'; |
37
|
import { deepClone, isDefinedAndNotNull, isEmpty, isUndefined } from '@core/utils';
|
38
|
import { deepClone, isDefinedAndNotNull, isEmpty, isUndefined } from '@core/utils';
|
38
|
import { JsonArray, JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point';
|
39
|
import { JsonArray, JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point';
|
39
|
import { Direction } from '@shared/models/page/sort-order';
|
40
|
import { Direction } from '@shared/models/page/sort-order';
|
|
|
41
|
+import _ from 'lodash';
|
40
|
|
42
|
|
41
|
@Component({
|
43
|
@Component({
|
42
|
selector: 'tb-profile-lwm2m-device-transport-configuration',
|
44
|
selector: 'tb-profile-lwm2m-device-transport-configuration',
|
|
@@ -230,24 +232,30 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
@@ -230,24 +232,30 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
230
|
const isNotZeroInstanceId = (instance) => !instance.includes('/0/');
|
232
|
const isNotZeroInstanceId = (instance) => !instance.includes('/0/');
|
231
|
return attribute.some(isNotZeroInstanceId) || telemetry.some(isNotZeroInstanceId);
|
233
|
return attribute.some(isNotZeroInstanceId) || telemetry.some(isNotZeroInstanceId);
|
232
|
}
|
234
|
}
|
233
|
-
|
|
|
234
|
private addInstances = (attribute: string[], telemetry: string[], clientObserveAttrTelemetry: ObjectLwM2M[]): void => {
|
235
|
private addInstances = (attribute: string[], telemetry: string[], clientObserveAttrTelemetry: ObjectLwM2M[]): void => {
|
235
|
const instancesPath = attribute.concat(telemetry)
|
236
|
const instancesPath = attribute.concat(telemetry)
|
236
|
.filter(instance => !instance.includes('/0/'))
|
237
|
.filter(instance => !instance.includes('/0/'))
|
237
|
.map(instance => instance.slice(1, instance.lastIndexOf('/')))
|
238
|
.map(instance => instance.slice(1, instance.lastIndexOf('/')))
|
238
|
.sort(this.sortPath);
|
239
|
.sort(this.sortPath);
|
239
|
-
|
|
|
240
|
new Set(instancesPath).forEach(path => {
|
240
|
new Set(instancesPath).forEach(path => {
|
241
|
const pathParameter = Array.from(path.split('/'), String);
|
241
|
const pathParameter = Array.from(path.split('/'), String);
|
242
|
const objectLwM2M = clientObserveAttrTelemetry.find(x => x.keyId === pathParameter[0]);
|
242
|
const objectLwM2M = clientObserveAttrTelemetry.find(x => x.keyId === pathParameter[0]);
|
243
|
if (objectLwM2M) {
|
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
|
objectLwM2M.instances.push(instance);
|
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
|
private updateObserveAttrTelemetryObjects = (parameters: string[], objectLwM2MS: ObjectLwM2M[],
|
259
|
private updateObserveAttrTelemetryObjects = (parameters: string[], objectLwM2MS: ObjectLwM2M[],
|
252
|
nameParameter: string): void => {
|
260
|
nameParameter: string): void => {
|
253
|
parameters.forEach(parameter => {
|
261
|
parameters.forEach(parameter => {
|