diff --git a/UIMod/onboard_bundled/assets/css/home.css b/UIMod/onboard_bundled/assets/css/home.css index 2bc78208..1578a958 100644 --- a/UIMod/onboard_bundled/assets/css/home.css +++ b/UIMod/onboard_bundled/assets/css/home.css @@ -21,6 +21,21 @@ transition: opacity var(--transition-fast); } +.uptime-display { + position: absolute; + right: 50px; + top: 22px; + font-family: 'Share Tech Mono', monospace; + font-size: 0.8rem; + color: rgba(255, 255, 255, 0.75); + background-color: rgba(0, 0, 0, 0.35); + padding: 2px 8px; + border-radius: 4px; + letter-spacing: 0.5px; + white-space: nowrap; + transition: opacity 0.3s ease; +} + .status-indicator { width: 16px; height: 16px; diff --git a/UIMod/onboard_bundled/assets/js/server-api.js b/UIMod/onboard_bundled/assets/js/server-api.js index 38d91e8d..5d1bb125 100644 --- a/UIMod/onboard_bundled/assets/js/server-api.js +++ b/UIMod/onboard_bundled/assets/js/server-api.js @@ -262,7 +262,7 @@ function pollRecurringTasks() { fetch('/api/v2/server/status') .then(response => response.json()) .then(data => { - updateStatusIndicator(data.isRunning); + updateStatusIndicator(data.isRunning, false, data.uptime); if (data.uuid) { localStorage.setItem('gameserverrunID', data.uuid); } @@ -290,13 +290,15 @@ function pollRecurringTasks() { }, 30000); } -function updateStatusIndicator(isRunning, isError = false) { +function updateStatusIndicator(isRunning, isError = false, uptime = '') { const indicator = document.getElementById('status-indicator'); + const uptimeDisplay = document.getElementById('uptime-display'); if (isError) { indicator.className = 'status-indicator error'; indicator.title = 'Error fetching server status'; window.gamserverstate = false; + if (uptimeDisplay) uptimeDisplay.style.display = 'none'; return; } @@ -309,4 +311,14 @@ function updateStatusIndicator(isRunning, isError = false) { indicator.title = 'Server is offline'; window.gamserverstate = false; } + + // Show uptime only when server is running and uptime is not "0s" + if (uptimeDisplay) { + if (isRunning && uptime && uptime !== '0s') { + uptimeDisplay.textContent = uptime; + uptimeDisplay.style.display = 'inline-block'; + } else { + uptimeDisplay.style.display = 'none'; + } + } } \ No newline at end of file diff --git a/UIMod/onboard_bundled/ui/index.html b/UIMod/onboard_bundled/ui/index.html index 19b65dd0..aa7b51dc 100644 --- a/UIMod/onboard_bundled/ui/index.html +++ b/UIMod/onboard_bundled/ui/index.html @@ -63,6 +63,7 @@