adding indexPattern to agg so its not accessed from vis.indexPattern (#20491) (#20559)

This commit is contained in:
Peter Pisljar 2018-07-09 19:40:34 +02:00 committed by GitHub
parent 316ddaf53f
commit 383437d3df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 17 additions and 16 deletions

View file

@ -186,7 +186,7 @@ export function CoordinateMapsVisualizationProvider(Notifier, Private) {
return;
}
const indexPatternName = agg.vis.indexPattern.id;
const indexPatternName = agg._indexPattern.id;
const field = agg.fieldName();
const filter = { meta: { negate: false, index: indexPatternName } };
filter[filterName] = { ignore_unmapped: true };

View file

@ -58,7 +58,7 @@ describe('editor', function () {
]
});
const $el = $('<vis-editor-agg-params agg="agg" index-pattern="vis.indexPattern" group-name="groupName"></vis-editor-agg-params>');
const $el = $('<vis-editor-agg-params agg="agg" index-pattern="agg._indexPattern" group-name="groupName"></vis-editor-agg-params>');
const $parentScope = $injector.get('$rootScope').$new();
agg = $parentScope.agg = vis.aggs.bySchemaName.segment[0];

View file

@ -28,5 +28,5 @@ export function createFilterDateHistogram(agg, key) {
gte: start.valueOf(),
lt: start.add(interval).valueOf(),
format: 'epoch_millis'
}, agg.vis.indexPattern);
}, agg._indexPattern);
}

View file

@ -31,5 +31,5 @@ export function createFilterDateRange(agg, key) {
if (range.to) filter.lt = +range.to;
if (range.to && range.from) filter.format = 'epoch_millis';
return buildRangeFilter(agg.params.field, filter, agg.vis.indexPattern);
return buildRangeFilter(agg.params.field, filter, agg._indexPattern);
}

View file

@ -26,6 +26,6 @@ export function createFilterFilters(aggConfig, key) {
const filter = dslFilters[key];
if (filter) {
return buildQueryFilter(filter.query, aggConfig.vis.indexPattern.id);
return buildQueryFilter(filter.query, aggConfig._indexPattern.id);
}
}

View file

@ -25,7 +25,7 @@ export function createFilterHistogram(aggConfig, key) {
return buildRangeFilter(
aggConfig.params.field,
{ gte: value, lt: value + aggConfig.params.interval },
aggConfig.vis.indexPattern,
aggConfig._indexPattern,
aggConfig.fieldFormatter()(key)
);
}

View file

@ -32,5 +32,5 @@ export function createFilterIpRange(aggConfig, key) {
};
}
return buildRangeFilter(aggConfig.params.field, { gte: range.from, lte: range.to }, aggConfig.vis.indexPattern);
return buildRangeFilter(aggConfig.params.field, { gte: range.from, lte: range.to }, aggConfig._indexPattern);
}

View file

@ -23,7 +23,7 @@ export function createFilterRange(aggConfig, key) {
return buildRangeFilter(
aggConfig.params.field,
key,
aggConfig.vis.indexPattern,
aggConfig._indexPattern,
aggConfig.fieldFormatter()(key)
);
}

View file

@ -92,7 +92,7 @@ export const dateHistogramBucketAgg = new BucketAggType({
name: 'field',
filterFieldTypes: 'date',
default: function (agg) {
return agg.vis.indexPattern.timeFieldName;
return agg._indexPattern.timeFieldName;
},
onChange: function (agg) {
if (_.get(agg, 'params.interval.val') === 'auto' && !agg.fieldIsTimeField()) {

View file

@ -43,7 +43,7 @@ export const dateRangeBucketAgg = new BucketAggType({
name: 'field',
filterFieldTypes: 'date',
default: function (agg) {
return agg.vis.indexPattern.timeFieldName;
return agg._indexPattern.timeFieldName;
}
}, {
name: 'ranges',

View file

@ -33,7 +33,7 @@
<div class="hintbox" ng-if="!indexedFields.length">
<p>
<i class="fa fa-danger text-danger"></i>
<strong>No Compatible Fields:</strong> The "{{ vis.indexPattern.title }}" index pattern does not contain any of the following field types: {{ agg.type.params.byName.field.filterFieldTypes | commaList:false }}
<strong>No Compatible Fields:</strong> The "{{ agg._indexPattern.title }}" index pattern does not contain any of the following field types: {{ agg.type.params.byName.field.filterFieldTypes | commaList:false }}
</p>
</div>

View file

@ -24,7 +24,7 @@
</div>
<div ng-show="agg.params.orderAgg" class="vis-editor-agg-order-agg">
<vis-editor-agg-params
index-pattern="vis.indexPattern"
index-pattern="agg._indexPattern"
agg="agg.params.orderAgg"
ng-if="agg.params.orderAgg"
group-name="'metrics'">

View file

@ -25,7 +25,7 @@
<div ng-if="agg.params.metricAgg === 'custom'" class="vis-editor-agg-order-agg">
<ng-form name="customMetricForm">
<vis-editor-agg-params
index-pattern="vis.indexPattern"
index-pattern="agg._indexPattern"
agg="agg.params.customMetric"
group-name="'metrics'">
</vis-editor-agg-params>

View file

@ -5,7 +5,7 @@
<ng-form name="{{aggType}}Form">
<vis-editor-agg-params
agg="agg.params[aggType]"
index-pattern="vis.indexPattern"
index-pattern="agg._indexPattern"
group-name="'{{aggGroup}}'">
</vis-editor-agg-params>
</ng-form>

View file

@ -137,7 +137,7 @@ export const topHitMetricAgg = new MetricAggType({
editor: null,
filterFieldTypes: [ 'number', 'date', 'ip', 'string' ],
default: function (agg) {
return agg.vis.indexPattern.timeFieldName;
return agg._indexPattern.timeFieldName;
},
write: _.noop // prevent default write, it is handled below
},
@ -187,7 +187,7 @@ export const topHitMetricAgg = new MetricAggType({
const path = agg.params.field.name;
let values = _(hits).map(hit => {
return path === '_source' ? hit._source : agg.vis.indexPattern.flattenHit(hit, true)[path];
return path === '_source' ? hit._source : agg._indexPattern.flattenHit(hit, true)[path];
})
.flatten()
.value();

View file

@ -65,6 +65,7 @@ class AggConfig {
constructor(vis, opts = {}) {
this.id = String(opts.id || AggConfig.nextId(vis.aggs));
this.vis = vis;
this._indexPattern = vis.indexPattern;
this._opts = opts;
this.enabled = typeof opts.enabled === 'boolean' ? opts.enabled : true;