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

[Rename] tile_map plugin #123

Merged
merged 1 commit into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/plugins/tile_map/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { schema, TypeOf } from '@kbn/config-schema';
import { schema, TypeOf } from '@osd/config-schema';

export const configSchema = schema.object({
url: schema.maybe(schema.string()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"id": "tileMap",
"version": "8.0.0",
"kibanaVersion": "kibana",
"opensearchDashboardsVersion": "opensearchDashboards",
"configPath": ["map", "tilemap"],
"ui": true,
"server": true,
"requiredPlugins": [
"visualizations",
"expressions",
"mapsLegacy",
"kibanaLegacy",
"opensearchDashboardsLegacy",
"data",
"share"
],
"requiredBundles": [
"kibanaUtils",
"opensearchDashboardsUtils",
"charts",
"visDefaultEditor"
]
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tile_map/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "tile_map",
"version": "kibana"
"version": "opensearchDashboards"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React, { useEffect } from 'react';
import { EuiPanel, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';

import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
import { BasicOptions, RangeOption, SelectOption, SwitchOption } from '../../../charts/public';
Expand Down
26 changes: 13 additions & 13 deletions src/plugins/tile_map/public/geohash_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
*/

import { min, isEqual } from 'lodash';
import { i18n } from '@kbn/i18n';
import { KibanaMapLayer, MapTypes } from '../../maps_legacy/public';
import { i18n } from '@osd/i18n';
import { OpenSearchDashboardsMapLayer, MapTypes } from '../../maps_legacy/public';
import { HeatmapMarkers } from './markers/heatmap';
import { ScaledCirclesMarkers } from './markers/scaled_circles';
import { ShadedCirclesMarkers } from './markers/shaded_circles';
import { GeohashGridMarkers } from './markers/geohash_grid';

export class GeohashLayer extends KibanaMapLayer {
constructor(featureCollection, featureCollectionMetaData, options, zoom, kibanaMap, leaflet) {
export class GeohashLayer extends OpenSearchDashboardsMapLayer {
constructor(featureCollection, featureCollectionMetaData, options, zoom, opensearchDashboardsMap, leaflet) {
super();

this._featureCollection = featureCollection;
this._featureCollectionMetaData = featureCollectionMetaData;

this._geohashOptions = options;
this._zoom = zoom;
this._kibanaMap = kibanaMap;
this._opensearchDashboardsMap = opensearchDashboardsMap;
this._leaflet = leaflet;
const geojson = this._leaflet.geoJson(this._featureCollection);
this._bounds = geojson.getBounds();
Expand All @@ -57,7 +57,7 @@ export class GeohashLayer extends KibanaMapLayer {
this._featureCollectionMetaData,
markerOptions,
this._zoom,
this._kibanaMap,
this._opensearchDashboardsMap,
this._leaflet
);
break;
Expand All @@ -67,7 +67,7 @@ export class GeohashLayer extends KibanaMapLayer {
this._featureCollectionMetaData,
markerOptions,
this._zoom,
this._kibanaMap,
this._opensearchDashboardsMap,
this._leaflet
);
break;
Expand All @@ -77,15 +77,15 @@ export class GeohashLayer extends KibanaMapLayer {
this._featureCollectionMetaData,
markerOptions,
this._zoom,
this._kibanaMap,
this._opensearchDashboardsMap,
this._leaflet
);
break;
case MapTypes.Heatmap:
let radius = 15;
if (this._featureCollectionMetaData.geohashGridDimensionsAtEquator) {
const minGridLength = min(this._featureCollectionMetaData.geohashGridDimensionsAtEquator);
const metersPerPixel = this._kibanaMap.getMetersPerPixel();
const metersPerPixel = this._opensearchDashboardsMap.getMetersPerPixel();
radius = minGridLength / metersPerPixel / 2;
}
radius = radius * parseFloat(this._geohashOptions.heatmap.heatClusterSize);
Expand All @@ -94,7 +94,7 @@ export class GeohashLayer extends KibanaMapLayer {
{
radius: radius,
blur: radius,
maxZoom: this._kibanaMap.getZoomLevel(),
maxZoom: this._opensearchDashboardsMap.getZoomLevel(),
minOpacity: 0.1,
tooltipFormatter: this._geohashOptions.tooltipFormatter,
},
Expand Down Expand Up @@ -149,12 +149,12 @@ export class GeohashLayer extends KibanaMapLayer {
updateExtent() {
// Client-side filtering is only enabled when server-side filter is not used
if (!this._geohashOptions.isFilteredByCollar) {
const bounds = this._kibanaMap.getLeafletBounds();
const bounds = this._opensearchDashboardsMap.getLeafletBounds();
if (!this._lastBounds || !this._lastBounds.equals(bounds)) {
//this removal is required to trigger the bounds filter again
this._kibanaMap.removeLayer(this);
this._opensearchDashboardsMap.removeLayer(this);
this._createGeohashMarkers();
this._kibanaMap.addLayer(this);
this._opensearchDashboardsMap.addLayer(this);
}
this._lastBounds = bounds;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tile_map/public/get_deprecation_message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import React from 'react';
import { UrlGeneratorContract } from 'src/plugins/share/public';
import { getCoreService, getQueryService, getShareService } from './services';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tile_map/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { PluginInitializerContext } from 'kibana/public';
import { PluginInitializerContext } from 'opensearch-dashboards/public';
import { TileMapPlugin as Plugin } from './plugin';

export function plugin(initializerContext: PluginInitializerContext) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/tile_map/public/markers/scaled_circles.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ScaledCirclesMarkers extends EventEmitter {
featureCollectionMetaData,
options,
targetZoom,
kibanaMap,
opensearchDasbhoardsMap,
leaflet
) {
super();
Expand Down Expand Up @@ -69,7 +69,7 @@ export class ScaledCirclesMarkers extends EventEmitter {
if (!options.isFilteredByCollar) {
layerOptions.filter = (feature) => {
const bucketRectBounds = feature.properties.geohash_meta.rectangle;
return kibanaMap.isInside(bucketRectBounds);
return opensearchDasbhoardsMap.isInside(bucketRectBounds);
};
}
this._leafletLayer = this._leaflet.geoJson(null, layerOptions);
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/tile_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Plugin,
PluginInitializerContext,
IUiSettingsClient,
} from 'kibana/public';
} from 'opensearch-dashboards/public';
import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public';
import { VisualizationsSetup } from '../../visualizations/public';
// TODO: Determine why visualizations don't populate without this
Expand All @@ -38,10 +38,10 @@ import {
setCoreService,
setFormatService,
setQueryService,
setKibanaLegacy,
setOpenSearchDashboardsLegacy,
setShareService,
} from './services';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { OpenSearchDashboardsLegacyStart } from '../../opensearch_dashboards_legacy/public';
import { SharePluginStart } from '../../share/public';

export interface TileMapConfigType {
Expand All @@ -67,7 +67,7 @@ export interface TileMapPluginSetupDependencies {
/** @internal */
export interface TileMapPluginStartDependencies {
data: DataPublicPluginStart;
kibanaLegacy: KibanaLegacyStart;
opensearchDashboardsLegacy: OpenSearchDashboardsLegacyStart;
share: SharePluginStart;
}

Expand Down Expand Up @@ -111,7 +111,7 @@ export class TileMapPlugin implements Plugin<TileMapPluginSetup, TileMapPluginSt
public start(core: CoreStart, plugins: TileMapPluginStartDependencies) {
setFormatService(plugins.data.fieldFormats);
setQueryService(plugins.data.query);
setKibanaLegacy(plugins.kibanaLegacy);
setOpenSearchDashboardsLegacy(plugins.opensearchDashboardsLegacy);
setShareService(plugins.share);
setCoreService(core);
return {};
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/tile_map/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

import { CoreStart } from 'kibana/public';
import { createGetterSetter } from '../../kibana_utils/public';
import { CoreStart } from 'opensearch-dashboards/public';
import { createGetterSetter } from '../../opensearch_dashboards_utils/public';
import { DataPublicPluginStart } from '../../data/public';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { OpenSearchDashboardsLegacyStart } from '../../opensearch_dashboards_legacy/public';
import { SharePluginStart } from '../../share/public';

export const [getCoreService, setCoreService] = createGetterSetter<CoreStart>('Core');
Expand All @@ -35,6 +35,6 @@ export const [getQueryService, setQueryService] = createGetterSetter<

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

export const [getKibanaLegacy, setKibanaLegacy] = createGetterSetter<KibanaLegacyStart>(
'KibanaLegacy'
export const [getOpenSearchDashboardsLegacy, setOpenSearchDashboardsLegacy] = createGetterSetter<OpenSearchDashboardsLegacyStart>(
'OpenSearchDashboardsLegacy'
);
4 changes: 2 additions & 2 deletions src/plugins/tile_map/public/tile_map_fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* under the License.
*/
import { convertToGeoJson } from '../../maps_legacy/public';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';

export const createTileMapFn = () => ({
name: 'tilemap',
type: 'render',
context: {
types: ['kibana_datatable'],
types: ['opensearch_dashboards_datatable'],
},
help: i18n.translate('tileMap.function.help', {
defaultMessage: 'Tilemap visualization',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tile_map/public/tile_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import { convertToGeoJson, MapTypes } from '../../maps_legacy/public';
import { Schemas } from '../../vis_default_editor/public';
import { createTileMapVisualization } from './tile_map_visualization';
Expand Down
40 changes: 20 additions & 20 deletions src/plugins/tile_map/public/tile_map_visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { get, round } from 'lodash';
import { getFormatService, getQueryService, getKibanaLegacy } from './services';
import { getFormatService, getQueryService, getOpenSearchDashboardsLegacy } from './services';
import {
geoContains,
mapTooltipProvider,
Expand Down Expand Up @@ -71,7 +71,7 @@ export const createTileMapVisualization = (dependencies) => {
name: 'bounds',
data: {},
};
const bounds = this._kibanaMap.getBounds();
const bounds = this._opensearchDashboardsMap.getBounds();
const mapCollar = scaleBounds(bounds);
if (!geoContains(geohashAgg.aggConfigParams.boundingBox, mapCollar)) {
updateVarsObject.data.boundingBox = {
Expand All @@ -91,14 +91,14 @@ export const createTileMapVisualization = (dependencies) => {
};

async render(esResponse, visParams) {
getKibanaLegacy().loadFontAwesome();
getOpenSearchDashboardsLegacy().loadFontAwesome();
await super.render(esResponse, visParams);
}

async _makeKibanaMap() {
await super._makeKibanaMap();
async _makeOpenSearchDasbhoardsMap() {
await super._makeOpenSearchDashboardsMap();

let previousPrecision = this._kibanaMap.getGeohashPrecision();
let previousPrecision = this._opensearchDashboardsMap.getGeohashPrecision();
let precisionChange = false;

const uiState = this.vis.getUiState();
Expand All @@ -108,11 +108,11 @@ export const createTileMapVisualization = (dependencies) => {
}
});

this._kibanaMap.on('zoomchange', () => {
precisionChange = previousPrecision !== this._kibanaMap.getGeohashPrecision();
previousPrecision = this._kibanaMap.getGeohashPrecision();
this._opensearchDashboardsMap.on('zoomchange', () => {
precisionChange = previousPrecision !== this._opensearchDashboardsMap.getGeohashPrecision();
previousPrecision = this._opensearchDashboardsMap.getGeohashPrecision();
});
this._kibanaMap.on('zoomend', () => {
this._opensearchDashboardsMap.on('zoomend', () => {
const geohashAgg = this._getGeoHashAgg();
if (!geohashAgg) {
return;
Expand All @@ -132,12 +132,12 @@ export const createTileMapVisualization = (dependencies) => {
}
});

this._kibanaMap.addDrawControl();
this._kibanaMap.on('drawCreated:rectangle', (event) => {
this._opensearchDashboardsMap.addDrawControl();
this._opensearchDashboardsMap.on('drawCreated:rectangle', (event) => {
const geohashAgg = this._getGeoHashAgg();
this.addSpatialFilter(geohashAgg, 'geo_bounding_box', event.bounds);
});
this._kibanaMap.on('drawCreated:polygon', (event) => {
this._opensearchDashboardsMap.on('drawCreated:polygon', (event) => {
const geohashAgg = this._getGeoHashAgg();
this.addSpatialFilter(geohashAgg, 'geo_polygon', { points: event.points });
});
Expand All @@ -154,13 +154,13 @@ export const createTileMapVisualization = (dependencies) => {
}

if (this._geohashLayer) {
this._kibanaMap.removeLayer(this._geohashLayer);
this._opensearchDashboardsMap.removeLayer(this._geohashLayer);
this._geohashLayer = null;
}

if (!geojsonFeatureCollectionAndMeta) {
this._geoJsonFeatureCollectionAndMeta = null;
this._kibanaMap.removeLayer(this._geohashLayer);
this._opensearchDashboardsMap.removeLayer(this._geohashLayer);
this._geohashLayer = null;
return;
}
Expand All @@ -181,25 +181,25 @@ export const createTileMapVisualization = (dependencies) => {
const { GeohashLayer } = await import('./geohash_layer');

if (this._geohashLayer) {
this._kibanaMap.removeLayer(this._geohashLayer);
this._opensearchDashboardsMap.removeLayer(this._geohashLayer);
this._geohashLayer = null;
}
const geohashOptions = this._getGeohashOptions();
this._geohashLayer = new GeohashLayer(
this._geoJsonFeatureCollectionAndMeta.featureCollection,
this._geoJsonFeatureCollectionAndMeta.meta,
geohashOptions,
this._kibanaMap.getZoomLevel(),
this._kibanaMap,
this._opensearchDashboardsMap.getZoomLevel(),
this._opensearchDashboardsMap,
(await lazyLoadMapsLegacyModules()).L
);
this._kibanaMap.addLayer(this._geohashLayer);
this._opensearchDashboardsMap.addLayer(this._geohashLayer);
}

async _updateParams() {
await super._updateParams();

this._kibanaMap.setDesaturateBaseLayer(this._params.isDesaturated);
this._opensearchDashboardsMap.setDesaturateBaseLayer(this._params.isDesaturated);

//avoid recreating the leaflet layer when there are option-changes that do not effect the representation
//e.g. tooltip-visibility, legend position, basemap-desaturation, ...
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tile_map/public/tilemap_fn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { convertToGeoJson } from '../../maps_legacy/public';
describe('interpreter/functions#tilemap', () => {
const fn = functionWrapper(createTileMapFn());
const context = {
type: 'kibana_datatable',
type: 'opensearch_dashboards_datatable',
rows: [{ 'col-0-1': 0 }],
columns: [{ id: 'col-0-1', name: 'Count' }],
};
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tile_map/public/tooltip_formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';

export function tooltipFormatter(metricTitle, metricFormat, feature) {
if (!feature) {
Expand Down
Loading