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

Migrate Coordinate Maps to NP #64668

Merged
merged 34 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8f9984e
Use NP format service
Apr 28, 2020
9848713
Use NP data query service
Apr 28, 2020
b66704f
Mostly file movement, a few updates. Some work towards using NP config
Apr 28, 2020
6a4c970
Import leaflet draw to avoid timing issue that prevents it from being…
Apr 29, 2020
151ddc9
Publish configs for maps_legacy and tile_maps using NP format
Apr 29, 2020
47aec38
Switch new maps over to using NP map config
Apr 29, 2020
a53a452
Consume mapsLegacy config on Maps server
Apr 29, 2020
5561154
Type fixes. Schema updates
Apr 29, 2020
d3bae1c
Add new plugin path to i18n
Apr 29, 2020
1855529
Mock configs for karma test service settings
Apr 29, 2020
bb3404c
Merge remote-tracking branch 'upstream/master' into np-migrate-coordi…
Apr 29, 2020
05b672b
Fix jest tests
Apr 30, 2020
c0154b3
Update test files to snake case
Apr 30, 2020
166b0c5
Use getIsEmsEnabled from kibana services
Apr 30, 2020
577b583
Review feedback
Apr 30, 2020
2368a9c
Review feedback. Set initializerContext as readonly
Apr 30, 2020
e24f4be
Type fix
Apr 30, 2020
d49a57f
Fix issue with heatlayer not getting loaded correctly
Apr 30, 2020
a391bb9
Update jest test
Apr 30, 2020
4c25a26
Change how popup is instantiated and bound to map
Apr 30, 2020
39c2231
Remove webpack shims and relocate to maps_legacy. Remove other leafle…
May 4, 2020
a384887
Clean up extra imports of leaflet resources
May 5, 2020
5a1cef4
Remove staggered loading. Clean up
May 5, 2020
7409be3
Merge remote-tracking branch 'upstream/master' into np-migrate-coordi…
May 5, 2020
b5785ef
Pull global L from local file
May 5, 2020
13bccc2
Forgot one leaflet reference
May 5, 2020
61b1c01
Remove one more unneeded leaflet ref in dashboard
May 5, 2020
3d7a38e
Uno mas
May 5, 2020
83e467d
Import leaflet for vega tests since it can't be initialized the norma…
May 5, 2020
8f861ce
Update browser tests service settings instantiation to include configs
May 5, 2020
9ef70a2
Merge remote-tracking branch 'upstream/master' into np-migrate-coordi…
May 5, 2020
098d419
Get rid of unused module.exports
May 5, 2020
f4af673
Merge branch 'master' into np-migrate-coordinate-maps
elasticmachine May 6, 2020
46ad010
Merge remote-tracking branch 'upstream/master' into np-migrate-coordi…
May 6, 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
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"src/plugins/telemetry",
"src/plugins/telemetry_management_section"
],
"tileMap": "src/legacy/core_plugins/tile_map",
"tileMap": "src/plugins/tile_map",
Copy link
Contributor

Choose a reason for hiding this comment

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

:)

"timelion": ["src/legacy/core_plugins/timelion", "src/plugins/vis_type_timelion"],
"uiActions": "src/plugins/ui_actions",
"visDefaultEditor": "src/plugins/vis_default_editor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import Bluebird from 'bluebird';
import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import $ from 'jquery';

