mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
parent
c40f854283
commit
4e31f600f6
118 changed files with 34006 additions and 10177 deletions
|
|
@ -2,20 +2,20 @@
|
|||
(C) 2013-23 - ntop.org
|
||||
*/
|
||||
|
||||
/* ******************************************************************** */
|
||||
/* ******************************************************************** */
|
||||
|
||||
function format_num_for_sort(num) {
|
||||
if (typeof num === 'number') {
|
||||
if(typeof num === "number") {
|
||||
/* Check if it's a number */
|
||||
return num;
|
||||
} else if (typeof num === 'string') {
|
||||
if (num == '') {
|
||||
} else if(typeof num === "string") {
|
||||
if(num == "") {
|
||||
/* Safety check */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* If it's a string convert it into a number */
|
||||
num = num.split(',').join('');
|
||||
num = num.split(',').join("");
|
||||
num = parseInt(num);
|
||||
} else {
|
||||
/* In case both failed, convert num to 0 */
|
||||
|
|
@ -25,7 +25,7 @@ function format_num_for_sort(num) {
|
|||
return num;
|
||||
}
|
||||
|
||||
// max number value for sort number with normalize option
|
||||
// max number value for sort number with normalize option
|
||||
// for cases: last scan and last duration column to handle empty values
|
||||
const MAX_NUMBER_VALUE = 99999999999;
|
||||
|
||||
|
|
@ -34,10 +34,10 @@ const normalize_number_value = function(lower_value, val, sort) {
|
|||
if (sort == 1) {
|
||||
val = MAX_NUMBER_VALUE;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
};
|
||||
/* ******************************************************************** */
|
||||
}
|
||||
return val;
|
||||
}
|
||||
/* ******************************************************************** */
|
||||
|
||||
/* Sort by Name */
|
||||
const sortByName = function(val_1, val_2, sort) {
|
||||
|
|
@ -46,13 +46,13 @@ const sortByName = function(val_1, val_2, sort) {
|
|||
if (!val_2) return 1;
|
||||
return val_1?.localeCompare(val_2);
|
||||
}
|
||||
|
||||
|
||||
if (!val_1) return 1;
|
||||
if (!val_2) return -1;
|
||||
return val_2?.localeCompare(val_1);
|
||||
};
|
||||
}
|
||||
|
||||
/* ******************************************************************** */
|
||||
/* ******************************************************************** */
|
||||
|
||||
/* Sort by IP Addresses */
|
||||
const sortByIP = function(val_1, val_2, sort) {
|
||||
|
|
@ -62,9 +62,9 @@ const sortByIP = function(val_1, val_2, sort) {
|
|||
return val_1.localeCompare(val_2);
|
||||
}
|
||||
return val_2.localeCompare(val_1);
|
||||
};
|
||||
}
|
||||
|
||||
/* ******************************************************************** */
|
||||
/* ******************************************************************** */
|
||||
|
||||
/* Sort by MAC Addresses */
|
||||
const sortByMacAddress = function(val_1, val_2, sort) {
|
||||
|
|
@ -74,9 +74,9 @@ const sortByMacAddress = function(val_1, val_2, sort) {
|
|||
return val_1.localeCompare(val_2);
|
||||
}
|
||||
return val_2.localeCompare(val_1);
|
||||
};
|
||||
}
|
||||
|
||||
/* ******************************************************************** */
|
||||
/* ******************************************************************** */
|
||||
|
||||
/* Sort by Number */
|
||||
const sortByNumber = function(val_1, val_2, sort) {
|
||||
|
|
@ -87,22 +87,22 @@ const sortByNumber = function(val_1, val_2, sort) {
|
|||
if (sort == 1) {
|
||||
return val_1 - val_2;
|
||||
}
|
||||
return val_2 - val_1;
|
||||
};
|
||||
return val_2 - val_1;
|
||||
}
|
||||
|
||||
/* ******************************************************************** */
|
||||
/* ******************************************************************** */
|
||||
|
||||
/* Sort by Number after values normalization */
|
||||
const sortByNumberWithNormalizationValue = function(val_1, val_2, sort, lower_value) {
|
||||
val_1 = normalize_number_value(lower_value, val_1, sort);
|
||||
val_2 = normalize_number_value(lower_value, val_2, sort);
|
||||
|
||||
return sortByNumber(val_1, val_2, sort);
|
||||
};
|
||||
return sortByNumber(val_1,val_2,sort);
|
||||
}
|
||||
|
||||
/* ******************************************************************** */
|
||||
/* ******************************************************************** */
|
||||
|
||||
const sortingFunctions = function() {
|
||||
const sortingFunctions = function () {
|
||||
return {
|
||||
sortByIP,
|
||||
sortByName,
|
||||
|
|
@ -112,4 +112,4 @@ const sortingFunctions = function() {
|
|||
};
|
||||
}();
|
||||
|
||||
export default sortingFunctions;
|
||||
export default sortingFunctions;
|
||||
Loading…
Add table
Add a link
Reference in a new issue