Permalink
Browse files

Improve NEMS TV Dashboard connection failure handling

  • Loading branch information...
NEMS Linux
NEMS Linux committed Nov 29, 2018
1 parent d1c791a commit ecfec4eead1a1a0869fcf6b36b74326a9c6c9626
Showing with 26 additions and 4 deletions.
  1. +26 −4 tv/index.php
@@ -27,6 +27,7 @@
<link type="image/ico" rel="icon" href="favicon.ico" />
<title><?php echo($pagetitle); ?></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-loading-overlay/2.1.6/loadingoverlay.min.js"></script>

</script>
<link rel="stylesheet" type="text/css" href="nagios.css" />
@@ -109,12 +110,12 @@ function updateCountDown(){
$(document).mousemove(function() {
if (!fadeInBuffer) {
if (timer) {
console.log("clearTimer");
// console.log("clearTimer");
clearTimeout(timer);
timer = 0;
}
console.log("fadeIn");
// console.log("fadeIn");
$('html').css({
cursor: ''
});
@@ -127,7 +128,7 @@ function updateCountDown(){
timer = setTimeout(function() {
console.log("fadeout");
// console.log("fadeout");
$('body').css({
cursor: 'none'
});
@@ -140,9 +141,30 @@ function updateCountDown(){
});
});
check_connect();
});
</script>
function check_connect() {
$.ajax({
type: 'GET',
url: '/tv/',
timeout: 5000, // allow this many milisecs for network connect to succeed
success: function(data) {
// we have a connection
$.LoadingOverlay("hide");
window.setTimeout(check_connect, 15000) // try again after 15 minutes
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
// no connection, refresh every 15 seconds until resolved
$.LoadingOverlay("show");
window.setTimeout(check_connect, 15000)
}
});
};
</script>

</body>
</html>

0 comments on commit ecfec4e

Please sign in to comment.