cjord
June 23, 2021, 5:44am
1
Is there any way to get the values of the time filter in a custom page on a plugin?
I would like to be able to read the values to display on the page as well as hook into the refresh event when the time filter is updated.
This is the closest reference I have been able to find and appears to be very out of date. Get time from Time Range from custom plugin
Thanks
dosant
(Anton Dosov)
June 23, 2021, 10:41am
2
Hi @cjord !
You need to use data plugin. It will be available on time filter services:
Something like: data.query.timefilter.timefilter.getTime()
Hi @Thomas_Pierrot , welcome to the community
You can get current global time range from time filter service in data plugin:
Then you can use it to build your custom range filter
And this is how it used in one of our developer examples plugins:
state,
} = useAppState({ data });
const isRestoring = !!state.restoreSessionId;
const enableSessionStorage = useCallback(() => {
data.search.session.enableStorage({
getName: async () => 'Search sessions example',
getUrlGeneratorData: async () => ({
initialState: {
time: data.query.timefilter.timefilter.getTime(),
filters: data.query.filterManager.getFilters(),
query: data.query.queryString.getQuery(),
indexPatternId: indexPattern?.id,
numericFieldName,
} as SearchSessionExamplesUrlGeneratorState,
restoreState: {
time: data.query.timefilter.timefilter.getAbsoluteTime(),
filters: data.query.filterManager.getFilters(),
query: data.query.queryString.getQuery(),
indexPatternId: indexPattern?.id,
system
(system)
Closed
July 21, 2021, 10:42am
3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.