From a990b69baa470d30a87bc54b97ca36979f0f41a2 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Fri, 7 Dec 2018 12:41:47 +0100 Subject: [PATCH] Explore: Parse initial dates - parse dates passed from URL - keep everything local time for now --- public/app/features/explore/Explore.tsx | 4 ++-- public/app/features/explore/TimePicker.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index fb2f6759111..e281fa2ec7d 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -38,7 +38,7 @@ import Graph from './Graph'; import Logs from './Logs'; import Table from './Table'; import ErrorBoundary from './ErrorBoundary'; -import TimePicker from './TimePicker'; +import TimePicker, { parseTime } from './TimePicker'; interface ExploreProps { datasourceSrv: DatasourceSrv; @@ -115,7 +115,7 @@ export class Explore extends React.PureComponent { } else { const { datasource, queries, range } = props.urlState as ExploreUrlState; 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 const initialGraphInterval = 15 * 1000; this.state = { diff --git a/public/app/features/explore/TimePicker.tsx b/public/app/features/explore/TimePicker.tsx index 47c52b07292..b9484fb9d45 100644 --- a/public/app/features/explore/TimePicker.tsx +++ b/public/app/features/explore/TimePicker.tsx @@ -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). * @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)) { return value; }