Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] Add super-fine option to grid/cluster layers #76526

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
64d439b
boilerplate
thomasneirynck Sep 2, 2020
c21d565
more boilerplate
thomasneirynck Sep 2, 2020
abf23ca
even more boilerplate
thomasneirynck Sep 2, 2020
d5e882d
add round-trip boilerplate
thomasneirynck Sep 2, 2020
416ed56
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 7, 2020
6b04156
move to common
thomasneirynck Sep 8, 2020
3f42ffe
move more files
thomasneirynck Sep 8, 2020
46e162a
move more utils
thomasneirynck Sep 8, 2020
3a67982
reuse existing implementation
thomasneirynck Sep 8, 2020
0df9b29
fix autodomain
thomasneirynck Sep 8, 2020
b1aa692
minor fixes
thomasneirynck Sep 8, 2020
2d84c57
undo typo
thomasneirynck Sep 8, 2020
9bb547f
enable grids
thomasneirynck Sep 8, 2020
a63d8a7
add shape support
thomasneirynck Sep 8, 2020
ee0f4d0
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 8, 2020
2342a35
create util folder
thomasneirynck Sep 8, 2020
b986964
remove some dupe
thomasneirynck Sep 8, 2020
86105f4
not done
thomasneirynck Sep 8, 2020
9693042
add new api extension
thomasneirynck Sep 8, 2020
3d28a58
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 9, 2020
01ed2d3
reuse implementation
thomasneirynck Sep 9, 2020
eecef6c
ts fixes
thomasneirynck Sep 9, 2020
9aa2038
type fixes
thomasneirynck Sep 9, 2020
9428aa1
more type fixes
thomasneirynck Sep 9, 2020
16f26d2
more type fixes
thomasneirynck Sep 9, 2020
b3bd0f1
remove cruft
thomasneirynck Sep 9, 2020
a148f5c
remove log
thomasneirynck Sep 9, 2020
db23dc5
remove dupes
thomasneirynck Sep 9, 2020
1ed2b67
simplification
thomasneirynck Sep 9, 2020
270f82c
reuse existing tile parsing
thomasneirynck Sep 9, 2020
751a39b
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 10, 2020
989f767
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 10, 2020
4e71f48
review feedback
thomasneirynck Sep 10, 2020
348a7ab
remove param
thomasneirynck Sep 10, 2020
0d5d0b6
remove fluffy try-catch
thomasneirynck Sep 10, 2020
7c642bf
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 14, 2020
a3946de
Add deprecation message to coordinate map and region map
nreese Sep 14, 2020
bbf755f
clean up text
nreese Sep 15, 2020
8c61d70
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 16, 2020
b773bb3
remove interfaces
thomasneirynck Sep 16, 2020
1e672ad
Merge branch 'master' of github.com:elastic/kibana into deprecation_m…
nreese Sep 16, 2020
1b5a900
add default distro link and view in maps link
nreese Sep 16, 2020
7571e3d
move url generation into onClick handler
nreese Sep 16, 2020
7ab105b
create tile map layer descritor
nreese Sep 16, 2020
a18083c
set metrics and color and scaling
nreese Sep 17, 2020
820acb3
lazy load createTileMapLayerDescriptor
nreese Sep 17, 2020
c9fa756
tslint fixes
nreese Sep 17, 2020
33f205e
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 17, 2020
99ca7d8
remove things
thomasneirynck Sep 18, 2020
fbecaf8
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 18, 2020
cfc4d21
add unit tests
thomasneirynck Sep 18, 2020
bb478aa
add unit tests
thomasneirynck Sep 18, 2020
45d587b
tslint cleanup for OSS code
nreese Sep 18, 2020
9fce05d
add snapshot
thomasneirynck Sep 18, 2020
070fac2
Merge branch 'deprecation_message' of https://github.com/nreese/kiban…
thomasneirynck Sep 18, 2020
5ad5585
Merge branch 'master' of github.com:elastic/kibana into maps/es_mvt_g…
thomasneirynck Sep 22, 2020
debec1e
feedback
thomasneirynck Sep 22, 2020
0b9fe76
make use of currentLayerType consistent
thomasneirynck Sep 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/plugins/tile_map/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"expressions",
"mapsLegacy",
"kibanaLegacy",
"data"
"data",
"share"
],
"requiredBundles": [
"kibanaUtils",
Expand Down
112 changes: 112 additions & 0 deletions src/plugins/tile_map/public/get_deprecation_message.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* 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 React from 'react';
import { EuiButton, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { getCoreService, getQueryService, getShareService } from './services';
import { indexPatterns } from '../../data/public';
import { Vis } from '../../visualizations/public';

export function getDeprecationMessage(vis: Vis) {
const mapsTileMapUrlGenerator = getShareService().urlGenerators.getUrlGenerator(
'MAPS_APP_TILE_MAP_URL_GENERATOR'
);

let action;
if (!mapsTileMapUrlGenerator) {
action = (
<FormattedMessage
id="tileMap.vis.defaultDistributionMessage"
defaultMessage="To get Maps, upgrade to the {defaultDistribution} of Elasticsearch and Kibana."
values={{
defaultDistribution: (
<EuiLink
color="accent"
external
href="https://www.elastic.co/downloads/kibana"
target="_blank"
>
default distribution
</EuiLink>
),
}}
/>
);
} else {
action = (
<div>
<EuiButton
onClick={async (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();

const query = getQueryService();
const createUrlParams = {
title: vis.title,
mapType: vis.params.mapType,
colorSchema: vis.params.colorSchema,
indexPatternId: vis.data.indexPattern?.id,
metricAgg: 'count',
filters: query.filterManager.getFilters(),
query: query.queryString.getQuery(),
timeRange: query.timefilter.timefilter.getTime(),
};

const bucketAggs = vis.data?.aggs?.byType('buckets');
if (bucketAggs?.length && bucketAggs[0].type.dslName === 'geohash_grid') {
createUrlParams.geoFieldName = bucketAggs[0].getField()?.name;
} else if (vis.data.indexPattern) {
// attempt to default to first geo point field when geohash is not configured yet
const geoField = vis.data.indexPattern.fields.find((field) => {
return (
!indexPatterns.isNestedField(field) &&
field.aggregatable &&
field.type === 'geo_point'
);
});
if (geoField) {
createUrlParams.geoFieldName = geoField.name;
}
}

const metricAggs = vis.data?.aggs?.byType('metrics');
if (metricAggs?.length) {
createUrlParams.metricAgg = metricAggs[0].type.dslName;
createUrlParams.metricFieldName = metricAggs[0].getField()?.name;
}

const url = await mapsTileMapUrlGenerator.createUrl(createUrlParams);
getCoreService().application.navigateToUrl(url);
}}
size="s"
>
<FormattedMessage id="tileMap.vis.viewInMaps" defaultMessage="View in Maps" />
</EuiButton>
</div>
);
}

return (
<FormattedMessage
id="tileMap.vis.deprecationMessage"
defaultMessage="Coordinate map will migrate to Maps in 8.0. With Maps, you can add multiple layers and indices, plot individual documents, symbolize features from data values, and more. {action}"
values={{ action }}
/>
);
}
20 changes: 15 additions & 5 deletions src/plugins/tile_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ import { createTileMapFn } from './tile_map_fn';
import { createTileMapTypeDefinition } from './tile_map_type';
import { IServiceSettings, MapsLegacyPluginSetup } from '../../maps_legacy/public';
import { DataPublicPluginStart } from '../../data/public';
import { setFormatService, setQueryService, setKibanaLegacy } from './services';
import {
setCoreService,
setFormatService,
setQueryService,
setKibanaLegacy,
setShareService,
} from './services';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { SharePluginStart } from '../../share/public';

export interface TileMapConfigType {
tilemap: any;
Expand All @@ -61,6 +68,7 @@ export interface TileMapPluginSetupDependencies {
export interface TileMapPluginStartDependencies {
data: DataPublicPluginStart;
kibanaLegacy: KibanaLegacyStart;
share: SharePluginStart;
}

export interface TileMapPluginSetup {
Expand Down Expand Up @@ -100,10 +108,12 @@ export class TileMapPlugin implements Plugin<TileMapPluginSetup, TileMapPluginSt
};
}

public start(core: CoreStart, { data, kibanaLegacy }: TileMapPluginStartDependencies) {
setFormatService(data.fieldFormats);
setQueryService(data.query);
setKibanaLegacy(kibanaLegacy);
public start(core: CoreStart, plugins: TileMapPluginStartDependencies) {
setFormatService(plugins.data.fieldFormats);
setQueryService(plugins.data.query);
setKibanaLegacy(plugins.kibanaLegacy);
setShareService(plugins.share);
setCoreService(core);
return {};
}
}
6 changes: 6 additions & 0 deletions src/plugins/tile_map/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
* under the License.
*/

import { CoreStart } from 'kibana/public';
import { createGetterSetter } from '../../kibana_utils/public';
import { DataPublicPluginStart } from '../../data/public';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { SharePluginStart } from '../../share/public';

export const [getCoreService, setCoreService] = createGetterSetter<CoreStart>('Core');

export const [getFormatService, setFormatService] = createGetterSetter<
DataPublicPluginStart['fieldFormats']
Expand All @@ -29,6 +33,8 @@ export const [getQueryService, setQueryService] = createGetterSetter<
DataPublicPluginStart['query']
>('Query');

export const [getShareService, setShareService] = createGetterSetter<SharePluginStart>('Share');

export const [getKibanaLegacy, setKibanaLegacy] = createGetterSetter<KibanaLegacyStart>(
'KibanaLegacy'
);
3 changes: 3 additions & 0 deletions src/plugins/tile_map/public/tile_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ import { createTileMapVisualization } from './tile_map_visualization';
import { TileMapOptions } from './components/tile_map_options';
import { supportsCssFilters } from './css_filters';
import { truncatedColorSchemas } from '../../charts/public';
import { getDeprecationMessage } from './get_deprecation_message';

export function createTileMapTypeDefinition(dependencies) {
const CoordinateMapsVisualization = createTileMapVisualization(dependencies);
const { uiSettings, serviceSettings } = dependencies;

return {
name: 'tile_map',
isDeprecated: true,
getDeprecationMessage,
title: i18n.translate('tileMap.vis.mapTitle', {
defaultMessage: 'Coordinate Map',
}),
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/visualizations/public/vis_types/base_vis_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
*/

import _ from 'lodash';
import { ReactElement } from 'react';
import { VisToExpressionAst, VisualizationControllerConstructor } from '../types';
import { TriggerContextMapping } from '../../../ui_actions/public';
import { Adapters } from '../../../inspector/public';
import { Vis } from '../vis';

export interface BaseVisTypeOptions {
name: string;
Expand All @@ -43,6 +45,8 @@ export interface BaseVisTypeOptions {
useCustomNoDataScreen?: boolean;
inspectorAdapters?: Adapters | (() => Adapters);
toExpressionAst?: VisToExpressionAst;
isDeprecated?: boolean;
getDeprecationMessage?: (vis: Vis) => ReactElement<any>;
}

export class BaseVisType {
Expand All @@ -68,6 +72,8 @@ export class BaseVisType {
useCustomNoDataScreen: boolean;
inspectorAdapters?: Adapters | (() => Adapters);
toExpressionAst?: VisToExpressionAst;
isDeprecated: boolean;
getDeprecationMessage?: (vis: Vis) => ReactElement<any>;

constructor(opts: BaseVisTypeOptions) {
if (!opts.icon && !opts.image) {
Expand Down Expand Up @@ -105,6 +111,8 @@ export class BaseVisType {
this.useCustomNoDataScreen = opts.useCustomNoDataScreen || false;
this.inspectorAdapters = opts.inspectorAdapters;
this.toExpressionAst = opts.toExpressionAst;
this.isDeprecated = opts.isDeprecated || false;
this.getDeprecationMessage = opts.getDeprecationMessage;
}

public get schemas() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 React, { ReactElement } from 'react';
import { EuiCallOut } from '@elastic/eui';

export function DeprecatedVisInfo({ message }: { message: ReactElement<any> }) {
return (
<EuiCallOut
className="hide-for-sharing"
data-test-subj="deprecatedVisInfo"
size="s"
title={message}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { EuiScreenReaderOnly } from '@elastic/eui';
import { VisualizeTopNav } from './visualize_top_nav';
import { ExperimentalVisInfo } from './experimental_vis_info';
import { DeprecatedVisInfo } from './deprecated_vis_info';
import {
SavedVisInstance,
VisualizeAppState,
Expand Down Expand Up @@ -79,28 +80,34 @@ export const VisualizeEditorCommon = ({
/>
)}
{visInstance?.vis?.type?.isExperimental && <ExperimentalVisInfo />}
{visInstance?.vis?.type?.isDeprecated && visInstance?.vis?.type?.getDeprecationMessage && (
<DeprecatedVisInfo message={visInstance.vis.type.getDeprecationMessage(visInstance?.vis)} />
)}
{visInstance && (
<EuiScreenReaderOnly>
<h1>
{'savedVis' in visInstance && visInstance.savedVis.id ? (
<FormattedMessage
id="visualize.pageHeading"
defaultMessage="{chartName} {chartType} visualization"
values={{
chartName: (visInstance as SavedVisInstance).savedVis.title,
chartType: (visInstance as SavedVisInstance).vis.type.title,
}}
/>
) : (
<FormattedMessage
id="visualize.byValue_pageHeading"
defaultMessage="Visualization of type {chartType} embedded into {originatingApp} app"
values={{
chartType: visInstance.vis.type.title,
originatingApp: originatingApp || 'dashboards',
}}
/>
)}
{
// @ts-expect-error
'savedVis' in visInstance && visInstance.savedVis.id ? (
<FormattedMessage
id="visualize.pageHeading"
defaultMessage="{chartName} {chartType} visualization"
values={{
chartName: (visInstance as SavedVisInstance).savedVis.title,
chartType: (visInstance as SavedVisInstance).vis.type.title,
}}
/>
) : (
<FormattedMessage
id="visualize.byValue_pageHeading"
defaultMessage="Visualization of type {chartType} embedded into {originatingApp} app"
values={{
chartType: visInstance.vis.type.title,
originatingApp: originatingApp || 'dashboards',
}}
/>
)
}
</h1>
</EuiScreenReaderOnly>
)}
Expand Down
8 changes: 6 additions & 2 deletions x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const FONTS_API_PATH = `${GIS_API_PATH}/fonts`;
export const API_ROOT_PATH = `/${GIS_API_PATH}`;

export const MVT_GETTILE_API_PATH = 'mvt/getTile';
export const MVT_GETGRIDTILE_API_PATH = 'mvt/getGridTile';
export const MVT_SOURCE_LAYER_NAME = 'source_layer';
export const KBN_TOO_MANY_FEATURES_PROPERTY = '__kbn_too_many_features__';
export const KBN_TOO_MANY_FEATURES_IMAGE_ID = '__kbn_too_many_features_image_id__';
Expand Down Expand Up @@ -165,8 +166,13 @@ export enum GRID_RESOLUTION {
COARSE = 'COARSE',
FINE = 'FINE',
MOST_FINE = 'MOST_FINE',
SUPER_FINE = 'SUPER_FINE',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is beyond the scope of this PR, but I wonder if we can have a range slider option next to the hard-coded select box values for advanced users to fine-tune their resolution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will create follow-up issue for this after this merges.

}

export const SUPER_FINE_ZOOM_DELTA = 7; // (2 ^ SUPER_FINE_ZOOM_DELTA) ^ 2 = number of cells in a given tile
export const GEOTILE_GRID_AGG_NAME = 'gridSplit';
export const GEOCENTROID_AGG_NAME = 'gridCentroid';

export const TOP_TERM_PERCENTAGE_SUFFIX = '__percentage';

export const COUNT_PROP_LABEL = i18n.translate('xpack.maps.aggs.defaultCountLabel', {
Expand Down Expand Up @@ -230,8 +236,6 @@ export enum SCALING_TYPES {
MVT = 'MVT',
}

export const RGBA_0000 = 'rgba(0,0,0,0)';

export enum MVT_FIELD_TYPE {
STRING = 'String',
NUMBER = 'Number',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { Feature } from 'geojson';
import { RENDER_AS } from '../constants';

export function convertCompositeRespToGeoJson(esResponse: any, renderAs: RENDER_AS): Feature[];
export function convertRegularRespToGeoJson(esResponse: any, renderAs: RENDER_AS): Feature[];
Loading