Fix bandwith counter
This commit is contained in:
@@ -128,6 +128,18 @@ function setUserSort(key) {
|
|||||||
updateSortIndicators();
|
updateSortIndicators();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
function sshTrafficHTML(u) {
|
||||||
|
const up = Number(u.total_uplink_bytes || 0);
|
||||||
|
const down = Number(u.total_downlink_bytes || 0);
|
||||||
|
const total = Number(u.total_bytes || (up + down) || 0);
|
||||||
|
const quota = Number(u.data_quota_bytes || 0);
|
||||||
|
const quotaLabel = quota > 0 ? formatBytes(quota) : "∞";
|
||||||
|
const state = u.quota_exceeded
|
||||||
|
? (u.quota_action === "throttle" ? ` · ${t("throttled")}` : ` · ${t("blocked")}`)
|
||||||
|
: "";
|
||||||
|
return `${escapeHTML(formatBytes(total))} / ${escapeHTML(quotaLabel)}${escapeHTML(state)}<div class="hint">↑ ${escapeHTML(formatBytes(up))} · ↓ ${escapeHTML(formatBytes(down))}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
function renderUsers(users) {
|
function renderUsers(users) {
|
||||||
// Cache the raw list so a header click can re-sort without refetching, and
|
// Cache the raw list so a header click can re-sort without refetching, and
|
||||||
// order by the active column so rows don't shuffle on each live poll.
|
// order by the active column so rows don't shuffle on each live poll.
|
||||||
@@ -144,12 +156,6 @@ function renderUsers(users) {
|
|||||||
const on = (u.active_conns || 0) > 0;
|
const on = (u.active_conns || 0) > 0;
|
||||||
if (on) online++;
|
if (on) online++;
|
||||||
if (isExpiredDate(u.expires_at)) expiredCount++;
|
if (isExpiredDate(u.expires_at)) expiredCount++;
|
||||||
const totalBytes = Number(u.total_bytes || ((u.total_uplink_bytes || 0) + (u.total_downlink_bytes || 0)) || 0);
|
|
||||||
const quotaBytes = Number(u.data_quota_bytes || 0);
|
|
||||||
const quotaLabel = quotaBytes > 0 ? formatBytes(quotaBytes) : "∞";
|
|
||||||
const quotaState = u.quota_exceeded
|
|
||||||
? (u.quota_action === "throttle" ? ` · ${t("throttled")}` : ` · ${t("blocked")}`)
|
|
||||||
: "";
|
|
||||||
const tr = document.createElement("tr");
|
const tr = document.createElement("tr");
|
||||||
const cells = [
|
const cells = [
|
||||||
u.username,
|
u.username,
|
||||||
@@ -159,13 +165,14 @@ function renderUsers(users) {
|
|||||||
u.max_connections || 0,
|
u.max_connections || 0,
|
||||||
u.limit_mbps_up || 0,
|
u.limit_mbps_up || 0,
|
||||||
u.limit_mbps_down || 0,
|
u.limit_mbps_down || 0,
|
||||||
`${formatBytes(totalBytes)} / ${quotaLabel}${quotaState}`,
|
sshTrafficHTML(u),
|
||||||
u.expires_at ? fmtDate(u.expires_at) : "—",
|
u.expires_at ? fmtDate(u.expires_at) : "—",
|
||||||
];
|
];
|
||||||
if (isSA) cells.push(u.owner_username || "—");
|
if (isSA) cells.push(u.owner_username || "—");
|
||||||
cells.forEach((c, i) => {
|
cells.forEach((c, i) => {
|
||||||
const td = document.createElement("td");
|
const td = document.createElement("td");
|
||||||
if (i === 1) td.innerHTML = c; else td.textContent = c;
|
if (i === 1 || i === 7) td.innerHTML = c; else td.textContent = c;
|
||||||
|
if (i === 7) td.style.fontSize = ".7rem";
|
||||||
tr.appendChild(td);
|
tr.appendChild(td);
|
||||||
});
|
});
|
||||||
const tdA = document.createElement("td");
|
const tdA = document.createElement("td");
|
||||||
|
|||||||
+2
-2
@@ -273,7 +273,7 @@
|
|||||||
<table>
|
<table>
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th data-sort-key="username">User</th><th data-sort-key="status">Status</th><th data-sort-key="auth">Auth</th>
|
<th data-sort-key="username">User</th><th data-sort-key="status">Status</th><th data-sort-key="auth">Auth</th>
|
||||||
<th data-sort-key="conn">Conn</th><th data-sort-key="max">Max</th><th data-sort-key="up">Up</th><th data-sort-key="down">Dn</th><th data-sort-key="usage">Usage / Quota</th><th data-sort-key="expires">Expires</th>
|
<th data-sort-key="conn">Conn</th><th data-sort-key="max">Max</th><th data-sort-key="up">Up</th><th data-sort-key="down">Dn</th><th data-sort-key="usage">Traffic</th><th data-sort-key="expires">Expires</th>
|
||||||
<th id="ownerColHead" data-sort-key="owner" class="superadmin-only hidden">Owner</th>
|
<th id="ownerColHead" data-sort-key="owner" class="superadmin-only hidden">Owner</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
@@ -1560,7 +1560,7 @@
|
|||||||
so behavior is identical to the old single file. Keep this load order. -->
|
so behavior is identical to the old single file. Keep this load order. -->
|
||||||
<script defer src="assets/js/01-core.js?v=20260715quotareset1"></script>
|
<script defer src="assets/js/01-core.js?v=20260715quotareset1"></script>
|
||||||
<script defer src="assets/js/02-shell.js?v=20260714pamfix1"></script>
|
<script defer src="assets/js/02-shell.js?v=20260714pamfix1"></script>
|
||||||
<script defer src="assets/js/03-ssh-users.js?v=20260715quotareset1"></script>
|
<script defer src="assets/js/03-ssh-users.js?v=20260715sshtraffic1"></script>
|
||||||
<script defer src="assets/js/04-xray.js?v=20260715quotareset1"></script>
|
<script defer src="assets/js/04-xray.js?v=20260715quotareset1"></script>
|
||||||
<script defer src="assets/js/05-resellers.js?v=20260714pamfix1"></script>
|
<script defer src="assets/js/05-resellers.js?v=20260714pamfix1"></script>
|
||||||
<script defer src="assets/js/06-servers.js?v=20260714pamfix1"></script>
|
<script defer src="assets/js/06-servers.js?v=20260714pamfix1"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user