From dd59fda439be8e1fd6d1c6cd3bfacafef6b8eddc Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Tue, 20 May 2025 11:06:07 +0100 Subject: [PATCH] feat: Add network status icons and uptime color-coding to dashboard --- src/public/js/ui/dashboard.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/public/js/ui/dashboard.js b/src/public/js/ui/dashboard.js index 3133d9398..84b0d1d9c 100644 --- a/src/public/js/ui/dashboard.js +++ b/src/public/js/ui/dashboard.js @@ -429,6 +429,25 @@ PulseApp.ui.dashboard = (() => { const diskReadFormatted = guest.status === STATUS_RUNNING ? PulseApp.utils.formatSpeed(guest.diskread, 0) : '-'; const diskWriteFormatted = guest.status === STATUS_RUNNING ? PulseApp.utils.formatSpeed(guest.diskwrite, 0) : '-'; + + // Icons and colors + const upArrow = '↑'; + const downArrow = '↓'; + + let netInIcon = ''; + let netOutIcon = ''; + + if (guest.status === STATUS_RUNNING) { + const netInActive = guest.netin > 0; + const netOutActive = guest.netout > 0; + + netInIcon = `${downArrow}`; + netOutIcon = `${upArrow}`; + } else { + netInIcon = `${downArrow}`; + netOutIcon = `${upArrow}`; + } + const netInFormatted = guest.status === STATUS_RUNNING ? PulseApp.utils.formatSpeed(guest.netin, 0) : '-'; const netOutFormatted = guest.status === STATUS_RUNNING ? PulseApp.utils.formatSpeed(guest.netout, 0) : '-'; @@ -437,18 +456,26 @@ PulseApp.ui.dashboard = (() => { : 'ct-icon bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300 px-1.5 py-0.5 font-medium'; const typeIcon = `${guest.type === GUEST_TYPE_VM ? GUEST_TYPE_VM : 'LXC'}`; + let uptimeDisplay = '-'; + if (guest.status === STATUS_RUNNING) { + uptimeDisplay = PulseApp.utils.formatUptime(guest.uptime); + if (guest.uptime < 3600) { // Less than 1 hour (3600 seconds) + uptimeDisplay = `${uptimeDisplay}`; + } + } + row.innerHTML = ` ${guest.name} ${typeIcon} ${guest.id} - ${guest.status === STATUS_STOPPED ? '-' : PulseApp.utils.formatUptime(guest.uptime)} + ${uptimeDisplay} ${cpuBarHTML} ${memoryBarHTML} ${diskBarHTML} ${diskReadFormatted} ${diskWriteFormatted} - ${netInFormatted} - ${netOutFormatted} + ${netInIcon}${netInFormatted} + ${netOutIcon}${netOutFormatted} `; return row; }