Skip to content

Commit

Permalink
[AggConfigParams] Some cleanup of the agg config params, and other st…
Browse files Browse the repository at this point in the history
…raggling code
  • Loading branch information
panda01 committed Apr 25, 2016
1 parent 3366e81 commit bd4b5c6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 36 deletions.
23 changes: 5 additions & 18 deletions src/plugins/kbn_vislib_vis_types/public/tile_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,15 @@ export default function TileMapVisType(Private, getAppState, courier, config) {
},
mapMoveEnd: function (event, uiState) {
uiState.set('mapCenter', event.center);

const agg = _.get(event, 'chart.geohashGridAgg');
if (!agg) return;
agg.params.mapCenter = event.center;

const editableVis = agg.vis.getEditableVis();
if (!editableVis) return;


const editableAgg = editableVis.aggs.byId[agg.id];
if (editableAgg) {
editableAgg.params.mapCenter = event.center;
}
uiState.set('mapZoom', event.zoom);
},
mapZoomEnd: function (event, uiState) {
const agg = _.get(event, 'chart.geohashGridAgg');
uiState.set('mapZoom', event.zoom);

if (!agg) return;
agg.params.mapZoom = event.zoom;

courier.fetch();
const agg = _.get(event, 'chart.geohashGridAgg');
if (agg && agg.params.autoPrecision) {
courier.fetch();
}
}
},
responseConverter: geoJsonConverter,
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/kibana/public/dashboard/components/panel/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ uiModules
// create child ui state from the savedObj
const uiState = panelConfig.uiState || {};
$scope.uiState = $scope.parentUiState.createChild(getPanelId(panelConfig.panel), uiState, true);
if (panelConfig.uiState) {
panelConfig.uiState = $scope.uiState;
}
if (panelConfig.setUiState) {
panelConfig.setUiState($scope.uiState);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_response/geo_json/geo_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default function TileMapConverterFn(Private, timefilter, $compile, $rootS
properties: {
min: _.min(values),
max: _.max(values),
zoom: _.get(geoAgg, 'params.mapZoom'),
center: _.get(geoAgg, 'params.mapCenter')
zoom: geoAgg.vis.uiStateVal('mapZoom'),
center: geoAgg.vis.uiStateVal('mapCenter')
}
}
};
Expand Down
7 changes: 2 additions & 5 deletions src/ui/public/agg_types/buckets/geo_hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@ export default function GeoHashAggDefinition(Private, config) {
controller: function ($scope) {
},
write: function (aggConfig, output) {
let currZoom = null;
if (aggConfig.params.mapZoom || aggConfig.vis.hasUiState()) { // First iteration
currZoom = aggConfig.vis.hasUiState() ? aggConfig.vis.uiStateVal('mapZoom') : aggConfig.params.mapZoom;
}
currZoom = currZoom || aggConfig.vis.params.mapZoom;
const vis = aggConfig.vis;
const currZoom = vis.hasUiState() ? vis.uiStateVal('mapZoom') : vis.params.mapZoom;
const autoPrecisionVal = zoomPrecision[currZoom];
output.params.precision = aggConfig.params.autoPrecision ? autoPrecisionVal : getPrecision(aggConfig.params.precision);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/vis/vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function VisFactory(Notifier, Private) {
};

Vis.prototype.clone = function () {
return new Vis(this.indexPattern, this.getState());
return new Vis(this.indexPattern, this.getState(), this.getUiState());
};

Vis.prototype.requesting = function () {
Expand Down Expand Up @@ -135,7 +135,7 @@ export default function VisFactory(Notifier, Private) {
Vis.prototype.getUiState = function () {
return this.__uiState;
};
Vis.prototype.uiStateVal = function(key, val) {
Vis.prototype.uiStateVal = function (key, val) {
if (this.hasUiState()) {
if (_.isUndefined(val)) {
return this.__uiState.get(key);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/vislib/lib/handler/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function HandlerBaseClass(Private) {
return new Handler(vis, opts);
}

this.data = opts.data || new Data(vis.data, vis._attr, vis.getUiState());
this.data = opts.data || new Data(vis.data, vis._attr, vis.uiState);
this.vis = vis;
this.el = vis.el;
this.ChartClass = vis.ChartClass;
Expand Down
7 changes: 2 additions & 5 deletions src/ui/public/vislib/visualizations/tile_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,13 @@ export default function TileMapFactory(Private) {
*/
TileMap.prototype._appendMap = function (selection) {
const container = $(selection).addClass('tilemap');
// Lol couldn't think of another way to access this object...
const uiStateParams = {
const uiStateParams = this.handler.vis ? {
mapCenter: this.handler.vis.uiState.get('mapCenter'),
mapZoom: this.handler.vis.uiState.get('mapZoom')
};
} : {};

const params = _.assign({}, this._chartData.geohashGridAgg.vis.params, uiStateParams);

// this.handler.vis.uiState

const map = new TileMapMap(container, this._chartData, {
center: params.mapCenter,
zoom: params.mapZoom,
Expand Down

0 comments on commit bd4b5c6

Please sign in to comment.