fix: update traffic metrics to use bytes instead of traffic values
This commit is contained in:
@@ -280,17 +280,8 @@ async function updateTrafficLimit(event, clientId) {
|
|||||||
|
|
||||||
if (data.success !== false) {
|
if (data.success !== false) {
|
||||||
alert('Traffic limit updated successfully');
|
alert('Traffic limit updated successfully');
|
||||||
// Update current value display (keep usage info if available)
|
// Reload page to show updated traffic info
|
||||||
const currentDiv = document.getElementById('currentTrafficLimit');
|
window.location.reload();
|
||||||
const usageMatch = currentDiv.textContent.match(/used: ([\d.]+) GB/);
|
|
||||||
if (usageMatch && limitBytes !== null) {
|
|
||||||
displayText += ` (used: ${usageMatch[1]} GB)`;
|
|
||||||
}
|
|
||||||
currentDiv.textContent = displayText;
|
|
||||||
// Reset form
|
|
||||||
select.value = '';
|
|
||||||
customInput.value = '';
|
|
||||||
customInput.style.display = 'none';
|
|
||||||
} else {
|
} else {
|
||||||
alert('Error: ' + (data.error || 'Unknown error'));
|
alert('Error: ' + (data.error || 'Unknown error'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,15 +133,15 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 text-sm">
|
<td class="px-6 py-4 text-sm">
|
||||||
<div class="text-gray-600">
|
<div class="text-gray-600">
|
||||||
↑ {{ (client.traffic_sent|default(0) / 1024 / 1024)|number_format(2) }} MB
|
↑ {{ (client.bytes_sent|default(0) / 1024 / 1024)|number_format(2) }} MB
|
||||||
</div>
|
</div>
|
||||||
<div class="text-gray-600">
|
<div class="text-gray-600">
|
||||||
↓ {{ (client.traffic_received|default(0) / 1024 / 1024)|number_format(2) }} MB
|
↓ {{ (client.bytes_received|default(0) / 1024 / 1024)|number_format(2) }} MB
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 text-sm">
|
<td class="px-6 py-4 text-sm">
|
||||||
{% if client.traffic_limit %}
|
{% if client.traffic_limit %}
|
||||||
{% set total_traffic = (client.traffic_sent|default(0) + client.traffic_received|default(0)) %}
|
{% set total_traffic = (client.bytes_sent|default(0) + client.bytes_received|default(0)) %}
|
||||||
{% set limit_gb = (client.traffic_limit / 1073741824)|number_format(2) %}
|
{% set limit_gb = (client.traffic_limit / 1073741824)|number_format(2) %}
|
||||||
{% set used_gb = (total_traffic / 1073741824)|number_format(2) %}
|
{% set used_gb = (total_traffic / 1073741824)|number_format(2) %}
|
||||||
{% set percentage = ((total_traffic / client.traffic_limit) * 100)|round %}
|
{% set percentage = ((total_traffic / client.traffic_limit) * 100)|round %}
|
||||||
|
|||||||
Reference in New Issue
Block a user