-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use canvas pipeline in visualize (#25996)
- Loading branch information
Showing
39 changed files
with
2,011 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/kbn-interpreter/src/plugin/types/kibana_context.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export const kibanaContext = () => ({ | ||
name: 'kibana_context', | ||
from: { | ||
null: () => { | ||
return { | ||
type: 'kibana_context', | ||
}; | ||
}, | ||
}, | ||
to: { | ||
null: () => { | ||
return { | ||
type: 'null', | ||
}; | ||
}, | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export const kibanaTable = () => ({ | ||
name: 'kibana_table', | ||
serialize: context => { | ||
context.columns.forEach(column => { | ||
column.aggConfig = column.aggConfig.toJSON(); | ||
}); | ||
return context; | ||
}, | ||
validate: tabify => { | ||
if (!tabify.columns) { | ||
throw new Error('tabify must have a columns array, even if it is empty'); | ||
} | ||
}, | ||
from: { | ||
null: () => { | ||
return { | ||
type: 'kibana_table', | ||
columns: [], | ||
}; | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/legacy/core_plugins/interpreter/public/functions/esaggs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { get } from 'lodash'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { CourierRequestHandlerProvider } from 'ui/vis/request_handlers/courier'; | ||
import { AggConfigs } from 'ui/vis/agg_configs'; | ||
|
||
// need to get rid of angular from these | ||
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'; | ||
|
||
const courierRequestHandlerProvider = CourierRequestHandlerProvider; | ||
const courierRequestHandler = courierRequestHandlerProvider().handler; | ||
|
||
export const esaggs = () => ({ | ||
name: 'esaggs', | ||
type: 'kibana_table', | ||
context: { | ||
types: [ | ||
'kibana_context', | ||
'null', | ||
], | ||
}, | ||
help: i18n.translate('common.core_plugins.interpreter.public.functions.esaggs.help', { defaultMessage: 'Run AggConfig aggregation' }), | ||
args: { | ||
index: { | ||
types: ['string', 'null'], | ||
default: null, | ||
}, | ||
metricsAtAllLevels: { | ||
types: ['boolean'], | ||
default: false, | ||
}, | ||
partialRows: { | ||
types: ['boolean'], | ||
default: false, | ||
}, | ||
aggConfigs: { | ||
types: ['string'], | ||
default: '""', | ||
}, | ||
}, | ||
async fn(context, args, handlers) { | ||
const $injector = await chrome.dangerouslyGetActiveInjector(); | ||
const Private = $injector.get('Private'); | ||
const indexPatterns = Private(IndexPatternsProvider); | ||
const SearchSource = Private(SearchSourceProvider); | ||
const queryFilter = Private(FilterBarQueryFilterProvider); | ||
|
||
const aggConfigsState = JSON.parse(args.aggConfigs); | ||
const indexPattern = await indexPatterns.get(args.index); | ||
const aggs = new AggConfigs(indexPattern, aggConfigsState); | ||
|
||
// we should move searchSource creation inside courier request handler | ||
const searchSource = new SearchSource(); | ||
searchSource.setField('index', indexPattern); | ||
|
||
const response = await courierRequestHandler({ | ||
searchSource: searchSource, | ||
aggs: aggs, | ||
timeRange: get(context, 'timeRange', null), | ||
query: get(context, 'query', null), | ||
filters: get(context, 'filters', null), | ||
forceFetch: true, | ||
isHierarchical: args.metricsAtAllLevels, | ||
partialRows: args.partialRows, | ||
inspectorAdapters: handlers.inspectorAdapters, | ||
queryFilter, | ||
}); | ||
|
||
return { | ||
type: 'kibana_table', | ||
index: args.index, | ||
...response, | ||
}; | ||
}, | ||
}); |
40 changes: 40 additions & 0 deletions
40
src/legacy/core_plugins/interpreter/public/functions/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { esaggs } from './esaggs'; | ||
import { kibana } from './kibana'; | ||
import { kibanaContext } from './kibana_context'; | ||
import { vega } from './vega'; | ||
import { timelionVis } from './timelion_vis'; | ||
import { tsvb } from './tsvb'; | ||
import { kibanaMarkdown } from './markdown'; | ||
import { inputControlVis } from './input_control'; | ||
import { metric } from './metric'; | ||
import { kibanaPie } from './pie'; | ||
import { regionmap } from './regionmap'; | ||
import { tilemap } from './tilemap'; | ||
import { kibanaTable } from './table'; | ||
import { tagcloud } from './tagcloud'; | ||
import { vislib } from './vislib'; | ||
import { visualization } from './visualization'; | ||
|
||
export const functions = [ | ||
esaggs, kibana, kibanaContext, vega, timelionVis, tsvb, kibanaMarkdown, inputControlVis, | ||
metric, kibanaPie, regionmap, tilemap, kibanaTable, tagcloud, vislib, visualization | ||
]; |
50 changes: 50 additions & 0 deletions
50
src/legacy/core_plugins/interpreter/public/functions/input_control.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const inputControlVis = () => ({ | ||
name: 'input_control_vis', | ||
type: 'render', | ||
context: { | ||
types: [], | ||
}, | ||
help: i18n.translate('common.core_plugins.interpreter.public.functions.input_control.help', { | ||
defaultMessage: 'Input control visualization' | ||
}), | ||
args: { | ||
visConfig: { | ||
types: ['string'], | ||
default: '"{}"', | ||
} | ||
}, | ||
fn(context, args) { | ||
const params = JSON.parse(args.visConfig); | ||
return { | ||
type: 'render', | ||
as: 'visualization', | ||
value: { | ||
visConfig: { | ||
type: 'input_controls_vis', | ||
params: params | ||
}, | ||
} | ||
}; | ||
} | ||
}); |
51 changes: 51 additions & 0 deletions
51
src/legacy/core_plugins/interpreter/public/functions/kibana.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const kibana = () => ({ | ||
name: 'kibana', | ||
type: 'kibana_context', | ||
context: {}, | ||
help: i18n.translate('common.core_plugins.interpreter.public.functions.kibana.help', { | ||
defaultMessage: 'Gets kibana global context' | ||
}), | ||
args: {}, | ||
fn(context, args, handlers) { | ||
const initialContext = handlers.getInitialContext ? handlers.getInitialContext() : {}; | ||
|
||
if (context.query) { | ||
initialContext.query = initialContext.query.concat(context.query); | ||
} | ||
|
||
if (context.filters) { | ||
initialContext.filters = initialContext.filters.concat(context.filters); | ||
} | ||
|
||
const timeRange = initialContext.timeRange || context.timeRange; | ||
|
||
return { | ||
...context, | ||
type: 'kibana_context', | ||
query: initialContext.query, | ||
filters: initialContext.filters, | ||
timeRange: timeRange, | ||
}; | ||
}, | ||
}); |
Oops, something went wrong.