Skip to content

Commit

Permalink
Enable send to background in Timelion (#82232) (#82258)
Browse files Browse the repository at this point in the history
* Enable send to background in Timelion

* add jest
  • Loading branch information
alexwizp authored Nov 2, 2020
1 parent b64ee15 commit b9d313b
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 101 deletions.
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

0 comments on commit b9d313b

Please sign in to comment.