Skip to content

Commit

Permalink
nettoyage code
Browse files Browse the repository at this point in the history
  • Loading branch information
bjacomy committed Nov 25, 2020
1 parent d7910d5 commit 6fc5555
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
19 changes: 7 additions & 12 deletions public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import { VisualizationsSetup } from '../../../src/plugins/visualizations/public'
import { Timefilter } from '../../../src/plugins/data/public/query/timefilter';
import { createTransformVisDefinition } from './transform_vis';
import { createTransformVisFn } from './transform_fn';
import { getTransformRequestHandler} from './request_handler';
import { DataPublicPluginSetup, DataPublicPluginStart ,IDataPluginServices} from '../../../src/plugins/data/public';
//import { setData, setInjectedMetadata,setInjectedVars } from './services';
import { SearchAPI } from './data_model/search_api'
//import { start} from './legacy'


import {
setNotifications,
setData,
Expand All @@ -28,13 +26,12 @@ export interface TransformPluginSetupDependencies {
expressions: ReturnType<ExpressionsPublicPlugin['setup']>;
visualizations: VisualizationsSetup;
data: DataPublicPluginSetup;
dataStart: SearchAPI;

}
export interface TransformPluginStartDependencies {
expressions: ReturnType<ExpressionsPublicPlugin['setup']>;
visualizations: VisualizationsSetup;
data: DataPublicPluginStart;
dataStart: SearchAPI;
uiActions:IDataPluginServices;
}

Expand All @@ -48,18 +45,16 @@ export class TransformPlugin implements Plugin<void, void> {

public async setup(
core: CoreSetup,
{ expressions, visualizations, data, dataStart }: TransformPluginSetupDependencies
{ expressions, visualizations, data }: TransformPluginSetupDependencies
) {
//setData(dataStart);
const config = createTransformVisDefinition({ uiSettings: core.uiSettings, es: dataStart, data, timefilter: data.query.timefilter.timefilter});
const config = createTransformVisDefinition({ uiSettings: core.uiSettings, data, timefilter: data.query.timefilter.timefilter});
visualizations.createReactVisualization(config);
////console.log("dataStartold",dataStartold)
expressions.registerFunction(() =>
createTransformVisFn({ uiSettings: core.uiSettings, es: dataStart , timeFilter: data.query.timefilter.timefilter})
createTransformVisFn({ uiSettings: core.uiSettings, timeFilter: data.query.timefilter.timefilter})
);
/* expressions.registerType(() =>
getTransformRequestHandler({ uiSettings: core.uiSettings,es: dataStart, timeFilter: data.query.timefilter.timefilter })
);*/



}
Expand Down
6 changes: 3 additions & 3 deletions public/request_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ const babelTransform = (code: string) => {

export function getTransformRequestHandler({
uiSettings,
es,
//es,
timeFilter
}: {
uiSettings: IUiSettingsClient;
//es: SearchAPI;
es: LegacyApiCaller
//es: LegacyApiCaller

timeFilter:Timefilter
} ,abortSignal?: AbortSignal ) {
Expand All @@ -49,7 +49,7 @@ export function getTransformRequestHandler({
visParams: VisParams;
}): Promise<TransformVisData> => {
const data : DataPublicPluginStart = getData();
es = data.search.__LEGACY.esClient;
const es = data.search.__LEGACY.esClient;
const settings = uiSettings;
//const options = chrome.getInjected('transformVisOptions');
//const test = {name: 'string', defaultValue: undefined};
Expand Down
10 changes: 4 additions & 6 deletions public/transform_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ import { IUiSettingsClient } from 'kibana/public';
import { ExpressionFunctionDefinition, Render, KibanaContext } from '../../../src/plugins/expressions/public';
import { Arguments, TransformVisParams } from './types';
import { getTransformRequestHandler } from './request_handler';
import { LegacyApiCaller } from '../../../src/plugins/data/public/search/legacy/es_client';
import { esQuery, TimeRange, Query, Filter } from '../../../src/plugins/data/public';
//import { SearchAPI } from './data_model/search_api'
import { Timefilter } from 'src/plugins/data/public/query';
import { now } from 'lodash';


interface RenderValue {
visType: 'transform';
Expand All @@ -37,11 +35,11 @@ interface RenderValue {

export const createTransformVisFn = ({
uiSettings,
es,
//es,
timeFilter
}: {
uiSettings: IUiSettingsClient;
es: LegacyApiCaller;
//es: LegacyApiCaller;
timeFilter:Timefilter
}): ExpressionFunctionDefinition<'transform_vis', KibanaContext | null, Arguments, Promise<Render<RenderValue>>> => ({
name: 'transform_vis',
Expand Down Expand Up @@ -75,7 +73,7 @@ export const createTransformVisFn = ({
},
async fn(input, args) {

const transformRequestHandler = getTransformRequestHandler({ uiSettings, es ,timeFilter});
const transformRequestHandler = getTransformRequestHandler({ uiSettings, timeFilter});
const response = await transformRequestHandler({
timeRange: get(input, 'timeRange', null),
query: <Query | null> get(input, 'query', null),
Expand Down
7 changes: 1 addition & 6 deletions public/transform_vis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@ import { i18n } from '@kbn/i18n';

import { IUiSettingsClient } from 'kibana/public';
import { DefaultEditorSize } from '../../../src/plugins/vis_default_editor/public';

import { getTransformVisWrapper } from './transform_vis_controller';
import { getTransformOptions } from './transform_options';
import { getTransformRequestHandler } from './request_handler';
import { DataPublicPluginSetup } from '../../../src/plugins/data/public';
import { LegacyApiCaller } from '../../../src/plugins/data/public/search/legacy/es_client';
import { Timefilter } from '../../../src/plugins/data/public/query/timefilter';
import { SearchAPI } from './data_model/search_api'

export const createTransformVisDefinition = ({
uiSettings,
es,
data,
timefilter}: {
uiSettings: IUiSettingsClient;
es: SearchAPI;
data: DataPublicPluginSetup;
timefilter:Timefilter
}) => {
const transformRequestHandler = getTransformRequestHandler({ uiSettings: uiSettings,es : es, timeFilter :timefilter });
const transformRequestHandler = getTransformRequestHandler({ uiSettings: uiSettings, timeFilter :timefilter });
const transformVisWrapper = getTransformVisWrapper(data);

return {
Expand Down
7 changes: 4 additions & 3 deletions public/transform_vis_controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import ShadowDOM from 'react-shadow';
// @ts-ignore
import { saveAs } from '@elastic/filesaver';
import OnMount from './on_mount';
import { ExprVis } from '../../../src/plugins/visualizations/public/expressions/vis';
import { Vis } from '../../../src/plugins/visualizations/public/vis';
//import { Vis } from '../../../src/legacy/core_plugins/visualizations/public/np_ready/public';
import { TransformVisData } from './types';
import { DataPublicPluginSetup } from '../../../src/plugins/data/public';

interface TransformVisComponentProps extends TransformVisData {
renderComplete: () => {};
vis: ExprVis ;
vis: Vis ;
data: DataPublicPluginSetup;
}

interface TransformVisWrapperProps {
vis: ExprVis;
vis: Vis;
visData: TransformVisData;
renderComplete: () => {};
}
Expand Down

0 comments on commit 6fc5555

Please sign in to comment.