Commit 687cf013 by Daniel Lee Committed by GitHub

Merge pull request #14385 from grafana/davkal/fix-explore-date-parsing

Explore: Parse initial dates
parents 619b4b48 a990b69b
...@@ -38,7 +38,7 @@ import Graph from './Graph'; ...@@ -38,7 +38,7 @@ import Graph from './Graph';
import Logs from './Logs'; import Logs from './Logs';
import Table from './Table'; import Table from './Table';
import ErrorBoundary from './ErrorBoundary'; import ErrorBoundary from './ErrorBoundary';
import TimePicker from './TimePicker'; import TimePicker, { parseTime } from './TimePicker';
interface ExploreProps { interface ExploreProps {
datasourceSrv: DatasourceSrv; datasourceSrv: DatasourceSrv;
...@@ -115,7 +115,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> { ...@@ -115,7 +115,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
} else { } else {
const { datasource, queries, range } = props.urlState as ExploreUrlState; const { datasource, queries, range } = props.urlState as ExploreUrlState;
initialQueries = ensureQueries(queries); initialQueries = ensureQueries(queries);
const initialRange = range || { ...DEFAULT_RANGE }; const initialRange = { from: parseTime(range.from), to: parseTime(range.to) } || { ...DEFAULT_RANGE };
// Millies step for helper bar charts // Millies step for helper bar charts
const initialGraphInterval = 15 * 1000; const initialGraphInterval = 15 * 1000;
this.state = { this.state = {
......
...@@ -15,7 +15,7 @@ export const DEFAULT_RANGE = { ...@@ -15,7 +15,7 @@ export const DEFAULT_RANGE = {
* Return a human-editable string of either relative (inludes "now") or absolute local time (in the shape of DATE_FORMAT). * Return a human-editable string of either relative (inludes "now") or absolute local time (in the shape of DATE_FORMAT).
* @param value Epoch or relative time * @param value Epoch or relative time
*/ */
export function parseTime(value: string, isUtc = false): string { export function parseTime(value: string | moment.Moment, isUtc = false): string | moment.Moment {
if (moment.isMoment(value)) { if (moment.isMoment(value)) {
return value; return value;
} }
......
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