Commit c8abaf1a0670dcf38b8013768c46729d56b00491

Authored by Mirco Pizzichini
Committed by Igor Kulikov
1 parent 3d5920e8

Add the possibility to select a title icon in widget configuration (#1900)

... ... @@ -181,12 +181,15 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
181 181 vm.widgetCol = widgetCol;
182 182 vm.widgetStyle = widgetStyle;
183 183 vm.showWidgetTitle = showWidgetTitle;
  184 + vm.showWidgetTitleIcon = showWidgetTitleIcon;
184 185 vm.hasWidgetTitleTemplate = hasWidgetTitleTemplate;
185 186 vm.widgetTitleTemplate = widgetTitleTemplate;
186 187 vm.showWidgetTitlePanel = showWidgetTitlePanel;
187 188 vm.showWidgetActions = showWidgetActions;
188 189 vm.widgetTitleStyle = widgetTitleStyle;
189 190 vm.widgetTitle = widgetTitle;
  191 + vm.widgetTitleIcon = widgetTitleIcon;
  192 + vm.widgetTitleIconStyle = widgetTitleIconStyle;
190 193 vm.customWidgetHeaderActions = customWidgetHeaderActions;
191 194 vm.widgetActions = widgetActions;
192 195 vm.dropWidgetShadow = dropWidgetShadow;
... ... @@ -880,6 +883,14 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
880 883 }
881 884 }
882 885
  886 + function showWidgetTitleIcon(widget) {
  887 + if (angular.isDefined(widget.config.showTitleIcon)) {
  888 + return widget.config.showTitleIcon;
  889 + } else {
  890 + return false;
  891 + }
  892 + }
  893 +
883 894 function hasWidgetTitleTemplate(widget) {
884 895 var ctx = widgetContext(widget);
885 896 if (ctx && ctx.widgetTitleTemplate) {
... ... @@ -934,6 +945,25 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
934 945 }
935 946 }
936 947
  948 + function widgetTitleIcon(widget) {
  949 + if (angular.isDefined(widget.config.titleIcon)) {
  950 + return widget.config.titleIcon;
  951 + } else {
  952 + return '';
  953 + }
  954 + }
  955 +
  956 + function widgetTitleIconStyle(widget) {
  957 + var style = {};
  958 + if (angular.isDefined(widget.config.iconColor)) {
  959 + style.color = widget.config.iconColor;
  960 + }
  961 + if (angular.isDefined(widget.config.iconSize)) {
  962 + style.fontSize = widget.config.iconSize;
  963 + }
  964 + return style;
  965 + }
  966 +
