Commit 426dbbeea11597b8b999cdd55c4375527367f71a
1 parent
d1c6a907
Add ability to choose direction of legend items in legend settings
Showing
11 changed files
with
70 additions
and
10 deletions
@@ -276,6 +276,16 @@ export default angular.module('thingsboard.types', []) | @@ -276,6 +276,16 @@ export default angular.module('thingsboard.types', []) | ||
276 | name: 'alias.filter-type-entity-view-search-query' | 276 | name: 'alias.filter-type-entity-view-search-query' |
277 | } | 277 | } |
278 | }, | 278 | }, |
279 | + direction: { | ||
280 | + column: { | ||
281 | + value: "column", | ||
282 | + name: "direction.column" | ||
283 | + }, | ||
284 | + row: { | ||
285 | + value: "row", | ||
286 | + name: "direction.row" | ||
287 | + } | ||
288 | + }, | ||
279 | position: { | 289 | position: { |
280 | top: { | 290 | top: { |
281 | value: "top", | 291 | value: "top", |
@@ -21,10 +21,26 @@ export default function LegendConfigPanelController(mdPanelRef, $scope, types, l | @@ -21,10 +21,26 @@ export default function LegendConfigPanelController(mdPanelRef, $scope, types, l | ||
21 | vm.legendConfig = legendConfig; | 21 | vm.legendConfig = legendConfig; |
22 | vm.onLegendConfigUpdate = onLegendConfigUpdate; | 22 | vm.onLegendConfigUpdate = onLegendConfigUpdate; |
23 | vm.positions = types.position; | 23 | vm.positions = types.position; |
24 | + vm.directions = types.direction; | ||
25 | + vm.isRowDirection = vm.legendConfig.direction === types.direction.row.value; | ||
24 | 26 | ||
25 | vm._mdPanelRef.config.onOpenComplete = function () { | 27 | vm._mdPanelRef.config.onOpenComplete = function () { |
26 | $scope.theForm.$setPristine(); | 28 | $scope.theForm.$setPristine(); |
27 | - } | 29 | + }; |
30 | + | ||
31 | + vm.onChangeDirection = function() { | ||
32 | + if (vm.legendConfig.direction === types.direction.row.value) { | ||
33 | + vm.isRowDirection = true; | ||
34 | + vm.legendConfig.position = types.position.bottom.value; | ||
35 | + vm.legendConfig.showMin = false; | ||
36 | + vm.legendConfig.showMax = false; | ||
37 | + vm.legendConfig.showAvg = false; | ||
38 | + vm.legendConfig.showTotal = false; | ||
39 | + } | ||
40 | + else { | ||
41 | + vm.isRowDirection = false; | ||
42 | + } | ||
43 | + }; | ||
28 | 44 | ||
29 | $scope.$watch('vm.legendConfig', function () { | 45 | $scope.$watch('vm.legendConfig', function () { |
30 | if (onLegendConfigUpdate) { | 46 | if (onLegendConfigUpdate) { |
@@ -21,23 +21,33 @@ | @@ -21,23 +21,33 @@ | ||
21 | <section layout="column"> | 21 | <section layout="column"> |
22 | <md-content class="md-padding" layout="column"> | 22 | <md-content class="md-padding" layout="column"> |
23 | <md-input-container> | 23 | <md-input-container> |
24 | + <label translate>legend.direction</label> | ||
25 | + <md-select ng-model="vm.legendConfig.direction" style="min-width: 150px;" | ||
26 | + ng-change="vm.onChangeDirection()"> | ||
27 | + <md-option ng-repeat="direction in vm.directions" ng-value="direction.value"> | ||
28 | + {{direction.name | translate}} | ||
29 | + </md-option> | ||
30 | + </md-select> | ||
31 | + </md-input-container> | ||
32 | + <md-input-container> | ||
24 | <label translate>legend.position</label> | 33 | <label translate>legend.position</label> |
25 | <md-select ng-model="vm.legendConfig.position" style="min-width: 150px;"> | 34 | <md-select ng-model="vm.legendConfig.position" style="min-width: 150px;"> |
26 | - <md-option ng-repeat="pos in vm.positions" ng-value="pos.value"> | 35 | + <md-option ng-repeat="pos in vm.positions" ng-value="pos.value" |
36 | + ng-disabled="(vm.isRowDirection && (pos.value === vm.positions.left.value || pos.value === vm.positions.right.value))"> | ||
27 | {{pos.name | translate}} | 37 | {{pos.name | translate}} |
28 | </md-option> | 38 | </md-option> |
29 | </md-select> | 39 | </md-select> |
30 | </md-input-container> | 40 | </md-input-container> |
31 | - <md-checkbox flex aria-label="{{ 'legend.show-min' | translate }}" | 41 | + <md-checkbox flex aria-label="{{ 'legend.show-min' | translate }}" ng-disabled="vm.isRowDirection" |
32 | ng-model="vm.legendConfig.showMin">{{ 'legend.show-min' | translate }} | 42 | ng-model="vm.legendConfig.showMin">{{ 'legend.show-min' | translate }} |
33 | </md-checkbox> | 43 | </md-checkbox> |
34 | - <md-checkbox flex aria-label="{{ 'legend.show-max' | translate }}" | 44 | + <md-checkbox flex aria-label="{{ 'legend.show-max' | translate }}" ng-disabled="vm.isRowDirection" |
35 | ng-model="vm.legendConfig.showMax">{{ 'legend.show-max' | translate }} | 45 | ng-model="vm.legendConfig.showMax">{{ 'legend.show-max' | translate }} |
36 | </md-checkbox> | 46 | </md-checkbox> |
37 | - <md-checkbox flex aria-label="{{ 'legend.show-avg' | translate }}" | 47 | + <md-checkbox flex aria-label="{{ 'legend.show-avg' | translate }}" ng-disabled="vm.isRowDirection" |
38 | ng-model="vm.legendConfig.showAvg">{{ 'legend.show-avg' | translate }} | 48 | ng-model="vm.legendConfig.showAvg">{{ 'legend.show-avg' | translate }} |
39 | </md-checkbox> | 49 | </md-checkbox> |
40 | - <md-checkbox flex aria-label="{{ 'legend.show-total' | translate }}" | 50 | + <md-checkbox flex aria-label="{{ 'legend.show-total' | translate }}" ng-disabled="vm.isRowDirection" |
41 | ng-model="vm.legendConfig.showTotal">{{ 'legend.show-total' | translate }} | 51 | ng-model="vm.legendConfig.showTotal">{{ 'legend.show-total' | translate }} |
42 | </md-checkbox> | 52 | </md-checkbox> |
43 | </md-content> | 53 | </md-content> |
@@ -102,6 +102,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) { | @@ -102,6 +102,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) { | ||
102 | scope.updateView = function () { | 102 | scope.updateView = function () { |
103 | var value = {}; | 103 | var value = {}; |
104 | var model = scope.model; | 104 | var model = scope.model; |
105 | + value.direction = model.direction; | ||
105 | value.position = model.position; | 106 | value.position = model.position; |
106 | value.showMin = model.showMin; | 107 | value.showMin = model.showMin; |
107 | value.showMax = model.showMax; | 108 | value.showMax = model.showMax; |
@@ -117,6 +118,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) { | @@ -117,6 +118,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) { | ||
117 | scope.model = {}; | 118 | scope.model = {}; |
118 | } | 119 | } |
119 | var model = scope.model; | 120 | var model = scope.model; |
121 | + model.direction = value.direction || types.direction.column.value; | ||
120 | model.position = value.position || types.position.bottom.value; | 122 | model.position = value.position || types.position.bottom.value; |
121 | model.showMin = angular.isDefined(value.showMin) ? value.showMin : false; | 123 | model.showMin = angular.isDefined(value.showMin) ? value.showMin : false; |
122 | model.showMax = angular.isDefined(value.showMax) ? value.showMax : false; | 124 | model.showMax = angular.isDefined(value.showMax) ? value.showMax : false; |
@@ -124,6 +126,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) { | @@ -124,6 +126,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) { | ||
124 | model.showTotal = angular.isDefined(value.showTotal) ? value.showTotal : false; | 126 | model.showTotal = angular.isDefined(value.showTotal) ? value.showTotal : false; |
125 | } else { | 127 | } else { |
126 | scope.model = { | 128 | scope.model = { |
129 | + direction: types.direction.column.value, | ||
127 | position: types.position.bottom.value, | 130 | position: types.position.bottom.value, |
128 | showMin: false, | 131 | showMin: false, |
129 | showMax: false, | 132 | showMax: false, |
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | 21 | ||
22 | .tb-legend-config-panel { | 22 | .tb-legend-config-panel { |
23 | min-width: 220px; | 23 | min-width: 220px; |
24 | - max-height: 220px; | 24 | + max-height: 300px; |
25 | overflow: hidden; | 25 | overflow: hidden; |
26 | background: #fff; | 26 | background: #fff; |
27 | border-radius: 4px; | 27 | border-radius: 4px; |
@@ -41,7 +41,7 @@ | @@ -41,7 +41,7 @@ | ||
41 | } | 41 | } |
42 | 42 | ||
43 | .md-padding { | 43 | .md-padding { |
44 | - padding: 0 16px; | 44 | + padding: 12px 16px 0; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 |
@@ -43,6 +43,8 @@ function Legend($compile, $templateCache, types) { | @@ -43,6 +43,8 @@ function Legend($compile, $templateCache, types) { | ||
43 | scope.isHorizontal = scope.legendConfig.position === types.position.bottom.value || | 43 | scope.isHorizontal = scope.legendConfig.position === types.position.bottom.value || |
44 | scope.legendConfig.position === types.position.top.value; | 44 | scope.legendConfig.position === types.position.top.value; |
45 | 45 | ||
46 | + scope.isRowDirection = scope.legendConfig.direction === types.direction.row.value; | ||
47 | + | ||
46 | scope.toggleHideData = function(index) { | 48 | scope.toggleHideData = function(index) { |
47 | scope.legendData.keys[index].dataKey.hidden = !scope.legendData.keys[index].dataKey.hidden; | 49 | scope.legendData.keys[index].dataKey.hidden = !scope.legendData.keys[index].dataKey.hidden; |
48 | } | 50 | } |
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | --> | 17 | --> |
18 | <table class="tb-legend"> | 18 | <table class="tb-legend"> |
19 | <thead> | 19 | <thead> |
20 | - <tr class="tb-legend-header"> | 20 | + <tr class="tb-legend-header" ng-if="!isRowDirection"> |
21 | <th colspan="2"></th> | 21 | <th colspan="2"></th> |
22 | <th ng-if="legendConfig.showMin === true">{{ 'legend.min' | translate }}</th> | 22 | <th ng-if="legendConfig.showMin === true">{{ 'legend.min' | translate }}</th> |
23 | <th ng-if="legendConfig.showMax === true">{{ 'legend.max' | translate }}</th> | 23 | <th ng-if="legendConfig.showMax === true">{{ 'legend.max' | translate }}</th> |
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | </tr> | 26 | </tr> |
27 | </thead> | 27 | </thead> |
28 | <tbody> | 28 | <tbody> |
29 | - <tr class="tb-legend-keys" ng-repeat="legendKey in legendData.keys"> | 29 | + <tr class="tb-legend-keys" ng-repeat="legendKey in legendData.keys" ng-class="{ 'tb-row-direction': isRowDirection }"> |
30 | <td><span class="tb-legend-line" ng-style="{backgroundColor: legendKey.dataKey.color}"></span></td> | 30 | <td><span class="tb-legend-line" ng-style="{backgroundColor: legendKey.dataKey.color}"></span></td> |
31 | <td class="tb-legend-label" | 31 | <td class="tb-legend-label" |
32 | ng-click="toggleHideData(legendKey.dataIndex)" | 32 | ng-click="toggleHideData(legendKey.dataIndex)" |
@@ -670,6 +670,10 @@ | @@ -670,6 +670,10 @@ | ||
670 | "dialog": { | 670 | "dialog": { |
671 | "close": "Close dialog" | 671 | "close": "Close dialog" |
672 | }, | 672 | }, |
673 | + "direction": { | ||
674 | + "column": "Column", | ||
675 | + "row": "Row" | ||
676 | + }, | ||
673 | "error": { | 677 | "error": { |
674 | "unable-to-connect": "Unable to connect to the server! Please check your internet connection.", | 678 | "unable-to-connect": "Unable to connect to the server! Please check your internet connection.", |
675 | "unhandled-error-code": "Unhandled error code: {{errorCode}}", | 679 | "unhandled-error-code": "Unhandled error code: {{errorCode}}", |
@@ -1116,6 +1120,7 @@ | @@ -1116,6 +1120,7 @@ | ||
1116 | "select": "Select target layout" | 1120 | "select": "Select target layout" |
1117 | }, | 1121 | }, |
1118 | "legend": { | 1122 | "legend": { |
1123 | + "direction": "Legend direction", | ||
1119 | "position": "Legend position", | 1124 | "position": "Legend position", |
1120 | "show-max": "Show max value", | 1125 | "show-max": "Show max value", |
1121 | "show-min": "Show min value", | 1126 | "show-min": "Show min value", |
@@ -670,6 +670,10 @@ | @@ -670,6 +670,10 @@ | ||
670 | "dialog": { | 670 | "dialog": { |
671 | "close": "Закрыть диалог" | 671 | "close": "Закрыть диалог" |
672 | }, | 672 | }, |
673 | + "direction": { | ||
674 | + "column": "Колонка", | ||
675 | + "row": "Строка" | ||
676 | + }, | ||
673 | "error": { | 677 | "error": { |
674 | "unable-to-connect": "Не удалось подключиться к серверу! Пожалуйста, проверьте интернет-соединение.", | 678 | "unable-to-connect": "Не удалось подключиться к серверу! Пожалуйста, проверьте интернет-соединение.", |
675 | "unhandled-error-code": "Код необработанной ошибки: {{errorCode}}", | 679 | "unhandled-error-code": "Код необработанной ошибки: {{errorCode}}", |
@@ -1109,6 +1113,7 @@ | @@ -1109,6 +1113,7 @@ | ||
1109 | "select": "Выбрать макет" | 1113 | "select": "Выбрать макет" |
1110 | }, | 1114 | }, |
1111 | "legend": { | 1115 | "legend": { |
1116 | + "direction": "Расположение элементов легенды", | ||
1112 | "position": "Расположение легенды", | 1117 | "position": "Расположение легенды", |
1113 | "show-max": "Показать максимальное значение", | 1118 | "show-max": "Показать максимальное значение", |
1114 | "show-min": "Показать минимальное значение", | 1119 | "show-min": "Показать минимальное значение", |
@@ -795,6 +795,10 @@ | @@ -795,6 +795,10 @@ | ||
795 | "dialog": { | 795 | "dialog": { |
796 | "close": "Закрити діалогове вікно" | 796 | "close": "Закрити діалогове вікно" |
797 | }, | 797 | }, |
798 | + "direction": { | ||
799 | + "column": "Колонка", | ||
800 | + "row": "Рядок" | ||
801 | + }, | ||
798 | "error": { | 802 | "error": { |
799 | "unable-to-connect": "Неможливо підключитися до сервера! Перевірте підключення до Інтернету.", | 803 | "unable-to-connect": "Неможливо підключитися до сервера! Перевірте підключення до Інтернету.", |
800 | "unhandled-error-code": "Неопрацьований помилковий код: {{errorCode}}", | 804 | "unhandled-error-code": "Неопрацьований помилковий код: {{errorCode}}", |
@@ -1526,6 +1530,7 @@ | @@ -1526,6 +1530,7 @@ | ||
1526 | "select": "Вибрати макет" | 1530 | "select": "Вибрати макет" |
1527 | }, | 1531 | }, |
1528 | "legend": { | 1532 | "legend": { |
1533 | + "direction": "Розташування елементів легенди", | ||
1529 | "position": "Розташування легенди", | 1534 | "position": "Розташування легенди", |
1530 | "show-max": "Показати максимальне значення", | 1535 | "show-max": "Показати максимальне значення", |
1531 | "show-min": "Показати мінімальне значення ", | 1536 | "show-min": "Показати мінімальне значення ", |