Table-mode: sort ips numerically (#2007)

Fix #1746 - sort IPs numerically in the table mode
This commit is contained in:
Filip Barl
2016-11-22 11:05:59 +01:00
committed by GitHub
parent 7b0bf508dd
commit d15e884cb1
8 changed files with 150 additions and 14 deletions

View File

@@ -22,6 +22,11 @@ function renderSvg(text, unit) {
}
function padToThreeDigits(n) {
return `000${n}`.slice(-3);
}
function makeFormatters(renderFn) {
const formatters = {
filesize(value) {
@@ -75,6 +80,11 @@ export function longestCommonPrefix(strArr) {
return (new LCP(strArr)).lcp();
}
// Converts IPs from '10.244.253.4' to '010.244.253.004' format.
export function ipToPaddedString(value) {
return value.match(/\d+/g).map(padToThreeDigits).join('.');
}
// Formats metadata values. Add a key to the `formatters` obj
// that matches the `dataType` of the field. You must return an Object
// with the keys `value` and `title` defined.