import 'leaflet/dist/leaflet.js';
import 'leaflet-vega';
// Will be replaced with new path when tests are moved
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { createVegaVisualization } from '../../../../../../plugins/vis_type_vega/public/vega_visualization';
Expand Down Expand Up @@ -100,6 +103,39 @@ describe('VegaVisualizations', () => {
setSavedObjects(npStart.core.savedObjects);
setNotifications(npStart.core.notifications);

const mockMapConfig = {
includeElasticMapsService: true,
proxyElasticMapsServiceInMaps: false,
tilemap: {
deprecated: {
config: {
options: {
attribution: '',
},
},
},
options: {
attribution: '',
minZoom: 0,
maxZoom: 10,
},
},
regionmap: {
includeElasticMapsService: true,
layers: [],
},
manifestServiceUrl: '',
emsFileApiUrl: 'https://vector.maps.elastic.co',
emsTileApiUrl: 'https://tiles.maps.elastic.co',
emsLandingPageUrl: 'https://maps.elastic.co/v7.7',
emsFontLibraryUrl: 'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf',
emsTileLayerId: {
bright: 'road_map',
desaturated: 'road_map_desaturated',
dark: 'dark_map',
},
};

beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(() => {
Expand Down Expand Up @@ -127,7 +163,7 @@ describe('VegaVisualizations', () => {
return 'not found';
}
});
const serviceSettings = new ServiceSettings();
const serviceSettings = new ServiceSettings(mockMapConfig, mockMapConfig.tilemap);
vegaVisualizationDependencies = {
serviceSettings,
core: {
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import 'ui/autoload/all';
import './management';
import './dev_tools';
import { showAppRedirectNotification } from '../../../../plugins/kibana_legacy/public';
import 'leaflet';
import { localApplicationService } from './local_application_service';

npSetup.plugins.kibanaLegacy.registerLegacyAppAlias('doc', 'discover', { keepPrefix: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import _ from 'lodash';

import ChoroplethLayer from '../choropleth_layer';
import { ImageComparator } from 'test_utils/image_comparator';
import worldJson from './world.json';
Expand Down Expand Up @@ -103,31 +104,29 @@ describe('RegionMapsVisualizationTests', function() {
let getManifestStub;
beforeEach(
ngMock.inject(() => {
const mapConfig = {
emsFileApiUrl: '',
emsTileApiUrl: '',
emsLandingPageUrl: '',
};
const tilemapsConfig = {
deprecated: {
config: {
options: {
attribution: '123',
},
},
},
};
setInjectedVarFunc(injectedVar => {
switch (injectedVar) {
case 'mapConfig':
return {
emsFileApiUrl: '',
emsTileApiUrl: '',
emsLandingPageUrl: '',
};
case 'tilemapsConfig':
return {
deprecated: {
config: {
options: {
attribution: '123',
},
},
},
};
case 'version':
return '123';
default:
return 'not found';
}
});
const serviceSettings = new ServiceSettings();
const serviceSettings = new ServiceSettings(mapConfig, tilemapsConfig);
const regionmapsConfig = {
includeElasticMapsService: true,
layers: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import $ from 'jquery';
import L from 'leaflet';
import _ from 'lodash';
import d3 from 'd3';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -86,6 +85,7 @@ export default class ChoroplethLayer extends KibanaMapLayer {
this._layerName = name;
this._layerConfig = layerConfig;

// eslint-disable-next-line no-undef
this._leafletLayer = L.geoJson(null, {
onEachFeature: (feature, layer) => {
layer.on('click', () => {
Expand All @@ -96,6 +96,7 @@ export default class ChoroplethLayer extends KibanaMapLayer {
mouseover: () => {
const tooltipContents = this._tooltipFormatter(feature);
if (!location) {
// eslint-disable-next-line no-undef
const leafletGeojson = L.geoJson(feature);
location = leafletGeojson.getBounds().getCenter();
}
Expand Down Expand Up @@ -428,13 +429,15 @@ CORS configuration of the server permits requests from the Kibana application on

const { min, max } = getMinMax(this._metrics);

// eslint-disable-next-line no-undef
const boundsOfAllFeatures = new L.LatLngBounds();
return {
leafletStyleFunction: geojsonFeature => {
const match = geojsonFeature.__kbnJoinedMetric;
if (!match) {
return emptyStyle();
}
// eslint-disable-next-line no-undef
const boundsOfFeature = L.geoJson(geojsonFeature).getBounds();
boundsOfAllFeatures.extend(boundsOfFeature);

Expand Down
50 changes: 0 additions & 50 deletions src/legacy/core_plugins/tile_map/index.ts

This file was deleted.

67 changes: 67 additions & 0 deletions src/plugins/maps_legacy/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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 { schema, TypeOf } from '@kbn/config-schema';
import { configSchema as tilemapSchema } from '../tile_map/config';

// TODO: Pull this portion from region_map
export const regionmapSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
layers: schema.arrayOf(
schema.object({
url: schema.string(),
format: schema.object({
type: schema.string({ defaultValue: 'geojson' }),
}),
meta: schema.object({
feature_collection_path: schema.string({ defaultValue: 'data' }),
}),
attribution: schema.string(),
name: schema.string(),
fields: schema.arrayOf(
schema.object({
name: schema.string(),
description: schema.string(),
})
),
}),
{ defaultValue: [] }
),
});

export const configSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
proxyElasticMapsServiceInMaps: schema.boolean({ defaultValue: false }),
tilemap: tilemapSchema,
regionmap: regionmapSchema,
manifestServiceUrl: schema.string({ defaultValue: '' }),
emsFileApiUrl: schema.string({ defaultValue: 'https://vector.maps.elastic.co' }),
emsTileApiUrl: schema.string({ defaultValue: 'https://tiles.maps.elastic.co' }),
emsLandingPageUrl: schema.string({ defaultValue: 'https://maps.elastic.co/v7.7' }),
emsFontLibraryUrl: schema.string({
defaultValue: 'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf',
}),
emsTileLayerId: schema.object({
bright: schema.string({ defaultValue: 'road_map' }),
desaturated: schema.string({ defaultValue: 'road_map_desaturated' }),
dark: schema.string({ defaultValue: 'dark_map' }),
}),
});

export type ConfigSchema = TypeOf<typeof configSchema>;
4 changes: 3 additions & 1 deletion src/plugins/maps_legacy/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"id": "mapsLegacy",
"version": "8.0.0",
"kibanaVersion": "kibana",
"ui": true
"configPath": ["map"],
"ui": true,
"server": true
}
2 changes: 1 addition & 1 deletion src/plugins/maps_legacy/public/__tests__/map/kibana_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import expect from '@kbn/expect';
import { KibanaMap } from '../../map/kibana_map';
import { KibanaMapLayer } from '../../map/kibana_map_layer';
import L from 'leaflet';

describe('kibana_map tests', function() {
let domNode;
Expand Down Expand Up @@ -218,6 +217,7 @@ describe('kibana_map tests', function() {
function makeMockLayer(attribution) {
const layer = new KibanaMapLayer();
layer._attribution = attribution;
// eslint-disable-next-line no-undef
layer._leafletLayer = L.geoJson(null);
return layer;
}
Expand Down
21 changes: 16 additions & 5 deletions src/plugins/maps_legacy/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
* under the License.
*/

import { CoreSetup } from 'kibana/public';
import { bindSetupCoreAndPlugins, MapsLegacyPlugin } from './plugin';
// @ts-ignore
import * as colorUtil from './map/color_util';
import { CoreSetup, PluginInitializerContext } from 'kibana/public';
// @ts-ignore
import { L } from './leaflet';
// @ts-ignore
import { KibanaMap } from './map/kibana_map';
import { bindSetupCoreAndPlugins, MapsLegacyPlugin } from './plugin';
// @ts-ignore
import * as colorUtil from './map/color_util';
// @ts-ignore
import { KibanaMapLayer } from './map/kibana_map_layer';
// @ts-ignore
Expand All @@ -41,8 +44,15 @@ import {
// @ts-ignore
import { mapTooltipProvider } from './tooltip_provider';

export function plugin() {
return new MapsLegacyPlugin();
export interface MapsLegacyConfigType {
emsTileLayerId: string;
includeElasticMapsService: boolean;
proxyElasticMapsServiceInMaps: boolean;
tilemap: any;
}

export function plugin(initializerContext: PluginInitializerContext) {
return new MapsLegacyPlugin(initializerContext);
}

/** @public */
Expand All @@ -59,6 +69,7 @@ export {
FileLayer,
TmsLayer,
mapTooltipProvider,
L,
};

// Due to a leaflet/leaflet-draw bug, it's not possible to consume leaflet maps w/ draw control
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@
* under the License.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

nice trick


require('../node_modules/leaflet/dist/leaflet.css');
window.L = module.exports = require('../node_modules/leaflet/dist/leaflet');
window.L.Browser.touch = false;
window.L.Browser.pointer = false;
export let L;

require('../node_modules/leaflet.heat/dist/leaflet-heat.js');
if (!window.hasOwnProperty('L')) {
require('leaflet/dist/leaflet.css');
window.L = require('leaflet/dist/leaflet.js');
window.L.Browser.touch = false;
window.L.Browser.pointer = false;

require('../node_modules/leaflet-draw/dist/leaflet.draw.css');
require('../node_modules/leaflet-draw/dist/leaflet.draw.js');

require('../node_modules/leaflet-responsive-popup/leaflet.responsive.popup.css');
require('../node_modules/leaflet-responsive-popup/leaflet.responsive.popup.js');
require('leaflet-vega');
require('leaflet.heat/dist/leaflet-heat.js');
require('leaflet-draw/dist/leaflet.draw.css');
require('leaflet-draw/dist/leaflet.draw.js');
require('leaflet-responsive-popup/leaflet.responsive.popup.css');
require('leaflet-responsive-popup/leaflet.responsive.popup.js');
} else {
L = window.L;
}
Loading