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

[6.4] Add EMS hot link (#21154) #21351

Merged
merged 1 commit into from
Jul 27, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ vis-editor-vis-options > * {
.flex-parent();
}

.vis-editor-config .ems-hotlink {
font-size: 12px;
}

/**
* 1. TODO: Override bootstrap styles. Remove !important once we're rid of bootstrap.
*/
Expand Down Expand Up @@ -485,3 +489,5 @@ vis-editor-vis-options > * {
.agg-select-help {
float: right;
}


3 changes: 2 additions & 1 deletion src/core_plugins/region_map/public/region_map_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmaps
const VisFactory = Private(VisFactoryProvider);
const RegionMapsVisualization = Private(RegionMapsVisualizationProvider);

const vectorLayers = regionmapsConfig.layers.map(mapToLayerWithId.bind(null, 'self_hosted'));
const vectorLayers = regionmapsConfig.layers.map(mapToLayerWithId.bind(null, 'self_hosted', false));
const selectedLayer = vectorLayers[0];
const selectedJoinField = selectedLayer ? vectorLayers[0].fields[0] : null;

Expand All @@ -50,6 +50,7 @@ VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmaps
addTooltip: true,
colorSchema: 'Yellow to Red',
selectedLayer: selectedLayer,
emsHotLink: '',
selectedJoinField: selectedJoinField,
isDisplayWarning: true,
wms: config.get('visualization:tileMap:WMSdefaults'),
Expand Down
12 changes: 12 additions & 0 deletions src/core_plugins/region_map/public/region_map_vis_params.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
</div>
</div>

<div class="kuiSideBarFormRow" ng-hide="!editorState.params.emsHotLink">
<a
class="ems-hotlink"
target="_blank"
rel="noopener noreferrer"
ng-href="{{editorState.params.emsHotLink}}"
target="_blank"
title="Preview {{editorState.params.selectedLayer.name}} on the Elastic Maps Service"
>Preview on EMS
</a>
</div>

<div class="kuiSideBarFormRow">
<label class="kuiSideBarFormRow__label" for="joinField">
Join field
Expand Down
15 changes: 14 additions & 1 deletion src/core_plugins/region_map/public/region_map_vis_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ uiModules.get('kibana/region_map')
serviceSettings.getFileLayers()
.then(function (layersFromService) {

layersFromService = layersFromService.map(mapToLayerWithId.bind(null, 'elastic_maps_service'));
layersFromService = layersFromService.map(mapToLayerWithId.bind(null, 'elastic_maps_service', true));
const newVectorLayers = $scope.collections.vectorLayers.slice();
for (let i = 0; i < layersFromService.length; i += 1) {
const layerFromService = layersFromService[i];
Expand Down Expand Up @@ -87,9 +87,22 @@ uiModules.get('kibana/region_map')
}

function onLayerChange() {

if (!$scope.editorState.params.selectedLayer) {
return;
}

$scope.editorState.params.selectedJoinField = $scope.editorState.params.selectedLayer.fields[0];

if ($scope.editorState.params.selectedLayer.isEMS) {
$scope.editorState.params.emsHotLink = serviceSettings.getEMSHotLink($scope.editorState.params.selectedLayer);
} else {
$scope.editorState.params.emsHotLink = null;
}
}

onLayerChange();

}
};
});
3 changes: 2 additions & 1 deletion src/core_plugins/region_map/public/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

import _ from 'lodash';

export function mapToLayerWithId(prefix, layer) {
export function mapToLayerWithId(prefix, isEMS, layer) {
const clonedLayer = _.cloneDeep(layer);
clonedLayer.layerId = prefix + '.' + layer.name;
clonedLayer.isEMS = isEMS;
return clonedLayer;
}
1 change: 1 addition & 0 deletions src/server/config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export default async () => Joi.object({
}).default(),
map: Joi.object({
manifestServiceUrl: Joi.string().default(' https://catalogue.maps.elastic.co/v2/manifest'),
emsLandingPageUrl: Joi.string().default('https://maps.elastic.co/v2'),
includeElasticMapsService: Joi.boolean().default(true)
}).default(),
tilemap: Joi.object({
Expand Down
5 changes: 5 additions & 0 deletions src/ui/public/vis/map/service_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ uiModules.get('kibana')
}
}
}

getEMSHotLink(fileLayer) {
const id = `file/${fileLayer.name}`;
return `${mapConfig.emsLandingPageUrl}#${id}`;
}
}

return new ServiceSettings();
Expand Down