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