mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-29 02:01:43 +00:00
Table-mode: sort ips numerically (#2007)
Fix #1746 - sort IPs numerically in the table mode
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user