mirror of
https://github.com/TheBinaryNinja/tvapp2.git
synced 2026-06-04 02:55:41 -04:00
fix(hdhr): animated uptime now counting
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user