adding yml switch for using interpreter in expressions (#33832)
This commit is contained in:
parent
e934a48266
commit
61e5300391
7 changed files with 39 additions and 12 deletions
|
@ -118,6 +118,9 @@ password that the Kibana server uses to perform maintenance on the Kibana index
|
||||||
at startup. Your Kibana users still need to authenticate with Elasticsearch,
|
at startup. Your Kibana users still need to authenticate with Elasticsearch,
|
||||||
which is proxied through the Kibana server.
|
which is proxied through the Kibana server.
|
||||||
|
|
||||||
|
`interpreter.enableInVisualize`:: *Default: true* Enables use of interpreter in
|
||||||
|
Visualize.
|
||||||
|
|
||||||
`kibana.defaultAppId:`:: *Default: "discover"* The default application to load.
|
`kibana.defaultAppId:`:: *Default: "discover"* The default application to load.
|
||||||
|
|
||||||
`kibana.index:`:: *Default: ".kibana"* Kibana uses an index in Elasticsearch to
|
`kibana.index:`:: *Default: ".kibana"* Kibana uses an index in Elasticsearch to
|
||||||
|
|
|
@ -28,7 +28,16 @@ export default function InterpreterPlugin(kibana: any) {
|
||||||
require: ['kibana', 'elasticsearch'],
|
require: ['kibana', 'elasticsearch'],
|
||||||
publicDir: resolve(__dirname, 'public'),
|
publicDir: resolve(__dirname, 'public'),
|
||||||
uiExports: {
|
uiExports: {
|
||||||
injectDefaultVars: server => ({ serverBasePath: server.config().get('server.basePath') }),
|
injectDefaultVars: server => ({
|
||||||
|
serverBasePath: server.config().get('server.basePath'),
|
||||||
|
interpreterConfig: server.config().get('interpreter'),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
config: (Joi: any) => {
|
||||||
|
return Joi.object({
|
||||||
|
enabled: Joi.boolean().default(true),
|
||||||
|
enableInVisualize: Joi.boolean().default(true),
|
||||||
|
}).default();
|
||||||
},
|
},
|
||||||
init,
|
init,
|
||||||
};
|
};
|
||||||
|
|
|
@ -83,6 +83,9 @@ new CoreSystem({
|
||||||
enabled: true,
|
enabled: true,
|
||||||
enableExternalUrls: true
|
enableExternalUrls: true
|
||||||
},
|
},
|
||||||
|
interpreterConfig: {
|
||||||
|
enableInVisualize: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rootDomElement,
|
rootDomElement,
|
||||||
|
|
|
@ -29,4 +29,5 @@ export interface PluginSpecOptions {
|
||||||
publicDir: string;
|
publicDir: string;
|
||||||
uiExports?: UiExports;
|
uiExports?: UiExports;
|
||||||
init: InitPluginFunction;
|
init: InitPluginFunction;
|
||||||
|
config: any;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,7 @@ import { RequestAdapter } from '../../../inspector/adapters/request';
|
||||||
|
|
||||||
describe('visualize loader', () => {
|
describe('visualize loader', () => {
|
||||||
|
|
||||||
const DataLoader = EmbeddedVisualizeHandler.__ENABLE_PIPELINE_DATA_LOADER__
|
let DataLoader;
|
||||||
? PipelineDataLoader
|
|
||||||
: VisualizeDataLoader;
|
|
||||||
let searchSource;
|
let searchSource;
|
||||||
let vis;
|
let vis;
|
||||||
let $rootScope;
|
let $rootScope;
|
||||||
|
@ -76,12 +74,12 @@ describe('visualize loader', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(ngMock.module('kibana', 'kibana/directive'));
|
beforeEach(ngMock.module('kibana', 'kibana/directive'));
|
||||||
beforeEach(ngMock.inject((_$rootScope_, savedVisualizations, Private) => {
|
beforeEach(ngMock.inject((_$rootScope_, savedVisualizations, interpreterConfig, Private) => {
|
||||||
$rootScope = _$rootScope_;
|
$rootScope = _$rootScope_;
|
||||||
searchSource = Private(FixturesStubbedSearchSourceProvider);
|
searchSource = Private(FixturesStubbedSearchSourceProvider);
|
||||||
const indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
const indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||||
|
|
||||||
|
DataLoader = interpreterConfig.enableInVisualize ? PipelineDataLoader : VisualizeDataLoader;
|
||||||
// Create a new Vis object
|
// Create a new Vis object
|
||||||
const Vis = Private(VisProvider);
|
const Vis = Private(VisProvider);
|
||||||
vis = new Vis(indexPattern, {
|
vis = new Vis(indexPattern, {
|
||||||
|
|
|
@ -53,6 +53,7 @@ interface EmbeddedVisualizeHandlerParams extends VisualizeLoaderParams {
|
||||||
Private: IPrivate;
|
Private: IPrivate;
|
||||||
queryFilter: any;
|
queryFilter: any;
|
||||||
autoFetch?: boolean;
|
autoFetch?: boolean;
|
||||||
|
pipelineDataLoader?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RENDER_COMPLETE_EVENT = 'render_complete';
|
const RENDER_COMPLETE_EVENT = 'render_complete';
|
||||||
|
@ -71,13 +72,13 @@ export class EmbeddedVisualizeHandler {
|
||||||
* This should not be used by any plugin.
|
* This should not be used by any plugin.
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
public static readonly __ENABLE_PIPELINE_DATA_LOADER__: boolean = false;
|
|
||||||
public readonly data$: Rx.Observable<any>;
|
public readonly data$: Rx.Observable<any>;
|
||||||
public readonly inspectorAdapters: Adapters = {};
|
public readonly inspectorAdapters: Adapters = {};
|
||||||
private vis: Vis;
|
private vis: Vis;
|
||||||
private handlers: any;
|
private handlers: any;
|
||||||
private loaded: boolean = false;
|
private loaded: boolean = false;
|
||||||
private destroyed: boolean = false;
|
private destroyed: boolean = false;
|
||||||
|
private pipelineDataLoader: boolean = false;
|
||||||
|
|
||||||
private listeners = new EventEmitter();
|
private listeners = new EventEmitter();
|
||||||
private firstRenderComplete: Promise<void>;
|
private firstRenderComplete: Promise<void>;
|
||||||
|
@ -117,6 +118,7 @@ export class EmbeddedVisualizeHandler {
|
||||||
filters,
|
filters,
|
||||||
query,
|
query,
|
||||||
autoFetch = true,
|
autoFetch = true,
|
||||||
|
pipelineDataLoader = false,
|
||||||
Private,
|
Private,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
|
@ -131,6 +133,8 @@ export class EmbeddedVisualizeHandler {
|
||||||
forceFetch: false,
|
forceFetch: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.pipelineDataLoader = pipelineDataLoader;
|
||||||
|
|
||||||
// Listen to the first RENDER_COMPLETE_EVENT to resolve this promise
|
// Listen to the first RENDER_COMPLETE_EVENT to resolve this promise
|
||||||
this.firstRenderComplete = new Promise(resolve => {
|
this.firstRenderComplete = new Promise(resolve => {
|
||||||
this.listeners.once(RENDER_COMPLETE_EVENT, resolve);
|
this.listeners.once(RENDER_COMPLETE_EVENT, resolve);
|
||||||
|
@ -171,7 +175,7 @@ export class EmbeddedVisualizeHandler {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.dataLoader = EmbeddedVisualizeHandler.__ENABLE_PIPELINE_DATA_LOADER__
|
this.dataLoader = pipelineDataLoader
|
||||||
? new PipelineDataLoader(vis)
|
? new PipelineDataLoader(vis)
|
||||||
: new VisualizeDataLoader(vis, Private);
|
: new VisualizeDataLoader(vis, Private);
|
||||||
this.renderCompleteHelper = new RenderCompleteHelper(element);
|
this.renderCompleteHelper = new RenderCompleteHelper(element);
|
||||||
|
@ -481,7 +485,7 @@ export class EmbeddedVisualizeHandler {
|
||||||
let renderer: any = null;
|
let renderer: any = null;
|
||||||
let args: any[] = [];
|
let args: any[] = [];
|
||||||
|
|
||||||
if (EmbeddedVisualizeHandler.__ENABLE_PIPELINE_DATA_LOADER__) {
|
if (this.pipelineDataLoader) {
|
||||||
renderer = registries.renderers.get(get(response || {}, 'as', 'visualization'));
|
renderer = registries.renderers.get(get(response || {}, 'as', 'visualization'));
|
||||||
args = [this.element, get(response, 'value', { visType: this.vis.type.name }), this.handlers];
|
args = [this.element, get(response, 'value', { visType: this.vis.type.name }), this.handlers];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -30,7 +30,11 @@ import { EmbeddedVisualizeHandler } from './embedded_visualize_handler';
|
||||||
import { VisSavedObject, VisualizeLoaderParams } from './types';
|
import { VisSavedObject, VisualizeLoaderParams } from './types';
|
||||||
|
|
||||||
export class VisualizeLoader {
|
export class VisualizeLoader {
|
||||||
constructor(private readonly savedVisualizations: any, private readonly Private: IPrivate) {}
|
constructor(
|
||||||
|
private readonly savedVisualizations: any,
|
||||||
|
private readonly pipelineDataLoader: boolean,
|
||||||
|
private readonly Private: IPrivate
|
||||||
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a saved visualization specified by its id into a DOM element.
|
* Renders a saved visualization specified by its id into a DOM element.
|
||||||
|
@ -135,14 +139,19 @@ export class VisualizeLoader {
|
||||||
queryFilter: this.Private(FilterBarQueryFilterProvider),
|
queryFilter: this.Private(FilterBarQueryFilterProvider),
|
||||||
// lets add Private to the params, we'll need to pass it to visualize later
|
// lets add Private to the params, we'll need to pass it to visualize later
|
||||||
Private: this.Private,
|
Private: this.Private,
|
||||||
|
pipelineDataLoader: this.pipelineDataLoader,
|
||||||
};
|
};
|
||||||
|
|
||||||
return new EmbeddedVisualizeHandler(element, savedObj, handlerParams);
|
return new EmbeddedVisualizeHandler(element, savedObj, handlerParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function VisualizeLoaderProvider(savedVisualizations: any, Private: IPrivate) {
|
function VisualizeLoaderProvider(
|
||||||
return new VisualizeLoader(savedVisualizations, Private);
|
savedVisualizations: any,
|
||||||
|
interpreterConfig: any,
|
||||||
|
Private: IPrivate
|
||||||
|
) {
|
||||||
|
return new VisualizeLoader(savedVisualizations, interpreterConfig.enableInVisualize, Private);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue