[vis] expose a #requesting() method for indicating transitions in vis state

This commit is contained in:
Spencer Alger 2015-02-06 15:44:03 -07:00
parent bc53427877
commit 67f09b5da5
6 changed files with 25 additions and 11 deletions

View file

@ -174,6 +174,19 @@ define(function (require) {
return this.type.createFilter(this, key);
};
/**
* Hook into param onRequest handling, and tell the aggConfig that it
* is being sent to elasticsearc.
*
* @return {[type]} [description]
*/
AggConfig.prototype.requesting = function () {
var self = this;
self.type.params.forEach(function (param) {
if (param.onRequest) param.onRequest(self);
});
};
/**
* Convert this aggConfig to it's dsl syntax.
*
@ -185,18 +198,10 @@ define(function (require) {
*/
AggConfig.prototype.toDsl = function () {
if (this.type.hasNoDsl) return;
var self = this;
self.type.params.forEach(function (param) {
if (param.onRequest) {
param.onRequest(self);
}
});
var output = self.write();
var output = this.write();
var configDsl = {};
configDsl[self.type.name] = output.params;
configDsl[this.type.name] = output.params;
// if the config requires subAggs, write them to the dsl as well
if (output.subAggs) {

View file

@ -90,6 +90,10 @@ define(function (require) {
return new Vis(this.indexPattern, this.getState());
};
Vis.prototype.requesting = function () {
_.invoke(this.aggs.getRequestAggs(), 'requesting');
};
Vis.prototype.isHierarchical = function () {
if (_.isFunction(this.type.hierarchicalData)) {
return !!this.type.hierarchicalData(this);

View file

@ -589,6 +589,7 @@ define(function (require) {
});
$scope.searchSource.aggs(function () {
$scope.vis.requesting();
return $scope.vis.aggs.toDsl();
});

View file

@ -199,7 +199,9 @@ define(function (require) {
$state.save();
searchSource.set('filter', $state.filters);
if (!$state.linked) searchSource.set('query', $state.query);
if ($scope.vis.type.requiresSearch) courier.fetch();
if ($scope.vis.type.requiresSearch) {
courier.fetch();
}
};

View file

@ -61,6 +61,7 @@ define(function (require) {
})
.then(function (vis) {
self.searchSource.aggs(function () {
self.vis.requesting();
return self.vis.aggs.toDsl();
});

View file

@ -76,6 +76,7 @@ define(function (require) {
lte: bounds.max.valueOf()
};
}
return filter;
};