Refine device traffic display and sorting
Build and Deploy Gateway / build-and-push (push) Successful in 14s
Build and Deploy Gateway / deploy (push) Successful in 7s

This commit is contained in:
2026-08-07 17:51:53 +03:00
parent c430557dc0
commit 0a37121dbe
5 changed files with 17 additions and 64 deletions
+4 -2
View File
@@ -34,7 +34,7 @@ export function formatByteString(value) {
export function sortDevicesByTraffic(devices, direction = 'desc') {
const factor = direction === 'asc' ? 1 : -1;
return (Array.isArray(devices) ? devices : [])
.map((device, index) => ({ device, index }))
.map((device) => ({ device }))
.sort((left, right) => {
const pinned = Number(right.device.pinned === true) - Number(left.device.pinned === true);
if (pinned) return pinned;
@@ -42,7 +42,9 @@ export function sortDevicesByTraffic(devices, direction = 'desc') {
+ byteString(left.device.proxyUploadBytes) + byteString(left.device.proxyDownloadBytes);
const rightTotal = byteString(right.device.uploadBytes) + byteString(right.device.downloadBytes)
+ byteString(right.device.proxyUploadBytes) + byteString(right.device.proxyDownloadBytes);
if (leftTotal === rightTotal) return left.index - right.index;
if (leftTotal === rightTotal) {
return String(left.device.id || '').localeCompare(String(right.device.id || ''));
}
return (leftTotal < rightTotal ? -1 : 1) * factor;
})
.map(({ device }) => device);