From 426dbbeea11597b8b999cdd55c4375527367f71a Mon Sep 17 00:00:00 2001 From: Chantsova Ekaterina Date: Tue, 16 Apr 2019 11:38:22 +0300 Subject: [PATCH] Add ability to choose direction of legend items in legend settings --- ui/src/app/common/types.constant.js | 10 ++++++++++ .../legend-config-panel.controller.js | 18 ++++++++++++++++- .../components/legend-config-panel.tpl.html | 20 ++++++++++++++----- .../app/components/legend-config.directive.js | 3 +++ ui/src/app/components/legend-config.scss | 4 ++-- ui/src/app/components/legend.directive.js | 2 ++ ui/src/app/components/legend.scss | 4 ++++ ui/src/app/components/legend.tpl.html | 4 ++-- ui/src/app/locale/locale.constant-en_US.json | 5 +++++ ui/src/app/locale/locale.constant-ru_RU.json | 5 +++++ ui/src/app/locale/locale.constant-uk_UA.json | 5 +++++ 11 files changed, 70 insertions(+), 10 deletions(-) diff --git a/ui/src/app/common/types.constant.js b/ui/src/app/common/types.constant.js index ed75737ca7..8e85e1a054 100644 --- a/ui/src/app/common/types.constant.js +++ b/ui/src/app/common/types.constant.js @@ -276,6 +276,16 @@ export default angular.module('thingsboard.types', []) name: 'alias.filter-type-entity-view-search-query' } }, + direction: { + column: { + value: "column", + name: "direction.column" + }, + row: { + value: "row", + name: "direction.row" + } + }, position: { top: { value: "top", diff --git a/ui/src/app/components/legend-config-panel.controller.js b/ui/src/app/components/legend-config-panel.controller.js index 9365c3a2f2..6253da01a5 100644 --- a/ui/src/app/components/legend-config-panel.controller.js +++ b/ui/src/app/components/legend-config-panel.controller.js @@ -21,10 +21,26 @@ export default function LegendConfigPanelController(mdPanelRef, $scope, types, l vm.legendConfig = legendConfig; vm.onLegendConfigUpdate = onLegendConfigUpdate; vm.positions = types.position; + vm.directions = types.direction; + vm.isRowDirection = vm.legendConfig.direction === types.direction.row.value; vm._mdPanelRef.config.onOpenComplete = function () { $scope.theForm.$setPristine(); - } + }; + + vm.onChangeDirection = function() { + if (vm.legendConfig.direction === types.direction.row.value) { + vm.isRowDirection = true; + vm.legendConfig.position = types.position.bottom.value; + vm.legendConfig.showMin = false; + vm.legendConfig.showMax = false; + vm.legendConfig.showAvg = false; + vm.legendConfig.showTotal = false; + } + else { + vm.isRowDirection = false; + } + }; $scope.$watch('vm.legendConfig', function () { if (onLegendConfigUpdate) { diff --git a/ui/src/app/components/legend-config-panel.tpl.html b/ui/src/app/components/legend-config-panel.tpl.html index 2e4eb5f00a..848330744d 100644 --- a/ui/src/app/components/legend-config-panel.tpl.html +++ b/ui/src/app/components/legend-config-panel.tpl.html @@ -20,24 +20,34 @@
+ + + + + {{direction.name | translate}} + + + - + {{pos.name | translate}} - {{ 'legend.show-min' | translate }} - {{ 'legend.show-max' | translate }} - {{ 'legend.show-avg' | translate }} - {{ 'legend.show-total' | translate }} diff --git a/ui/src/app/components/legend-config.directive.js b/ui/src/app/components/legend-config.directive.js index f68bc0afd9..2cf59f40ec 100644 --- a/ui/src/app/components/legend-config.directive.js +++ b/ui/src/app/components/legend-config.directive.js @@ -102,6 +102,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) { scope.updateView = function () { var value = {}; var model = scope.model; + value.direction = model.direction; value.position = model.position; value.showMin = model.showMin; value.showMax = model.showMax; @@ -117,6 +118,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) { scope.model = {}; } var model = scope.model; + model.direction = value.direction || types.direction.column.value; model.position = value.position || types.position.bottom.value; model.showMin = angular.isDefined(value.showMin) ? value.showMin : false; model.showMax = angular.isDefined(value.showMax) ? value.showMax : false; @@ -124,6 +126,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) { model.showTotal = angular.isDefined(value.showTotal) ? value.showTotal : false; } else { scope.model = { + direction: types.direction.column.value, position: types.position.bottom.value, showMin: false, showMax: false, diff --git a/ui/src/app/components/legend-config.scss b/ui/src/app/components/legend-config.scss index 3f64a2fcab..e131470312 100644 --- a/ui/src/app/components/legend-config.scss +++ b/ui/src/app/components/legend-config.scss @@ -21,7 +21,7 @@ .tb-legend-config-panel { min-width: 220px; - max-height: 220px; + max-height: 300px; overflow: hidden; background: #fff; border-radius: 4px; @@ -41,7 +41,7 @@ } .md-padding { - padding: 0 16px; + padding: 12px 16px 0; } } diff --git a/ui/src/app/components/legend.directive.js b/ui/src/app/components/legend.directive.js index 4b38be22aa..76ffdb4e78 100644 --- a/ui/src/app/components/legend.directive.js +++ b/ui/src/app/components/legend.directive.js @@ -43,6 +43,8 @@ function Legend($compile, $templateCache, types) { scope.isHorizontal = scope.legendConfig.position === types.position.bottom.value || scope.legendConfig.position === types.position.top.value; + scope.isRowDirection = scope.legendConfig.direction === types.direction.row.value; + scope.toggleHideData = function(index) { scope.legendData.keys[index].dataKey.hidden = !scope.legendData.keys[index].dataKey.hidden; } diff --git a/ui/src/app/components/legend.scss b/ui/src/app/components/legend.scss index b5bc68252d..b363319e95 100644 --- a/ui/src/app/components/legend.scss +++ b/ui/src/app/components/legend.scss @@ -57,5 +57,9 @@ table.tb-legend { opacity: .6; } } + + &.tb-row-direction { + display: inline-block; + } } } diff --git a/ui/src/app/components/legend.tpl.html b/ui/src/app/components/legend.tpl.html index 31047bb8d8..d8ce5df1cb 100644 --- a/ui/src/app/components/legend.tpl.html +++ b/ui/src/app/components/legend.tpl.html @@ -17,7 +17,7 @@ --> - + @@ -26,7 +26,7 @@ - +
{{ 'legend.min' | translate }} {{ 'legend.max' | translate }}