Skip to content

Commit

Permalink
merge tms and vector loading
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed May 3, 2017
1 parent b4b7a4f commit 6b41e66
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 594 deletions.
30 changes: 20 additions & 10 deletions src/core_plugins/choropleth/public/choropleth_controller.js
Expand Up @@ -29,6 +29,8 @@ module.controller('KbnChoroplethController', function ($scope, $element, Private
});
let choroplethLayer = null;

const configuredLayers = $scope.vis.type.params.vectorLayers ? $scope.vis.type.params.vectorLayers.slice() : [];

const kibanaMapReady = makeKibanaMap();
$scope.$watch('esResponse', async function (response) {
kibanaMapReady.then(() => {
Expand All @@ -48,13 +50,15 @@ module.controller('KbnChoroplethController', function ($scope, $element, Private
});
}

if (!$scope.vis.params.selectedJoinField) {
if (!$scope.vis.params.selectedJoinField && $scope.vis.params.selectedLayer) {
$scope.vis.params.selectedJoinField = $scope.vis.params.selectedLayer.fields[0];
}
updateChoroplethLayer($scope.vis.params.selectedLayer.url);
choroplethLayer.setMetrics(results, metricsAgg);
setTooltipFormatter();

if ($scope.vis.params.selectedLayer) {
updateChoroplethLayer($scope.vis.params.selectedLayer.url);
choroplethLayer.setMetrics(results, metricsAgg);
setTooltipFormatter();
}
kibanaMap.useUiStateFromVisualization($scope.vis);
kibanaMap.resize();
$element.trigger('renderComplete');
Expand All @@ -63,13 +67,14 @@ module.controller('KbnChoroplethController', function ($scope, $element, Private

$scope.$watch('vis.params', (visParams) => {
kibanaMapReady.then(() => {
if (!visParams.selectedJoinField) {
if (!visParams.selectedJoinField && $scope.vis.params.selectedLayer) {
visParams.selectedJoinField = visParams.selectedLayer.fields[0];
}

updateChoroplethLayer(visParams.selectedLayer.url);
choroplethLayer.setJoinField(visParams.selectedJoinField.name);
choroplethLayer.setColorRamp(truncatedColorMaps[visParams.colorSchema]);
if ($scope.vis.params.selectedLayer) {
updateChoroplethLayer(visParams.selectedLayer.url);
choroplethLayer.setJoinField(visParams.selectedJoinField.name);
choroplethLayer.setColorRamp(truncatedColorMaps[visParams.colorSchema]);
}
setTooltipFormatter();

kibanaMap.setShowTooltip(visParams.addTooltip);
Expand All @@ -83,7 +88,9 @@ module.controller('KbnChoroplethController', function ($scope, $element, Private
getAvailableVectorLayers()
.then(function (layersFromService) {
//todo: disable play-button until these settings are loaded!
$scope.vis.type.params.vectorLayers = $scope.vis.type.params.vectorLayers.concat(layersFromService);
//todo: ensure to make a preselct in the combox!!!
console.log(layersFromService);
$scope.vis.type.params.vectorLayers = configuredLayers.concat(layersFromService);
$scope.$apply();
});

Expand All @@ -104,6 +111,9 @@ module.controller('KbnChoroplethController', function ($scope, $element, Private
}

function setTooltipFormatter() {
if (!choroplethLayer) {
return;
}
const metricsAgg = _.first($scope.vis.aggs.bySchemaName.metric);
if ($scope.vis.aggs.bySchemaName.segment && $scope.vis.aggs.bySchemaName.segment[0]) {
const fieldName = $scope.vis.aggs.bySchemaName.segment[0].makeLabel();
Expand Down
217 changes: 0 additions & 217 deletions src/ui/public/vis_maps/lib/map_settings.js

This file was deleted.

0 comments on commit 6b41e66

Please sign in to comment.