thingsboard-developers
Details
ui/src/app/api/alias-controller.js 10(+10 -0)
diff --git a/ui/src/app/api/alias-controller.js b/ui/src/app/api/alias-controller.js
index 66781a8..9074fef 100644
--- a/ui/src/app/api/alias-controller.js
+++ b/ui/src/app/api/alias-controller.js
@@ -143,6 +143,11 @@ export default class AliasController {
for (var i=0;i<resolvedEntities.length;i++) {
var resolvedEntity = resolvedEntities[i];
newDatasource = angular.copy(datasource);
+ if (resolvedEntity.origEntity) {
+ newDatasource.entity = angular.copy(resolvedEntity.origEntity);
+ } else {
+ newDatasource.entity = {};
+ }
newDatasource.entityId = resolvedEntity.id;
newDatasource.entityType = resolvedEntity.entityType;
newDatasource.entityName = resolvedEntity.name;
@@ -164,6 +169,11 @@ export default class AliasController {
} else {
var entity = aliasInfo.currentEntity;
if (entity) {
+ if (entity.origEntity) {
+ datasource.entity = angular.copy(entity.origEntity);
+ } else {
+ datasource.entity = {};
+ }
datasource.entityId = entity.id;
datasource.entityType = entity.entityType;
datasource.entityName = entity.name;
ui/src/app/api/entity.service.js 44(+32 -12)
diff --git a/ui/src/app/api/entity.service.js b/ui/src/app/api/entity.service.js
index 00c7ecf..d5751f1 100644
--- a/ui/src/app/api/entity.service.js
+++ b/ui/src/app/api/entity.service.js
@@ -344,17 +344,21 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
}
function entityToEntityInfo(entity) {
- return { name: entity.name, entityType: entity.id.entityType, id: entity.id.id, entityDescription: entity.additionalInfo?entity.additionalInfo.description:"" };
+ return { origEntity: entity, name: entity.name, entityType: entity.id.entityType, id: entity.id.id, entityDescription: entity.additionalInfo?entity.additionalInfo.description:"" };
}
function entityRelationInfoToEntityInfo(entityRelationInfo, direction) {
+ var deferred = $q.defer();
var entityId = direction == types.entitySearchDirection.from ? entityRelationInfo.to : entityRelationInfo.from;
- var name = direction == types.entitySearchDirection.from ? entityRelationInfo.toName : entityRelationInfo.fromName;
- return {
- name: name,
- entityType: entityId.entityType,
- id: entityId.id
- };
+ getEntity(entityId.entityType, entityId.id, {ignoreLoading: true}).then(
+ function success(entity) {
+ deferred.resolve(entityToEntityInfo(entity));
+ },
+ function fail() {
+ deferred.reject();
+ }
+ );
+ return deferred.promise;
}
function entitiesToEntitiesInfo(entities) {
@@ -368,13 +372,22 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
}
function entityRelationInfosToEntitiesInfo(entityRelations, direction) {
- var entitiesInfo = [];
+ var deferred = $q.defer();
+ var entitiesInfoTaks = [];
if (entityRelations) {
for (var d = 0; d < entityRelations.length; d++) {
- entitiesInfo.push(entityRelationInfoToEntityInfo(entityRelations[d], direction));
+ entitiesInfoTaks.push(entityRelationInfoToEntityInfo(entityRelations[d], direction));
}
}
- return entitiesInfo;
+ $q.all(entitiesInfoTaks).then(
+ function success(entitiesInfo) {
+ deferred.resolve(entitiesInfo);
+ },
+ function fail() {
+ deferred.reject();
+ }
+ );
+ return deferred.promise;
}
@@ -581,8 +594,15 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
var limit = Math.min(allRelations.length, maxItems);
allRelations.length = limit;
}
- result.entities = entityRelationInfosToEntitiesInfo(allRelations, filter.direction);
- deferred.resolve(result);
+ entityRelationInfosToEntitiesInfo(allRelations, filter.direction).then(
+ function success(entities) {
+ result.entities = entities;
+ deferred.resolve(result);
+ },
+ function fail() {
+ deferred.reject();
+ }
+ );
} else {
deferred.reject();
}