mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Parse initial dates
- parse dates passed from URL - keep everything local time for now
This commit is contained in:
parent
140205a783
commit
a990b69baa
@ -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> {
|
|||||||
} 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 = {
|
|||||||
* 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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user