feat: implement numeric sorting for the "Traffic" column in network connections table to enhance data analysis
This commit is contained in:
@@ -3919,6 +3919,43 @@
|
||||
console.warn('Table not found:', tableId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fast path: simple numeric sort for Network Analysis "Traffic" column
|
||||
if (tableId === 'network-connections-table' && column === 'traffic') {
|
||||
var tbody = table.tBodies && table.tBodies[0] ? table.tBodies[0] : table.querySelector('tbody');
|
||||
if (!tbody) {
|
||||
console.warn('No tbody found for network-connections-table');
|
||||
return;
|
||||
}
|
||||
|
||||
// Toggle sort direction
|
||||
if (component.sortColumn === column) {
|
||||
component.sortDirection = component.sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
component.sortColumn = column;
|
||||
component.sortDirection = 'desc'; // default to highest traffic first
|
||||
}
|
||||
|
||||
var rows = Array.from(tbody.querySelectorAll('tr.table-row')).filter(function (row) {
|
||||
return row.style.display !== 'none';
|
||||
});
|
||||
|
||||
rows.sort(function (a, b) {
|
||||
var aBytes = parseFloat(a.getAttribute('data-traffic') || '0') || 0;
|
||||
var bBytes = parseFloat(b.getAttribute('data-traffic') || '0') || 0;
|
||||
|
||||
if (component.sortDirection === 'asc') {
|
||||
return aBytes - bBytes;
|
||||
}
|
||||
return bBytes - aBytes;
|
||||
});
|
||||
|
||||
rows.forEach(function (row) {
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.sortColumn === column) {
|
||||
component.sortDirection = component.sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
|
||||
Reference in New Issue
Block a user