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,12 +181,15 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
181 vm.widgetCol = widgetCol; 181 vm.widgetCol = widgetCol;
182 vm.widgetStyle = widgetStyle; 182 vm.widgetStyle = widgetStyle;
183 vm.showWidgetTitle = showWidgetTitle; 183 vm.showWidgetTitle = showWidgetTitle;
  184 + vm.showWidgetTitleIcon = showWidgetTitleIcon;
184 vm.hasWidgetTitleTemplate = hasWidgetTitleTemplate; 185 vm.hasWidgetTitleTemplate = hasWidgetTitleTemplate;
185 vm.widgetTitleTemplate = widgetTitleTemplate; 186 vm.widgetTitleTemplate = widgetTitleTemplate;
186 vm.showWidgetTitlePanel = showWidgetTitlePanel; 187 vm.showWidgetTitlePanel = showWidgetTitlePanel;
187 vm.showWidgetActions = showWidgetActions; 188 vm.showWidgetActions = showWidgetActions;
188 vm.widgetTitleStyle = widgetTitleStyle; 189 vm.widgetTitleStyle = widgetTitleStyle;
189 vm.widgetTitle = widgetTitle; 190 vm.widgetTitle = widgetTitle;
  191 + vm.widgetTitleIcon = widgetTitleIcon;
  192 + vm.widgetTitleIconStyle = widgetTitleIconStyle;
