additional visualizations plugin cleanup before moving to NP (#59318)
This commit is contained in:
parent
f0e063c9f5
commit
a6489aa70e
|
@ -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 |
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -59,7 +59,7 @@ export class InputControlVisPlugin implements Plugin<Promise<void>, void> {
|
|||
};
|
||||
|
||||
expressions.registerFunction(createInputControlVisFn);
|
||||
visualizations.types.createBaseVisualization(
|
||||
visualizations.createBaseVisualization(
|
||||
createInputControlVisTypeDefinition(visualizationDependencies)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -45,7 +45,6 @@ import { getPainlessError } from './get_painless_error';
|
|||
import { discoverResponseHandler } from './response_handler';
|
||||
import {
|
||||
angular,
|
||||
buildVislibDimensions,
|
||||
getRequestInspectorStats,
|
||||
getResponseInspectorStats,
|
||||
getServices,
|
||||
|
@ -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';
|
||||
|
@ -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;
|
||||
|
@ -993,7 +1017,7 @@ function discoverController(
|
|||
},
|
||||
};
|
||||
|
||||
$scope.vis = new visualizations.Vis(
|
||||
$scope.vis = visualizations.createVis(
|
||||
$scope.searchSource.getField('index'),
|
||||
visSavedObject.visState
|
||||
);
|
||||
|
|
|
@ -29,7 +29,7 @@ import { getServices } from '../../../../kibana_services';
|
|||
|
||||
function getMapsAppBaseUrl() {
|
||||
const mapsAppVisAlias = getServices()
|
||||
.visualizations.types.getAliases()
|
||||
.visualizations.getAliases()
|
||||
.find(({ name }) => {
|
||||
return name === 'maps';
|
||||
});
|
||||
|
@ -38,7 +38,7 @@ function getMapsAppBaseUrl() {
|
|||
|
||||
export function isMapsAppRegistered() {
|
||||
return getServices()
|
||||
.visualizations.types.getAliases()
|
||||
.visualizations.getAliases()
|
||||
.some(({ name }) => {
|
||||
return name === 'maps';
|
||||
});
|
||||
|
|
|
@ -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';
|
||||
|
||||
/**
|
||||
|
@ -58,10 +58,7 @@ const services = {
|
|||
|
||||
savedObjectManagementRegistry.register({
|
||||
id: 'savedVisualizations',
|
||||
service: createSavedVisLoader({
|
||||
...services,
|
||||
...{ visualizationTypes: new TypesService().start() },
|
||||
}),
|
||||
service: visualizations.savedVisualizationsLoader,
|
||||
title: 'visualizations',
|
||||
});
|
||||
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -111,9 +111,7 @@ describe('RegionMapsVisualizationTests', function() {
|
|||
|
||||
if (!visRegComplete) {
|
||||
visRegComplete = true;
|
||||
visualizationsSetup.types.createBaseVisualization(
|
||||
createRegionMapTypeDefinition(dependencies)
|
||||
);
|
||||
visualizationsSetup.createBaseVisualization(createRegionMapTypeDefinition(dependencies));
|
||||
}
|
||||
|
||||
RegionMapsVisualization = createRegionMapVisualization(dependencies);
|
||||
|
@ -160,7 +158,7 @@ describe('RegionMapsVisualizationTests', function() {
|
|||
|
||||
imageComparator = new ImageComparator();
|
||||
|
||||
vis = new visualizationsStart.Vis(indexPattern, {
|
||||
vis = visualizationsStart.createVis(indexPattern, {
|
||||
type: 'region_map',
|
||||
});
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ export class RegionMapPlugin implements Plugin<Promise<void>, void> {
|
|||
|
||||
expressions.registerFunction(createRegionMapFn);
|
||||
|
||||
visualizations.types.createBaseVisualization(
|
||||
visualizations.createBaseVisualization(
|
||||
createRegionMapTypeDefinition(visualizationDependencies)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -88,9 +88,7 @@ describe('CoordinateMapsVisualizationTest', function() {
|
|||
|
||||
if (!visRegComplete) {
|
||||
visRegComplete = true;
|
||||
visualizationsSetup.types.createBaseVisualization(
|
||||
createTileMapTypeDefinition(dependencies)
|
||||
);
|
||||
visualizationsSetup.createBaseVisualization(createTileMapTypeDefinition(dependencies));
|
||||
}
|
||||
|
||||
CoordinateMapsVisualization = createTileMapVisualization(dependencies);
|
||||
|
@ -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 = {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
@ -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(*)';
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
@ -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' } }],
|
||||
});
|
||||
|
@ -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) => {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
@ -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' } },
|
||||
|
@ -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'));
|
||||
|
|
|
@ -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' } },
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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: {} },
|
||||
|
|
|
@ -53,7 +53,7 @@ export class TagCloudPlugin implements Plugin<void, void> {
|
|||
colors: charts.colors,
|
||||
};
|
||||
expressions.registerFunction(createTagCloudFn);
|
||||
visualizations.types.createBaseVisualization(
|
||||
visualizations.createBaseVisualization(
|
||||
createTagCloudVisTypeDefinition(visualizationDependencies)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -57,7 +57,7 @@ export class MetricsPlugin implements Plugin<Promise<void>, void> {
|
|||
) {
|
||||
expressions.registerFunction(createMetricsFn);
|
||||
setUISettings(core.uiSettings);
|
||||
visualizations.types.createReactVisualization(metricsVisDefinition);
|
||||
visualizations.createReactVisualization(metricsVisDefinition);
|
||||
}
|
||||
|
||||
public start(core: CoreStart, { data }: MetricsPluginStartDependencies) {
|
||||
|
|
|
@ -93,7 +93,7 @@ describe('VegaVisualizations', () => {
|
|||
|
||||
if (!visRegComplete) {
|
||||
visRegComplete = true;
|
||||
visualizationsSetup.types.createBaseVisualization(
|
||||
visualizationsSetup.createBaseVisualization(
|
||||
createVegaTypeDefinition(vegaVisualizationDependencies)
|
||||
);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ describe('VegaVisualizations', () => {
|
|||
setupDOM('512px', '512px');
|
||||
imageComparator = new ImageComparator();
|
||||
|
||||
vis = new visualizationsStart.Vis(indexPattern, { type: 'vega' });
|
||||
vis = visualizationsStart.createVis(indexPattern, { type: 'vega' });
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
|
|
@ -84,9 +84,7 @@ export class VegaPlugin implements Plugin<Promise<void>, void> {
|
|||
|
||||
expressions.registerFunction(() => createVegaFn(visualizationDependencies));
|
||||
|
||||
visualizations.types.createBaseVisualization(
|
||||
createVegaTypeDefinition(visualizationDependencies)
|
||||
);
|
||||
visualizations.createBaseVisualization(createVegaTypeDefinition(visualizationDependencies));
|
||||
}
|
||||
|
||||
public start(core: CoreStart, { data }: VegaPluginStartDependencies) {
|
||||
|
|
|
@ -19,10 +19,11 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
// @ts-ignore
|
||||
import { Status, defaultFeedbackMessage } from '../../visualizations/public';
|
||||
import { Status } from '../../visualizations/public';
|
||||
import { DefaultEditorSize } from '../../vis_default_editor/public';
|
||||
import { VegaVisualizationDependencies } from './plugin';
|
||||
import { VegaVisEditor } from './components';
|
||||
import { defaultFeedbackMessage } from '../../../../plugins/kibana_utils/common';
|
||||
|
||||
import { createVegaRequestHandler } from './vega_request_handler';
|
||||
// @ts-ignore
|
||||
|
|
|
@ -97,14 +97,14 @@ export class VisTypeVislibPlugin implements Plugin<Promise<void>, void> {
|
|||
// Register legacy vislib types that have been converted
|
||||
convertedFns.forEach(expressions.registerFunction);
|
||||
convertedTypes.forEach(vis =>
|
||||
visualizations.types.createBaseVisualization(vis(visualizationDependencies))
|
||||
visualizations.createBaseVisualization(vis(visualizationDependencies))
|
||||
);
|
||||
}
|
||||
|
||||
// Register non-converted types
|
||||
vislibFns.forEach(expressions.registerFunction);
|
||||
vislibTypes.forEach(vis =>
|
||||
visualizations.types.createBaseVisualization(vis(visualizationDependencies))
|
||||
visualizations.createBaseVisualization(vis(visualizationDependencies))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ describe('No global chart settings', function() {
|
|||
responseHandler = vislibSlicesResponseHandler;
|
||||
|
||||
let id1 = 1;
|
||||
stubVis1 = new visualizationsStart.Vis(indexPattern, {
|
||||
stubVis1 = visualizationsStart.createVis(indexPattern, {
|
||||
type: 'pie',
|
||||
aggs: rowAgg,
|
||||
});
|
||||
|
@ -222,7 +222,7 @@ describe('Vislib PieChart Class Test Suite', function() {
|
|||
responseHandler = vislibSlicesResponseHandler;
|
||||
|
||||
let id = 1;
|
||||
stubVis = new visualizationsStart.Vis(indexPattern, {
|
||||
stubVis = visualizationsStart.createVis(indexPattern, {
|
||||
type: 'pie',
|
||||
aggs: dataAgg,
|
||||
});
|
||||
|
|
|
@ -72,7 +72,7 @@ export class VisTypeXyPlugin implements Plugin<Promise<void>, void> {
|
|||
|
||||
visFunctions.forEach((fn: any) => expressions.registerFunction(fn));
|
||||
visTypeDefinitions.forEach((vis: any) =>
|
||||
visualizations.types.createBaseVisualization(vis(visualizationDependencies))
|
||||
visualizations.createBaseVisualization(vis(visualizationDependencies))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,20 +43,11 @@ export { Vis, VisParams, VisState } from './vis';
|
|||
import { VisualizeEmbeddableFactory, VisualizeEmbeddable } from './embeddable';
|
||||
export type VisualizeEmbeddableFactoryContract = PublicContract<VisualizeEmbeddableFactory>;
|
||||
export type VisualizeEmbeddableContract = PublicContract<VisualizeEmbeddable>;
|
||||
export { TypesService } from './vis_types/types_service';
|
||||
export { Status } from './legacy/update_status'; // should remove
|
||||
export { VISUALIZE_EMBEDDABLE_TYPE, VisualizeInput } from './embeddable';
|
||||
export { SchemaConfig } from './legacy/build_pipeline';
|
||||
|
||||
export function plugin(initializerContext: PluginInitializerContext) {
|
||||
return new VisualizationsPlugin(initializerContext);
|
||||
}
|
||||
|
||||
/** @public static code */
|
||||
export { TypesService } from './vis_types/types_service';
|
||||
export { VISUALIZE_EMBEDDABLE_TYPE, VisualizeInput } from './embeddable';
|
||||
|
||||
export { Status } from './legacy/update_status';
|
||||
export { buildPipeline, buildVislibDimensions, SchemaConfig } from './legacy/build_pipeline';
|
||||
|
||||
// @ts-ignore
|
||||
export { updateOldState } from './legacy/vis_update_state';
|
||||
export { calculateObjectHash } from './legacy/calculate_object_hash';
|
||||
export { createSavedVisLoader } from './saved_visualizations/saved_visualizations';
|
||||
export { defaultFeedbackMessage } from './misc/default_feedback_message';
|
||||
|
|
|
@ -43,12 +43,12 @@ describe('Vis Class', function() {
|
|||
beforeEach(
|
||||
ngMock.inject(function(Private) {
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
visTypes = visualizations.types;
|
||||
visTypes = visualizations;
|
||||
})
|
||||
);
|
||||
|
||||
beforeEach(function() {
|
||||
vis = new visualizations.Vis(indexPattern, stateFixture);
|
||||
vis = visualizations.createVis(indexPattern, stateFixture);
|
||||
});
|
||||
|
||||
const verifyVis = function(vis) {
|
||||
|
@ -84,7 +84,7 @@ describe('Vis Class', function() {
|
|||
|
||||
describe('setState()', function() {
|
||||
it('should set the state to defaults', function() {
|
||||
const vis = new visualizations.Vis(indexPattern);
|
||||
const vis = visualizations.createVis(indexPattern);
|
||||
expect(vis).to.have.property('type');
|
||||
expect(vis.type).to.eql(visTypes.get('histogram'));
|
||||
expect(vis).to.have.property('aggs');
|
||||
|
@ -100,7 +100,7 @@ describe('Vis Class', function() {
|
|||
expect(vis.isHierarchical()).to.be(true);
|
||||
});
|
||||
it('should return false for non-hierarchical vis (like histogram)', function() {
|
||||
const vis = new visualizations.Vis(indexPattern);
|
||||
const vis = visualizations.createVis(indexPattern);
|
||||
expect(vis.isHierarchical()).to.be(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,20 +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 function calculateObjectHash(obj: object): string;
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { PersistedState } from '../../../../../../../plugins/visualizations/public';
|
||||
import { calculateObjectHash } from './calculate_object_hash';
|
||||
import { calculateObjectHash } from '../../../../../../../plugins/kibana_utils/common';
|
||||
import { Vis } from '../vis';
|
||||
|
||||
enum Status {
|
||||
|
|
|
@ -28,23 +28,19 @@ import { usageCollectionPluginMock } from '../../../../../../plugins/usage_colle
|
|||
import { uiActionsPluginMock } from '../../../../../../plugins/ui_actions/public/mocks';
|
||||
|
||||
const createSetupContract = (): VisualizationsSetup => ({
|
||||
types: {
|
||||
createBaseVisualization: jest.fn(),
|
||||
createReactVisualization: jest.fn(),
|
||||
registerAlias: jest.fn(),
|
||||
hideTypes: jest.fn(),
|
||||
},
|
||||
createBaseVisualization: jest.fn(),
|
||||
createReactVisualization: jest.fn(),
|
||||
registerAlias: jest.fn(),
|
||||
hideTypes: jest.fn(),
|
||||
});
|
||||
|
||||
const createStartContract = (): VisualizationsStart => ({
|
||||
types: {
|
||||
get: jest.fn(),
|
||||
all: jest.fn(),
|
||||
getAliases: jest.fn(),
|
||||
},
|
||||
get: jest.fn(),
|
||||
all: jest.fn(),
|
||||
getAliases: jest.fn(),
|
||||
savedVisualizationsLoader: {} as any,
|
||||
showNewVisModal: jest.fn(),
|
||||
Vis: jest.fn(),
|
||||
createVis: jest.fn(),
|
||||
});
|
||||
|
||||
const createInstance = async () => {
|
||||
|
|
|
@ -48,27 +48,27 @@ import { visualization as visualizationRenderer } from './expressions/visualizat
|
|||
import {
|
||||
DataPublicPluginSetup,
|
||||
DataPublicPluginStart,
|
||||
IIndexPattern,
|
||||
} from '../../../../../../plugins/data/public';
|
||||
import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/public';
|
||||
import { createSavedVisLoader, SavedVisualizationsLoader } from './saved_visualizations';
|
||||
import { VisImpl, VisImplConstructor } from './vis_impl';
|
||||
import { VisImpl } from './vis_impl';
|
||||
import { showNewVisModal } from './wizard';
|
||||
import { UiActionsStart } from '../../../../../../plugins/ui_actions/public';
|
||||
import { DataStart as LegacyDataStart } from '../../../../data/public';
|
||||
import { VisState } from './types';
|
||||
|
||||
/**
|
||||
* Interface for this plugin's returned setup/start contracts.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface VisualizationsSetup {
|
||||
types: TypesSetup;
|
||||
}
|
||||
|
||||
export interface VisualizationsStart {
|
||||
types: TypesStart;
|
||||
export type VisualizationsSetup = TypesSetup;
|
||||
|
||||
export interface VisualizationsStart extends TypesStart {
|
||||
savedVisualizationsLoader: SavedVisualizationsLoader;
|
||||
Vis: VisImplConstructor;
|
||||
createVis: (indexPattern: IIndexPattern, visState?: VisState) => VisImpl;
|
||||
showNewVisModal: typeof showNewVisModal;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ export class VisualizationsPlugin
|
|||
embeddable.registerEmbeddableFactory(VISUALIZE_EMBEDDABLE_TYPE, embeddableFactory);
|
||||
|
||||
return {
|
||||
types: this.types.setup(),
|
||||
...this.types.setup(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -152,9 +152,15 @@ export class VisualizationsPlugin
|
|||
setSavedVisualizationsLoader(savedVisualizationsLoader);
|
||||
|
||||
return {
|
||||
types,
|
||||
...types,
|
||||
showNewVisModal,
|
||||
Vis: VisImpl,
|
||||
/**
|
||||
* creates new instance of Vis
|
||||
* @param {IIndexPattern} indexPattern - index pattern to use
|
||||
* @param {VisState} visState - visualization configuration
|
||||
*/
|
||||
createVis: (indexPattern: IIndexPattern, visState?: VisState) =>
|
||||
new VisImpl(indexPattern, visState),
|
||||
savedVisualizationsLoader,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ import {
|
|||
SavedObject,
|
||||
SavedObjectKibanaServices,
|
||||
} from '../../../../../../../plugins/saved_objects/public';
|
||||
import { updateOldState } from '../../../index';
|
||||
// @ts-ignore
|
||||
import { updateOldState } from '../legacy/vis_update_state';
|
||||
import { extractReferences, injectReferences } from './saved_visualization_references';
|
||||
import { IIndexPattern } from '../../../../../../../plugins/data/public';
|
||||
import { VisSavedObject } from '../types';
|
||||
|
|
|
@ -67,15 +67,32 @@ export class TypesService {
|
|||
this.types[visDefinition.name] = visDefinition;
|
||||
};
|
||||
return {
|
||||
/**
|
||||
* registers a visualization type
|
||||
* @param {VisType} config - visualization type definition
|
||||
*/
|
||||
createBaseVisualization: (config: any) => {
|
||||
const vis = new BaseVisType(config);
|
||||
registerVisualization(() => vis);
|
||||
},
|
||||
/**
|
||||
* registers a visualization which uses react for rendering
|
||||
* @param {VisType} config - visualization type definition
|
||||
*/
|
||||
createReactVisualization: (config: any) => {
|
||||
const vis = new ReactVisType(config);
|
||||
registerVisualization(() => vis);
|
||||
},
|
||||
/**
|
||||
* registers a visualization alias
|
||||
* alias is a visualization type without implementation, it just redirects somewhere in kibana
|
||||
* @param {VisTypeAlias} config - visualization alias definition
|
||||
*/
|
||||
registerAlias: visTypeAliasRegistry.add,
|
||||
/**
|
||||
* allows to hide specific visualization types from create visualization dialog
|
||||
* @param {string[]} typeNames - list of type ids to hide
|
||||
*/
|
||||
hideTypes: (typeNames: string[]) => {
|
||||
typeNames.forEach((name: string) => {
|
||||
if (this.types[name]) {
|
||||
|
@ -90,12 +107,22 @@ export class TypesService {
|
|||
|
||||
public start() {
|
||||
return {
|
||||
/**
|
||||
* returns specific visualization or undefined if not found
|
||||
* @param {string} visualization - id of visualization to return
|
||||
*/
|
||||
get: (visualization: string) => {
|
||||
return this.types[visualization];
|
||||
},
|
||||
/**
|
||||
* returns all registered visualization types
|
||||
*/
|
||||
all: () => {
|
||||
return [...Object.values(this.types)];
|
||||
},
|
||||
/**
|
||||
* returns all registered aliases
|
||||
*/
|
||||
getAliases: visTypeAliasRegistry.get,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -29,6 +29,11 @@ export interface ShowNewVisModalParams {
|
|||
onClose?: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* shows modal dialog that allows you to create new visualization
|
||||
* @param {string[]} editorParams
|
||||
* @param {function} onClose - function that will be called when dialog is closed
|
||||
*/
|
||||
export function showNewVisModal({ editorParams = [], onClose }: ShowNewVisModalParams = {}) {
|
||||
const container = document.createElement('div');
|
||||
let isClosed = false;
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
// adopted form https://github.com/bevacqua/hash-sum
|
||||
|
||||
function pad(hash, len) {
|
||||
function pad(hash: string, len: number): string {
|
||||
while (hash.length < len) {
|
||||
hash = '0' + hash;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
function fold(hash, text) {
|
||||
function fold(hash: number, text: string): number {
|
||||
let i;
|
||||
let chr;
|
||||
let len;
|
||||
|
@ -35,22 +35,25 @@ function fold(hash, text) {
|
|||
}
|
||||
for (i = 0, len = text.length; i < len; i++) {
|
||||
chr = text.charCodeAt(i);
|
||||
// eslint-disable-next-line no-bitwise
|
||||
hash = (hash << 5) - hash + chr;
|
||||
// eslint-disable-next-line no-bitwise
|
||||
hash |= 0;
|
||||
}
|
||||
return hash < 0 ? hash * -2 : hash;
|
||||
}
|
||||
|
||||
function foldObject(hash, o, seen) {
|
||||
function foldObject(hash: number, o: any, seen: any[]) {
|
||||
function foldKey(h: number, key: string): number {
|
||||
return foldValue(h, o[key], key, seen);
|
||||
}
|
||||
|
||||
return Object.keys(o)
|
||||
.sort()
|
||||
.reduce(foldKey, hash);
|
||||
function foldKey(hash, key) {
|
||||
return foldValue(hash, o[key], key, seen);
|
||||
}
|
||||
}
|
||||
|
||||
function foldValue(input, value, key, seen) {
|
||||
function foldValue(input: number, value: any, key: string, seen: any[]) {
|
||||
const hash = fold(fold(fold(input, key), toString(value)), typeof value);
|
||||
if (value === null) {
|
||||
return fold(hash, 'null');
|
||||
|
@ -72,11 +75,11 @@ function foldValue(input, value, key, seen) {
|
|||
return fold(hash, value.toString());
|
||||
}
|
||||
|
||||
function toString(o) {
|
||||
function toString(o: object): string {
|
||||
return Object.prototype.toString.call(o);
|
||||
}
|
||||
|
||||
function sum(o) {
|
||||
function sum(o: object): string {
|
||||
return pad(foldValue(0, o, '', []).toString(16), 8);
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export const defaultFeedbackMessage = i18n.translate('visualizations.defaultFeedbackMessage', {
|
||||
export const defaultFeedbackMessage = i18n.translate('kibana_utils.defaultFeedbackMessage', {
|
||||
defaultMessage: 'Have feedback? Please create an issue in {link}.',
|
||||
values: {
|
||||
link:
|
|
@ -26,3 +26,5 @@ export { createGetterSetter, Get, Set } from './create_getter_setter';
|
|||
export { distinctUntilChangedWithInitialValue } from './distinct_until_changed_with_initial_value';
|
||||
export { url } from './url';
|
||||
export { now } from './now';
|
||||
export { calculateObjectHash } from './calculate_object_hash';
|
||||
export { defaultFeedbackMessage } from './default_feedback_message';
|
||||
|
|
|
@ -22,7 +22,7 @@ import { SelfChangingComponent } from './self_changing_components';
|
|||
|
||||
import { setup as visualizations } from '../../../../../../src/legacy/core_plugins/visualizations/public/np_ready/public/legacy';
|
||||
|
||||
visualizations.types.createReactVisualization({
|
||||
visualizations.createReactVisualization({
|
||||
name: 'self_changing_vis',
|
||||
title: 'Self Changing Vis',
|
||||
icon: 'controlsHorizontal',
|
||||
|
|
|
@ -103,7 +103,7 @@ export class LensPlugin {
|
|||
this.datatableVisualization.setup(core, dependencies);
|
||||
this.metricVisualization.setup(core, dependencies);
|
||||
|
||||
visualizations.types.registerAlias(getLensAliasConfig());
|
||||
visualizations.registerAlias(getLensAliasConfig());
|
||||
|
||||
kibanaLegacy.registerLegacyApp({
|
||||
id: 'lens',
|
||||
|
|
|
@ -23,7 +23,7 @@ The Maps app offers more functionality and is easier to use.`,
|
|||
}
|
||||
);
|
||||
|
||||
visualizationsSetup.types.registerAlias({
|
||||
visualizationsSetup.registerAlias({
|
||||
aliasUrl: MAP_BASE_URL,
|
||||
name: APP_ID,
|
||||
title: i18n.translate('xpack.maps.visTypeAlias.title', {
|
||||
|
@ -37,5 +37,5 @@ visualizationsSetup.types.registerAlias({
|
|||
});
|
||||
|
||||
if (!showMapVisualizationTypes) {
|
||||
visualizationsSetup.types.hideTypes(['region_map', 'tile_map']);
|
||||
visualizationsSetup.hideTypes(['region_map', 'tile_map']);
|
||||
}
|
||||
|
|
|
@ -2849,7 +2849,6 @@
|
|||
"timelion.vis.intervalLabel": "間隔",
|
||||
"uiActions.actionPanel.title": "オプション",
|
||||
"uiActions.errors.incompatibleAction": "操作に互換性がありません",
|
||||
"visualizations.defaultFeedbackMessage": "フィードバックがありますか?{link} で問題を報告してください。",
|
||||
"visualizations.newVisWizard.betaDescription": "このビジュアライゼーションはベータ段階で、変更される可能性があります。デザインとコードはオフィシャル GA 機能よりも完成度が低く、現状のまま保証なしで提供されています。ベータ機能にはオフィシャル GA 機能の SLA が適用されません",
|
||||
"visualizations.newVisWizard.betaTitle": "ベータ",
|
||||
"visualizations.newVisWizard.chooseSourceTitle": "ソースの選択",
|
||||
|
|
|
@ -2850,7 +2850,6 @@
|
|||
"timelion.vis.intervalLabel": "时间间隔",
|
||||
"uiActions.actionPanel.title": "选项",
|
||||
"uiActions.errors.incompatibleAction": "操作不兼容",
|
||||
"visualizations.defaultFeedbackMessage": "想反馈?请在“{link}中创建问题。",
|
||||
"visualizations.newVisWizard.betaDescription": "此可视化为公测版,可能会进行更改。设计和代码相对于正式发行版功能还不够成熟,将按原样提供,且不提供任何保证。公测版功能不受正式发行版功能支持 SLA 的约束",
|
||||
"visualizations.newVisWizard.betaTitle": "公测版",
|
||||
"visualizations.newVisWizard.chooseSourceTitle": "选择源",
|
||||
|
|
Loading…
Reference in a new issue