From 308fa1fd8c497b0dcab14b61c96826dfa2737576 Mon Sep 17 00:00:00 2001 From: DudnikMaksym Date: Wed, 19 Feb 2020 15:24:02 +0200 Subject: [PATCH] UI: (#2372) Added fetchLastLevelOnly checkbox to alias query filter. Updated ENG, RUS, UKR locales. Updated getRelatedEntities and (constructRelatedEntitiesSearchQuery) function(s) by adding fetchLastLevelOnly attribute. --- ui/src/app/api/entity.service.js | 15 +++++---- ui/src/app/entity/entity-filter.directive.js | 1 + ui/src/app/entity/entity-filter.tpl.html | 32 ++++++++++++++++++++ ui/src/app/locale/locale.constant-en_US.json | 1 + ui/src/app/locale/locale.constant-ru_RU.json | 1 + ui/src/app/locale/locale.constant-uk_UA.json | 1 + 6 files changed, 45 insertions(+), 6 deletions(-) diff --git a/ui/src/app/api/entity.service.js b/ui/src/app/api/entity.service.js index 0a6b06d498..b795432dee 100644 --- a/ui/src/app/api/entity.service.js +++ b/ui/src/app/api/entity.service.js @@ -593,7 +593,8 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device parameters: { rootId: relationQueryRootEntityId.id, rootType: relationQueryRootEntityId.entityType, - direction: filter.direction + direction: filter.direction, + fetchLastLevelOnly: filter.fetchLastLevelOnly }, filters: filter.filters }; @@ -643,7 +644,8 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device parameters: { rootId: searchQueryRootEntityId.id, rootType: searchQueryRootEntityId.entityType, - direction: filter.direction + direction: filter.direction, + fetchLastLevelOnly: filter.fetchLastLevelOnly }, relationType: filter.relationType }; @@ -1075,10 +1077,10 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device } } - function getRelatedEntities(rootEntityId, entityType, entitySubTypes, maxLevel, keys, typeTranslatePrefix, relationType, direction) { + function getRelatedEntities(rootEntityId, entityType, entitySubTypes, maxLevel, keys, typeTranslatePrefix, relationType, direction, fetchLastLevelOnly) { var deferred = $q.defer(); - var entitySearchQuery = constructRelatedEntitiesSearchQuery(rootEntityId, entityType, entitySubTypes, maxLevel, relationType, direction); + var entitySearchQuery = constructRelatedEntitiesSearchQuery(rootEntityId, entityType, entitySubTypes, maxLevel, relationType, direction,fetchLastLevelOnly); if (!entitySearchQuery) { deferred.reject(); } else { @@ -1499,13 +1501,14 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device ); } - function constructRelatedEntitiesSearchQuery(rootEntityId, entityType, entitySubTypes, maxLevel, relationType, direction) { + function constructRelatedEntitiesSearchQuery(rootEntityId, entityType, entitySubTypes, maxLevel, relationType, direction, fetchLastLevelOnly) { var searchQuery = { parameters: { rootId: rootEntityId.id, rootType: rootEntityId.entityType, - direction: direction + direction: direction, + fetchLastLevelOnly: !!fetchLastLevelOnly }, relationType: relationType }; diff --git a/ui/src/app/entity/entity-filter.directive.js b/ui/src/app/entity/entity-filter.directive.js index e49d79d228..39e3892ff9 100644 --- a/ui/src/app/entity/entity-filter.directive.js +++ b/ui/src/app/entity/entity-filter.directive.js @@ -83,6 +83,7 @@ export default function EntityFilterDirective($compile, $templateCache, $q, $doc filter.rootEntity = null; filter.direction = types.entitySearchDirection.from; filter.maxLevel = 1; + filter.fetchLastLevelOnly = false; if (filter.type === types.aliasFilterType.relationsQuery.value) { filter.filters = []; } else if (filter.type === types.aliasFilterType.assetSearchQuery.value) { diff --git a/ui/src/app/entity/entity-filter.tpl.html b/ui/src/app/entity/entity-filter.tpl.html index eb889bd215..bfc63a7d24 100644 --- a/ui/src/app/entity/entity-filter.tpl.html +++ b/ui/src/app/entity/entity-filter.tpl.html @@ -161,6 +161,14 @@ +
+
+ + + +
+
@@ -222,6 +230,14 @@
+
+
+ + + +
+
@@ -291,6 +307,14 @@
+
+
+ + + +
+
@@ -360,6 +384,14 @@
+
+
+ + + +
+
diff --git a/ui/src/app/locale/locale.constant-en_US.json b/ui/src/app/locale/locale.constant-en_US.json index ba49ffb7fb..3527b82e06 100644 --- a/ui/src/app/locale/locale.constant-en_US.json +++ b/ui/src/app/locale/locale.constant-en_US.json @@ -207,6 +207,7 @@ "entity-filter-no-entity-matched": "No entities matching specified filter were found.", "no-entity-filter-specified": "No entity filter specified", "root-state-entity": "Use dashboard state entity as root", + "last-level-relation": "Fetch last level relation only", "root-entity": "Root entity", "state-entity-parameter-name": "State entity parameter name", "default-state-entity": "Default state entity", diff --git a/ui/src/app/locale/locale.constant-ru_RU.json b/ui/src/app/locale/locale.constant-ru_RU.json index f4ed6d5c93..8d8ab8fa1f 100644 --- a/ui/src/app/locale/locale.constant-ru_RU.json +++ b/ui/src/app/locale/locale.constant-ru_RU.json @@ -206,6 +206,7 @@ "entity-filter-no-entity-matched": "Объекты, соответствующие фильтру, не найдены.", "no-entity-filter-specified": "Не указан фильтр объектов", "root-state-entity": "Использовать объект, полученный из дашборда, как корневой", + "last-level-relation": "Использовать только отношения последнего уровня", "root-entity": "Корневой объект", "state-entity-parameter-name": "Название объекта состояния", "default-state-entity": "Объект состояния по умолчанию", diff --git a/ui/src/app/locale/locale.constant-uk_UA.json b/ui/src/app/locale/locale.constant-uk_UA.json index 53d16bea5e..a0cdfa1841 100644 --- a/ui/src/app/locale/locale.constant-uk_UA.json +++ b/ui/src/app/locale/locale.constant-uk_UA.json @@ -225,6 +225,7 @@ "entity-filter-no-entity-matched": "Не знайдено жодних сутностей, які відповідають вказаному фільтру.", "no-entity-filter-specified": "Фільтр обїектів не вказано", "root-state-entity": "Використовувати сутінсть стану як кореневу", + "last-level-relation": "Використовувати лише відношення останнього рівня", "group-state-entity": "Використовувати групу сутностей стану як кореневу", "root-entity": "Коренева сутність", "state-entity-parameter-name": "Параметр сутності стану",