diff --git a/client/app/services/dashboard.js b/client/app/services/dashboard.js index 86869c5e70..4be6b612cf 100644 --- a/client/app/services/dashboard.js +++ b/client/app/services/dashboard.js @@ -33,50 +33,6 @@ export function collectDashboardFilters(dashboard, queryResults, urlParams) { return _.values(filters); } -function prepareWidgetsForDashboard(widgets) { - // Default height for auto-height widgets. - // Compute biggest widget size and choose between it and some magic number. - // This value should be big enough so auto-height widgets will not overlap other ones. - const defaultWidgetSizeY = - Math.max( - _ - .chain(widgets) - .map(w => w.options.position.sizeY) - .max() - .value(), - 20, - ) + 5; - - // Fix layout: - // 1. sort and group widgets by row - // 2. update position of widgets in each row - place it right below - // biggest widget from previous row - _.chain(widgets) - .sortBy(widget => widget.options.position.row) - .groupBy(widget => widget.options.position.row) - .reduce((row, widgetsAtRow) => { - let height = 1; - _.each(widgetsAtRow, (widget) => { - height = Math.max( - height, - widget.options.position.autoHeight ? defaultWidgetSizeY : widget.options.position.sizeY, - ); - widget.options.position.row = row; - if (widget.options.position.sizeY < 1) { - widget.options.position.sizeY = defaultWidgetSizeY; - } - }); - return row + height; - }, 0) - .value(); - - // Sort widgets by updated column and row value - widgets = _.sortBy(widgets, widget => widget.options.position.col); - widgets = _.sortBy(widgets, widget => widget.options.position.row); - - return widgets; -} - function calculateNewWidgetPosition(existingWidgets, newWidget) { const width = _.extend({ sizeX: dashboardGridOptions.defaultSizeX }, _.extend({}, newWidget.options).position).sizeX; @@ -125,7 +81,7 @@ function calculateNewWidgetPosition(existingWidgets, newWidget) { function DashboardService($resource, $http, $location, currentUser) { function prepareDashboardWidgets(widgets) { - return prepareWidgetsForDashboard(_.map(widgets, widget => new Widget(widget))); + return _.map(widgets, widget => new Widget(widget)); } function transformSingle(dashboard) { @@ -187,7 +143,6 @@ function DashboardService($resource, $http, $location, currentUser) { }; resource.prepareDashboardWidgets = prepareDashboardWidgets; - resource.prepareWidgetsForDashboard = prepareWidgetsForDashboard; resource.prototype.getParametersDefs = function getParametersDefs() { const globalParams = {}; const queryParams = $location.search();