diff --git a/ui/src/app/api/entity.service.js b/ui/src/app/api/entity.service.js index 344edf5e7b..fc09a4016c 100644 --- a/ui/src/app/api/entity.service.js +++ b/ui/src/app/api/entity.service.js @@ -425,6 +425,17 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device } var stateEntityId = getStateEntityId(filter, stateParams); switch (filter.type) { + case types.aliasFilterType.singleEntity.value: + getEntity(filter.singleEntity.entityType, filter.singleEntity.id).then( + function success(entity) { + result.entities = entitiesToEntitiesInfo([entity]); + deferred.resolve(result); + }, + function fail() { + deferred.reject(); + } + ); + break; case types.aliasFilterType.entityList.value: getEntities(filter.entityType, filter.entityList).then( function success(entities) { @@ -600,6 +611,8 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device var filter = entityAlias.filter; if (filterAliasFilterTypeByEntityTypes(filter.type, entityTypes)) { switch (filter.type) { + case types.aliasFilterType.singleEntity.value: + return entityTypes.indexOf(filter.singleEntity.entityType) > -1 ? true : false; case types.aliasFilterType.entityList.value: return entityTypes.indexOf(filter.entityType) > -1 ? true : false; case types.aliasFilterType.entityName.value: @@ -642,6 +655,8 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device function filterAliasFilterTypeByEntityType(aliasFilterType, entityType) { switch (aliasFilterType) { + case types.aliasFilterType.singleEntity.value: + return true; case types.aliasFilterType.entityList.value: return true; case types.aliasFilterType.entityName.value: diff --git a/ui/src/app/common/dashboard-utils.service.js b/ui/src/app/common/dashboard-utils.service.js index 0fc940dd4d..57919fba58 100644 --- a/ui/src/app/common/dashboard-utils.service.js +++ b/ui/src/app/common/dashboard-utils.service.js @@ -203,7 +203,7 @@ function DashboardUtils(types, utils, timeService) { } if (angular.isUndefined(dashboard.configuration.states)) { dashboard.configuration.states = { - 'default': createDefaultState('Default', true) + 'default': createDefaultState(dashboard.title, true) }; var mainLayout = dashboard.configuration.states['default'].layouts['main']; @@ -272,16 +272,16 @@ function DashboardUtils(types, utils, timeService) { } if (angular.isUndefined(dashboard.configuration.settings)) { dashboard.configuration.settings = {}; - dashboard.configuration.settings.stateControllerId = 'default'; - dashboard.configuration.settings.showTitle = true; + dashboard.configuration.settings.stateControllerId = 'entity'; + dashboard.configuration.settings.showTitle = false; dashboard.configuration.settings.showDashboardsSelect = true; dashboard.configuration.settings.showEntitiesSelect = true; dashboard.configuration.settings.showDashboardTimewindow = true; dashboard.configuration.settings.showDashboardExport = true; - dashboard.configuration.settings.toolbarAlwaysOpen = false; + dashboard.configuration.settings.toolbarAlwaysOpen = true; } else { if (angular.isUndefined(dashboard.configuration.settings.stateControllerId)) { - dashboard.configuration.settings.stateControllerId = 'default'; + dashboard.configuration.settings.stateControllerId = 'entity'; } } if (angular.isDefined(dashboard.configuration.gridSettings)) { @@ -344,9 +344,8 @@ function DashboardUtils(types, utils, timeService) { function createSingleEntityFilter(entityType, entityId) { return { - type: types.aliasFilterType.entityList.value, - entityList: [entityId], - entityType: entityType, + type: types.aliasFilterType.singleEntity.value, + singleEntity: { entityType: entityType, id: entityId }, resolveMultiple: false }; } diff --git a/ui/src/app/common/types.constant.js b/ui/src/app/common/types.constant.js index 61fc120da1..7bac29dff9 100644 --- a/ui/src/app/common/types.constant.js +++ b/ui/src/app/common/types.constant.js @@ -157,6 +157,10 @@ export default angular.module('thingsboard.types', []) } }, aliasFilterType: { + singleEntity: { + value: 'singleEntity', + name: 'alias.filter-type-single-entity' + }, entityList: { value: 'entityList', name: 'alias.filter-type-entity-list' diff --git a/ui/src/app/dashboard/dashboard-settings.controller.js b/ui/src/app/dashboard/dashboard-settings.controller.js index c69c6caab7..4799729ef4 100644 --- a/ui/src/app/dashboard/dashboard-settings.controller.js +++ b/ui/src/app/dashboard/dashboard-settings.controller.js @@ -33,11 +33,11 @@ export default function DashboardSettingsController($scope, $mdDialog, statesCon if (vm.settings) { if (angular.isUndefined(vm.settings.stateControllerId)) { - vm.settings.stateControllerId = 'default'; + vm.settings.stateControllerId = 'entity'; } if (angular.isUndefined(vm.settings.showTitle)) { - vm.settings.showTitle = true; + vm.settings.showTitle = false; } if (angular.isUndefined(vm.settings.titleColor)) { @@ -61,7 +61,7 @@ export default function DashboardSettingsController($scope, $mdDialog, statesCon } if (angular.isUndefined(vm.settings.toolbarAlwaysOpen)) { - vm.settings.toolbarAlwaysOpen = false; + vm.settings.toolbarAlwaysOpen = true; } } diff --git a/ui/src/app/dashboard/dashboard-toolbar.directive.js b/ui/src/app/dashboard/dashboard-toolbar.directive.js index 63a34f8918..52121cddc7 100644 --- a/ui/src/app/dashboard/dashboard-toolbar.directive.js +++ b/ui/src/app/dashboard/dashboard-toolbar.directive.js @@ -51,10 +51,17 @@ function DashboardToolbarController($scope, $element, $timeout, mdFabToolbarAnim vm.mdFabToolbarElement = angular.element($element[0].querySelector('md-fab-toolbar')); - $timeout(function() { - vm.mdFabBackgroundElement = angular.element(vm.mdFabToolbarElement[0].querySelector('.md-fab-toolbar-background')); - vm.mdFabTriggerElement = angular.element(vm.mdFabToolbarElement[0].querySelector('md-fab-trigger button')); - }); + function initElements() { + $timeout(function() { + vm.mdFabBackgroundElement = angular.element(vm.mdFabToolbarElement[0].querySelector('.md-fab-toolbar-background')); + vm.mdFabTriggerElement = angular.element(vm.mdFabToolbarElement[0].querySelector('md-fab-trigger button')); + if (!vm.mdFabBackgroundElement || !vm.mdFabBackgroundElement[0]) { + initElements(); + } else { + triggerFabResize(); + } + }); + } addResizeListener(vm.mdFabToolbarElement[0], triggerFabResize); // eslint-disable-line no-undef @@ -62,7 +69,12 @@ function DashboardToolbarController($scope, $element, $timeout, mdFabToolbarAnim removeResizeListener(vm.mdFabToolbarElement[0], triggerFabResize); // eslint-disable-line no-undef }); + initElements(); + function triggerFabResize() { + if (!vm.mdFabBackgroundElement || !vm.mdFabBackgroundElement[0]) { + return; + } var ctrl = vm.mdFabToolbarElement.controller('mdFabToolbar'); if (ctrl.isOpen) { if (!vm.mdFabBackgroundElement[0].offsetWidth) { diff --git a/ui/src/app/dashboard/dashboard.controller.js b/ui/src/app/dashboard/dashboard.controller.js index f41a635f8e..950e73a23f 100644 --- a/ui/src/app/dashboard/dashboard.controller.js +++ b/ui/src/app/dashboard/dashboard.controller.js @@ -757,7 +757,7 @@ export default function DashboardController(types, utils, dashboardUtils, widget angular.isDefined(vm.dashboard.configuration.settings.toolbarAlwaysOpen)) { return vm.dashboard.configuration.settings.toolbarAlwaysOpen; } else { - return false; + return true; } } @@ -766,7 +766,7 @@ export default function DashboardController(types, utils, dashboardUtils, widget angular.isDefined(vm.dashboard.configuration.settings.showTitle)) { return vm.dashboard.configuration.settings.showTitle; } else { - return true; + return false; } } diff --git a/ui/src/app/dashboard/dashboard.tpl.html b/ui/src/app/dashboard/dashboard.tpl.html index 72820bbf58..394a6014db 100644 --- a/ui/src/app/dashboard/dashboard.tpl.html +++ b/ui/src/app/dashboard/dashboard.tpl.html @@ -16,7 +16,7 @@ --> + hide-expand-button="vm.widgetEditMode || vm.iframeMode || forceFullscreen" expand-tooltip-direction="bottom" ng-if="vm.dashboard">
alias.filter-type-required +
+ + +