mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
use default range from time picker
This commit is contained in:
@@ -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);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user