Commit 63fa9fdc by Tobias Skarhed Committed by Torkel Ödegaard

Add temporary url parameter

parent 338a37ab
...@@ -63,32 +63,24 @@ export class DashboardCtrl implements PanelContainer { ...@@ -63,32 +63,24 @@ export class DashboardCtrl implements PanelContainer {
.finally(() => { .finally(() => {
this.dashboard = dashboard; this.dashboard = dashboard;
this.dashboard.processRepeats(); this.dashboard.processRepeats();
console.log(this.dashboard.panels);
if (window.location.search.search('autofitpanels') !== -1) {
let maxRows = Math.max( let maxRows = Math.max(
...this.dashboard.panels.map(panel => { ...this.dashboard.panels.map(panel => {
return panel.gridPos.h + panel.gridPos.y; return panel.gridPos.h + panel.gridPos.y;
}) })
); );
console.log('maxRows: ' + maxRows);
//Consider navbar and submenu controls, padding and margin //Consider navbar and submenu controls, padding and margin
let availableHeight = window.innerHeight - 80; let availableHeight = window.innerHeight - 80;
let availableRows = Math.floor(availableHeight / (GRID_CELL_HEIGHT + GRID_CELL_VMARGIN)); let availableRows = Math.floor(availableHeight / (GRID_CELL_HEIGHT + GRID_CELL_VMARGIN));
let scaleFactor = maxRows / availableRows;
console.log('availableRows: ' + availableRows);
let scaleFactor = maxRows / availableRows; this.dashboard.panels.forEach((panel, i) => {
console.log(scaleFactor); panel.gridPos.y = Math.round(panel.gridPos.y / scaleFactor) || 1;
panel.gridPos.h = Math.round(panel.gridPos.h / scaleFactor) || 1;
this.dashboard.panels.forEach((panel, i) => { });
console.log(i); }
console.log(panel.gridPos);
panel.gridPos.y = Math.round(panel.gridPos.y / scaleFactor) || 1;
panel.gridPos.h = Math.round(panel.gridPos.h / scaleFactor) || 1;
console.log(panel.gridPos);
});
console.log(this.dashboard.panels);
this.unsavedChangesSrv.init(dashboard, this.$scope); this.unsavedChangesSrv.init(dashboard, this.$scope);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment