Skip to content

Commit

Permalink
Fix for the progressbar UI javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Dec 9, 2024
1 parent 6b0fe0c commit 67bd5d8
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions modules/frontend/html/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,26 +313,42 @@ function aqlanalyze(e) {
});
}

function refreshProgress() {
var lastwasidle = false;
var progressSocket = new WebSocket(

let lastwasidle;
let progressSocket;

function connectProgress() {
progressSocket = new WebSocket(
location.origin.replace(/^http/, "ws") + "/api/backend/progress"
);

progressSocket.onopen = function (event) {
console.log("Open event");
console.log(event);
lastwasidle = false;
}

/*
progressSocket.onerror = function (event) {
console.log("Error event");
console.log(event);
$("#backendstatus").html("Adalanche backend is still offline");
$("#upperstatus").show();
$("#progressbars").empty().hide();
$("#offlineblur").show();
setTimeout(refreshProgress, 3000);
};
*/

progressSocket.onclose = function (event) {
console.log("Close event");
console.log(event);

$("#backendstatus").html("Adalanche backend is offline");
$("#upperstatus").show();
$("#progressbars").empty().hide();
$("#offlineblur").show();
setTimeout(refreshProgress, 3000);
setTimeout(connectProgress, 3000);
};

progressSocket.onmessage = function (message) {
Expand Down Expand Up @@ -397,9 +413,10 @@ function refreshProgress() {
lastwasidle = true;
}
};
}
};

connectProgress();

refreshProgress();

function toast(contents) {
Toastify({
Expand Down

0 comments on commit 67bd5d8

Please sign in to comment.