Commit 55609382 by Torkel Ödegaard

fix: fixed panel size rerendering issues

parent 47014ddb
...@@ -75,7 +75,7 @@ export class DashboardViewState { ...@@ -75,7 +75,7 @@ export class DashboardViewState {
} }
// remember if editStateChanged // remember if editStateChanged
this.editStateChanged = state.edit !== this.state.edit; this.editStateChanged = (state.edit || false) !== (this.state.edit || false);
_.extend(this.state, state); _.extend(this.state, state);
this.dashboard.meta.fullscreen = this.state.fullscreen; this.dashboard.meta.fullscreen = this.state.fullscreen;
......
...@@ -52,12 +52,9 @@ export class PanelCtrl { ...@@ -52,12 +52,9 @@ export class PanelCtrl {
this.events.emit('panel-teardown'); this.events.emit('panel-teardown');
this.events.removeAllListeners(); this.events.removeAllListeners();
}); });
this.calculatePanelHeight();
} }
init() { init() {
this.events.on('panel-size-changed', this.onSizeChanged.bind(this));
this.events.emit('panel-initialized'); this.events.emit('panel-initialized');
this.publishAppEvent('panel-initialized', {scope: this.$scope}); this.publishAppEvent('panel-initialized', {scope: this.$scope});
} }
...@@ -184,13 +181,6 @@ export class PanelCtrl { ...@@ -184,13 +181,6 @@ export class PanelCtrl {
this.events.emit('render', payload); this.events.emit('render', payload);
} }
private onSizeChanged() {
this.calculatePanelHeight();
this.$timeout(() => {
this.render();
}, 100);
}
duplicate() { duplicate() {
this.dashboard.duplicatePanel(this.panel); this.dashboard.duplicatePanel(this.panel);
this.$timeout(() => { this.$timeout(() => {
......
...@@ -53,7 +53,7 @@ var panelTemplate = ` ...@@ -53,7 +53,7 @@ var panelTemplate = `
</div> </div>
`; `;
module.directive('grafanaPanel', function($rootScope, $document) { module.directive('grafanaPanel', function($rootScope, $document, $timeout) {
return { return {
restrict: 'E', restrict: 'E',
template: panelTemplate, template: panelTemplate,
...@@ -106,11 +106,19 @@ module.directive('grafanaPanel', function($rootScope, $document) { ...@@ -106,11 +106,19 @@ module.directive('grafanaPanel', function($rootScope, $document) {
} }
}); });
ctrl.events.on('render', () => { ctrl.events.on('panel-size-changed', () => {
if (lastHeight !== ctrl.height) { ctrl.calculatePanelHeight();
panelHeightUpdated(); panelHeightUpdated();
} $timeout(() => {
ctrl.render();
});
});
// set initial height
ctrl.calculatePanelHeight();
panelHeightUpdated();
ctrl.events.on('render', () => {
if (transparentLastState !== ctrl.panel.transparent) { if (transparentLastState !== ctrl.panel.transparent) {
panelContainer.toggleClass('panel-transparent', ctrl.panel.transparent === true); panelContainer.toggleClass('panel-transparent', ctrl.panel.transparent === true);
transparentLastState = ctrl.panel.transparent; transparentLastState = ctrl.panel.transparent;
......
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