Commit 1998c08d by Erik Sundell

use default range from time picker

parent 109ff1a3
......@@ -139,7 +139,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
this.modifiedQueries = initialQueries.slice();
this.timeSrv = getTimeSrv();
this.timeSrv.init({
time: { from: 'now-6h', to: 'now' },
time: DEFAULT_RANGE,
refresh: false,
getTimezone: () => 'utc',
timeRangeUpdated: () => console.log('refreshDashboard!'),
......
......@@ -25,7 +25,7 @@ export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
const { datasource, initialQuery, exploreEvents } = this.props;
const loader = getAngularLoader();
const template = '<plugin-component type="query-ctrl"> </plugin-component>';
const target = { datasource: datasource.name };
const target = { datasource: datasource.name, ...initialQuery };
const scopeProps = {
target,
ctrl: {
......
......@@ -3,7 +3,7 @@ import moment from 'moment';
import * as dateMath from 'app/core/utils/datemath';
import * as rangeUtil from 'app/core/utils/rangeutil';
import { RawTimeRange } from 'app/types/series';
import { RawTimeRange, TimeRange } from 'app/types/series';
const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export const DEFAULT_RANGE = {
......@@ -120,6 +120,12 @@ export default class TimePicker extends PureComponent<TimePickerProps, TimePicke
to: moment(nextTo),
};
const nextTimeRange: TimeRange = {
raw: nextRange,
from,
to,
};
this.setState(
{
rangeString: rangeUtil.describeTimeRange(nextRange),
......@@ -127,7 +133,7 @@ export default class TimePicker extends PureComponent<TimePickerProps, TimePicke
toRaw: nextRange.to.format(DATE_FORMAT),
},
() => {
onChangeTime(nextRange);
onChangeTime(nextTimeRange);
}
);
}
......
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