From 4ee603d7a2ad40a37fe5b17bdac3ca8509841282 Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Wed, 1 Oct 2025 00:48:17 -0700 Subject: [PATCH] fix(hdhr): animated uptime now counting --- tvapp2/www/hdhomerun.html | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tvapp2/www/hdhomerun.html b/tvapp2/www/hdhomerun.html index 013fa825..bd743958 100644 --- a/tvapp2/www/hdhomerun.html +++ b/tvapp2/www/hdhomerun.html @@ -386,6 +386,55 @@ }).responseText; } + function runUptime() + { + const toastTypeClass = []; + toastTypeClass[ 'DEFAULT' ] = 'text-bg-primary'; + toastTypeClass[ 'UNHEALTHY' ] = 'text-bg-warning'; + toastTypeClass[ 'HEALTHY' ] = 'text-bg-success'; + toastTypeClass[ 'ERROR' ] = 'text-bg-danger'; + + $.ajax( + { + url: 'api/health', + type: 'GET', + data: { + query: 'uptime', + silent: true + }, + success: function( data ) + { + const status = data.message; + const code = data.code; + const uptimeShort = data.uptimeShort; + const uptimeLong = data.uptimeLong; + if ( status ) + { + $('a#uptime').text(`${ uptimeShort }`); + + const tooltip = bootstrap.Tooltip.getInstance('#uptime') // Returns a Bootstrap tooltip instance + tooltip.setContent( { '.tooltip-inner': `HDHomeRun server started ${ uptimeLong }` } ) + } + }, + error: function( data ) + { + const toastClass = toastTypeClass['ERROR']; + const toastElm = document.getElementById('tvapp2Toast'); + toastElm.classList.add(toastClass); + + $('.toast #toast-title').html(`Could not get uptime from api`); + $('.toast #toast-message').html(`Failed to communicate with the api. Try restarting the docker container to restore connection.`); + $('#tvapp2Toast').toast('show'); + } + }).always(function() + { + setTimeout(function() + { + runUptime(); + }, parseInt(timerUptime)); + }).responseText; + } + /* Action > Do Resync */