Skip to content

Commit

Permalink
Merge branch 'master' into fixing-bucket-span-estimator-loading-max_b…
Browse files Browse the repository at this point in the history
…uckets
  • Loading branch information
elasticmachine authored Mar 9, 2020
2 parents e5f48e2 + a6489aa commit c942b44
Show file tree
Hide file tree
Showing 53 changed files with 201 additions and 247 deletions.
6 changes: 3 additions & 3 deletions src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1178,10 +1178,10 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy';
| `ui/index_patterns` | `data.indexPatterns` | still in progress |
| `ui/registry/field_formats` | `data.fieldFormats` | |
| `ui/registry/feature_catalogue` | `home.featureCatalogue.register` | Must add `home` as a dependency in your kibana.json. |
| `ui/registry/vis_types` | `visualizations.types` | -- |
| `ui/vis` | `visualizations.types` | -- |
| `ui/registry/vis_types` | `visualizations` | -- |
| `ui/vis` | `visualizations` | -- |
| `ui/share` | `share` | `showShareContextMenu` is now called `toggleShareContextMenu`, `ShareContextMenuExtensionsRegistryProvider` is now called `register` |
| `ui/vis/vis_factory` | `visualizations.types` | -- |
| `ui/vis/vis_factory` | `visualizations` | -- |
| `ui/vis/vis_filters` | `visualizations.filters` | -- |
| `ui/utils/parse_es_interval` | `import { parseEsInterval } from '../data/public'` | `parseEsInterval`, `ParsedInterval`, `InvalidEsCalendarIntervalError`, `InvalidEsIntervalFormatError` items were moved to the `Data Plugin` as a static code |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
} from '../../../../../../plugins/data/public';

import { buildTabularInspectorData } from './build_tabular_inspector_data';
import { calculateObjectHash } from '../../../../visualizations/public';
import { calculateObjectHash } from '../../../../../../plugins/kibana_utils/common';
import { tabifyAggResponse } from '../../../../../core_plugins/data/public';
import { PersistedState } from '../../../../../../plugins/visualizations/public';
import { Adapters } from '../../../../../../plugins/inspector/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import { i18n } from '@kbn/i18n';
import { createInputControlVisController } from './vis_controller';
import { getControlsTab } from './components/editor/controls_tab';
import { OptionsTab } from './components/editor/options_tab';
import { Status, defaultFeedbackMessage } from '../../visualizations/public';
import { Status } from '../../visualizations/public';
import { InputControlVisDependencies } from './plugin';
import { defaultFeedbackMessage } from '../../../../plugins/kibana_utils/common';

