Merge pull request #2931 from spalger/fix/issueDeLukas
Fix issue de lukas
This commit is contained in:
commit
598bfe49ad
|
@ -26,7 +26,7 @@ define(function (require) {
|
|||
var revRoundingRules = roundingRules.slice(0).reverse();
|
||||
|
||||
function find(rules, check, last) {
|
||||
return function (buckets, duration) {
|
||||
function pick(buckets, duration) {
|
||||
var target = duration / buckets;
|
||||
var lastResp;
|
||||
|
||||
|
@ -45,6 +45,11 @@ define(function (require) {
|
|||
}
|
||||
|
||||
return moment.duration(Math.floor(target), 'ms');
|
||||
}
|
||||
|
||||
return function (buckets, duration) {
|
||||
var interval = pick(buckets, duration);
|
||||
if (interval) return moment.duration(interval._data);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -585,6 +585,7 @@ define(function (require) {
|
|||
});
|
||||
|
||||
$scope.searchSource.aggs(function () {
|
||||
$scope.vis.requesting();
|
||||
return $scope.vis.aggs.toDsl();
|
||||
});
|
||||
|
||||
|
|
|
@ -65,8 +65,15 @@ define(function (require) {
|
|||
});
|
||||
|
||||
var savedVis = $route.current.locals.savedVis;
|
||||
|
||||
var vis = savedVis.vis;
|
||||
var editableVis = vis.clone();
|
||||
vis.requesting = function () {
|
||||
var requesting = editableVis.requesting;
|
||||
requesting.call(vis);
|
||||
requesting.call(editableVis);
|
||||
};
|
||||
|
||||
var searchSource = savedVis.searchSource;
|
||||
|
||||
// config panel templates
|
||||
|
@ -199,7 +206,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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ define(function (require) {
|
|||
})
|
||||
.then(function (vis) {
|
||||
self.searchSource.aggs(function () {
|
||||
self.vis.requesting();
|
||||
return self.vis.aggs.toDsl();
|
||||
});
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ define(function (require) {
|
|||
lte: bounds.max.valueOf()
|
||||
};
|
||||
}
|
||||
|
||||
return filter;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue