From 55609382f1f7d6402dd9782f7b1a2100a35bb08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 9 Dec 2017 13:53:03 +0100 Subject: [PATCH] fix: fixed panel size rerendering issues --- .../app/features/dashboard/view_state_srv.ts | 2 +- public/app/features/panel/panel_ctrl.ts | 10 ---------- public/app/features/panel/panel_directive.ts | 18 +++++++++++++----- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/public/app/features/dashboard/view_state_srv.ts b/public/app/features/dashboard/view_state_srv.ts index dec507d2002..0c4c510b4fc 100644 --- a/public/app/features/dashboard/view_state_srv.ts +++ b/public/app/features/dashboard/view_state_srv.ts @@ -75,7 +75,7 @@ export class DashboardViewState { } // remember if editStateChanged - this.editStateChanged = state.edit !== this.state.edit; + this.editStateChanged = (state.edit || false) !== (this.state.edit || false); _.extend(this.state, state); this.dashboard.meta.fullscreen = this.state.fullscreen; diff --git a/public/app/features/panel/panel_ctrl.ts b/public/app/features/panel/panel_ctrl.ts index 91c1b06cbf4..ab74a006fce 100644 --- a/public/app/features/panel/panel_ctrl.ts +++ b/public/app/features/panel/panel_ctrl.ts @@ -52,12 +52,9 @@ export class PanelCtrl { this.events.emit('panel-teardown'); this.events.removeAllListeners(); }); - - this.calculatePanelHeight(); } init() { - this.events.on('panel-size-changed', this.onSizeChanged.bind(this)); this.events.emit('panel-initialized'); this.publishAppEvent('panel-initialized', {scope: this.$scope}); } @@ -184,13 +181,6 @@ export class PanelCtrl { this.events.emit('render', payload); } - private onSizeChanged() { - this.calculatePanelHeight(); - this.$timeout(() => { - this.render(); - }, 100); - } - duplicate() { this.dashboard.duplicatePanel(this.panel); this.$timeout(() => { diff --git a/public/app/features/panel/panel_directive.ts b/public/app/features/panel/panel_directive.ts index 323cd4e6f6b..d5b4bafa1ae 100644 --- a/public/app/features/panel/panel_directive.ts +++ b/public/app/features/panel/panel_directive.ts @@ -53,7 +53,7 @@ var panelTemplate = ` `; -module.directive('grafanaPanel', function($rootScope, $document) { +module.directive('grafanaPanel', function($rootScope, $document, $timeout) { return { restrict: 'E', template: panelTemplate, @@ -106,11 +106,19 @@ module.directive('grafanaPanel', function($rootScope, $document) { } }); - ctrl.events.on('render', () => { - if (lastHeight !== ctrl.height) { - panelHeightUpdated(); - } + ctrl.events.on('panel-size-changed', () => { + ctrl.calculatePanelHeight(); + panelHeightUpdated(); + $timeout(() => { + ctrl.render(); + }); + }); + // set initial height + ctrl.calculatePanelHeight(); + panelHeightUpdated(); + + ctrl.events.on('render', () => { if (transparentLastState !== ctrl.panel.transparent) { panelContainer.toggleClass('panel-transparent', ctrl.panel.transparent === true); transparentLastState = ctrl.panel.transparent;