Commit f274195d by Torkel Ödegaard

wip: refactoring interval and time override handling

parent d49e857b
......@@ -9,7 +9,7 @@ import { PanelHeader } from './PanelHeader/PanelHeader';
import { DataPanel } from './DataPanel';
// Utils
import { applyPanelTimeOverrides, getResolution, calculateInterval } from 'app/features/dashboard/utils/panel';
import { applyPanelTimeOverrides } from 'app/features/dashboard/utils/panel';
// Types
import { PanelModel } from '../panel_model';
......@@ -25,12 +25,8 @@ export interface Props {
export interface State {
refreshCounter: number;
renderCounter: number;
timeInfo: string;
timeRange: TimeRange;
interval: {
interval: string;
intervalMs: number;
};
timeInfo?: string;
timeRange?: TimeRange;
}
export class PanelChrome extends PureComponent<Props, State> {
......@@ -42,12 +38,6 @@ export class PanelChrome extends PureComponent<Props, State> {
this.state = {
refreshCounter: 0,
renderCounter: 0,
timeInfo: '',
timeRange: this.timeSrv.timeRange(),
interval: {
interval: undefined,
intervalMs: undefined,
},
};
}
......@@ -68,25 +58,20 @@ export class PanelChrome extends PureComponent<Props, State> {
}
const { panel } = this.props;
const timeRange = this.timeSrv.timeRange();
const timeData = applyPanelTimeOverrides(panel, timeRange);
const resolution = getResolution(panel);
const interval = calculateInterval(panel, panel.datasource, timeData.timeRange, resolution);
const timeData = applyPanelTimeOverrides(panel, this.timeSrv.timeRange());
this.setState(prevState => ({
...prevState,
this.setState({
refreshCounter: this.state.refreshCounter + 1,
interval,
...timeData,
}));
timeRange: timeData.timeRange,
timeInfo: timeData.timeInfo,
});
};
onRender = () => {
console.log('onRender');
this.setState(prevState => ({
...prevState,
this.setState({
renderCounter: this.state.renderCounter + 1,
}));
});
};
get isVisible() {
......
......@@ -20,7 +20,7 @@ export class TimeSrv {
private autoRefreshBlocked: boolean;
/** @ngInject */
constructor(private $rootScope, private $timeout, private $location, private timer, private contextSrv) {
constructor($rootScope, private $timeout, private $location, private timer, private contextSrv) {
// default time
this.time = { from: '6h', to: 'now' };
......@@ -189,7 +189,6 @@ export class TimeSrv {
this.$location.search(urlParams);
}
this.$rootScope.appEvent('time-range-changed', this.time);
this.$timeout(this.refreshDashboard.bind(this), 0);
}
......
// Store
// Store
import store from 'app/core/store';
// Models
......
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