From 8a37cf0d0de1a762805844f48e7c2436240a88ee Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 15 Jun 2017 13:45:40 +0300 Subject: [PATCH] TB-63: Improve alarm widget layout. --- ui/src/app/common/types.constant.js | 2 +- ui/src/app/components/dashboard.directive.js | 39 +++++++++++ ui/src/app/components/dashboard.tpl.html | 19 +++-- ui/src/app/components/widget.controller.js | 5 ++ ui/src/app/locale/locale.constant.js | 5 ++ ui/src/app/locale/translate-handler.js | 2 +- ui/src/app/widget/lib/alarms-table-widget.js | 70 +++++++++++++------ .../app/widget/lib/alarms-table-widget.scss | 26 ++++++- .../widget/lib/alarms-table-widget.tpl.html | 13 ---- 9 files changed, 139 insertions(+), 42 deletions(-) diff --git a/ui/src/app/common/types.constant.js b/ui/src/app/common/types.constant.js index 6a4cbccc2f..ad09c820ed 100644 --- a/ui/src/app/common/types.constant.js +++ b/ui/src/app/common/types.constant.js @@ -395,7 +395,7 @@ export default angular.module('thingsboard.types', []) }, translate: { dashboardStatePrefix: "dashboardState.state.", - keyLabelPrefix: "key.label." + customTranslationsPrefix: "custom." } } ).name; diff --git a/ui/src/app/components/dashboard.directive.js b/ui/src/app/components/dashboard.directive.js index c6b4349858..f21df59927 100644 --- a/ui/src/app/components/dashboard.directive.js +++ b/ui/src/app/components/dashboard.directive.js @@ -177,7 +177,10 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $ vm.widgetBackgroundColor = widgetBackgroundColor; vm.widgetPadding = widgetPadding; vm.showWidgetTitle = showWidgetTitle; + vm.showWidgetTitlePanel = showWidgetTitlePanel; vm.widgetTitleStyle = widgetTitleStyle; + vm.widgetTitle = widgetTitle; + vm.widgetActions = widgetActions; vm.dropWidgetShadow = dropWidgetShadow; vm.enableWidgetFullscreen = enableWidgetFullscreen; vm.hasTimewindow = hasTimewindow; @@ -747,6 +750,15 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $ } } + function showWidgetTitlePanel(widget) { + var ctx = widgetContext(widget); + if (ctx && ctx.hideTitlePanel) { + return false; + } else { + return showWidgetTitle(widget) || hasTimewindow(widget); + } + } + function widgetTitleStyle(widget) { if (angular.isDefined(widget.config.titleStyle)) { return widget.config.titleStyle; @@ -755,6 +767,33 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $ } } + function widgetTitle(widget) { + var ctx = widgetContext(widget); + if (ctx && ctx.widgetTitle + && ctx.widgetTitle.length) { + return ctx.widgetTitle; + } else { + return widget.config.title; + } + } + + function widgetActions(widget) { + var ctx = widgetContext(widget); + if (ctx && ctx.widgetActions && ctx.widgetActions.length) { + return ctx.widgetActions; + } else { + return []; + } + } + + function widgetContext(widget) { + var context; + if (widget.$ctx) { + context = widget.$ctx(); + } + return context; + } + function dropWidgetShadow(widget) { if (angular.isDefined(widget.config.dropShadow)) { return widget.config.dropShadow; diff --git a/ui/src/app/components/dashboard.tpl.html b/ui/src/app/components/dashboard.tpl.html index 08bdd42963..da069b0ad3 100644 --- a/ui/src/app/components/dashboard.tpl.html +++ b/ui/src/app/components/dashboard.tpl.html @@ -37,7 +37,8 @@ class="tb-widget" ng-class="{'tb-highlighted': vm.isHighlighted(widget), 'tb-not-highlighted': vm.isNotHighlighted(widget), - 'md-whiteframe-4dp': vm.dropWidgetShadow(widget)}" + 'md-whiteframe-4dp': vm.dropWidgetShadow(widget), + 'tb-has-timewindow': vm.hasTimewindow(widget)}" tb-mousedown="vm.widgetMouseDown($event, widget)" ng-click="vm.widgetClicked($event, widget)" tb-contextmenu="vm.openWidgetContextMenu($event, widget, $mdOpenMousepointMenu)" @@ -45,11 +46,21 @@ color: vm.widgetColor(widget), backgroundColor: vm.widgetBackgroundColor(widget), padding: vm.widgetPadding(widget)}"> -
- {{widget.config.title}} +
+ {{vm.widgetTitle(widget)}}
-
+
+ + + {{ action.name | translate }} + + +
- -
- {{ vm.alarmsTitle }} - - - search - - {{ 'action.search' | translate }} - - -
-