937 967 function customWidgetHeaderActions(widget) {
938 968 var ctx = widgetContext(widget);
939 969 if (ctx && ctx.customHeaderActions && ctx.customHeaderActions.length) {
... ...
... ... @@ -47,7 +47,12 @@
47 47 <div layout="row" layout-align="space-between start">
48 48 <div class="tb-widget-title" layout="column" layout-align="center start" ng-show="vm.showWidgetTitlePanel(widget)">
49 49 <div ng-if="vm.hasWidgetTitleTemplate(widget)" ng-include="vm.widgetTitleTemplate(widget)"></div>
50   - <span ng-show="vm.showWidgetTitle(widget)" ng-style="vm.widgetTitleStyle(widget)" class="md-subhead title">{{vm.widgetTitle(widget)}}</span>
  50 + <span ng-show="vm.showWidgetTitle(widget)" ng-style="vm.widgetTitleStyle(widget)" class="md-subhead title">
  51 + <md-icon class="material-icons" ng-if="vm.showWidgetTitleIcon(widget)" ng-style="vm.widgetTitleIconStyle(widget)">
  52 + {{vm.widgetTitleIcon(widget)}}
  53 + </md-icon>
  54 + {{vm.widgetTitle(widget)}}
  55 + </span>
51 56 <tb-timewindow aggregation="{{vm.hasAggregation(widget)}}" ng-if="vm.hasTimewindow(widget)" ng-model="widget.config.timewindow"></tb-timewindow>
52 57 </div>
53 58 <div class="tb-widget-actions" layout="row" layout-align="start center" ng-show="vm.showWidgetActions(widget)" tb-mousedown="$event.stopPropagation()"
... ...
... ... @@ -109,6 +109,10 @@ function WidgetConfig($compile, $templateCache, $rootScope, $translate, $timeout
109 109 if (config) {
110 110 scope.selectedTab = 0;
111 111 scope.title = config.title;
  112 + scope.showTitleIcon = angular.isDefined(config.showTitleIcon) ? config.showTitleIcon : false;
  113 + scope.titleIcon = angular.isDefined(config.titleIcon) ? config.titleIcon : '';
  114 + scope.iconColor = angular.isDefined(config.iconColor) ? config.iconColor : 'rgba(0, 0, 0, 0.87)';
  115 + scope.iconSize = angular.isDefined(config.iconSize) ? config.iconSize : '24px';
112 116 scope.showTitle = config.showTitle;
113 117 scope.dropShadow = angular.isDefined(config.dropShadow) ? config.dropShadow : true;
114 118 scope.enableFullscreen = angular.isDefined(config.enableFullscreen) ? config.enableFullscreen : true;
... ... @@ -236,14 +240,18 @@ function WidgetConfig($compile, $templateCache, $rootScope, $translate, $timeout
236 240 }
237 241 };
238 242
239   - scope.$watch('title + showTitle + dropShadow + enableFullscreen + backgroundColor + color + ' +
240   - 'padding + margin + widgetStyle + titleStyle + mobileOrder + mobileHeight + units + decimals + useDashboardTimewindow + displayTimewindow + ' +
241   - 'alarmSearchStatus + alarmsPollingInterval + showLegend', function () {
  243 + scope.$watch('title + showTitleIcon + titleIcon + iconColor + iconSize + showTitle + dropShadow + enableFullscreen + backgroundColor + ' +
  244 + 'color + padding + margin + widgetStyle + titleStyle + mobileOrder + mobileHeight + units + decimals + useDashboardTimewindow + ' +
  245 + 'displayTimewindow + alarmSearchStatus + alarmsPollingInterval + showLegend', function () {
242 246 if (ngModelCtrl.$viewValue) {
243 247 var value = ngModelCtrl.$viewValue;
244 248 if (value.config) {
245 249 var config = value.config;
246 250 config.title = scope.title;
  251 + config.showTitleIcon = scope.showTitleIcon;
  252 + config.titleIcon = scope.titleIcon;
  253 + config.iconColor = scope.iconColor;
  254 + config.iconSize = scope.iconSize;
247 255 config.showTitle = scope.showTitle;
248 256 config.dropShadow = scope.dropShadow;
249 257 config.enableFullscreen = scope.enableFullscreen;
... ...
... ... @@ -191,6 +191,32 @@
191 191 </div>
192 192 </div>
193 193 <div layout='column' layout-align="center" layout-gt-sm='row' layout-align-gt-sm="start center">
  194 + <div layout="row" flex layout-padding>
  195 + <md-checkbox aria-label="{{ 'widget-config.display-icon' | translate }}"
  196 + ng-model="showTitleIcon">{{ 'widget-config.display-icon' | translate }}
  197 + </md-checkbox>
  198 + </div>
  199 + <div flex>
  200 + <tb-material-icon-select ng-disabled="!showTitleIcon" ng-model="titleIcon">
  201 + </tb-material-icon-select>
  202 + </div>
  203 + <div flex
  204 + md-color-picker
  205 + ng-model="iconColor"
  206 + label="{{ 'widget-config.icon-color' | translate }}"
  207 + icon="format_color_fill"
  208 + default="rgba(0, 0, 0, 0.87)"
  209 + md-color-clear-button="false"
  210 + open-on-input="true"
  211 + md-color-generic-palette="false"
  212 + md-color-history="false"
  213 + ></div>
  214 + <md-input-container flex>
  215 + <label translate>widget-config.icon-size</label>
  216 + <input ng-model="iconSize">
  217 + </md-input-container>
  218 + </div>
  219 + <div layout='column' layout-align="center" layout-gt-sm='row' layout-align-gt-sm="start center">
194 220 <div layout="row" layout-padding>
195 221 <md-checkbox aria-label="{{ 'widget-config.display-title' | translate }}"
196 222 ng-model="showTitle">{{ 'widget-config.display-title' | translate }}
... ...
... ... @@ -1610,7 +1610,10 @@
1610 1610 "edit-action": "Edit action",
1611 1611 "delete-action": "Delete action",
1612 1612 "delete-action-title": "Delete widget action",
1613   - "delete-action-text": "Are you sure you want delete widget action with name '{{actionName}}'?"
  1613 + "delete-action-text": "Are you sure you want delete widget action with name '{{actionName}}'?",
  1614 + "display-icon": "Display title icon",
  1615 + "icon-color": "Icon color",
  1616 + "icon-size": "Icon size"
1614 1617 },
1615 1618 "widget-type": {
1616 1619 "import": "Import widget type",
... ... @@ -1714,4 +1717,4 @@
1714 1717 "cs_CZ": "Czech"
1715 1718 }
1716 1719 }
1717   -}
\ No newline at end of file
  1720 +}
... ...
... ... @@ -1610,7 +1610,10 @@
1610 1610 "edit-action": "Editar acción",
1611 1611 "delete-action": "Eliminar acción",
1612 1612 "delete-action-title": "Eliminar acción del widget",
1613   - "delete-action-text": "¿Está seguro de que desea eliminar la acción del widget con nombre '{{actionName}}'?"
  1613 + "delete-action-text": "¿Está seguro de que desea eliminar la acción del widget con nombre '{{actionName}}'?",
  1614 + "display-icon": "Mostrar icono del título",
  1615 + "icon-color": "Color del icono",
  1616 + "icon-size": "Tamaño del icono"
1614 1617 },
1615 1618 "widget-type": {
1616 1619 "import": "Importar tipo de widget",
... ...
... ... @@ -1431,7 +1431,10 @@
1431 1431 "title-style": "Style de titre",
1432 1432 "units": "Symbole spécial à afficher à côté de la valeur",
1433 1433 "use-dashboard-timewindow": "Utiliser la fenêtre de temps du tableau de bord",
1434   - "widget-style": "Style du widget"
  1434 + "widget-style": "Style du widget",
  1435 + "display-icon": "Afficher l'icône du titre",
  1436 + "icon-color": "Couleur de l'icône",
  1437 + "icon-size": "Taille de l'icône"
1435 1438 },
1436 1439 "widget-type": {
1437 1440 "create-new-widget-type": "Créer un nouveau type de widget",
... ...
... ... @@ -1545,7 +1545,10 @@
1545 1545 "edit-action": "Modifica azione",
1546 1546 "delete-action": "Cancella azione",
1547 1547 "delete-action-title": "Cancella azione del widget",
1548   - "delete-action-text": "Sei sicuro di voler cancellare l'azione del widget '{{actionName}}'?"
  1548 + "delete-action-text": "Sei sicuro di voler cancellare l'azione del widget '{{actionName}}'?",
  1549 + "display-icon": "Mostra icona titolo",
  1550 + "icon-color": "Colore dell'icona",
  1551 + "icon-size": "Dimensione dell'icona"
1549 1552 },
1550 1553 "widget-type": {
1551 1554 "import": "Importa un tipo di widget",
... ...