diff --git a/public/js/app.js b/public/js/app.js index 21fabc0..30f80ab 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -161,7 +161,7 @@ networkChart.draw(); }); } - + // Source filter listener if (dom.sourceFilter) { dom.sourceFilter.addEventListener('change', () => { @@ -346,22 +346,22 @@ // ---- Update Dashboard ---- function updateDashboard(data) { // Server count - dom.totalServers.textContent = `${data.activeServers} / ${data.totalServers}`; + dom.totalServers.textContent = `${data.activeServers}/${data.totalServers}`; // CPU const cpuPct = data.cpu.percent; dom.cpuPercent.textContent = formatPercent(cpuPct); - dom.cpuDetail.textContent = `${data.cpu.used.toFixed(1)} / ${data.cpu.total.toFixed(0)} 核心`; + dom.cpuDetail.textContent = `${data.cpu.used.toFixed(1)}/${data.cpu.total.toFixed(0)} 核心`; // Memory const memPct = data.memory.percent; dom.memPercent.textContent = formatPercent(memPct); - dom.memDetail.textContent = `${formatBytes(data.memory.used)} / ${formatBytes(data.memory.total)}`; + dom.memDetail.textContent = `${formatBytes(data.memory.used)}/${formatBytes(data.memory.total)}`; // Disk const diskPct = data.disk.percent; dom.diskPercent.textContent = formatPercent(diskPct); - dom.diskDetail.textContent = `${formatBytes(data.disk.used)} / ${formatBytes(data.disk.total)}`; + dom.diskDetail.textContent = `${formatBytes(data.disk.used)}/${formatBytes(data.disk.total)}`; // Bandwidth dom.totalBandwidth.textContent = formatBandwidth(data.network.total || 0); @@ -392,7 +392,7 @@ if (currentSourceFilter !== 'all') { filtered = allServersData.filter(s => s.source === currentSourceFilter); } - + // Sort servers: online first, then alphabetically by name (job) filtered.sort((a, b) => { if (a.up !== b.up) return a.up ? -1 : 1; @@ -403,7 +403,7 @@ const totalFiltered = filtered.length; const totalPages = Math.ceil(totalFiltered / pageSize) || 1; - + if (currentPage > totalPages) currentPage = totalPages; const startIndex = (currentPage - 1) * pageSize; @@ -415,7 +415,7 @@ function renderPagination(totalPages) { if (!dom.paginationControls) return; - + if (totalPages <= 1) { dom.paginationControls.innerHTML = ''; return; @@ -424,25 +424,25 @@ let html = ''; // Previous button html += ``; - + // Page numbers for (let i = 1; i <= totalPages; i++) { - if (i === 1 || i === totalPages || (i >= currentPage - 2 && i <= currentPage + 2)) { - html += ``; - } else if (i === currentPage - 3 || i === currentPage + 3) { - html += `...`; - } + if (i === 1 || i === totalPages || (i >= currentPage - 2 && i <= currentPage + 2)) { + html += ``; + } else if (i === currentPage - 3 || i === currentPage + 3) { + html += `...`; + } } // Next button html += ``; - + dom.paginationControls.innerHTML = html; } - window.changePage = function(page) { - currentPage = page; - renderFilteredServers(); + window.changePage = function (page) { + currentPage = page; + renderFilteredServers(); }; // ---- Server Table ---- @@ -548,24 +548,22 @@ // Define metrics to show const cpuValueHtml = ` -