2020-02-13 13:54:51 +01:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
2021-02-04 03:12:39 +01:00
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
|
|
* 2.0.
|
2020-02-13 13:54:51 +01:00
|
|
|
*/
|
|
|
|
|
2020-05-15 12:01:27 +02:00
|
|
|
import { CoreSetup } from 'kibana/public';
|
2020-04-15 12:22:37 +02:00
|
|
|
import { ExpressionsSetup } from '../../../../../src/plugins/expressions/public';
|
2020-03-25 16:16:11 +01:00
|
|
|
import { EditorFrameSetup, FormatFactory } from '../types';
|
2020-04-30 23:44:16 +02:00
|
|
|
import { DataPublicPluginStart } from '../../../../../src/plugins/data/public';
|
2020-02-13 13:54:51 +01:00
|
|
|
|
2020-04-30 23:44:16 +02:00
|
|
|
interface DatatableVisualizationPluginStartPlugins {
|
|
|
|
data: DataPublicPluginStart;
|
|
|
|
}
|
2020-02-13 13:54:51 +01:00
|
|
|
export interface DatatableVisualizationPluginSetupPlugins {
|
|
|
|
expressions: ExpressionsSetup;
|
2020-03-25 16:16:11 +01:00
|
|
|
formatFactory: Promise<FormatFactory>;
|
2020-02-13 13:54:51 +01:00
|
|
|
editorFrame: EditorFrameSetup;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DatatableVisualization {
|
|
|
|
constructor() {}
|
|
|
|
|
|
|
|
setup(
|
2020-04-30 23:44:16 +02:00
|
|
|
core: CoreSetup<DatatableVisualizationPluginStartPlugins, void>,
|
2020-02-13 13:54:51 +01:00
|
|
|
{ expressions, formatFactory, editorFrame }: DatatableVisualizationPluginSetupPlugins
|
|
|
|
) {
|
2020-09-29 19:00:29 +02:00
|
|
|
editorFrame.registerVisualization(async () => {
|
|
|
|
const {
|
2020-12-15 12:37:59 +01:00
|
|
|
getDatatable,
|
2021-02-04 16:22:09 +01:00
|
|
|
datatableColumn,
|
2020-09-29 19:00:29 +02:00
|
|
|
getDatatableRenderer,
|
|
|
|
datatableVisualization,
|
|
|
|
} = await import('../async_services');
|
2020-12-15 12:37:59 +01:00
|
|
|
const resolvedFormatFactory = await formatFactory;
|
2020-12-14 13:28:23 +01:00
|
|
|
|
2021-02-04 16:22:09 +01:00
|
|
|
expressions.registerFunction(() => datatableColumn);
|
2020-12-15 12:37:59 +01:00
|
|
|
expressions.registerFunction(() => getDatatable({ formatFactory: resolvedFormatFactory }));
|
2020-09-29 19:00:29 +02:00
|
|
|
expressions.registerRenderer(() =>
|
|
|
|
getDatatableRenderer({
|
2020-12-15 12:37:59 +01:00
|
|
|
formatFactory: resolvedFormatFactory,
|
2020-09-29 19:00:29 +02:00
|
|
|
getType: core
|
|
|
|
.getStartServices()
|
|
|
|
.then(([_, { data: dataStart }]) => dataStart.search.aggs.types.get),
|
|
|
|
})
|
|
|
|
);
|
|
|
|
return datatableVisualization;
|
|
|
|
});
|
2020-02-13 13:54:51 +01:00
|
|
|
}
|
|
|
|
}
|