Skip to content

Commit

Permalink
Resize the default dashboard size and max widget size as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Oct 10, 2013
1 parent b92a119 commit f302bef
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions hawtio-web/src/main/webapp/app/dashboard/js/gridsterDirective.ts
Expand Up @@ -113,12 +113,32 @@ module Dashboard {

function onDashboardLoad(dashboard) {
$scope.dashboard = dashboard;
var widgets = ((dashboard) ? dashboard.widgets : null) || [];

var minHeight = 10;
var minWidth = 6;

angular.forEach(widgets, (widget) => {
if (angular.isDefined(widget.row) && minHeight < widget.row) {
minHeight = widget.row + 1;
}
if (angular.isDefined(widget.size_x
&& angular.isDefined(widget.col))) {
var rightEdge = widget.col + widget.size_x;
if (rightEdge > minWidth) {
minWidth = rightEdge + 1;
}
}

});

var gridster = $element.gridster({
widget_margins: [gridMargin, gridMargin],
widget_base_dimensions: [$scope.gridX, $scope.gridY],
extra_rows: 10,
extra_cols: 6,
extra_rows: minHeight,
extra_cols: minWidth,
max_size_x: minWidth,
max_size_y: minHeight,
draggable: {
stop: (event, ui) => {
if (serializeDashboard()) {
Expand All @@ -129,7 +149,6 @@ module Dashboard {
}).data('gridster');

var template = $templateCache.get("widgetTemplate");
var widgets = ((dashboard) ? dashboard.widgets : null) || [];
angular.forEach(widgets, (widget) => {
var childScope = $scope.$new(false);
childScope.widget = widget;
Expand Down

0 comments on commit f302bef

Please sign in to comment.