mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
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:
parent
3ca45ba546
commit
b153ea0da3
3 changed files with 7 additions and 8 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue