|
@@ -65,24 +65,7 @@ export class DashboardCtrl implements PanelContainer {
|
|
|
this.dashboard = dashboard;
|
|
this.dashboard = dashboard;
|
|
|
this.dashboard.processRepeats();
|
|
this.dashboard.processRepeats();
|
|
|
|
|
|
|
|
- if (this.$location.search().autofitpanels) {
|
|
|
|
|
- let maxRows = Math.max(
|
|
|
|
|
- ...this.dashboard.panels.map(panel => {
|
|
|
|
|
- return panel.gridPos.h + panel.gridPos.y;
|
|
|
|
|
- })
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- //Consider navbar and submenu controls, padding and margin
|
|
|
|
|
- let availableHeight = window.innerHeight - 80;
|
|
|
|
|
- let availableRows = Math.floor(availableHeight / (GRID_CELL_HEIGHT + GRID_CELL_VMARGIN));
|
|
|
|
|
- let scaleFactor = maxRows / availableRows;
|
|
|
|
|
-
|
|
|
|
|
- this.dashboard.panels.forEach((panel, i) => {
|
|
|
|
|
- panel.gridPos.y = Math.round(panel.gridPos.y / scaleFactor) || 1;
|
|
|
|
|
- panel.gridPos.h = Math.round(panel.gridPos.h / scaleFactor) || 1;
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ this.autofitPanels();
|
|
|
this.unsavedChangesSrv.init(dashboard, this.$scope);
|
|
this.unsavedChangesSrv.init(dashboard, this.$scope);
|
|
|
|
|
|
|
|
// TODO refactor ViewStateSrv
|
|
// TODO refactor ViewStateSrv
|
|
@@ -99,6 +82,26 @@ export class DashboardCtrl implements PanelContainer {
|
|
|
.catch(this.onInitFailed.bind(this, 'Dashboard init failed', true));
|
|
.catch(this.onInitFailed.bind(this, 'Dashboard init failed', true));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ autofitPanels() {
|
|
|
|
|
+ if (this.$location.search().autofitpanels) {
|
|
|
|
|
+ let maxRows = Math.max(
|
|
|
|
|
+ ...this.dashboard.panels.map(panel => {
|
|
|
|
|
+ return panel.gridPos.h + panel.gridPos.y;
|
|
|
|
|
+ })
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ //Consider navbar and submenu controls, padding and margin
|
|
|
|
|
+ let availableHeight = window.innerHeight - 80;
|
|
|
|
|
+ let availableRows = Math.floor(availableHeight / (GRID_CELL_HEIGHT + GRID_CELL_VMARGIN));
|
|
|
|
|
+ let scaleFactor = maxRows / availableRows;
|
|
|
|
|
+
|
|
|
|
|
+ this.dashboard.panels.forEach((panel, i) => {
|
|
|
|
|
+ panel.gridPos.y = Math.round(panel.gridPos.y / scaleFactor) || 1;
|
|
|
|
|
+ panel.gridPos.h = Math.round(panel.gridPos.h / scaleFactor) || 1;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
onInitFailed(msg, fatal, err) {
|
|
onInitFailed(msg, fatal, err) {
|
|
|
console.log(msg, err);
|
|
console.log(msg, err);
|
|
|
|
|
|