Skip to content

Commit

Permalink
adding indexPattern to agg so its not accessed from vis.indexPattern (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar authored Jul 9, 2018
1 parent 316ddaf commit 383437d
Show file tree
Hide file tree
Showing 16 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/buckets/create_filter/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/buckets/create_filter/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/buckets/create_filter/ip_range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/buckets/create_filter/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function createFilterRange(aggConfig, key) {
return buildRangeFilter(
aggConfig.params.field,
key,
aggConfig.vis.indexPattern,
aggConfig._indexPattern,
aggConfig.fieldFormatter()(key)
);
}
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/buckets/date_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/buckets/date_range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/controls/field.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/controls/order_agg.html
Original file line number Diff line number Diff line change
Expand Up @@ -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'">
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/controls/sub_agg.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/controls/sub_metric.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_types/metrics/top_hit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/ui/public/vis/agg_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 383437d

Please sign in to comment.