export function createInputControlVisTypeDefinition(deps: InputControlVisDependencies) {
const InputControlVisController = createInputControlVisController(deps);
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/input_control_vis/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class InputControlVisPlugin implements Plugin<Promise<void>, void> {
};

expressions.registerFunction(createInputControlVisFn);
visualizations.types.createBaseVisualization(
visualizations.createBaseVisualization(
createInputControlVisTypeDefinition(visualizationDependencies)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export function setServices(newServices: any) {
// EXPORT legacy static dependencies, should be migrated when available in a new version;
export { angular };
export { wrapInI18nContext } from 'ui/i18n';
export { buildVislibDimensions } from '../../../visualizations/public';
export { getRequestInspectorStats, getResponseInspectorStats } from '../../../data/public';
// @ts-ignore
export { intervalOptions } from 'ui/agg_types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { getPainlessError } from './get_painless_error';
import { discoverResponseHandler } from './response_handler';
import {
angular,
buildVislibDimensions,
getRequestInspectorStats,
getResponseInspectorStats,
getServices,
Expand Down Expand Up @@ -76,6 +75,7 @@ const {
import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../helpers/breadcrumbs';
import {
esFilters,
fieldFormats,
indexPatterns as indexPatternsUtils,
} from '../../../../../../../plugins/data/public';
import { getIndexPatternId } from '../helpers/get_index_pattern_id';
Expand Down Expand Up @@ -812,21 +812,45 @@ function discoverController(
$fetchObservable.next();
};

function getDimensions(aggs, timeRange) {
const [metric, agg] = aggs;
agg.params.timeRange = timeRange;
const bounds = agg.params.timeRange ? timefilter.calculateBounds(agg.params.timeRange) : null;
agg.buckets.setBounds(bounds);

const { esUnit, esValue } = agg.buckets.getInterval();
return {
x: {
accessor: 0,
label: agg.makeLabel(),
format: fieldFormats.serialize(agg),
params: {
date: true,
interval: moment.duration(esValue, esUnit),
intervalESValue: esValue,
intervalESUnit: esUnit,
format: agg.buckets.getScaledDateFormat(),
bounds: agg.buckets.getBounds(),
},
},
y: {
accessor: 1,
format: fieldFormats.serialize(metric),
label: metric.makeLabel(),
},
};
}

function onResults(resp) {
logInspectorResponse(resp);

if ($scope.opts.timefield) {
const tabifiedData = tabifyAggResponse($scope.vis.aggs, resp);
$scope.searchSource.rawResponse = resp;
Promise.resolve(
buildVislibDimensions($scope.vis, {
timefilter,
timeRange: $scope.timeRange,
searchSource: $scope.searchSource,
})
).then(resp => {
$scope.histogramData = discoverResponseHandler(tabifiedData, resp);
});
$scope.histogramData = discoverResponseHandler(
tabifiedData,
getDimensions($scope.vis.aggs.aggs, $scope.timeRange)
);
}

$scope.hits = resp.hits.total;
Expand Down Expand Up @@ -993,7 +1017,7 @@ function discoverController(
},
};

$scope.vis = new visualizations.Vis(
$scope.vis = visualizations.createVis(
$scope.searchSource.getField('index'),
visSavedObject.visState
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { getServices } from '../../../../kibana_services';

function getMapsAppBaseUrl() {
const mapsAppVisAlias = getServices()
.visualizations.types.getAliases()
.visualizations.getAliases()
.find(({ name }) => {
return name === 'maps';
});
Expand All @@ -38,7 +38,7 @@ function getMapsAppBaseUrl() {

export function isMapsAppRegistered() {
return getServices()
.visualizations.types.getAliases()
.visualizations.getAliases()
.some(({ name }) => {
return name === 'maps';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { i18n } from '@kbn/i18n';
import { npStart } from 'ui/new_platform';
import { SavedObjectLoader } from '../../../../../plugins/saved_objects/public';
import { createSavedDashboardLoader } from '../dashboard';
import { TypesService, createSavedVisLoader } from '../../../visualizations/public';
import { start as visualizations } from '../../../visualizations/public/np_ready/public/legacy';
import { createSavedSearchesLoader } from '../../../../../plugins/discover/public';

/**
Expand Down Expand Up @@ -58,10 +58,7 @@ const services = {

savedObjectManagementRegistry.register({
id: 'savedVisualizations',
service: createSavedVisLoader({
...services,
...{ visualizationTypes: new TypesService().start() },
}),
service: visualizations.savedVisualizationsLoader,
title: 'visualizations',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function initVisualizeApp(app, deps) {
resolve: {
savedVis: function(redirectWhenMissing, $route, $rootScope, kbnUrl) {
const { core, data, savedVisualizations, visualizations } = deps;
const visTypes = visualizations.types.all();
const visTypes = visualizations.all();
const visType = find(visTypes, { name: $route.current.params.type });
const shouldHaveIndex = visType.requiresSearch && visType.options.showIndexSelection;
const hasIndex =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ describe('RegionMapsVisualizationTests', function() {

if (!visRegComplete) {
visRegComplete = true;
visualizationsSetup.types.createBaseVisualization(
createRegionMapTypeDefinition(dependencies)
);
visualizationsSetup.createBaseVisualization(createRegionMapTypeDefinition(dependencies));
}

RegionMapsVisualization = createRegionMapVisualization(dependencies);
Expand Down Expand Up @@ -160,7 +158,7 @@ describe('RegionMapsVisualizationTests', function() {

imageComparator = new ImageComparator();

vis = new visualizationsStart.Vis(indexPattern, {
vis = visualizationsStart.createVis(indexPattern, {
type: 'region_map',
});

Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/region_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class RegionMapPlugin implements Plugin<Promise<void>, void> {

expressions.registerFunction(createRegionMapFn);

visualizations.types.createBaseVisualization(
visualizations.createBaseVisualization(
createRegionMapTypeDefinition(visualizationDependencies)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ describe('CoordinateMapsVisualizationTest', function() {

if (!visRegComplete) {
visRegComplete = true;
visualizationsSetup.types.createBaseVisualization(
createTileMapTypeDefinition(dependencies)
);
visualizationsSetup.createBaseVisualization(createTileMapTypeDefinition(dependencies));
}

CoordinateMapsVisualization = createTileMapVisualization(dependencies);
Expand Down Expand Up @@ -126,7 +124,7 @@ describe('CoordinateMapsVisualizationTest', function() {
setupDOM('512px', '512px');

imageComparator = new ImageComparator();
vis = new visualizationsStart.Vis(indexPattern, {
vis = visualizationsStart.createVis(indexPattern, {
type: 'tile_map',
});
vis.params = {
Expand Down
4 changes: 1 addition & 3 deletions src/legacy/core_plugins/tile_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export class TileMapPlugin implements Plugin<Promise<void>, void> {

expressions.registerFunction(() => createTileMapFn(visualizationDependencies));

visualizations.types.createBaseVisualization(
createTileMapTypeDefinition(visualizationDependencies)
);
visualizations.createBaseVisualization(createTileMapTypeDefinition(visualizationDependencies));
}

public start(core: CoreStart) {
Expand Down
10 changes: 2 additions & 8 deletions src/legacy/core_plugins/timelion/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import '../../data/public/legacy';
import './services/saved_sheet_register';

import rootTemplate from 'plugins/timelion/index.html';
import { createSavedVisLoader, TypesService } from '../../visualizations/public';
import { start as visualizations } from '../../visualizations/public/np_ready/public/legacy';

import { loadKbnTopNavDirectives } from '../../../../plugins/kibana_legacy/public';
loadKbnTopNavDirectives(npStart.plugins.navigation.ui);
Expand Down Expand Up @@ -127,13 +127,7 @@ app.controller('timelion', function(
timefilter.enableAutoRefreshSelector();
timefilter.enableTimeRangeSelector();

const savedVisualizations = createSavedVisLoader({
savedObjectsClient: npStart.core.savedObjects.client,
indexPatterns: npStart.plugins.data.indexPatterns,
chrome: npStart.core.chrome,
overlays: npStart.core.overlays,
visualizationTypes: new TypesService().start(),
});
const savedVisualizations = visualizations.savedVisualizationsLoader;
const timezone = Private(timezoneProvider)();

const defaultExpression = '.es(*)';
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/vis_type_markdown/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class MarkdownPlugin implements Plugin<void, void> {
}

public setup(core: CoreSetup, { expressions, visualizations }: MarkdownPluginSetupDependencies) {
visualizations.types.createReactVisualization(markdownVisDefinition);
visualizations.createReactVisualization(markdownVisDefinition);
expressions.registerFunction(createMarkdownVisFn);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('metric_vis - createMetricVisTypeDefinition', () => {
let vis: Vis;

beforeAll(() => {
visualizationsSetup.types.createReactVisualization(createMetricVisTypeDefinition());
visualizationsSetup.createReactVisualization(createMetricVisTypeDefinition());
(npStart.plugins.data.fieldFormats.getType as jest.Mock).mockImplementation(() => {
return fieldFormats.UrlFormat;
});
Expand All @@ -59,7 +59,7 @@ describe('metric_vis - createMetricVisTypeDefinition', () => {

// TODO: remove when Vis is converted to typescript. Only importing Vis as type
// @ts-ignore
vis = new visualizationsStart.Vis(stubIndexPattern, {
vis = visualizationsStart.createVis(stubIndexPattern, {
type: 'metric',
aggs: [{ id: '1', type: 'top_hits', schema: 'metric', params: { field: 'ip' } }],
});
Expand All @@ -80,7 +80,7 @@ describe('metric_vis - createMetricVisTypeDefinition', () => {
};

const el = document.createElement('div');
const metricVisType = visualizationsStart.types.get('metric');
const metricVisType = visualizationsStart.get('metric');
const Controller = metricVisType.visualization;
const controller = new Controller(el, vis);
const render = (esResponse: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/vis_type_metric/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class MetricVisPlugin implements Plugin<void, void> {
{ expressions, visualizations, charts }: MetricVisPluginSetupDependencies
) {
expressions.registerFunction(createMetricVisFn);
visualizations.types.createReactVisualization(createMetricVisTypeDefinition());
visualizations.createReactVisualization(createMetricVisTypeDefinition());
}

public start(core: CoreStart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ describe('Table Vis - AggTable Directive', function() {
const tabifiedData = {};

const init = () => {
const vis1 = new visualizationsStart.Vis(indexPattern, 'table');
const vis1 = visualizationsStart.createVis(indexPattern, 'table');
tabifiedData.metricOnly = tabifyAggResponse(vis1.aggs, metricOnly);

const vis2 = new visualizationsStart.Vis(indexPattern, {
const vis2 = visualizationsStart.createVis(indexPattern, {
type: 'table',
params: {
showMetricsAtAllLevels: true,
Expand All @@ -69,7 +69,7 @@ describe('Table Vis - AggTable Directive', function() {
metricsAtAllLevels: true,
});

const vis3 = new visualizationsStart.Vis(indexPattern, {
const vis3 = visualizationsStart.createVis(indexPattern, {
type: 'table',
aggs: [
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('Table Vis - AggTable Directive', function() {
beforeEach(initLocalAngular);

ngMock.inject(function() {
visualizationsSetup.types.createBaseVisualization(tableVisTypeDefinition);
visualizationsSetup.createBaseVisualization(tableVisTypeDefinition);
});

beforeEach(ngMock.module('kibana/table_vis'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ describe('Table Vis - AggTableGroup Directive', function() {
const tabifiedData = {};

const init = () => {
const vis1 = new visualizationsStart.Vis(indexPattern, 'table');
const vis1 = visualizationsStart.createVis(indexPattern, 'table');
tabifiedData.metricOnly = tabifyAggResponse(vis1.aggs, metricOnly);

const vis2 = new visualizationsStart.Vis(indexPattern, {
const vis2 = visualizationsStart.createVis(indexPattern, {
type: 'pie',
aggs: [
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/vis_type_table/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class TableVisPlugin implements Plugin<Promise<void>, void> {
) {
expressions.registerFunction(createTableVisFn);

visualizations.types.createBaseVisualization(tableVisTypeDefinition);
visualizations.createBaseVisualization(tableVisTypeDefinition);
}

public start(core: CoreStart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('TagCloudVisualizationTest', function() {
beforeEach(async function() {
setupDOM('512px', '512px');
imageComparator = new ImageComparator();
vis = new visualizationsStart.Vis(indexPattern, {
vis = visualizationsStart.createVis(indexPattern, {
type: 'tagcloud',
params: {
bucket: { accessor: 0, format: {} },
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/vis_type_tagcloud/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class TagCloudPlugin implements Plugin<void, void> {
colors: charts.colors,
};
expressions.registerFunction(createTagCloudFn);
visualizations.types.createBaseVisualization(
visualizations.createBaseVisualization(
createTagCloudVisTypeDefinition(visualizationDependencies)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/vis_type_timelion/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class TimelionVisPlugin implements Plugin<void, void> {
};

expressions.registerFunction(() => getTimelionVisualizationConfig(dependencies));
visualizations.types.createReactVisualization(getTimelionVisDefinition(dependencies));
visualizations.createReactVisualization(getTimelionVisDefinition(dependencies));
}

public start(core: CoreStart, plugins: PluginsStart) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { metricsRequestHandler } from './request_handler';
import { EditorController } from './editor_controller';
// @ts-ignore
import { PANEL_TYPES } from '../../../../plugins/vis_type_timeseries/common/panel_types';
import { defaultFeedbackMessage } from '../../visualizations/public';
import { defaultFeedbackMessage } from '../../../../plugins/kibana_utils/common';

export const metricsVisDefinition = {
name: 'metrics',
Expand Down
Loading

0 comments on commit c942b44

Please sign in to comment.