Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d2273533
Unverified
Commit
d2273533
authored
Mar 05, 2020
by
Marcus Andersson
Committed by
GitHub
Mar 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: when reloading page make sure that time picker history is converted to dateTime.
parent
ea3d368e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
public/app/core/components/TimePicker/TimePickerWithHistory.tsx
+17
-2
No files found.
public/app/core/components/TimePicker/TimePickerWithHistory.tsx
View file @
d2273533
import
React
from
'react'
;
import
{
LocalStorageValueProvider
}
from
'../LocalStorageValueProvider'
;
import
{
TimeRange
,
isDateTime
}
from
'@grafana/data'
;
import
{
TimeRange
,
isDateTime
,
dateTime
}
from
'@grafana/data'
;
import
{
Props
as
TimePickerProps
,
TimePicker
}
from
'@grafana/ui/src/components/TimePicker/TimePicker'
;
const
LOCAL_STORAGE_KEY
=
'grafana.dashboard.timepicker.history'
;
...
...
@@ -14,7 +14,7 @@ export const TimePickerWithHistory: React.FC<Props> = props => {
return
(
<
TimePicker
{
...
props
}
history=
{
values
}
history=
{
convertIfJson
(
values
)
}
onChange=
{
value
=>
{
onAppendToHistory
(
value
,
values
,
onSaveToStore
);
props
.
onChange
(
value
);
...
...
@@ -25,6 +25,21 @@ export const TimePickerWithHistory: React.FC<Props> = props => {
</
LocalStorageValueProvider
>
);
};
function
convertIfJson
(
history
:
TimeRange
[]):
TimeRange
[]
{
return
history
.
map
(
time
=>
{
if
(
isDateTime
(
time
.
from
))
{
return
time
;
}
return
{
from
:
dateTime
(
time
.
from
),
to
:
dateTime
(
time
.
to
),
raw
:
time
.
raw
,
};
});
}
function
onAppendToHistory
(
toAppend
:
TimeRange
,
values
:
TimeRange
[],
onSaveToStore
:
(
values
:
TimeRange
[])
=>
void
)
{
if
(
!
isAbsolute
(
toAppend
))
{
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment