ip range label and filter improvements

* updated the filter labels to match the range labels
* fixed the filter creation to work for unbound ranges
This commit is contained in:
Spencer 2016-10-19 10:57:58 -07:00 committed by Matthew Bargar
parent 3ca45ba546
commit b153ea0da3
3 changed files with 7 additions and 8 deletions

View file

@ -41,7 +41,7 @@ describe('AggConfig Filters', function () {
});
let aggConfig = vis.aggs.byTypeName.ip_range[0];
let filter = createFilter(aggConfig, '0.0.0.0-1.1.1.1');
let filter = createFilter(aggConfig, '0.0.0.0 to 1.1.1.1');
expect(filter).to.have.property('range');
expect(filter).to.have.property('meta');
expect(filter.meta).to.have.property('index', indexPattern.id);

View file

@ -6,10 +6,10 @@ export default function createIpRangeFilterProvider() {
if (aggConfig.params.ipRangeType === 'mask') {
range = new CidrMask(key).getRange();
} else {
let addresses = key.split(/\-/);
let [from, to] = key.split(/\s+to\s+/);
range = {
from: addresses[0],
to: addresses[1]
from: from === '-Infinity' ? -Infinity : from,
to: to === 'Infinity' ? Infinity : to
};
}

View file

@ -15,10 +15,9 @@ export default function RangeAggDefinition(Private) {
createFilter: createFilter,
getKey: function (bucket, key, agg) {
if (key) return key;
const from = _.get(bucket, 'from', '*');
const to = _.get(bucket, 'to', '*');
return `${from}-${to}`;
const from = _.get(bucket, 'from', '-Infinity');
const to = _.get(bucket, 'to', 'Infinity');
return `${from} to ${to}`;
},
makeLabel: function (aggConfig) {
return aggConfig.getFieldDisplayName() + ' IP ranges';