scrollable panels: fix initial content size (#9960)

This commit is contained in:
Alexander Zobnin
2017-11-22 09:05:33 +03:00
committed by Torkel Ödegaard
parent 830c307bba
commit 18ca7a53aa
2 changed files with 23 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ import Remarkable from 'remarkable';
import {GRID_CELL_HEIGHT, GRID_CELL_VMARGIN} from 'app/core/constants'; import {GRID_CELL_HEIGHT, GRID_CELL_VMARGIN} from 'app/core/constants';
const TITLE_HEIGHT = 27; const TITLE_HEIGHT = 27;
const PANEL_BORDER = 2; const PANEL_BORDER = 12;
import {Emitter} from 'app/core/core'; import {Emitter} from 'app/core/core';
@@ -62,6 +62,7 @@ export class PanelCtrl {
} }
refresh() { refresh() {
this.setPanelHeight();
this.events.emit('refresh', null); this.events.emit('refresh', null);
} }
@@ -70,6 +71,7 @@ export class PanelCtrl {
} }
changeView(fullscreen, edit) { changeView(fullscreen, edit) {
this.setPanelHeight();
this.publishAppEvent('panel-change-view', { this.publishAppEvent('panel-change-view', {
fullscreen: fullscreen, edit: edit, panelId: this.panel.id fullscreen: fullscreen, edit: edit, panelId: this.panel.id
}); });
@@ -168,8 +170,15 @@ export class PanelCtrl {
console.log(PANEL_BORDER + TITLE_HEIGHT); console.log(PANEL_BORDER + TITLE_HEIGHT);
} }
setPanelHeight() {
if (this.$scope.setPanelHeight) {
this.$scope.setPanelHeight();
}
}
render(payload?) { render(payload?) {
this.timing.renderStart = new Date().getTime(); this.timing.renderStart = new Date().getTime();
this.setPanelHeight();
this.events.emit('render', payload); this.events.emit('render', payload);
} }

View File

@@ -65,6 +65,7 @@ module.directive('grafanaPanel', function($rootScope, $document) {
var cornerInfoElem = elem.find('.panel-info-corner'); var cornerInfoElem = elem.find('.panel-info-corner');
var ctrl = scope.ctrl; var ctrl = scope.ctrl;
var infoDrop; var infoDrop;
var panelScrollbar;
// the reason for handling these classes this way is for performance // the reason for handling these classes this way is for performance
// limit the watchers on panels etc // limit the watchers on panels etc
@@ -90,13 +91,24 @@ module.directive('grafanaPanel', function($rootScope, $document) {
if (ctrl.__proto__.constructor.scrollable) { if (ctrl.__proto__.constructor.scrollable) {
panelContent.addClass('panel-content--scrollable'); panelContent.addClass('panel-content--scrollable');
var myScrollbar = new GeminiScrollbar({ panelScrollbar = new GeminiScrollbar({
autoshow: false, autoshow: false,
element: panelContent[0] element: panelContent[0]
}).create(); }).create();
} }
} }
function setPanelHeight() {
panelContent.height(ctrl.height);
if (panelScrollbar) {
panelScrollbar.update();
}
}
if (ctrl.__proto__.constructor.scrollable) {
ctrl.$scope.setPanelHeight = setPanelHeight;
}
// set initial transparency // set initial transparency
if (ctrl.panel.transparent) { if (ctrl.panel.transparent) {
transparentLastState = true; transparentLastState = true;