...
|
...
|
@@ -53,7 +53,7 @@ import { |
53
|
53
|
ImportEntityData
|
54
|
54
|
} from '@shared/models/entity.models';
|
55
|
55
|
import { EntityRelationService } from '@core/http/entity-relation.service';
|
56
|
|
-import { deepClone, isDefined, isDefinedAndNotNull } from '@core/utils';
|
|
56
|
+import { deepClone, generateSecret, guid, isDefined, isDefinedAndNotNull } from '@core/utils';
|
57
|
57
|
import { Asset } from '@shared/models/asset.models';
|
58
|
58
|
import { Device, DeviceCredentialsType } from '@shared/models/device.models';
|
59
|
59
|
import { AttributeService } from '@core/http/attribute.service';
|
...
|
...
|
@@ -1011,9 +1011,9 @@ export class EntityService { |
1011
|
1011
|
description: edgeEntityData.description
|
1012
|
1012
|
},
|
1013
|
1013
|
edgeLicenseKey: edgeEntityData.edgeLicenseKey,
|
1014
|
|
- cloudEndpoint: edgeEntityData.cloudEndpoint,
|
1015
|
|
- routingKey: edgeEntityData.routingKey,
|
1016
|
|
- secret: edgeEntityData.secret
|
|
1014
|
+ cloudEndpoint: edgeEntityData.cloudEndpoint !== '' ? edgeEntityData.cloudEndpoint : window.location.origin,
|
|
1015
|
+ routingKey: edgeEntityData.routingKey !== '' ? edgeEntityData.routingKey : guid(),
|
|
1016
|
+ secret: edgeEntityData.secret !== '' ? edgeEntityData.secret : generateSecret(20)
|
1017
|
1017
|
};
|
1018
|
1018
|
saveEntityObservable = this.edgeService.saveEdge(edge, config);
|
1019
|
1019
|
break;
|
...
|
...
|
@@ -1028,41 +1028,6 @@ export class EntityService { |
1028
|
1028
|
let result;
|
1029
|
1029
|
let additionalInfo;
|
1030
|
1030
|
switch (entityType) {
|
1031
|
|
- case EntityType.EDGE:
|
1032
|
|
- result = entity as Edge;
|
1033
|
|
- additionalInfo = result.additionalInfo || {};
|
1034
|
|
- const edgeEntityData: EdgeImportEntityData = entityData as EdgeImportEntityData;
|
1035
|
|
- if (result.label !== edgeEntityData.label ||
|
1036
|
|
- result.type !== edgeEntityData.type ||
|
1037
|
|
- result.cloudEndpoint !== edgeEntityData.cloudEndpoint ||
|
1038
|
|
- result.edgeLicenseKey !== edgeEntityData.edgeLicenseKey ||
|
1039
|
|
- result.routingKey !== edgeEntityData.routingKey ||
|
1040
|
|
- result.secret !== edgeEntityData.secret ||
|
1041
|
|
- additionalInfo.description !== edgeEntityData.description) {
|
1042
|
|
- result.type = edgeEntityData.type;
|
1043
|
|
- if (edgeEntityData.label !== '') {
|
1044
|
|
- result.label = edgeEntityData.label;
|
1045
|
|
- }
|
1046
|
|
- if (edgeEntityData.description !== '') {
|
1047
|
|
- result.additionalInfo = additionalInfo;
|
1048
|
|
- result.additionalInfo.description = edgeEntityData.description;
|
1049
|
|
- }
|
1050
|
|
- if (edgeEntityData.cloudEndpoint !== '') {
|
1051
|
|
- result.cloudEndpoint = edgeEntityData.cloudEndpoint;
|
1052
|
|
- }
|
1053
|
|
- if (edgeEntityData.edgeLicenseKey !== '') {
|
1054
|
|
- result.edgeLicenseKey = edgeEntityData.edgeLicenseKey;
|
1055
|
|
- }
|
1056
|
|
- if (edgeEntityData.routingKey !== '') {
|
1057
|
|
- result.routingKey = edgeEntityData.routingKey;
|
1058
|
|
- }
|
1059
|
|
- if (edgeEntityData.cloudEndpoint !== '') {
|
1060
|
|
- result.secret = edgeEntityData.secret;
|
1061
|
|
- }
|
1062
|
|
- tasks.push(this.edgeService.saveEdge(result, config));
|
1063
|
|
- }
|
1064
|
|
- tasks.push(this.saveEntityData(entity.id, edgeEntityData, config));
|
1065
|
|
- break;
|
1066
|
1031
|
case EntityType.ASSET:
|
1067
|
1032
|
case EntityType.DEVICE:
|
1068
|
1033
|
result = entity as (Device | Asset);
|
...
|
...
|
@@ -1089,6 +1054,37 @@ export class EntityService { |
1089
|
1054
|
}
|
1090
|
1055
|
tasks.push(this.saveEntityData(entity.id, entityData, config));
|
1091
|
1056
|
break;
|
|
1057
|
+ case EntityType.EDGE:
|
|
1058
|
+ result = entity as Edge;
|
|
1059
|
+ additionalInfo = result.additionalInfo || {};
|
|
1060
|
+ const edgeEntityData: EdgeImportEntityData = entityData as EdgeImportEntityData;
|
|
1061
|
+ if (result.label !== edgeEntityData.label ||
|
|
1062
|
+ result.type !== edgeEntityData.type ||
|
|
1063
|
+ (edgeEntityData.cloudEndpoint !== '' && result.cloudEndpoint !== edgeEntityData.cloudEndpoint) ||
|
|
1064
|
+ (edgeEntityData.edgeLicenseKey !== '' && result.edgeLicenseKey !== edgeEntityData.edgeLicenseKey) ||
|
|
1065
|
+ (edgeEntityData.routingKey !== '' && result.routingKey !== edgeEntityData.routingKey) ||
|
|
1066
|
+ (edgeEntityData.secret !== '' && result.secret !== edgeEntityData.secret) ||
|
|
1067
|
+ additionalInfo.description !== edgeEntityData.description) {
|
|
1068
|
+ result.label = edgeEntityData.label;
|
|
1069
|
+ result.type = edgeEntityData.type;
|
|
1070
|
+ result.additionalInfo = additionalInfo;
|
|
1071
|
+ result.additionalInfo.description = edgeEntityData.description;
|
|
1072
|
+ if (edgeEntityData.cloudEndpoint !== '') {
|
|
1073
|
+ result.cloudEndpoint = edgeEntityData.cloudEndpoint;
|
|
1074
|
+ }
|
|
1075
|
+ if (edgeEntityData.edgeLicenseKey !== '') {
|
|
1076
|
+ result.edgeLicenseKey = edgeEntityData.edgeLicenseKey;
|
|
1077
|
+ }
|
|
1078
|
+ if (edgeEntityData.routingKey !== '') {
|
|
1079
|
+ result.routingKey = edgeEntityData.routingKey;
|
|
1080
|
+ }
|
|
1081
|
+ if (edgeEntityData.secret !== '') {
|
|
1082
|
+ result.secret = edgeEntityData.secret;
|
|
1083
|
+ }
|
|
1084
|
+ tasks.push(this.edgeService.saveEdge(result, config));
|
|
1085
|
+ }
|
|
1086
|
+ tasks.push(this.saveEntityData(entity.id, edgeEntityData, config));
|
|
1087
|
+ break;
|
1092
|
1088
|
}
|
1093
|
1089
|
return tasks;
|
1094
|
1090
|
}
|
...
|
...
|
|