Quellcode durchsuchen

fix: fixed panel size rerendering issues

Torkel Ödegaard vor 8 Jahren
Ursprung
Commit
55609382f1

+ 1 - 1
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;

+ 0 - 10
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(() => {

+ 13 - 5
public/app/features/panel/panel_directive.ts

@@ -53,7 +53,7 @@ var panelTemplate = `
   </div>
 `;
 
-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;