190 vm.customWidgetHeaderActions = customWidgetHeaderActions; 193 vm.customWidgetHeaderActions = customWidgetHeaderActions;
191 vm.widgetActions = widgetActions; 194 vm.widgetActions = widgetActions;
192 vm.dropWidgetShadow = dropWidgetShadow; 195 vm.dropWidgetShadow = dropWidgetShadow;
@@ -880,6 +883,14 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $ @@ -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 function hasWidgetTitleTemplate(widget) { 894 function hasWidgetTitleTemplate(widget) {
884 var ctx = widgetContext(widget); 895 var ctx = widgetContext(widget);
885 if (ctx && ctx.widgetTitleTemplate) { 896 if (ctx && ctx.widgetTitleTemplate) {
@@ -934,6 +945,25 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $ @@ -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 function customWidgetHeaderActions(widget) { 967 function customWidgetHeaderActions(widget) {
938 var ctx = widgetContext(widget); 968 var ctx = widgetContext(widget);
939 if (ctx && ctx.customHeaderActions && ctx.customHeaderActions.length) { 969 if (ctx && ctx.customHeaderActions && ctx.customHeaderActions.length) {
@@ -47,7 +47,12 @@ @@ -47,7 +47,12 @@
47 <div layout="row" layout-align="space-between start"> 47 <div layout="row" layout-align="space-between start">
48 <div class="tb-widget-title" layout="column" layout-align="center start" ng-show="vm.showWidgetTitlePanel(widget)"> 48 <div class="tb-widget-title" layout="column" layout-align="center start" ng-show="vm.showWidgetTitlePanel(widget)">
49 <div ng-if="vm.hasWidgetTitleTemplate(widget)" ng-include="vm.widgetTitleTemplate(widget)"></div> 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 <tb-timewindow aggregation="{{vm.hasAggregation(widget)}}" ng-if="vm.hasTimewindow(widget)" ng-model="widget.config.timewindow"></tb-timewindow> 56 <tb-timewindow aggregation="{{vm.hasAggregation(widget)}}" ng-if="vm.hasTimewindow(widget)" ng-model="widget.config.timewindow"></tb-timewindow>
52 </div> 57 </div>
53 <div class="tb-widget-actions" layout="row" layout-align="start center" ng-show="vm.showWidgetActions(widget)" tb-mousedown="$event.stopPropagation()" 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,6 +109,10 @@ function WidgetConfig($compile, $templateCache, $rootScope, $translate, $timeout
109 if (config) { 109 if (config) {
110 scope.selectedTab = 0; 110 scope.selectedTab = 0;
111 scope.title = config.title; 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 scope.showTitle = config.showTitle; 116 scope.showTitle = config.showTitle;
113 scope.dropShadow = angular.isDefined(config.dropShadow) ? config.dropShadow : true; 117 scope.dropShadow = angular.isDefined(config.dropShadow) ? config.dropShadow : true;
114 scope.enableFullscreen = angular.isDefined(config.enableFullscreen) ? config.enableFullscreen : true; 118 scope.enableFullscreen = angular.isDefined(config.enableFullscreen) ? config.enableFullscreen : true;
@@ -236,14 +240,18 @@ function WidgetConfig($compile, $templateCache, $rootScope, $translate, $timeout @@ -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 if (ngModelCtrl.$viewValue) { 246 if (ngModelCtrl.$viewValue) {
243 var value = ngModelCtrl.$viewValue; 247 var value = ngModelCtrl.$viewValue;
244 if (value.config) { 248 if (value.config) {
245 var config = value.config; 249 var config = value.config;
246 config.title = scope.title; 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 config.showTitle = scope.showTitle; 255 config.showTitle = scope.showTitle;
248 config.dropShadow = scope.dropShadow; 256 config.dropShadow = scope.dropShadow;
249 config.enableFullscreen = scope.enableFullscreen; 257 config.enableFullscreen = scope.enableFullscreen;
@@ -191,6 +191,32 @@ @@ -191,6 +191,32 @@
191 </div> 191 </div>
192 </div> 192 </div>
193 <div layout='column' layout-align="center" layout-gt-sm='row' layout-align-gt-sm="start center"> 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 <div layout="row" layout-padding> 220 <div layout="row" layout-padding>
195 <md-checkbox aria-label="{{ 'widget-config.display-title' | translate }}" 221 <md-checkbox aria-label="{{ 'widget-config.display-title' | translate }}"
196 ng-model="showTitle">{{ 'widget-config.display-title' | translate }} 222 ng-model="showTitle">{{ 'widget-config.display-title' | translate }}
@@ -1610,7 +1610,10 @@ @@ -1610,7 +1610,10 @@
1610 "edit-action": "Edit action", 1610 "edit-action": "Edit action",
1611 "delete-action": "Delete action", 1611 "delete-action": "Delete action",
1612 "delete-action-title": "Delete widget action", 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 "widget-type": { 1618 "widget-type": {
1616 "import": "Import widget type", 1619 "import": "Import widget type",
@@ -1714,4 +1717,4 @@ @@ -1714,4 +1717,4 @@
1714 "cs_CZ": "Czech" 1717 "cs_CZ": "Czech"
1715 } 1718 }
1716 } 1719 }
1717 -}  
  1720 +}
@@ -1610,7 +1610,10 @@ @@ -1610,7 +1610,10 @@
1610 "edit-action": "Editar acción", 1610 "edit-action": "Editar acción",
1611 "delete-action": "Eliminar acción", 1611 "delete-action": "Eliminar acción",
1612 "delete-action-title": "Eliminar acción del widget", 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 "widget-type": { 1618 "widget-type": {
1616 "import": "Importar tipo de widget", 1619 "import": "Importar tipo de widget",
@@ -1431,7 +1431,10 @@ @@ -1431,7 +1431,10 @@
1431 "title-style": "Style de titre", 1431 "title-style": "Style de titre",
1432 "units": "Symbole spécial à afficher à côté de la valeur", 1432 "units": "Symbole spécial à afficher à côté de la valeur",
1433 "use-dashboard-timewindow": "Utiliser la fenêtre de temps du tableau de bord", 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 "widget-type": { 1439 "widget-type": {
1437 "create-new-widget-type": "Créer un nouveau type de widget", 1440 "create-new-widget-type": "Créer un nouveau type de widget",
@@ -1545,7 +1545,10 @@ @@ -1545,7 +1545,10 @@
1545 "edit-action": "Modifica azione", 1545 "edit-action": "Modifica azione",
1546 "delete-action": "Cancella azione", 1546 "delete-action": "Cancella azione",
1547 "delete-action-title": "Cancella azione del widget", 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 "widget-type": { 1553 "widget-type": {
1551 "import": "Importa un tipo di widget", 1554 "import": "Importa un tipo di widget",