thingsboard-memoizeit
Changes
ui/src/app/api/subscription.js 16(+16 -0)
ui/src/app/components/dashboard.directive.js 42(+17 -25)
Details
ui/src/app/api/subscription.js 16(+16 -0)
diff --git a/ui/src/app/api/subscription.js b/ui/src/app/api/subscription.js
index 030b852..215da0f 100644
--- a/ui/src/app/api/subscription.js
+++ b/ui/src/app/api/subscription.js
@@ -296,6 +296,21 @@ export default class Subscription {
}
}
+ resetData() {
+ for (var i=0;i<this.data.length;i++) {
+ this.data[i].data = [];
+ this.hiddenData[i].data = [];
+ if (this.displayLegend) {
+ this.legendData.data[i].min = null;
+ this.legendData.data[i].max = null;
+ this.legendData.data[i].avg = null;
+ this.legendData.data[i].total = null;
+ this.legendData.data[i].hidden = false;
+ }
+ }
+ this.onDataUpdated();
+ }
+
startWatchingTimewindow() {
var subscription = this;
this.timeWindowWatchRegistration = this.ctx.$scope.$watch(function () {
@@ -720,6 +735,7 @@ export default class Subscription {
this.ctx.datasourceService.unsubscribeFromDatasource(listener);
}
this.datasourceListeners = [];
+ this.resetData();
}
}
}
ui/src/app/components/dashboard.directive.js 42(+17 -25)
diff --git a/ui/src/app/components/dashboard.directive.js b/ui/src/app/components/dashboard.directive.js
index 1c2c654..cdd15b0 100644
--- a/ui/src/app/components/dashboard.directive.js
+++ b/ui/src/app/components/dashboard.directive.js
@@ -16,6 +16,7 @@
import './dashboard.scss';
import $ from 'jquery';
+import 'javascript-detect-element-resize/detect-element-resize';
import angularGridster from 'angular-gridster';
import thingsboardTypes from '../common/types.constant';
import thingsboardApiWidget from '../api/widget.service';
@@ -225,6 +226,18 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
}
};
+ addResizeListener(gridsterParent[0], onGirdsterParentResize); // eslint-disable-line no-undef
+
+ $scope.$on("$destroy", function () {
+ removeResizeListener(gridsterParent[0], onGirdsterParentResize); // eslint-disable-line no-undef
+ });
+
+ function onGirdsterParentResize() {
+ if (gridsterParent.height() && vm.autofillHeight) {
+ updateMobileOpts();
+ }
+ }
+
$scope.$watchCollection('vm.widgets', function () {
var ids = [];
for (var i=0;i<vm.widgets.length;i++) {
@@ -262,6 +275,9 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
delete vm.widgetLayoutInfo[widgetId];
}
}
+ if (vm.autofillHeight) {
+ updateMobileOpts();
+ }
});
//TODO: widgets visibility
@@ -316,31 +332,7 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $
});
$scope.$watch('vm.autofillHeight', function () {
- if (vm.autofillHeight) {
- //if (gridsterParent.height()) {
- // updateMobileOpts();
- //} else {
- if ($scope.parentHeighWatcher) {
- $scope.parentHeighWatcher();
- }
- if (gridsterParent.height()) {
- updateMobileOpts();
- }
- $scope.parentHeighWatcher = $scope.$watch(function() { return gridsterParent.height(); },
- function(newHeight) {
- if (newHeight) {
- updateMobileOpts();
- }
- }
- );
- } else {
- if ($scope.parentHeighWatcher) {
- $scope.parentHeighWatcher();
- $scope.parentHeighWatcher = null;
- }
-
- updateMobileOpts();
- }
+ updateMobileOpts();
});
$scope.$watch('vm.isMobileDisabled', function () {
diff --git a/ui/src/app/components/widget.controller.js b/ui/src/app/components/widget.controller.js
index 8d91b2d..baedd09 100644
--- a/ui/src/app/components/widget.controller.js
+++ b/ui/src/app/components/widget.controller.js
@@ -562,6 +562,9 @@ export default function WidgetController($scope, $timeout, $window, $element, $q
}
function onInit(skipSizeCheck) {
+ if (!widgetContext.$containerParent) {
+ return;
+ }
if (!skipSizeCheck) {
checkSize();
}
diff --git a/ui/src/app/dashboard/dashboard.controller.js b/ui/src/app/dashboard/dashboard.controller.js
index 6b9b0b3..735c881 100644
--- a/ui/src/app/dashboard/dashboard.controller.js
+++ b/ui/src/app/dashboard/dashboard.controller.js
@@ -72,6 +72,12 @@ export default function DashboardController(types, utils, dashboardUtils, widget
set: function() { }
});
+ Object.defineProperty(vm, 'rightLayoutOpened', {
+ get: function() {
+ return !vm.isMobile || vm.isRightLayoutOpened; },
+ set: function() { }
+ });
+
vm.layouts = {
main: {
show: false,
diff --git a/ui/src/app/dashboard/dashboard.tpl.html b/ui/src/app/dashboard/dashboard.tpl.html
index 96ce711..1a3b9bf 100644
--- a/ui/src/app/dashboard/dashboard.tpl.html
+++ b/ui/src/app/dashboard/dashboard.tpl.html
@@ -150,7 +150,7 @@
zIndex: 1}"
md-component-id="right-dashboard-layout"
aria-label="Right dashboard layout"
- md-is-open="!vm.isMobile || vm.isRightLayoutOpened"
+ md-is-open="vm.rightLayoutOpened"
md-is-locked-open="!vm.isMobile">
<tb-dashboard-layout style="height: 100%;"
layout-ctx="vm.layouts.right.layoutCtx"
diff --git a/ui/src/app/dashboard/states/default-state-controller.js b/ui/src/app/dashboard/states/default-state-controller.js
index 4844b4c..716d333 100644
--- a/ui/src/app/dashboard/states/default-state-controller.js
+++ b/ui/src/app/dashboard/states/default-state-controller.js
@@ -42,8 +42,10 @@ export default function DefaultStateController($scope, $location, $state, $state
params: params
}
//append new state
+ stopWatchStateObject();
vm.stateObject[0] = newState;
gotoState(vm.stateObject[0].id, true, openRightLayout);
+ watchStateObject();
}
}
@@ -57,24 +59,36 @@ export default function DefaultStateController($scope, $location, $state, $state
params: params
}
//replace with new state
+ stopWatchStateObject();
vm.stateObject[0] = newState;
gotoState(vm.stateObject[0].id, true, openRightLayout);
+ watchStateObject();
}
}
function navigatePrevState(index) {
if (index < vm.stateObject.length-1) {
+ stopWatchStateObject();
vm.stateObject.splice(index+1, vm.stateObject.length-index-1);
gotoState(vm.stateObject[vm.stateObject.length-1].id, true);
+ watchStateObject();
}
}
function getStateId() {
- return vm.stateObject[vm.stateObject.length-1].id;
+ if (vm.stateObject && vm.stateObject.length) {
+ return vm.stateObject[vm.stateObject.length-1].id;
+ } else {
+ return '';
+ }
}
function getStateParams() {
- return vm.stateObject[vm.stateObject.length-1].params;
+ if (vm.stateObject && vm.stateObject.length) {
+ return vm.stateObject[vm.stateObject.length - 1].params;
+ } else {
+ return {};
+ }
}
function getStateParamsByStateId(stateId) {
@@ -102,7 +116,7 @@ export default function DefaultStateController($scope, $location, $state, $state
if (translation != translationId) {
result = translation + '';
} else {
- result = state.name;
+ result = id;
}
return result;
}
@@ -194,7 +208,4 @@ export default function DefaultStateController($scope, $location, $state, $state
$location.search({state : angular.toJson(vm.stateObject)});
}
}
-
-
-
}
diff --git a/ui/src/app/dashboard/states/entity-state-controller.js b/ui/src/app/dashboard/states/entity-state-controller.js
index 6e7685e..dd295cc 100644
--- a/ui/src/app/dashboard/states/entity-state-controller.js
+++ b/ui/src/app/dashboard/states/entity-state-controller.js
@@ -44,9 +44,11 @@ export default function EntityStateController($scope, $location, $state, $stateP
params: params
}
//append new state
+ stopWatchStateObject();
vm.stateObject.push(newState);
vm.selectedStateIndex = vm.stateObject.length-1;
gotoState(vm.stateObject[vm.stateObject.length-1].id, true, openRightLayout);
+ watchStateObject();
}
);
}
@@ -62,8 +64,10 @@ export default function EntityStateController($scope, $location, $state, $stateP
params: params
}
//replace with new state
+ stopWatchStateObject();
vm.stateObject[vm.stateObject.length - 1] = newState;
gotoState(vm.stateObject[vm.stateObject.length - 1].id, true, openRightLayout);
+ watchStateObject();
}
);
}
@@ -71,18 +75,28 @@ export default function EntityStateController($scope, $location, $state, $stateP
function navigatePrevState(index) {
if (index < vm.stateObject.length-1) {
+ stopWatchStateObject();
vm.stateObject.splice(index+1, vm.stateObject.length-index-1);
vm.selectedStateIndex = vm.stateObject.length-1;
gotoState(vm.stateObject[vm.stateObject.length-1].id, true);
+ watchStateObject();
}
}
function getStateId() {
- return vm.stateObject[vm.stateObject.length-1].id;
+ if (vm.stateObject && vm.stateObject.length) {
+ return vm.stateObject[vm.stateObject.length-1].id;
+ } else {
+ return '';
+ }
}
function getStateParams() {
- return vm.stateObject[vm.stateObject.length-1].params;
+ if (vm.stateObject && vm.stateObject.length) {
+ return vm.stateObject[vm.stateObject.length - 1].params;
+ } else {
+ return {};
+ }
}
function getStateParamsByStateId(stateId) {
diff --git a/ui/src/app/dashboard/states/manage-dashboard-states.controller.js b/ui/src/app/dashboard/states/manage-dashboard-states.controller.js
index 452e94f..3595f65 100644
--- a/ui/src/app/dashboard/states/manage-dashboard-states.controller.js
+++ b/ui/src/app/dashboard/states/manage-dashboard-states.controller.js
@@ -122,7 +122,7 @@ export default function ManageDashboardStatesController($scope, $mdDialog, $filt
}
function getStateIndex(id) {
- var result = $filter('filter')(vm.allStates, {id: id});
+ var result = $filter('filter')(vm.allStates, {id: id}, true);
if (result && result.length) {
return vm.allStates.indexOf(result[0]);
}