Merge pull request #2 from volodymyr-babak/import-updates
Fixes for import
This commit is contained in:
commit
2fbdda052a
@ -53,7 +53,7 @@ import {
|
|||||||
ImportEntityData
|
ImportEntityData
|
||||||
} from '@shared/models/entity.models';
|
} from '@shared/models/entity.models';
|
||||||
import { EntityRelationService } from '@core/http/entity-relation.service';
|
import { EntityRelationService } from '@core/http/entity-relation.service';
|
||||||
import { deepClone, isDefined, isDefinedAndNotNull } from '@core/utils';
|
import { deepClone, generateSecret, guid, isDefined, isDefinedAndNotNull } from '@core/utils';
|
||||||
import { Asset } from '@shared/models/asset.models';
|
import { Asset } from '@shared/models/asset.models';
|
||||||
import { Device, DeviceCredentialsType } from '@shared/models/device.models';
|
import { Device, DeviceCredentialsType } from '@shared/models/device.models';
|
||||||
import { AttributeService } from '@core/http/attribute.service';
|
import { AttributeService } from '@core/http/attribute.service';
|
||||||
@ -1011,9 +1011,9 @@ export class EntityService {
|
|||||||
description: edgeEntityData.description
|
description: edgeEntityData.description
|
||||||
},
|
},
|
||||||
edgeLicenseKey: edgeEntityData.edgeLicenseKey,
|
edgeLicenseKey: edgeEntityData.edgeLicenseKey,
|
||||||
cloudEndpoint: edgeEntityData.cloudEndpoint,
|
cloudEndpoint: edgeEntityData.cloudEndpoint !== '' ? edgeEntityData.cloudEndpoint : window.location.origin,
|
||||||
routingKey: edgeEntityData.routingKey,
|
routingKey: edgeEntityData.routingKey !== '' ? edgeEntityData.routingKey : guid(),
|
||||||
secret: edgeEntityData.secret
|
secret: edgeEntityData.secret !== '' ? edgeEntityData.secret : generateSecret(20)
|
||||||
};
|
};
|
||||||
saveEntityObservable = this.edgeService.saveEdge(edge, config);
|
saveEntityObservable = this.edgeService.saveEdge(edge, config);
|
||||||
break;
|
break;
|
||||||
@ -1028,41 +1028,6 @@ export class EntityService {
|
|||||||
let result;
|
let result;
|
||||||
let additionalInfo;
|
let additionalInfo;
|
||||||
switch (entityType) {
|
switch (entityType) {
|
||||||
case EntityType.EDGE:
|
|
||||||
result = entity as Edge;
|
|
||||||
additionalInfo = result.additionalInfo || {};
|
|
||||||
const edgeEntityData: EdgeImportEntityData = entityData as EdgeImportEntityData;
|
|
||||||
if (result.label !== edgeEntityData.label ||
|
|
||||||
result.type !== edgeEntityData.type ||
|
|
||||||
result.cloudEndpoint !== edgeEntityData.cloudEndpoint ||
|
|
||||||
result.edgeLicenseKey !== edgeEntityData.edgeLicenseKey ||
|
|
||||||
result.routingKey !== edgeEntityData.routingKey ||
|
|
||||||
result.secret !== edgeEntityData.secret ||
|
|
||||||
additionalInfo.description !== edgeEntityData.description) {
|
|
||||||
result.type = edgeEntityData.type;
|
|
||||||
if (edgeEntityData.label !== '') {
|
|
||||||
result.label = edgeEntityData.label;
|
|
||||||
}
|
|
||||||
if (edgeEntityData.description !== '') {
|
|
||||||
result.additionalInfo = additionalInfo;
|
|
||||||
result.additionalInfo.description = edgeEntityData.description;
|
|
||||||
}
|
|
||||||
if (edgeEntityData.cloudEndpoint !== '') {
|
|
||||||
result.cloudEndpoint = edgeEntityData.cloudEndpoint;
|
|
||||||
}
|
|
||||||
if (edgeEntityData.edgeLicenseKey !== '') {
|
|
||||||
result.edgeLicenseKey = edgeEntityData.edgeLicenseKey;
|
|
||||||
}
|
|
||||||
if (edgeEntityData.routingKey !== '') {
|
|
||||||
result.routingKey = edgeEntityData.routingKey;
|
|
||||||
}
|
|
||||||
if (edgeEntityData.cloudEndpoint !== '') {
|
|
||||||
result.secret = edgeEntityData.secret;
|
|
||||||
}
|
|
||||||
tasks.push(this.edgeService.saveEdge(result, config));
|
|
||||||
}
|
|
||||||
tasks.push(this.saveEntityData(entity.id, edgeEntityData, config));
|
|
||||||
break;
|
|
||||||
case EntityType.ASSET:
|
case EntityType.ASSET:
|
||||||
case EntityType.DEVICE:
|
case EntityType.DEVICE:
|
||||||
result = entity as (Device | Asset);
|
result = entity as (Device | Asset);
|
||||||
@ -1089,6 +1054,37 @@ export class EntityService {
|
|||||||
}
|
}
|
||||||
tasks.push(this.saveEntityData(entity.id, entityData, config));
|
tasks.push(this.saveEntityData(entity.id, entityData, config));
|
||||||
break;
|
break;
|
||||||
|
case EntityType.EDGE:
|
||||||
|
result = entity as Edge;
|
||||||
|
additionalInfo = result.additionalInfo || {};
|
||||||
|
const edgeEntityData: EdgeImportEntityData = entityData as EdgeImportEntityData;
|
||||||
|
if (result.label !== edgeEntityData.label ||
|
||||||
|
result.type !== edgeEntityData.type ||
|
||||||
|
(edgeEntityData.cloudEndpoint !== '' && result.cloudEndpoint !== edgeEntityData.cloudEndpoint) ||
|
||||||
|
(edgeEntityData.edgeLicenseKey !== '' && result.edgeLicenseKey !== edgeEntityData.edgeLicenseKey) ||
|
||||||
|
(edgeEntityData.routingKey !== '' && result.routingKey !== edgeEntityData.routingKey) ||
|
||||||
|
(edgeEntityData.secret !== '' && result.secret !== edgeEntityData.secret) ||
|
||||||
|
additionalInfo.description !== edgeEntityData.description) {
|
||||||
|
result.label = edgeEntityData.label;
|
||||||
|
result.type = edgeEntityData.type;
|
||||||
|
result.additionalInfo = additionalInfo;
|
||||||
|
result.additionalInfo.description = edgeEntityData.description;
|
||||||
|
if (edgeEntityData.cloudEndpoint !== '') {
|
||||||
|
result.cloudEndpoint = edgeEntityData.cloudEndpoint;
|
||||||
|
}
|
||||||
|
if (edgeEntityData.edgeLicenseKey !== '') {
|
||||||
|
result.edgeLicenseKey = edgeEntityData.edgeLicenseKey;
|
||||||
|
}
|
||||||
|
if (edgeEntityData.routingKey !== '') {
|
||||||
|
result.routingKey = edgeEntityData.routingKey;
|
||||||
|
}
|
||||||
|
if (edgeEntityData.secret !== '') {
|
||||||
|
result.secret = edgeEntityData.secret;
|
||||||
|
}
|
||||||
|
tasks.push(this.edgeService.saveEdge(result, config));
|
||||||
|
}
|
||||||
|
tasks.push(this.saveEntityData(entity.id, edgeEntityData, config));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,6 @@ import {
|
|||||||
} from '@home/components/import-export/import-export.models';
|
} from '@home/components/import-export/import-export.models';
|
||||||
import { EdgeImportEntityData, ImportEntitiesResultInfo, ImportEntityData } from '@app/shared/models/entity.models';
|
import { EdgeImportEntityData, ImportEntitiesResultInfo, ImportEntityData } from '@app/shared/models/entity.models';
|
||||||
import { ImportExportService } from '@home/components/import-export/import-export.service';
|
import { ImportExportService } from '@home/components/import-export/import-export.service';
|
||||||
import { generateSecret, guid } from '@core/utils';
|
|
||||||
|
|
||||||
export interface ImportDialogCsvData {
|
export interface ImportDialogCsvData {
|
||||||
entityType: EntityType;
|
entityType: EntityType;
|
||||||
@ -284,9 +283,9 @@ export class ImportDialogCsvComponent extends DialogComponent<ImportDialogCsvCom
|
|||||||
if (this.entityType === EntityType.EDGE) {
|
if (this.entityType === EntityType.EDGE) {
|
||||||
const edgeEntityData: EdgeImportEntityData = entityData as EdgeImportEntityData;
|
const edgeEntityData: EdgeImportEntityData = entityData as EdgeImportEntityData;
|
||||||
edgeEntityData.edgeLicenseKey = '';
|
edgeEntityData.edgeLicenseKey = '';
|
||||||
edgeEntityData.cloudEndpoint = window.location.origin;
|
edgeEntityData.cloudEndpoint = '';
|
||||||
edgeEntityData.routingKey = guid();
|
edgeEntityData.routingKey = '';
|
||||||
edgeEntityData.secret = generateSecret(20);
|
edgeEntityData.secret = '';
|
||||||
return edgeEntityData;
|
return edgeEntityData;
|
||||||
} else {
|
} else {
|
||||||
return entityData;
|
return entityData;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user