From 02f57d69a1236b3afa7d7260b182e0d9b103b1ad Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 19 Sep 2017 13:11:29 -0400 Subject: [PATCH 01/13] enable turning on/off of warnings --- .../region_map/public/region_map_controller.js | 3 ++- src/core_plugins/region_map/public/region_map_vis.js | 3 ++- .../region_map/public/region_map_vis_params.html | 8 ++++++++ .../region_map/public/region_map_vis_params.js | 4 +++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/core_plugins/region_map/public/region_map_controller.js b/src/core_plugins/region_map/public/region_map_controller.js index 4df872e28ea15..6d9ddadb1f626 100644 --- a/src/core_plugins/region_map/public/region_map_controller.js +++ b/src/core_plugins/region_map/public/region_map_controller.js @@ -136,7 +136,8 @@ module.controller('KbnRegionMapController', function ($scope, $element, Private, $scope.vis.API.events.filter({ point: { aggConfigResult: aggConfigResult } }); }); choroplethLayer.on('styleChanged', function (event) { - if (event.mismatches.length > 0 && config.get('visualization:regionmap:showWarnings')) { + const shouldShowWarning = $scope.vis.params.isDisplayWarning && config.get('visualization:regionmap:showWarnings'); + if (event.mismatches.length > 0 && shouldShowWarning) { notify.warning( `Could not show ${event.mismatches.length} ${event.mismatches.length > 1 ? 'results' : 'result'} on the map.` + ` To avoid this, ensure that each term can be joined to a corresponding shape on that shape's join field.` diff --git a/src/core_plugins/region_map/public/region_map_vis.js b/src/core_plugins/region_map/public/region_map_vis.js index cc6a44d23f5a1..24bd8485810ec 100644 --- a/src/core_plugins/region_map/public/region_map_vis.js +++ b/src/core_plugins/region_map/public/region_map_vis.js @@ -32,7 +32,8 @@ VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmaps addTooltip: true, colorSchema: 'Yellow to Red', selectedLayer: selectedLayer, - selectedJoinField: selectedJoinField + selectedJoinField: selectedJoinField, + isDisplayWarning: true }, template: regionTemplate, }, diff --git a/src/core_plugins/region_map/public/region_map_vis_params.html b/src/core_plugins/region_map/public/region_map_vis_params.html index 7e5c1dff0231b..8e5270569188c 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.html +++ b/src/core_plugins/region_map/public/region_map_vis_params.html @@ -38,6 +38,14 @@
+
+ +
+ +
+
Style settings
diff --git a/src/core_plugins/region_map/public/region_map_vis_params.js b/src/core_plugins/region_map/public/region_map_vis_params.js index 9729f359509b0..b2a2bab81dba6 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.js +++ b/src/core_plugins/region_map/public/region_map_vis_params.js @@ -43,7 +43,9 @@ uiModules.get('kibana/region_map') }) .catch(function (error) { - notify.warning(error.message); + if ($scope.vis.params.isDisplayWarning) { + notify.warning(error.message); + } }); function onLayerChange() { From adf6c72290a80afa0c028c715b21046f64d59149 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 19 Sep 2017 13:20:47 -0400 Subject: [PATCH 02/13] add tooltip --- src/core_plugins/region_map/public/region_map_vis_params.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core_plugins/region_map/public/region_map_vis_params.html b/src/core_plugins/region_map/public/region_map_vis_params.html index 8e5270569188c..a0dd146e95d27 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.html +++ b/src/core_plugins/region_map/public/region_map_vis_params.html @@ -41,7 +41,9 @@
+
From 9a24aadb9922589baf52809b4f20e5b7e1cc99ef Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 19 Sep 2017 16:35:22 -0400 Subject: [PATCH 03/13] add server setting so users can opt out of connecting to the EMS service --- .../public/region_map_vis_params.js | 84 +++++++++++-------- src/server/config/schema.js | 1 + 2 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/core_plugins/region_map/public/region_map_vis_params.js b/src/core_plugins/region_map/public/region_map_vis_params.js index b2a2bab81dba6..1caeb114ecc2a 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.js +++ b/src/core_plugins/region_map/public/region_map_vis_params.js @@ -1,12 +1,11 @@ -import { uiModules } from 'ui/modules'; +import {uiModules} from 'ui/modules'; import regionMapVisParamsTemplate from './region_map_vis_params.html'; -import { mapToLayerWithId } from './util'; +import {mapToLayerWithId} from './util'; uiModules.get('kibana/region_map') - .directive('regionMapVisParams', function (serviceSettings, Notifier) { + .directive('regionMapVisParams', function (serviceSettings, regionmapsConfig, Notifier) { - - const notify = new Notifier({ location: 'Region map' }); + const notify = new Notifier({location: 'Region map'}); return { restrict: 'E', @@ -14,39 +13,54 @@ uiModules.get('kibana/region_map') link: function ($scope) { $scope.collections = $scope.vis.type.editorConfig.collections; - $scope.onLayerChange = onLayerChange; - serviceSettings.getFileLayers() - .then(function (layersFromService) { - - layersFromService = layersFromService.map(mapToLayerWithId.bind(null, 'elastic_maps_service')); - const newVectorLayers = $scope.collections.vectorLayers.slice(); - for (let i = 0; i < layersFromService.length; i += 1) { - const layerFromService = layersFromService[i]; - const alreadyAdded = newVectorLayers.some((layer) => layerFromService.layerId === layer.layerId); - if (!alreadyAdded) { - newVectorLayers.push(layerFromService); + + if (regionmapsConfig.includeElasticMapsService) { + + serviceSettings.getFileLayers() + .then(function (layersFromService) { + + layersFromService = layersFromService.map(mapToLayerWithId.bind(null, 'elastic_maps_service')); + const newVectorLayers = $scope.collections.vectorLayers.slice(); + for (let i = 0; i < layersFromService.length; i += 1) { + const layerFromService = layersFromService[i]; + const alreadyAdded = newVectorLayers.some((layer) => layerFromService.layerId === layer.layerId); + if (!alreadyAdded) { + newVectorLayers.push(layerFromService); + } + } + + $scope.collections.vectorLayers = newVectorLayers; + if ($scope.collections.vectorLayers[0] && !$scope.vis.params.selectedLayer) { + $scope.vis.params.selectedLayer = $scope.collections.vectorLayers[0]; + onLayerChange(); } - } - - $scope.collections.vectorLayers = newVectorLayers; - if ($scope.collections.vectorLayers[0] && !$scope.vis.params.selectedLayer) { - $scope.vis.params.selectedLayer = $scope.collections.vectorLayers[0]; - onLayerChange(); - } - - //the dirty flag is set to true because the change in vector layers config causes an update of the scope.params - //temp work-around. addressing this issue with the visualize refactor for 6.0 - setTimeout(function () { - $scope.dirty = false; - }, 0); - - }) - .catch(function (error) { - if ($scope.vis.params.isDisplayWarning) { + + //the dirty flag is set to true because the change in vector layers config causes an update of the scope.params + //temp work-around. addressing this issue with the visualize refactor for 6.0 + setTimeout(function () { + $scope.dirty = false; + }, 0); + $scope.collections.vectorLayers = newVectorLayers; + + if ($scope.collections.vectorLayers[0] && !$scope.vis.params.selectedLayer) { + $scope.vis.params.selectedLayer = $scope.collections.vectorLayers[0]; + onLayerChange(); + } + + + //the dirty flag is set to true because the change in vector layers config causes an update of the scope.params + //temp work-around. addressing this issue with the visualize refactor for 6.0 + setTimeout(function () { + $scope.dirty = false; + }, 0); + + + }) + .catch(function (error) { notify.warning(error.message); - } - }); + }); + } function onLayerChange() { $scope.vis.params.selectedJoinField = $scope.vis.params.selectedLayer.fields[0]; diff --git a/src/server/config/schema.js b/src/server/config/schema.js index e3438e23b611b..c50f42eb623d3 100644 --- a/src/server/config/schema.js +++ b/src/server/config/schema.js @@ -188,6 +188,7 @@ export default () => Joi.object({ }).default() }).default(), regionmap: Joi.object({ + includeElasticMapsService: Joi.boolean().default(true), layers: Joi.array().items(Joi.object({ url: Joi.string(), type: Joi.string(), From 50c80575cbb2ac4ce85eb1117f5efeddbe6c62e1 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 19 Sep 2017 18:57:26 -0400 Subject: [PATCH 04/13] replace WMS options with custom directive, so we can reuse it in region maps --- .../tile_map/public/editors/tile_map.html | 74 +----------------- .../tile_map/public/editors/wms_options.html | 76 +++++++++++++++++++ .../tile_map/public/editors/wms_options.js | 11 +++ .../tile_map/public/maps_visualization.js | 2 +- 4 files changed, 89 insertions(+), 74 deletions(-) create mode 100644 src/core_plugins/tile_map/public/editors/wms_options.html create mode 100644 src/core_plugins/tile_map/public/editors/wms_options.js diff --git a/src/core_plugins/tile_map/public/editors/tile_map.html b/src/core_plugins/tile_map/public/editors/tile_map.html index 903dfd24ad410..378fc891401cd 100644 --- a/src/core_plugins/tile_map/public/editors/tile_map.html +++ b/src/core_plugins/tile_map/public/editors/tile_map.html @@ -53,77 +53,5 @@
-
- -
- -
-
-

WMS is an OGC standard for map image services. For more information, go here.

- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -

* if this parameter is incorrect, maps will fail to load.

- - -
+
diff --git a/src/core_plugins/tile_map/public/editors/wms_options.html b/src/core_plugins/tile_map/public/editors/wms_options.html new file mode 100644 index 0000000000000..82db68026df94 --- /dev/null +++ b/src/core_plugins/tile_map/public/editors/wms_options.html @@ -0,0 +1,76 @@ +
+ +
+ +
+ +
+
+

WMS is an OGC standard for map image services. For more information, go here.

+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +

* if this parameter is incorrect, maps will fail to load.

+ + +
+
diff --git a/src/core_plugins/tile_map/public/editors/wms_options.js b/src/core_plugins/tile_map/public/editors/wms_options.js new file mode 100644 index 0000000000000..b082a16ca0ab1 --- /dev/null +++ b/src/core_plugins/tile_map/public/editors/wms_options.js @@ -0,0 +1,11 @@ +import { uiModules } from 'ui/modules'; +import wmsOptionsTemplate from './wms_options.html'; +const module = uiModules.get('kibana'); + +module.directive('wmsOptions', function () { + return { + restrict: 'E', + template: wmsOptionsTemplate, + replace: true + }; +}); diff --git a/src/core_plugins/tile_map/public/maps_visualization.js b/src/core_plugins/tile_map/public/maps_visualization.js index 232c147af3827..12d0704dd36f7 100644 --- a/src/core_plugins/tile_map/public/maps_visualization.js +++ b/src/core_plugins/tile_map/public/maps_visualization.js @@ -1,12 +1,12 @@ import 'ui/vislib'; import 'plugins/kbn_vislib_vis_types/controls/vislib_basic_options'; +import './editors/wms_options'; import $ from 'jquery'; import _ from 'lodash'; import { KibanaMap } from './kibana_map'; import { GeohashLayer } from './geohash_layer'; import { SearchSourceProvider } from 'ui/courier/data_source/search_source'; import { VisAggConfigProvider } from 'ui/vis/agg_config'; -// import './lib/service_settings'; import 'ui/vis/map/service_settings'; import './styles/_tilemap.less'; From 0177d3092220f4025d64f4f8fff3c15114673e0a Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 19 Sep 2017 19:09:13 -0400 Subject: [PATCH 05/13] add wms settings form to Region Map --- .../region_map/public/region_map_vis_params.html | 7 +++++-- .../region_map/public/region_map_vis_params.js | 2 ++ src/core_plugins/tile_map/public/editors/wms_options.html | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core_plugins/region_map/public/region_map_vis_params.html b/src/core_plugins/region_map/public/region_map_vis_params.html index a0dd146e95d27..77636569b05af 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.html +++ b/src/core_plugins/region_map/public/region_map_vis_params.html @@ -66,9 +66,12 @@ +
-
Basic settings
+
+ Base Layer Settings +
- +
diff --git a/src/core_plugins/region_map/public/region_map_vis_params.js b/src/core_plugins/region_map/public/region_map_vis_params.js index 1caeb114ecc2a..b9a0c8872a225 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.js +++ b/src/core_plugins/region_map/public/region_map_vis_params.js @@ -1,6 +1,8 @@ import {uiModules} from 'ui/modules'; import regionMapVisParamsTemplate from './region_map_vis_params.html'; import {mapToLayerWithId} from './util'; +import '../../tile_map/public/editors/wms_options'; +import _ from 'lodash'; uiModules.get('kibana/region_map') .directive('regionMapVisParams', function (serviceSettings, regionmapsConfig, Notifier) { diff --git a/src/core_plugins/tile_map/public/editors/wms_options.html b/src/core_plugins/tile_map/public/editors/wms_options.html index 82db68026df94..c23ac730c4ea0 100644 --- a/src/core_plugins/tile_map/public/editors/wms_options.html +++ b/src/core_plugins/tile_map/public/editors/wms_options.html @@ -1,5 +1,5 @@
- +
+
+ + +
+ +
+
-
- -
- -
-
Style settings
From 6e024c2bdf8176263fc1d05f23f2569a102ec41e Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 15 Nov 2017 01:14:40 -0500 Subject: [PATCH 10/13] improve wording --- src/core_plugins/region_map/public/region_map_controller.js | 4 ++-- src/core_plugins/region_map/public/region_map_vis_params.html | 4 ++-- src/core_plugins/tile_map/public/editors/wms_options.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core_plugins/region_map/public/region_map_controller.js b/src/core_plugins/region_map/public/region_map_controller.js index 71d4ffc750246..5cdef58ab0e9d 100644 --- a/src/core_plugins/region_map/public/region_map_controller.js +++ b/src/core_plugins/region_map/public/region_map_controller.js @@ -161,8 +161,8 @@ module.controller('KbnRegionMapController', function ($scope, $element, Private, if (event.mismatches.length > 0 && shouldShowWarning) { notify.warning( `Could not show ${event.mismatches.length} ${event.mismatches.length > 1 ? 'results' : 'result'} on the map.` - + ` To avoid this, ensure that each term can be joined to a corresponding shape on that shape's join field.` - + ` Could not join following terms: ${event.mismatches.join(',')}` + + ` To avoid this, ensure that each term can be matched to a corresponding shape on that shape's join field.` + + ` Could not match following terms: ${event.mismatches.join(',')}` ); } }); diff --git a/src/core_plugins/region_map/public/region_map_vis_params.html b/src/core_plugins/region_map/public/region_map_vis_params.html index 1dd5a4036e85c..ed0382d433c95 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.html +++ b/src/core_plugins/region_map/public/region_map_vis_params.html @@ -37,7 +37,7 @@
@@ -51,7 +51,7 @@
Style settings
-
+t
- +
diff --git a/src/core_plugins/tile_map/public/editors/tile_map.html b/src/core_plugins/tile_map/public/editors/tile_map.html index 378fc891401cd..61d2e19cf80a3 100644 --- a/src/core_plugins/tile_map/public/editors/tile_map.html +++ b/src/core_plugins/tile_map/public/editors/tile_map.html @@ -53,5 +53,5 @@ - + diff --git a/src/core_plugins/tile_map/public/editors/wms_options.html b/src/core_plugins/tile_map/public/editors/wms_options.html index c23ac730c4ea0..b8f7469c075d7 100644 --- a/src/core_plugins/tile_map/public/editors/wms_options.html +++ b/src/core_plugins/tile_map/public/editors/wms_options.html @@ -4,7 +4,7 @@ -
+

WMS is an OGC standard for map image services. For more information, go here.

+ ng-model="options.url">
@@ -28,8 +28,8 @@ WMS layers*
@@ -39,7 +39,7 @@ + ng-model="options.options.version">
@@ -48,7 +48,7 @@ + ng-model="options.options.format">
@@ -57,7 +57,7 @@ + ng-model="options.options.attribution">
@@ -66,7 +66,7 @@ + ng-model="options.options.styles">

* if this parameter is incorrect, maps will fail to load.

diff --git a/src/core_plugins/tile_map/public/editors/wms_options.js b/src/core_plugins/tile_map/public/editors/wms_options.js index 22084308d5e1c..6070ca0d6aa15 100644 --- a/src/core_plugins/tile_map/public/editors/wms_options.js +++ b/src/core_plugins/tile_map/public/editors/wms_options.js @@ -7,5 +7,8 @@ module.directive('wmsOptions', function () { restrict: 'E', template: wmsOptionsTemplate, replace: true, + scope: { + 'options': '=' + } }; });