Commit 426dbbeea11597b8b999cdd55c4375527367f71a

Authored by Chantsova Ekaterina
1 parent d1c6a907

Add ability to choose direction of legend items in legend settings

... ... @@ -276,6 +276,16 @@ export default angular.module('thingsboard.types', [])
276 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 289 position: {
280 290 top: {
281 291 value: "top",
... ...
... ... @@ -21,10 +21,26 @@ export default function LegendConfigPanelController(mdPanelRef, $scope, types, l
21 21 vm.legendConfig = legendConfig;
22 22 vm.onLegendConfigUpdate = onLegendConfigUpdate;
23 23 vm.positions = types.position;
  24 + vm.directions = types.direction;
  25 + vm.isRowDirection = vm.legendConfig.direction === types.direction.row.value;
24 26
25 27 vm._mdPanelRef.config.onOpenComplete = function () {
26 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 45 $scope.$watch('vm.legendConfig', function () {
30 46 if (onLegendConfigUpdate) {
... ...
... ... @@ -21,23 +21,33 @@
21 21 <section layout="column">
22 22 <md-content class="md-padding" layout="column">
23 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 33 <label translate>legend.position</label>
25 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 37 {{pos.name | translate}}
28 38 </md-option>
29 39 </md-select>
30 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 42 ng-model="vm.legendConfig.showMin">{{ 'legend.show-min' | translate }}
33 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 45 ng-model="vm.legendConfig.showMax">{{ 'legend.show-max' | translate }}
36 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 48 ng-model="vm.legendConfig.showAvg">{{ 'legend.show-avg' | translate }}
39 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 51 ng-model="vm.legendConfig.showTotal">{{ 'legend.show-total' | translate }}
42 52 </md-checkbox>
43 53 </md-content>
... ...
... ... @@ -102,6 +102,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) {
102 102 scope.updateView = function () {
103 103 var value = {};
104 104 var model = scope.model;
  105 + value.direction = model.direction;
105 106 value.position = model.position;
106 107 value.showMin = model.showMin;
107 108 value.showMax = model.showMax;
... ... @@ -117,6 +118,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) {
117 118 scope.model = {};
118 119 }
119 120 var model = scope.model;
  121 + model.direction = value.direction || types.direction.column.value;
120 122 model.position = value.position || types.position.bottom.value;
121 123 model.showMin = angular.isDefined(value.showMin) ? value.showMin : false;
122 124 model.showMax = angular.isDefined(value.showMax) ? value.showMax : false;
... ... @@ -124,6 +126,7 @@ function LegendConfig($compile, $templateCache, types, $mdPanel, $document) {
124 126 model.showTotal = angular.isDefined(value.showTotal) ? value.showTotal : false;
125 127 } else {
126 128 scope.model = {
  129 + direction: types.direction.column.value,
127 130 position: types.position.bottom.value,
128 131 showMin: false,
129 132 showMax: false,
... ...
... ... @@ -21,7 +21,7 @@
21 21
22 22 .tb-legend-config-panel {
23 23 min-width: 220px;
24   - max-height: 220px;
  24 + max-height: 300px;
25 25 overflow: hidden;
26 26 background: #fff;
27 27 border-radius: 4px;
... ... @@ -41,7 +41,7 @@
41 41 }
42 42
43 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 43 scope.isHorizontal = scope.legendConfig.position === types.position.bottom.value ||
44 44 scope.legendConfig.position === types.position.top.value;
45 45
  46 + scope.isRowDirection = scope.legendConfig.direction === types.direction.row.value;
  47 +
46 48 scope.toggleHideData = function(index) {
47 49 scope.legendData.keys[index].dataKey.hidden = !scope.legendData.keys[index].dataKey.hidden;
48 50 }
... ...
... ... @@ -57,5 +57,9 @@ table.tb-legend {
57 57 opacity: .6;
58 58 }
59 59 }
  60 +
  61 + &.tb-row-direction {
  62 + display: inline-block;
  63 + }
60 64 }
61 65 }
... ...
... ... @@ -17,7 +17,7 @@
17 17 -->
18 18 <table class="tb-legend">
19 19 <thead>
20   - <tr class="tb-legend-header">
  20 + <tr class="tb-legend-header" ng-if="!isRowDirection">
21 21 <th colspan="2"></th>
22 22 <th ng-if="legendConfig.showMin === true">{{ 'legend.min' | translate }}</th>
23 23 <th ng-if="legendConfig.showMax === true">{{ 'legend.max' | translate }}</th>
... ... @@ -26,7 +26,7 @@
26 26 </tr>
27 27 </thead>
28 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 30 <td><span class="tb-legend-line" ng-style="{backgroundColor: legendKey.dataKey.color}"></span></td>
31 31 <td class="tb-legend-label"
32 32 ng-click="toggleHideData(legendKey.dataIndex)"
... ...
... ... @@ -670,6 +670,10 @@
670 670 "dialog": {
671 671 "close": "Close dialog"
672 672 },
  673 + "direction": {
  674 + "column": "Column",
  675 + "row": "Row"
  676 + },
673 677 "error": {
674 678 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.",
675 679 "unhandled-error-code": "Unhandled error code: {{errorCode}}",
... ... @@ -1116,6 +1120,7 @@
1116 1120 "select": "Select target layout"
1117 1121 },
1118 1122 "legend": {
  1123 + "direction": "Legend direction",
1119 1124 "position": "Legend position",
1120 1125 "show-max": "Show max value",
1121 1126 "show-min": "Show min value",
... ...
... ... @@ -670,6 +670,10 @@
670 670 "dialog": {
671 671 "close": "Закрыть диалог"
672 672 },
  673 + "direction": {
  674 + "column": "Колонка",
  675 + "row": "Строка"
  676 + },
673 677 "error": {
674 678 "unable-to-connect": "Не удалось подключиться к серверу! Пожалуйста, проверьте интернет-соединение.",
675 679 "unhandled-error-code": "Код необработанной ошибки: {{errorCode}}",
... ... @@ -1109,6 +1113,7 @@
1109 1113 "select": "Выбрать макет"
1110 1114 },
1111 1115 "legend": {
  1116 + "direction": "Расположение элементов легенды",
1112 1117 "position": "Расположение легенды",
1113 1118 "show-max": "Показать максимальное значение",
1114 1119 "show-min": "Показать минимальное значение",
... ...
... ... @@ -795,6 +795,10 @@
795 795 "dialog": {
796 796 "close": "Закрити діалогове вікно"
797 797 },
  798 + "direction": {
  799 + "column": "Колонка",
  800 + "row": "Рядок"
  801 + },
798 802 "error": {
799 803 "unable-to-connect": "Неможливо підключитися до сервера! Перевірте підключення до Інтернету.",
800 804 "unhandled-error-code": "Неопрацьований помилковий код: {{errorCode}}",
... ... @@ -1526,6 +1530,7 @@
1526 1530 "select": "Вибрати макет"
1527 1531 },
1528 1532 "legend": {
  1533 + "direction": "Розташування елементів легенди",
1529 1534 "position": "Розташування легенди",
1530 1535 "show-max": "Показати максимальне значення",
1531 1536 "show-min": "Показати мінімальне значення ",
... ...