소스 검색

fixed issue with template refresh

Torkel Ödegaard 7 년 전
부모
커밋
11f66bb909

+ 7 - 0
public/app/features/dashboard/dashboard_ctrl.ts

@@ -162,10 +162,17 @@ export class DashboardCtrl {
     this.dashboard.removePanel(panel);
   }
 
+  onDestroy() {
+    if (this.dashboard) {
+      this.dashboard.destroy();
+    }
+  }
+
   init(dashboard) {
     this.$scope.onAppEvent('show-json-editor', this.showJsonEditor.bind(this));
     this.$scope.onAppEvent('template-variable-value-updated', this.templateVariableUpdated.bind(this));
     this.$scope.onAppEvent('panel-remove', this.onRemovingPanel.bind(this));
+    this.$scope.$on('$destroy', this.onDestroy.bind(this));
     this.setupDashboard(dashboard);
   }
 }

+ 4 - 0
public/app/features/dashboard/dashboard_model.ts

@@ -200,6 +200,10 @@ export class DashboardModel {
     this.events.emit('view-mode-changed', panel);
   }
 
+  timeRangeUpdated() {
+    this.events.emit('time-range-updated');
+  }
+
   startRefresh() {
     this.events.emit('refresh');
 

+ 0 - 1
public/app/features/dashboard/dashgrid/DashboardGrid.tsx

@@ -172,7 +172,6 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
 
   renderPanels() {
     const panelElements = [];
-    console.log('render panels');
 
     for (const panel of this.props.dashboard.panels) {
       const panelClasses = classNames({ panel: true, 'panel--fullscreen': panel.fullscreen });

+ 2 - 2
public/app/features/dashboard/time_srv.ts

@@ -6,8 +6,8 @@ import _ from 'lodash';
 import kbn from 'app/core/utils/kbn';
 import coreModule from 'app/core/core_module';
 import * as dateMath from 'app/core/utils/datemath';
-
 // Types
+
 import { TimeRange } from 'app/types';
 
 export class TimeSrv {
@@ -147,7 +147,7 @@ export class TimeSrv {
   }
 
   refreshDashboard() {
-    this.dashboard.startRefresh();
+    this.dashboard.timeRangeUpdated();
   }
 
   private startNextRefreshTimer(afterMs) {

+ 0 - 1
public/app/features/panel/metrics_panel_ctrl.ts

@@ -61,7 +61,6 @@ class MetricsPanelCtrl extends PanelCtrl {
   }
 
   private onMetricsPanelRefresh() {
-    console.log('metrics_panel_ctrl:onRefresh');
     // ignore fetching data if another panel is in fullscreen
     if (this.otherPanelInFullscreenMode()) {
       return;

+ 0 - 1
public/app/features/panel/panel_directive.ts

@@ -135,7 +135,6 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
       ctrl.events.on('panel-size-changed', () => {
         ctrl.calculatePanelHeight();
         $timeout(() => {
-          console.log('panel directive panel size changed, render');
           resizeScrollableContent();
           ctrl.render();
         });

+ 0 - 1
public/app/features/plugins/plugin_component.ts

@@ -211,7 +211,6 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
         elem.append(child);
         setTimeout(() => {
           scope.$applyAsync(() => {
-            console.log('post appendAndCompile, broadcast refresh', scope.panel);
             scope.$broadcast('component-did-mount');
           });
         });

+ 6 - 9
public/app/features/templating/variable_srv.ts

@@ -13,13 +13,12 @@ export class VariableSrv {
 
   /** @ngInject */
   constructor(private $rootScope, private $q, private $location, private $injector, private templateSrv) {
-    // update time variant variables
-    $rootScope.$on('refresh', this.onDashboardRefresh.bind(this), $rootScope);
     $rootScope.$on('template-variable-value-updated', this.updateUrlParamsWithCurrentVariables.bind(this), $rootScope);
   }
 
   init(dashboard) {
     this.dashboard = dashboard;
+    this.dashboard.on('time-range-updated', this.onTimeRangeUpdated.bind(this));
 
     // create working class models representing variables
     this.variables = dashboard.templating.list = dashboard.templating.list.map(this.createVariableFromModel.bind(this));
@@ -42,11 +41,7 @@ export class VariableSrv {
       });
   }
 
-  onDashboardRefresh(evt, payload) {
-    if (payload && payload.fromVariableValueUpdated) {
-      return Promise.resolve({});
-    }
-
+  onTimeRangeUpdated() {
     const promises = this.variables.filter(variable => variable.refresh === 2).map(variable => {
       const previousOptions = variable.options.slice();
 
@@ -57,7 +52,9 @@ export class VariableSrv {
       });
     });
 
-    return this.$q.all(promises);
+    return this.$q.all(promises).then(() => {
+      this.dashboard.startRefresh();
+    });
   }
 
   processVariable(variable, queryParams) {
@@ -136,7 +133,7 @@ export class VariableSrv {
     return this.$q.all(promises).then(() => {
       if (emitChangeEvents) {
         this.$rootScope.$emit('template-variable-value-updated');
-        this.$rootScope.$broadcast('refresh', { fromVariableValueUpdated: true });
+        this.dashboard.startRefresh();
       }
     });
   }

+ 0 - 1
public/app/plugins/datasource/testdata/datasource.ts

@@ -62,7 +62,6 @@ class TestDataDatasource {
           });
         }
 
-        console.log(res);
         return { data: data };
       });
   }

+ 0 - 1
public/app/plugins/panel/graph/graph.ts

@@ -339,7 +339,6 @@ class GraphElement {
 
   callPlot(options, incrementRenderCounter) {
     try {
-      console.log('plot', this.sortedSeries);
       this.plot = $.plot(this.elem, this.sortedSeries, options);
       if (this.ctrl.renderError) {
         delete this.ctrl.error;