2020-05-01 12:57:29 +02:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { AppMountParameters, CoreSetup, CoreStart } from 'kibana/public';
|
|
|
|
import { DataPublicPluginSetup, DataPublicPluginStart } from 'src/plugins/data/public';
|
2020-06-23 18:21:48 +02:00
|
|
|
import { EmbeddableSetup, EmbeddableStart } from 'src/plugins/embeddable/public';
|
2020-09-23 23:40:52 +02:00
|
|
|
import { DashboardStart } from 'src/plugins/dashboard/public';
|
2020-05-01 12:57:29 +02:00
|
|
|
import { ExpressionsSetup, ExpressionsStart } from 'src/plugins/expressions/public';
|
|
|
|
import { VisualizationsSetup } from 'src/plugins/visualizations/public';
|
|
|
|
import { NavigationPublicPluginStart } from 'src/plugins/navigation/public';
|
2020-09-14 11:08:59 +02:00
|
|
|
import { UrlForwardingSetup } from 'src/plugins/url_forwarding/public';
|
2020-09-23 17:53:21 +02:00
|
|
|
import { GlobalSearchPluginSetup } from '../../global_search/public';
|
2020-11-04 11:27:52 +01:00
|
|
|
import { ChartsPluginSetup, ChartsPluginStart } from '../../../../src/plugins/charts/public';
|
2020-05-01 12:57:29 +02:00
|
|
|
import { EditorFrameService } from './editor_frame_service';
|
2020-07-02 16:02:30 +02:00
|
|
|
import {
|
|
|
|
IndexPatternDatasource,
|
|
|
|
IndexPatternDatasourceSetupPlugins,
|
|
|
|
} from './indexpattern_datasource';
|
|
|
|
import { XyVisualization, XyVisualizationPluginSetupPlugins } from './xy_visualization';
|
|
|
|
import { MetricVisualization, MetricVisualizationPluginSetupPlugins } from './metric_visualization';
|
|
|
|
import {
|
|
|
|
DatatableVisualization,
|
|
|
|
DatatableVisualizationPluginSetupPlugins,
|
|
|
|
} from './datatable_visualization';
|
|
|
|
import { PieVisualization, PieVisualizationPluginSetupPlugins } from './pie_visualization';
|
2020-05-13 09:19:24 +02:00
|
|
|
import { AppNavLinkStatus } from '../../../../src/core/public';
|
2020-11-03 10:33:18 +01:00
|
|
|
import type { SavedObjectTaggingPluginStart } from '../../saved_objects_tagging/public';
|
2020-05-01 12:57:29 +02:00
|
|
|
|
2020-10-06 10:15:41 +02:00
|
|
|
import {
|
|
|
|
UiActionsStart,
|
|
|
|
ACTION_VISUALIZE_FIELD,
|
|
|
|
VISUALIZE_FIELD_TRIGGER,
|
|
|
|
} from '../../../../src/plugins/ui_actions/public';
|
2020-05-01 12:57:29 +02:00
|
|
|
import { NOT_INTERNATIONALIZED_PRODUCT_NAME } from '../common';
|
|
|
|
import { EditorFrameStart } from './types';
|
|
|
|
import { getLensAliasConfig } from './vis_type_alias';
|
2020-10-06 10:15:41 +02:00
|
|
|
import { visualizeFieldAction } from './trigger_actions/visualize_field_actions';
|
2020-09-23 17:53:21 +02:00
|
|
|
import { getSearchProvider } from './search_provider';
|
2020-05-01 12:57:29 +02:00
|
|
|
|
2020-10-19 17:21:25 +02:00
|
|
|
import { LensAttributeService } from './lens_attribute_service';
|
2020-05-01 12:57:29 +02:00
|
|
|
|
|
|
|
export interface LensPluginSetupDependencies {
|
2020-09-14 11:08:59 +02:00
|
|
|
urlForwarding: UrlForwardingSetup;
|
2020-05-01 12:57:29 +02:00
|
|
|
expressions: ExpressionsSetup;
|
|
|
|
data: DataPublicPluginSetup;
|
|
|
|
embeddable?: EmbeddableSetup;
|
|
|
|
visualizations: VisualizationsSetup;
|
2020-07-02 16:02:30 +02:00
|
|
|
charts: ChartsPluginSetup;
|
2020-09-23 17:53:21 +02:00
|
|
|
globalSearch?: GlobalSearchPluginSetup;
|
2020-05-01 12:57:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface LensPluginStartDependencies {
|
|
|
|
data: DataPublicPluginStart;
|
|
|
|
expressions: ExpressionsStart;
|
|
|
|
navigation: NavigationPublicPluginStart;
|
|
|
|
uiActions: UiActionsStart;
|
2020-09-23 23:40:52 +02:00
|
|
|
dashboard: DashboardStart;
|
2020-10-12 15:51:39 +02:00
|
|
|
embeddable: EmbeddableStart;
|
2020-11-04 11:27:52 +01:00
|
|
|
charts: ChartsPluginStart;
|
2020-11-03 10:33:18 +01:00
|
|
|
savedObjectsTagging?: SavedObjectTaggingPluginStart;
|
2020-05-01 12:57:29 +02:00
|
|
|
}
|
|
|
|
export class LensPlugin {
|
|
|
|
private datatableVisualization: DatatableVisualization;
|
|
|
|
private editorFrameService: EditorFrameService;
|
|
|
|
private createEditorFrame: EditorFrameStart['createInstance'] | null = null;
|
2020-10-19 17:21:25 +02:00
|
|
|
private attributeService: (() => Promise<LensAttributeService>) | null = null;
|
2020-05-01 12:57:29 +02:00
|
|
|
private indexpatternDatasource: IndexPatternDatasource;
|
|
|
|
private xyVisualization: XyVisualization;
|
|
|
|
private metricVisualization: MetricVisualization;
|
2020-05-05 21:59:32 +02:00
|
|
|
private pieVisualization: PieVisualization;
|
2020-05-01 12:57:29 +02:00
|
|
|
|
2020-10-19 17:21:25 +02:00
|
|
|
private stopReportManager?: () => void;
|
|
|
|
|
2020-05-01 12:57:29 +02:00
|
|
|
constructor() {
|
|
|
|
this.datatableVisualization = new DatatableVisualization();
|
|
|
|
this.editorFrameService = new EditorFrameService();
|
|
|
|
this.indexpatternDatasource = new IndexPatternDatasource();
|
|
|
|
this.xyVisualization = new XyVisualization();
|
|
|
|
this.metricVisualization = new MetricVisualization();
|
2020-05-05 21:59:32 +02:00
|
|
|
this.pieVisualization = new PieVisualization();
|
2020-05-01 12:57:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setup(
|
|
|
|
core: CoreSetup<LensPluginStartDependencies, void>,
|
2020-07-02 16:02:30 +02:00
|
|
|
{
|
2020-09-14 11:08:59 +02:00
|
|
|
urlForwarding,
|
2020-07-02 16:02:30 +02:00
|
|
|
expressions,
|
|
|
|
data,
|
|
|
|
embeddable,
|
|
|
|
visualizations,
|
|
|
|
charts,
|
2020-09-23 17:53:21 +02:00
|
|
|
globalSearch,
|
2020-07-02 16:02:30 +02:00
|
|
|
}: LensPluginSetupDependencies
|
2020-05-01 12:57:29 +02:00
|
|
|
) {
|
2020-10-19 17:21:25 +02:00
|
|
|
this.attributeService = async () => {
|
|
|
|
const { getLensAttributeService } = await import('./async_services');
|
|
|
|
const [coreStart, startDependencies] = await core.getStartServices();
|
|
|
|
return getLensAttributeService(coreStart, startDependencies);
|
|
|
|
};
|
2020-09-23 23:40:52 +02:00
|
|
|
const editorFrameSetupInterface = this.editorFrameService.setup(
|
|
|
|
core,
|
|
|
|
{
|
|
|
|
data,
|
|
|
|
embeddable,
|
2020-11-04 11:27:52 +01:00
|
|
|
charts,
|
2020-09-23 23:40:52 +02:00
|
|
|
expressions,
|
|
|
|
},
|
2020-10-19 17:21:25 +02:00
|
|
|
this.attributeService
|
2020-09-23 23:40:52 +02:00
|
|
|
);
|
2020-07-02 16:02:30 +02:00
|
|
|
const dependencies: IndexPatternDatasourceSetupPlugins &
|
|
|
|
XyVisualizationPluginSetupPlugins &
|
|
|
|
DatatableVisualizationPluginSetupPlugins &
|
|
|
|
MetricVisualizationPluginSetupPlugins &
|
|
|
|
PieVisualizationPluginSetupPlugins = {
|
2020-05-01 12:57:29 +02:00
|
|
|
expressions,
|
|
|
|
data,
|
2020-07-02 16:02:30 +02:00
|
|
|
charts,
|
2020-05-01 12:57:29 +02:00
|
|
|
editorFrame: editorFrameSetupInterface,
|
|
|
|
formatFactory: core
|
|
|
|
.getStartServices()
|
|
|
|
.then(([_, { data: dataStart }]) => dataStart.fieldFormats.deserialize),
|
|
|
|
};
|
|
|
|
this.indexpatternDatasource.setup(core, dependencies);
|
|
|
|
this.xyVisualization.setup(core, dependencies);
|
|
|
|
this.datatableVisualization.setup(core, dependencies);
|
|
|
|
this.metricVisualization.setup(core, dependencies);
|
2020-05-05 21:59:32 +02:00
|
|
|
this.pieVisualization.setup(core, dependencies);
|
2020-05-01 12:57:29 +02:00
|
|
|
|
|
|
|
visualizations.registerAlias(getLensAliasConfig());
|
|
|
|
|
2020-09-23 23:40:52 +02:00
|
|
|
const getByValueFeatureFlag = async () => {
|
|
|
|
const [, deps] = await core.getStartServices();
|
|
|
|
return deps.dashboard.dashboardFeatureFlagConfig;
|
|
|
|
};
|
|
|
|
|
2020-05-13 09:19:24 +02:00
|
|
|
core.application.register({
|
2020-05-01 12:57:29 +02:00
|
|
|
id: 'lens',
|
|
|
|
title: NOT_INTERNATIONALIZED_PRODUCT_NAME,
|
2020-05-13 09:19:24 +02:00
|
|
|
navLinkStatus: AppNavLinkStatus.hidden,
|
2020-05-01 12:57:29 +02:00
|
|
|
mount: async (params: AppMountParameters) => {
|
2020-10-19 17:21:25 +02:00
|
|
|
const { mountApp, stopReportManager } = await import('./async_services');
|
|
|
|
this.stopReportManager = stopReportManager;
|
2020-09-23 23:40:52 +02:00
|
|
|
return mountApp(core, params, {
|
|
|
|
createEditorFrame: this.createEditorFrame!,
|
|
|
|
attributeService: this.attributeService!,
|
|
|
|
getByValueFeatureFlag,
|
|
|
|
});
|
2020-05-01 12:57:29 +02:00
|
|
|
},
|
|
|
|
});
|
2020-05-13 09:19:24 +02:00
|
|
|
|
2020-09-23 17:53:21 +02:00
|
|
|
if (globalSearch) {
|
|
|
|
globalSearch.registerResultProvider(
|
|
|
|
getSearchProvider(
|
|
|
|
core.getStartServices().then(
|
|
|
|
([
|
|
|
|
{
|
|
|
|
application: { capabilities },
|
|
|
|
},
|
|
|
|
]) => capabilities
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-14 11:08:59 +02:00
|
|
|
urlForwarding.forwardApp('lens', 'lens');
|
2020-05-01 12:57:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
start(core: CoreStart, startDependencies: LensPluginStartDependencies) {
|
|
|
|
this.createEditorFrame = this.editorFrameService.start(core, startDependencies).createInstance;
|
2020-10-06 10:15:41 +02:00
|
|
|
// unregisters the Visualize action and registers the lens one
|
|
|
|
if (startDependencies.uiActions.hasAction(ACTION_VISUALIZE_FIELD)) {
|
|
|
|
startDependencies.uiActions.unregisterAction(ACTION_VISUALIZE_FIELD);
|
|
|
|
}
|
|
|
|
startDependencies.uiActions.addTriggerAction(
|
|
|
|
VISUALIZE_FIELD_TRIGGER,
|
|
|
|
visualizeFieldAction(core.application)
|
|
|
|
);
|
2020-05-01 12:57:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2020-10-19 17:21:25 +02:00
|
|
|
if (this.stopReportManager) {
|
|
|
|
this.stopReportManager();
|
|
|
|
}
|
2020-05-01 12:57:29 +02:00
|
|
|
}
|
|
|
|
}
|