diff --git a/ui/src/app/common/dashboard-utils.service.js b/ui/src/app/common/dashboard-utils.service.js index 64a2c646cd..c4b2486b68 100644 --- a/ui/src/app/common/dashboard-utils.service.js +++ b/ui/src/app/common/dashboard-utils.service.js @@ -425,12 +425,26 @@ function DashboardUtils(types, utils, timeService) { var prevColumns = prevGridSettings ? prevGridSettings.columns : 24; var ratio = gridSettings.columns / prevColumns; layout.gridSettings = gridSettings; + var maxRow = 0; for (var w in layout.widgets) { var widget = layout.widgets[w]; + maxRow = Math.max(maxRow, widget.row + widget.sizeY); + } + var newMaxRow = Math.round(maxRow * ratio); + for (w in layout.widgets) { + widget = layout.widgets[w]; + if (widget.row + widget.sizeY == maxRow) { + widget.row = Math.round(widget.row * ratio); + widget.sizeY = newMaxRow - widget.row; + } else { + widget.row = Math.round(widget.row * ratio); + widget.sizeY = Math.round(widget.sizeY * ratio); + } widget.sizeX = Math.round(widget.sizeX * ratio); - widget.sizeY = Math.round(widget.sizeY * ratio); widget.col = Math.round(widget.col * ratio); - widget.row = Math.round(widget.row * ratio); + if (widget.col + widget.sizeX > gridSettings.columns) { + widget.sizeX = gridSettings.columns - widget.col; + } } } diff --git a/ui/src/app/components/dashboard.directive.js b/ui/src/app/components/dashboard.directive.js index 36bda5121e..c489c32f7e 100644 --- a/ui/src/app/components/dashboard.directive.js +++ b/ui/src/app/components/dashboard.directive.js @@ -235,61 +235,6 @@ function DashboardController($scope, $rootScope, $element, $timeout, $mdMedia, $ removeResizeListener(gridsterParent[0], onGridsterParentResize); // eslint-disable-line no-undef }); - $scope.$watchCollection('vm.widgets', function () { - var ids = []; - for (var i=0;i