mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
removing kibana_table pipeline type (#28979)
This commit is contained in:
parent
09afa5489a
commit
8c3fdfa98b
16 changed files with 37 additions and 67 deletions
|
@ -29,7 +29,6 @@ import { render } from './render';
|
|||
import { shape } from './shape';
|
||||
import { string } from './string';
|
||||
import { style } from './style';
|
||||
import { kibanaTable } from './kibana_table';
|
||||
import { kibanaContext } from './kibana_context';
|
||||
|
||||
export const typeSpecs = [
|
||||
|
@ -45,6 +44,5 @@ export const typeSpecs = [
|
|||
shape,
|
||||
string,
|
||||
style,
|
||||
kibanaTable,
|
||||
kibanaContext,
|
||||
];
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* 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: [],
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
|
@ -34,7 +34,7 @@ const courierRequestHandler = courierRequestHandlerProvider().handler;
|
|||
|
||||
export const esaggs = () => ({
|
||||
name: 'esaggs',
|
||||
type: 'kibana_table',
|
||||
type: 'datatable',
|
||||
context: {
|
||||
types: [
|
||||
'kibana_context',
|
||||
|
@ -90,9 +90,12 @@ export const esaggs = () => ({
|
|||
});
|
||||
|
||||
return {
|
||||
type: 'kibana_table',
|
||||
index: args.index,
|
||||
...response,
|
||||
type: 'datatable',
|
||||
rows: response.rows,
|
||||
columns: response.columns.map(column => ({
|
||||
id: column.id,
|
||||
name: column.name,
|
||||
})),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ export const metric = () => ({
|
|||
type: 'render',
|
||||
context: {
|
||||
types: [
|
||||
'kibana_table'
|
||||
'datatable'
|
||||
],
|
||||
},
|
||||
help: i18n.translate('interpreter.functions.metric.help', {
|
||||
|
|
|
@ -26,7 +26,7 @@ export const kibanaPie = () => ({
|
|||
type: 'render',
|
||||
context: {
|
||||
types: [
|
||||
'kibana_table', 'null'
|
||||
'datatable'
|
||||
],
|
||||
},
|
||||
help: i18n.translate('interpreter.functions.pie.help', {
|
||||
|
|
|
@ -24,7 +24,7 @@ export const regionmap = () => ({
|
|||
type: 'render',
|
||||
context: {
|
||||
types: [
|
||||
'kibana_table'
|
||||
'datatable'
|
||||
],
|
||||
},
|
||||
help: i18n.translate('interpreter.functions.regionmap.help', {
|
||||
|
|
|
@ -28,7 +28,7 @@ export const kibanaTable = () => ({
|
|||
type: 'render',
|
||||
context: {
|
||||
types: [
|
||||
'kibana_table'
|
||||
'datatable'
|
||||
],
|
||||
},
|
||||
help: i18n.translate('interpreter.functions.table.help', {
|
||||
|
|
|
@ -24,7 +24,7 @@ export const tagcloud = () => ({
|
|||
type: 'render',
|
||||
context: {
|
||||
types: [
|
||||
'kibana_table'
|
||||
'datatable'
|
||||
],
|
||||
},
|
||||
help: i18n.translate('interpreter.functions.tagcloud.help', {
|
||||
|
|
|
@ -25,7 +25,7 @@ export const tilemap = () => ({
|
|||
type: 'render',
|
||||
context: {
|
||||
types: [
|
||||
'kibana_table'
|
||||
'datatable'
|
||||
],
|
||||
},
|
||||
help: i18n.translate('interpreter.functions.tilemap.help', {
|
||||
|
|
|
@ -26,7 +26,7 @@ export const vislib = () => ({
|
|||
type: 'render',
|
||||
context: {
|
||||
types: [
|
||||
'kibana_table', 'null'
|
||||
'datatable'
|
||||
],
|
||||
},
|
||||
help: i18n.translate('interpreter.functions.vislib.help', {
|
||||
|
|
|
@ -44,9 +44,6 @@ function getHandler(from, type) {
|
|||
export const visualization = () => ({
|
||||
name: 'visualization',
|
||||
type: 'render',
|
||||
context: {
|
||||
types: [],
|
||||
},
|
||||
help: i18n.translate('interpreter.functions.visualization.help', {
|
||||
defaultMessage: 'A simple visualization'
|
||||
}),
|
||||
|
|
|
@ -26,6 +26,7 @@ import { FormattedData } from './adapters/data';
|
|||
* inspector. It will only be called when the data view in the inspector is opened.
|
||||
*/
|
||||
export async function buildTabularInspectorData(table, queryFilter) {
|
||||
const aggConfigs = table.columns.map(column => column.aggConfig);
|
||||
const rows = table.rows.map(row => {
|
||||
return table.columns.reduce((prev, cur, colIndex) => {
|
||||
const value = row[cur.id];
|
||||
|
@ -45,12 +46,12 @@ export async function buildTabularInspectorData(table, queryFilter) {
|
|||
field: `col-${colIndex}-${col.aggConfig.id}`,
|
||||
filter: isCellContentFilterable && (value => {
|
||||
const rowIndex = rows.findIndex(row => row[`col-${colIndex}-${col.aggConfig.id}`].raw === value.raw);
|
||||
const filter = createFilter(table, colIndex, rowIndex, value.raw);
|
||||
const filter = createFilter(aggConfigs, table, colIndex, rowIndex, value.raw);
|
||||
queryFilter.addFilters(filter);
|
||||
}),
|
||||
filterOut: isCellContentFilterable && (value => {
|
||||
const rowIndex = rows.findIndex(row => row[`col-${colIndex}-${col.aggConfig.id}`].raw === value.raw);
|
||||
const filter = createFilter(table, colIndex, rowIndex, value.raw);
|
||||
const filter = createFilter(aggConfigs, table, colIndex, rowIndex, value.raw);
|
||||
const notOther = value.raw !== '__other__';
|
||||
const notMissing = value.raw !== '__missing__';
|
||||
if (Array.isArray(filter)) {
|
||||
|
|
|
@ -61,10 +61,11 @@ const getOtherBucketFilterTerms = (table, columnIndex, rowIndex) => {
|
|||
* @param {string} cellValue - value of the current cell
|
||||
* @return {array|string} - filter or list of filters to provide to queryFilter.addFilters()
|
||||
*/
|
||||
const createFilter = (table, columnIndex, rowIndex, cellValue) => {
|
||||
const { aggConfig, id: columnId } = table.columns[columnIndex];
|
||||
const createFilter = (aggConfigs, table, columnIndex, rowIndex, cellValue) => {
|
||||
const column = table.columns[columnIndex];
|
||||
const aggConfig = aggConfigs[columnIndex];
|
||||
let filter = [];
|
||||
const value = rowIndex > -1 ? table.rows[rowIndex][columnId] : cellValue;
|
||||
const value = rowIndex > -1 ? table.rows[rowIndex][column.id] : cellValue;
|
||||
if (value === null || value === undefined || !aggConfig.isFilterable()) {
|
||||
return;
|
||||
}
|
||||
|
@ -101,7 +102,7 @@ const VisFiltersProvider = (Private, getAppState) => {
|
|||
|
||||
dataPoints.forEach(val => {
|
||||
const { table, column, row, value } = val;
|
||||
const filter = createFilter(table, column, row, value);
|
||||
const filter = createFilter(event.aggConfigs, table, column, row, value);
|
||||
if (filter) {
|
||||
filter.forEach(f => {
|
||||
if (event.negate) {
|
||||
|
@ -117,7 +118,7 @@ const VisFiltersProvider = (Private, getAppState) => {
|
|||
};
|
||||
|
||||
const addFilter = (event) => {
|
||||
const filter = createFilter(event.table, event.column, event.row, event.value);
|
||||
const filter = createFilter(event.aggConfigs, event.table, event.column, event.row, event.value);
|
||||
queryFilter.addFilters(filter);
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import { VislibLibDataProvider } from '../../vislib/lib/data';
|
|||
import { uiModules } from '../../modules';
|
||||
import { VisFiltersProvider } from '../vis_filters';
|
||||
import { htmlIdGenerator, keyCodes } from '@elastic/eui';
|
||||
|
||||
import { getTableAggs } from '../../visualize/loader/pipeline_helpers/utilities';
|
||||
|
||||
uiModules.get('kibana')
|
||||
.directive('vislibLegend', function (Private, $timeout, i18n) {
|
||||
|
@ -106,7 +106,7 @@ uiModules.get('kibana')
|
|||
};
|
||||
|
||||
$scope.canFilter = function (legendData) {
|
||||
const filters = visFilters.filter({ data: legendData.values }, { simulate: true });
|
||||
const filters = visFilters.filter({ aggConfigs: $scope.tableAggs, data: legendData.values }, { simulate: true });
|
||||
return filters.length;
|
||||
};
|
||||
|
||||
|
@ -157,6 +157,8 @@ uiModules.get('kibana')
|
|||
if (vislibVis.visConfig) {
|
||||
$scope.getColor = vislibVis.visConfig.data.getColorFunc();
|
||||
}
|
||||
|
||||
$scope.tableAggs = getTableAggs($scope.vis);
|
||||
}
|
||||
|
||||
// Most of these functions were moved directly from the old Legend class. Not a fan of this.
|
||||
|
|
|
@ -29,12 +29,12 @@ import { RenderCompleteHelper } from '../../render_complete';
|
|||
import { AppState } from '../../state_management/app_state';
|
||||
import { timefilter } from '../../timefilter';
|
||||
import { RequestHandlerParams, Vis } from '../../vis';
|
||||
// import { VisualizeDataLoader } from './visualize_data_loader';
|
||||
import { PipelineDataLoader } from './pipeline_data_loader';
|
||||
import { visualizationLoader } from './visualization_loader';
|
||||
|
||||
import { DataAdapter, RequestAdapter } from '../../inspector/adapters';
|
||||
|
||||
import { getTableAggs } from './pipeline_helpers/utilities';
|
||||
import { VisSavedObject, VisualizeLoaderParams, VisualizeUpdateParams } from './types';
|
||||
|
||||
interface EmbeddedVisualizeHandlerParams extends VisualizeLoaderParams {
|
||||
|
@ -150,6 +150,7 @@ export class EmbeddedVisualizeHandler {
|
|||
this.events$ = this.vis.eventsSubject.asObservable().pipe(share());
|
||||
this.events$.subscribe(event => {
|
||||
if (this.actions[event.name]) {
|
||||
event.data.aggConfigs = getTableAggs(this.vis);
|
||||
this.actions[event.name](event.data);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,8 +19,11 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { identity } from 'lodash';
|
||||
import { AggConfig, Vis } from 'ui/vis';
|
||||
// @ts-ignore
|
||||
import { FieldFormat } from '../../../../field_formats/field_format';
|
||||
// @ts-ignore
|
||||
import { tabifyGetColumns } from '../../../agg_response/tabify/_get_columns';
|
||||
import chrome from '../../../chrome';
|
||||
// @ts-ignore
|
||||
import { fieldFormats } from '../../../registry/field_formats';
|
||||
|
@ -98,3 +101,8 @@ export const getFormat = (mapping: any) => {
|
|||
return getFieldFormat(id, mapping.params);
|
||||
}
|
||||
};
|
||||
|
||||
export const getTableAggs = (vis: Vis): AggConfig[] => {
|
||||
const columns = tabifyGetColumns(vis.aggs.getResponseAggs(), !vis.isHierarchical());
|
||||
return columns.map((c: any) => c.aggConfig);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue