Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable send to background in Timelion #82232

Merged
merged 2 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
* under the License.
*/

import { IndexPatternsContract } from 'src/plugins/data/public';
import { SavedObjectsClientContract } from 'kibana/public';
import type { IndexPatternsContract, ISearchStart } from 'src/plugins/data/public';
import type { SavedObjectsClientContract } from 'kibana/public';
import { createGetterSetter } from '../../../kibana_utils/public';

export const [getIndexPatterns, setIndexPatterns] = createGetterSetter<IndexPatternsContract>(
'IndexPatterns'
);

export const [getDataSearch, setDataSearch] = createGetterSetter<ISearchStart>('Search');

export const [getSavedObjectsClient, setSavedObjectsClient] = createGetterSetter<
SavedObjectsClientContract
>('SavedObjectsClient');
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { TimeRange, Filter, esQuery, Query } from '../../../data/public';
import { TimelionVisDependencies } from '../plugin';
import { getTimezone } from './get_timezone';
import { TimelionVisParams } from '../timelion_vis_fn';
import { getDataSearch } from '../helpers/plugin_services';

interface Stats {
cacheCount: number;
Expand Down Expand Up @@ -93,6 +94,7 @@ export function getTimelionRequestHandler({

// parse the time range client side to make sure it behaves like other charts
const timeRangeBounds = timefilter.calculateBounds(timeRange);
const sessionId = getDataSearch().session.getSessionId();

try {
return await http.post('/api/timelion/run', {
Expand All @@ -109,6 +111,7 @@ export function getTimelionRequestHandler({
interval: visParams.interval,
timezone,
},
sessionId,
}),
});
} catch (e) {
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/vis_type_timelion/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { VisualizationsSetup } from '../../visualizations/public';

import { getTimelionVisualizationConfig } from './timelion_vis_fn';
import { getTimelionVisDefinition } from './timelion_vis_type';
import { setIndexPatterns, setSavedObjectsClient } from './helpers/plugin_services';
import { setIndexPatterns, setSavedObjectsClient, setDataSearch } from './helpers/plugin_services';
import { ConfigSchema } from '../config';

import { getArgValueSuggestions } from './helpers/arg_value_suggestions';
Expand Down Expand Up @@ -104,6 +104,7 @@ export class TimelionVisPlugin
public start(core: CoreStart, plugins: TimelionVisStartDependencies) {
setIndexPatterns(plugins.data.indexPatterns);
setSavedObjectsClient(core.savedObjects.client);
setDataSearch(plugins.data.search);

return {
getArgValueSuggestions,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_type_timelion/server/routes/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function runRoute(
to: schema.maybe(schema.string()),
})
),
sessionId: schema.maybe(schema.string()),
}),
},
},
Expand Down
Loading