refactor: streamline numeric sorting for network connections by utilizing raw byte values from the backend
This commit is contained in:
@@ -2138,23 +2138,8 @@
|
||||
<tbody class="divide-y divide-neutral/40">
|
||||
@foreach($networkAnalysis['connections'] as $index => $connection)
|
||||
@php
|
||||
// Calculate bytes for sorting (extract numeric value)
|
||||
$bytesForSort = 0;
|
||||
if (isset($connection['bytes_human'])) {
|
||||
$bytesHuman = $connection['bytes_human'];
|
||||
// Extract number and unit, convert to bytes
|
||||
if (preg_match('/([\d.]+)\s*(Bytes|KiB|MiB|GiB|TiB)/i', $bytesHuman, $matches)) {
|
||||
$value = (float)$matches[1];
|
||||
$unit = strtoupper($matches[2]);
|
||||
$bytesForSort = match($unit) {
|
||||
'KIB' => $value * 1024,
|
||||
'MIB' => $value * 1024 * 1024,
|
||||
'GIB' => $value * 1024 * 1024 * 1024,
|
||||
'TIB' => $value * 1024 * 1024 * 1024 * 1024,
|
||||
default => $value
|
||||
};
|
||||
}
|
||||
}
|
||||
// Use raw bytes value from backend for reliable numeric sorting
|
||||
$bytesForSort = (int)($connection['bytes'] ?? 0);
|
||||
@endphp
|
||||
<tr wire:key="conn-{{ $index }}"
|
||||
class="hover:bg-background-secondary/50 transition-colors table-row"
|
||||
|
||||
Reference in New Issue
Block a user