fixing disabling aggregations (#13686)
This commit is contained in:
parent
1625f64013
commit
7c7494599d
|
@ -16,11 +16,11 @@ module.directive('vislibCategoryAxis', function () {
|
|||
|
||||
let lastAxisTitle = '';
|
||||
$scope.$watch(() => {
|
||||
return $scope.vis.aggs.map(agg => {
|
||||
return $scope.vis.getAggConfig().map(agg => {
|
||||
return agg.params.field ? agg.makeLabel() : '';
|
||||
}).join();
|
||||
}, () => {
|
||||
const agg = $scope.vis.aggs.find(agg => agg.schema.name === 'segment');
|
||||
const agg = $scope.vis.getAggConfig().find(agg => agg.schema.name === 'segment');
|
||||
const label = agg ? agg.makeLabel() : '';
|
||||
if (lastAxisTitle !== label) {
|
||||
lastAxisTitle = label;
|
||||
|
|
|
@ -127,7 +127,7 @@ module.directive('vislibValueAxes', function () {
|
|||
const isMatchingSeries = (isFirst && !series.valueAxis) || (series.valueAxis === axis.id);
|
||||
if (isMatchingSeries) {
|
||||
let seriesNumber = 0;
|
||||
$scope.vis.aggs.forEach(agg => {
|
||||
$scope.vis.getAggConfig().forEach(agg => {
|
||||
if (agg.schema.name === 'metric') {
|
||||
if (seriesNumber === i) matchingSeries.push(agg);
|
||||
seriesNumber++;
|
||||
|
@ -146,7 +146,7 @@ module.directive('vislibValueAxes', function () {
|
|||
};
|
||||
|
||||
$scope.$watch(() => {
|
||||
return $scope.vis.aggs.map(agg => {
|
||||
return $scope.vis.getAggConfig().map(agg => {
|
||||
try {
|
||||
return agg.makeLabel();
|
||||
} catch (e) {
|
||||
|
|
|
@ -345,7 +345,7 @@ function discoverController(
|
|||
// no timefield, no vis, nothing to update
|
||||
if (!$scope.opts.timefield) return;
|
||||
|
||||
const buckets = $scope.vis.aggs.bySchemaGroup.buckets;
|
||||
const buckets = $scope.vis.getAggConfig().bySchemaGroup.buckets;
|
||||
|
||||
if (buckets && buckets.length === 1) {
|
||||
$scope.bucketInterval = buckets[0].buckets.getInterval();
|
||||
|
@ -683,7 +683,7 @@ function discoverController(
|
|||
|
||||
$scope.searchSource.aggs(function () {
|
||||
$scope.vis.requesting();
|
||||
return $scope.vis.aggs.toDsl();
|
||||
return $scope.vis.getAggConfig().toDsl();
|
||||
});
|
||||
|
||||
// stash this promise so that other calls to setupVisualization will have to wait
|
||||
|
|
|
@ -33,8 +33,8 @@ module.controller('KbnRegionMapController', function ($scope, $element, Private,
|
|||
|
||||
$scope.$watch('esResponse', async function (response) {
|
||||
kibanaMapReady.then(() => {
|
||||
const metricsAgg = _.first($scope.vis.aggs.bySchemaName.metric);
|
||||
const termAggId = _.first(_.pluck($scope.vis.aggs.bySchemaName.segment, 'id'));
|
||||
const metricsAgg = _.first($scope.vis.getAggConfig().bySchemaName.metric);
|
||||
const termAggId = _.first(_.pluck($scope.vis.getAggConfig().bySchemaName.segment, 'id'));
|
||||
|
||||
let results;
|
||||
if (!response || !response.aggregations) {
|
||||
|
@ -112,9 +112,9 @@ module.controller('KbnRegionMapController', function ($scope, $element, Private,
|
|||
}
|
||||
|
||||
function setTooltipFormatter() {
|
||||
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();
|
||||
const metricsAgg = _.first($scope.vis.getAggConfig().bySchemaName.metric);
|
||||
if ($scope.vis.getAggConfig().bySchemaName.segment && $scope.vis.getAggConfig().bySchemaName.segment[0]) {
|
||||
const fieldName = $scope.vis.getAggConfig().bySchemaName.segment[0].makeLabel();
|
||||
choroplethLayer.setTooltipFormatter(tooltipFormatter, metricsAgg, fieldName);
|
||||
} else {
|
||||
choroplethLayer.setTooltipFormatter(tooltipFormatter, metricsAgg, null);
|
||||
|
@ -135,7 +135,7 @@ module.controller('KbnRegionMapController', function ($scope, $element, Private,
|
|||
choroplethLayer.setMetrics(previousMetrics, previousMetricsAgg);
|
||||
}
|
||||
choroplethLayer.on('select', function (event) {
|
||||
const aggs = $scope.vis.aggs.getResponseAggs();
|
||||
const aggs = $scope.vis.getAggConfig().getResponseAggs();
|
||||
const aggConfigResult = new AggConfigResult(aggs[0], false, event, event);
|
||||
$scope.vis.API.events.filter({ point: { aggConfigResult: aggConfigResult } });
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ module.controller('KbnTagCloudController', function ($scope, $element, Private,
|
|||
tagCloud.on('select', (event) => {
|
||||
const appState = getAppState();
|
||||
const clickHandler = filterBarClickHandler(appState);
|
||||
const aggs = $scope.vis.aggs.getResponseAggs();
|
||||
const aggs = $scope.vis.getAggConfig().getResponseAggs();
|
||||
const aggConfigResult = new AggConfigResult(aggs[0], false, event, event);
|
||||
clickHandler({ point: { aggConfigResult: aggConfigResult } });
|
||||
});
|
||||
|
@ -54,13 +54,13 @@ module.controller('KbnTagCloudController', function ($scope, $element, Private,
|
|||
return;
|
||||
}
|
||||
|
||||
const tagsAggId = _.first(_.pluck($scope.vis.aggs.bySchemaName.segment, 'id'));
|
||||
const tagsAggId = _.first(_.pluck($scope.vis.getAggConfig().bySchemaName.segment, 'id'));
|
||||
if (!tagsAggId || !response.aggregations) {
|
||||
tagCloud.setData([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const metricsAgg = _.first($scope.vis.aggs.bySchemaName.metric);
|
||||
const metricsAgg = _.first($scope.vis.getAggConfig().bySchemaName.metric);
|
||||
const buckets = response.aggregations[tagsAggId].buckets;
|
||||
|
||||
const tags = buckets.map((bucket) => {
|
||||
|
|
|
@ -303,7 +303,7 @@ export function MapsVisualizationProvider(serviceSettings, Notifier, getAppState
|
|||
}
|
||||
|
||||
_getGeoHashAgg() {
|
||||
return this.vis.aggs.find((agg) => {
|
||||
return this.vis.getAggConfig().find((agg) => {
|
||||
return _.get(agg, 'type.dslName') === 'geohash_grid';
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ export function TileMapTooltipFormatterProvider($compile, $rootScope, Private) {
|
|||
const vis = acr.aggConfig.vis;
|
||||
|
||||
const metricAgg = acr.aggConfig;
|
||||
let geoFormat = _.get(vis.aggs, 'byTypeName.geohash_grid[0].format');
|
||||
let geoFormat = _.get(vis.getAggConfig(), 'byTypeName.geohash_grid[0].format');
|
||||
if (!geoFormat) geoFormat = fieldFormats.getDefaultInstance('geo_point');
|
||||
|
||||
$tooltipScope.details = [
|
||||
|
|
|
@ -7,8 +7,8 @@ export function createRawData(vis, resp) {
|
|||
const results = { rows: [] };
|
||||
|
||||
// Create a reference to the buckets and metrics
|
||||
const metrics = vis.aggs.bySchemaGroup.metrics;
|
||||
const buckets = vis.aggs.bySchemaGroup.buckets;
|
||||
const metrics = vis.getAggConfig().bySchemaGroup.metrics;
|
||||
const buckets = vis.getAggConfig().bySchemaGroup.buckets;
|
||||
const aggs = [];
|
||||
|
||||
if (buckets) {
|
||||
|
|
|
@ -17,11 +17,11 @@ export function BuildHierarchicalDataProvider(Private, Notifier) {
|
|||
|
||||
return function (vis, resp) {
|
||||
// Create a refrenece to the buckets
|
||||
let buckets = vis.aggs.bySchemaGroup.buckets;
|
||||
let buckets = vis.getAggConfig().bySchemaGroup.buckets;
|
||||
|
||||
// Find the metric so it's easier to reference.
|
||||
// TODO: Change this to support multiple metrics.
|
||||
const metric = vis.aggs.bySchemaGroup.metrics[0];
|
||||
const metric = vis.getAggConfig().bySchemaGroup.metrics[0];
|
||||
|
||||
// Link each agg to the next agg. This will be
|
||||
// to identify the next bucket aggregation
|
||||
|
|
|
@ -5,11 +5,11 @@ export function AggResponseGetColumnsProvider(Private) {
|
|||
const AggConfig = Private(VisAggConfigProvider);
|
||||
|
||||
return function getColumns(vis, minimal) {
|
||||
const aggs = vis.aggs.getResponseAggs();
|
||||
const aggs = vis.getAggConfig().getResponseAggs();
|
||||
|
||||
if (minimal == null) minimal = !vis.isHierarchical();
|
||||
|
||||
if (!vis.aggs.bySchemaGroup.metrics) {
|
||||
if (!vis.getAggConfig().bySchemaGroup.metrics) {
|
||||
aggs.push(new AggConfig(vis, {
|
||||
type: 'count',
|
||||
schema: vis.type.schemas.metrics[0].name
|
||||
|
|
|
@ -115,7 +115,7 @@ export function AggTypesBucketsDateHistogramProvider(timefilter, config, Private
|
|||
|
||||
const scaleMetrics = interval.scaled && interval.scale < 1;
|
||||
if (scaleMetrics) {
|
||||
const all = _.every(agg.vis.aggs.bySchemaGroup.metrics, function (agg) {
|
||||
const all = _.every(agg.vis.getAggConfig().bySchemaGroup.metrics, function (agg) {
|
||||
return agg.type && agg.type.isScalable();
|
||||
});
|
||||
if (all) {
|
||||
|
|
|
@ -9,7 +9,7 @@ const parentPipelineAggController = function ($scope) {
|
|||
$scope.$watch('agg.params.metricAgg', updateOrderAgg);
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
const lastBucket = _.findLast($scope.vis.aggs, agg => agg.schema.group === 'buckets');
|
||||
const lastBucket = _.findLast($scope.vis.getAggConfig(), agg => agg.schema.group === 'buckets');
|
||||
if ($scope.aggForm && $scope.aggForm.agg) {
|
||||
$scope.aggForm.agg.$setValidity('bucket', true);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ const parentPipelineAggController = function ($scope) {
|
|||
};
|
||||
|
||||
function checkBuckets() {
|
||||
const lastBucket = _.findLast($scope.vis.aggs, agg => agg.schema.group === 'buckets');
|
||||
const lastBucket = _.findLast($scope.vis.getAggConfig(), agg => agg.schema.group === 'buckets');
|
||||
const bucketHasType = lastBucket && lastBucket.type;
|
||||
const bucketIsHistogram = bucketHasType && ['date_histogram', 'histogram'].includes(lastBucket.type.name);
|
||||
const canUseAggregation = lastBucket && bucketIsHistogram;
|
||||
|
@ -56,7 +56,7 @@ const parentPipelineAggController = function ($scope) {
|
|||
|
||||
// we aren't creating a custom aggConfig
|
||||
if (metricAgg !== 'custom') {
|
||||
if (!$scope.vis.aggs.find(agg => agg.id === metricAgg)) {
|
||||
if (!$scope.vis.getAggConfig().find(agg => agg.id === metricAgg)) {
|
||||
params.metricAgg = null;
|
||||
}
|
||||
params.customMetric = null;
|
||||
|
|
|
@ -62,7 +62,7 @@ export const ParentPipelineAggHelperProvider = function (Private) {
|
|||
if (agg.params.customMetric) {
|
||||
subAgg = agg.params.customMetric;
|
||||
} else {
|
||||
subAgg = agg.vis.aggs.byId[agg.params.metricAgg];
|
||||
subAgg = agg.vis.getAggConfig().byId[agg.params.metricAgg];
|
||||
}
|
||||
return subAgg.type.getFormat(subAgg);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ export function VisProvider(Private, indexPatterns, timefilter, getAppState) {
|
|||
}
|
||||
|
||||
updateState() {
|
||||
this.setState(this.getCurrentState());
|
||||
this.setState(this.getCurrentState(true));
|
||||
this.emit('update');
|
||||
}
|
||||
|
||||
|
@ -128,6 +128,10 @@ export function VisProvider(Private, indexPatterns, timefilter, getAppState) {
|
|||
return this.getStateInternal(false);
|
||||
}
|
||||
|
||||
getAggConfig() {
|
||||
return new AggConfigs(this, this.aggs.raw.filter(agg => agg.enabled));
|
||||
}
|
||||
|
||||
getState() {
|
||||
return this.getStateInternal(true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue