Commit 11f66bb9 by Torkel Ödegaard

fixed issue with template refresh

parent dddbe62d
......@@ -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);
}
}
......
......@@ -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');
......
......@@ -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 });
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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();
});
......
......@@ -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');
});
});
......
......@@ -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();
}
});
}
......
......@@ -62,7 +62,6 @@ class TestDataDatasource {
});
}
console.log(res);
return { data: data };
});
}
......
......@@ -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;
......
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