Commit 624f3a01 by Torkel Ödegaard

refactor: take submenu into account PR #12796

parent b1b8a380
...@@ -62,6 +62,7 @@ export class DashboardCtrl implements PanelContainer { ...@@ -62,6 +62,7 @@ export class DashboardCtrl implements PanelContainer {
.finally(() => { .finally(() => {
this.dashboard = dashboard; this.dashboard = dashboard;
this.dashboard.processRepeats(); this.dashboard.processRepeats();
this.dashboard.updateSubmenuVisibility();
this.dashboard.autoFitPanels(window.innerHeight); this.dashboard.autoFitPanels(window.innerHeight);
this.unsavedChangesSrv.init(dashboard, this.$scope); this.unsavedChangesSrv.init(dashboard, this.$scope);
...@@ -71,8 +72,6 @@ export class DashboardCtrl implements PanelContainer { ...@@ -71,8 +72,6 @@ export class DashboardCtrl implements PanelContainer {
this.dashboardViewState = this.dashboardViewStateSrv.create(this.$scope); this.dashboardViewState = this.dashboardViewStateSrv.create(this.$scope);
this.keybindingSrv.setupDashboardBindings(this.$scope, dashboard); this.keybindingSrv.setupDashboardBindings(this.$scope, dashboard);
this.dashboard.updateSubmenuVisibility();
this.setWindowTitleAndTheme(); this.setWindowTitleAndTheme();
this.$scope.appEvent('dashboard-initialized', dashboard); this.$scope.appEvent('dashboard-initialized', dashboard);
......
...@@ -836,16 +836,22 @@ export class DashboardModel { ...@@ -836,16 +836,22 @@ export class DashboardModel {
return; return;
} }
let currentGridHeight = Math.max( const currentGridHeight = Math.max(
...this.panels.map(panel => { ...this.panels.map(panel => {
return panel.gridPos.h + panel.gridPos.y; return panel.gridPos.h + panel.gridPos.y;
}) })
); );
//Consider navbar and submenu controls, padding and margin // Consider navbar and submenu controls, padding and margin
let visibleHeight = window.innerHeight - 55 - 20; let visibleHeight = window.innerHeight - 55 - 20;
let visibleGridHeight = Math.floor(visibleHeight / (GRID_CELL_HEIGHT + GRID_CELL_VMARGIN));
let scaleFactor = currentGridHeight / visibleGridHeight; // Remove submenu if visible
if (this.meta.submenuEnabled) {
visibleHeight -= 50;
}
const visibleGridHeight = Math.floor(visibleHeight / (GRID_CELL_HEIGHT + GRID_CELL_VMARGIN));
const scaleFactor = currentGridHeight / visibleGridHeight;
this.panels.forEach((panel, i) => { this.panels.forEach((panel, i) => {
panel.gridPos.y = Math.round(panel.gridPos.y / scaleFactor) || 1; panel.gridPos.y = Math.round(panel.gridPos.y / scaleFactor) || 1;
......
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