Skip to content

Commit

Permalink
updating to latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Nov 7, 2018
1 parent 8297042 commit 3a2e8e0
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import { CourierRequestHandlerProvider } from 'ui/vis/request_handlers/courier';
import { AggConfigs } from 'ui/vis/agg_configs';

// need to get rid of angular from these
import { VisProvider } from 'ui/vis/vis';
import { IndexPatternsProvider } from 'ui/index_patterns';
import { SearchSourceProvider } from 'ui/courier/search_source';
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';

import chrome from 'ui/chrome';

Expand All @@ -46,19 +46,27 @@ export default () => ({
types: ['string', 'null'],
default: null,
},
hierarchical: {
types: ['bool', 'null'],
default: false,
},
partialRows: {
types: ['bool', 'null'],
default: false,
},
aggConfigs: {
types: ['string'],
default: '""',
help: 'AggConfig definition',
multi: false,
},
},
fn(context, args) {
fn(context, args, handlers) {
return chrome.dangerouslyGetActiveInjector().then(async $injector => {
const Private = $injector.get('Private');
const indexPatterns = Private(IndexPatternsProvider);
const SearchSource = Private(SearchSourceProvider);
const Vis = Private(VisProvider);
const queryFilter = Private(FilterBarQueryFilterProvider);

const aggConfigsState = JSON.parse(args.aggConfigs);
const indexPattern = await indexPatterns.get(args.index);
Expand All @@ -68,17 +76,17 @@ export default () => ({
const searchSource = new SearchSource();
searchSource.setField('index', indexPattern);

// we need vis just for the inspector
const vis = new Vis(indexPattern);
vis.aggs = aggs;

const response = await courierRequestHandler(vis, {
const response = await courierRequestHandler({
searchSource: searchSource,
aggs: aggs,
timeRange: _.get(context, 'timeRange', null),
query: _.get(context, 'q', null),
filters: _.get(context, 'filters', null),
forceFetch: true
forceFetch: true,
isHierarchical: args.hierarchical,
showPartial: args.partialRows,
inspectorAdapters: handlers.inspectorAdapters,
queryFilter,
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import _ from 'lodash';

import { TimelionRequestHandlerProvider } from '../../../timelion/public/vis/timelion_request_handler';

// need to get rid of angular from these
import { VisProvider } from 'ui/vis/vis';

import chrome from 'ui/chrome';

Expand All @@ -49,16 +47,13 @@ export default () => ({
return chrome.dangerouslyGetActiveInjector().then(async $injector => {
const Private = $injector.get('Private');
const timelionRequestHandler = Private(TimelionRequestHandlerProvider).handler;
const Vis = Private(VisProvider);

// we need vis just for the inspector
const vis = new Vis(null, { type: 'timelion', params: { expression: args.expression } });

const response = await timelionRequestHandler(vis, {
const response = await timelionRequestHandler({
timeRange: _.get(context, 'timeRange', null),
query: _.get(context, 'q', null),
filters: _.get(context, 'filters', null),
forceFetch: true
forceFetch: true,
params: { expression: args.expression }
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import _ from 'lodash';

import { MetricsRequestHandlerProvider } from '../../../metrics/public/kbn_vis_types/request_handler';

// need to get rid of angular from these
import { VisProvider } from 'ui/vis/vis';

import chrome from 'ui/chrome';


Expand Down Expand Up @@ -53,18 +50,15 @@ export default () => ({
return chrome.dangerouslyGetActiveInjector().then(async $injector => {
const Private = $injector.get('Private');
const metricsRequestHandler = Private(MetricsRequestHandlerProvider).handler;
const Vis = Private(VisProvider);

const params = JSON.parse(args.params);

// we need vis just for the inspector
const vis = new Vis(null, { type: 'metrics', params: params });

const response = await metricsRequestHandler(vis, {
const response = await metricsRequestHandler({
timeRange: _.get(context, 'timeRange', null),
query: _.get(context, 'q', null),
filters: _.get(context, 'filters', null),
uiState: vis.getUiState(),
params: params,
uiState: {}, //vis.getUiState(),
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import chrome from 'ui/chrome';

import { VegaRequestHandlerProvider } from '../../../vega/public/vega_request_handler';
import { VisProvider } from 'ui/vis/vis';
import _ from 'lodash';

export default () => ({
Expand All @@ -43,16 +42,13 @@ export default () => ({

return chrome.dangerouslyGetActiveInjector().then(async $injector => {
const Private = $injector.get('Private');
const Vis = Private(VisProvider);
const vegaRequestHandler = Private(VegaRequestHandlerProvider).handler;

// we need to remove vis dependency from vega request handler
const vis = new Vis(null, { type: 'vega', params: { spec: args.spec } });

const response = await vegaRequestHandler(vis, {
timeRange: _.get(context, 'timeRange', null),
const response = await vegaRequestHandler({
timeRange: timeRange || _.get(context, 'timeRange', null),
query: _.get(context, 'q', null),
filters: _.get(context, 'filters', null),
params: { spec: args.spec },
forceFetch: true
});

Expand Down
15 changes: 13 additions & 2 deletions src/core_plugins/kibana_canvas_visualize/public/lib/load_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,20 @@

import { functionsRegistry } from 'plugins/canvas/lib/functions_registry';
import { typesRegistry } from 'plugins/canvas/lib/types_registry';
import { populateBrowserRegistries } from 'plugins/canvas/lib/browser_registries';
import { initialize } from 'plugins/canvas/lib/interpreter';
import { createSocket } from 'plugins/canvas/socket';
import chrome from 'ui/chrome';

import { functions } from '../functions';
import { typeSpecs } from '../types';

typeSpecs.forEach(typeDef => typesRegistry.register(typeDef));
functions.forEach(fnDef => functionsRegistry.register(fnDef));
const basePath = chrome.getBasePath();

createSocket(basePath).then(() => {
return populateBrowserRegistries().then(() => {
typeSpecs.forEach(typeDef => typesRegistry.register(typeDef));
functions.forEach(fnDef => functionsRegistry.register(fnDef));
return initialize();
});
});
14 changes: 7 additions & 7 deletions src/ui/public/visualize/loader/pipeline_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export const buildPipeline = (vis, params) => {
const filters = searchSource.getField('filter');
const visState = vis.getCurrentState();

let pipeline = `kibana | `;
let pipeline = `kibana | kibana_context q='${JSON.stringify(query)}' filters='${JSON.stringify(filters)}' | `;
if (vis.type.name === 'vega') {
pipeline += `vega spec='${visState.params.spec}' q='${JSON.stringify(query)}' filters='${JSON.stringify(filters)}'`;
pipeline += `vega spec='${visState.params.spec}'`;
} else if (vis.type.name === 'input_control_vis') {
pipeline += `visualization type='input_control_vis' visConfig='${JSON.stringify(visState.params)}'`;
} else if (vis.type.name === 'metrics') {
pipeline += `tsvb params='${JSON.stringify(visState.params)}' q='${JSON.stringify(query)}' filters='${JSON.stringify(filters)}'`;
pipeline += `tsvb params='${JSON.stringify(visState.params)}'`;
} else if (vis.type.name === 'timelion') {
pipeline += `timelion_vis expression='${visState.params.expression}' q='${JSON.stringify(query)}' filters='${JSON.stringify(filters)}'`;
pipeline += `timelion_vis expression='${visState.params.expression}'`;
} else if (vis.type.name === 'markdown') {
pipeline = `visualization type='markdown' visConfig='${JSON.stringify(visState.params)}'`;
} else {
Expand All @@ -48,7 +48,7 @@ export const buildPipeline = (vis, params) => {
schemas[schemaName].push(i);
});
pipeline += `
esaggs index='${indexPattern.id}' q='${JSON.stringify(query)}' filters='${JSON.stringify(filters)}'
esaggs index='${indexPattern.id}'
aggConfigs='${JSON.stringify(visState.aggs)}' |
visualization type='${vis.type.name}' visConfig='${JSON.stringify(visState.params)}' schemas='${JSON.stringify(schemas)}'
`;
Expand All @@ -57,8 +57,8 @@ export const buildPipeline = (vis, params) => {
return pipeline;
};

export const runPipeline = async (pipeline, context) => {
export const runPipeline = async (pipeline, context, handlers) => {
const ast = fromExpression(pipeline);
const pipelineResponse = await interpretAst(ast, context);
const pipelineResponse = await interpretAst(ast, context, handlers);
return pipelineResponse;
};
24 changes: 13 additions & 11 deletions src/ui/public/visualize/loader/visualize_data_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ export class VisualizeDataLoader {
this.vis.pipelineExpression = buildPipeline(this.vis, params);

try {
return await runPipeline(this.vis.pipelineExpression, {
query: params.query,
timeRange: params.timeRange,
partialRows: this.vis.params.partialRows || this.vis.type.requiresPartialRows,
isHierarchical: this.vis.isHierarchical(),
visParams: this.vis.params,
...params,
filters: params.filters
? params.filters.filter(filter => !filter.meta.disabled)
: undefined,
});
return await runPipeline(
this.vis.pipelineExpression,
{
query: params.query,
timeRange: params.timeRange,
filters: params.filters
? params.filters.filter(filter => !filter.meta.disabled)
: undefined,
},
{
inspectorAdapters: params.inspectorAdapters,
}
);
} catch (error) {
params.searchSource.cancelQueued();

Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ export function canvas(kibana) {
hacks: [
// window.onerror override
'plugins/canvas/lib/window_error_handler.js',
'plugins/canvas/register_feature',
],
home: ['plugins/canvas/register_feature'],
home: [],
mappings,
},

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/canvas/public/lib/interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export async function initialize() {
}

// Use the above promise to seed the interpreter with the functions it can defer to
export async function interpretAst(ast, context) {
export async function interpretAst(ast, context, handlers) {
// Load plugins before attempting to get functions, otherwise this gets racey
return Promise.all([functionList, getBrowserRegistries()])
.then(([serverFunctionList]) => {
return socketInterpreterProvider({
types: typesRegistry.toJS(),
handlers: createHandlers(socket),
handlers: { ...handlers, ...createHandlers(socket) },
functions: functionsRegistry.toJS(),
referableFunctions: serverFunctionList,
socket: socket,
Expand Down

0 comments on commit 3a2e8e0

Please sign in to comment.