From 5a023f34e03b89691b3413cc15db610df90ec1f2 Mon Sep 17 00:00:00 2001 From: Lars Karlslund Date: Wed, 14 Feb 2024 10:44:28 +0100 Subject: [PATCH] Fixed the binary icon --- modules/analyze/html/custom.js | 111 ++++++----- modules/analyze/html/graph.js | 181 +++--------------- .../icons/binary-code-binary-svgrepo-com.svg | 167 ---------------- modules/analyze/html/icons/binary-code.svg | 174 +++++++++++++++++ 4 files changed, 261 insertions(+), 372 deletions(-) delete mode 100644 modules/analyze/html/icons/binary-code-binary-svgrepo-com.svg create mode 100644 modules/analyze/html/icons/binary-code.svg diff --git a/modules/analyze/html/custom.js b/modules/analyze/html/custom.js index ab408e3..dd86734 100644 --- a/modules/analyze/html/custom.js +++ b/modules/analyze/html/custom.js @@ -313,67 +313,73 @@ function analyze(e) { }); } -function refreshStatus() { +function refreshProgress() { var lastwasidle = false - $.ajax({ - type: "GET", - url: "/progress", - dataType: "json", - timeout: 5000, - success: function (progressbars) { - $("#offlineblur").hide() - if (progressbars.length > 0) { - lastwasidle = false - keepProgressbars = new Set() - for (i in progressbars) { - progressbar = progressbars[i] - if (progressbar.Done) { - continue - } - keepProgressbars.add(progressbar.ID) + var progressSocket = new WebSocket(location.origin.replace(/^http/, 'ws') + '/progress'); + + progressSocket.onerror = function (event) { + $("#backendstatus").html("Adalanche backend is still offline"); + $("#upperstatus").show(); + $("#progressbars").empty().hide(); + $("#offlineblur").show(); + setTimeout(refreshProgress, 3000); + }; + + progressSocket.onclose = function (event) { + $("#backendstatus").html("Adalanche backend is offline"); + $("#upperstatus").show(); + $("#progressbars").empty().hide(); + $("#offlineblur").show(); + setTimeout(refreshProgress, 3000); + } - // find progressbar - pb = $("#"+progressbar.ID) - if (pb.length == 0 && !progressbar.Done) { - $("#progressbars").append(`
` + progressbar.Title + `
`) - pb = $("#" + progressbar.ID) - } + progressSocket.onmessage = function (progressbars) { + $("#offlineblur").hide() + if (progressbars.length > 0) { + lastwasidle = false + keepProgressbars = new Set() + for (i in progressbars) { + progressbar = progressbars[i] + if (progressbar.Done) { + continue + } + keepProgressbars.add(progressbar.ID) - // Update progressbar - pb.attr("aria-valuenow", progressbar.Percent.toFixed(0)) - pb.css("width", progressbar.Percent.toFixed(0)+"%") - pb.parent().next().html(progressbar.Percent.toFixed(2)+"%") + // find progressbar + pb = $("#"+progressbar.ID) + if (pb.length == 0 && !progressbar.Done) { + $("#progressbars").append(`
` + progressbar.Title + `
`) + pb = $("#" + progressbar.ID) } - // remove old progressbars - $("#progressbars .progress-bar").each(function (index) { - id = $(this).attr('id') - if (!keepProgressbars.has(id)) { - $(this).parent().parent().slideUp("slow", function () { $(this).remove(); }) - } - }) - $("#upperstatus").show() - $("#progressbars").show() - $("#backendstatus").html("Adalanche is processing") - } else { - if (!lastwasidle) { - $("#progressbars").empty().hide() - $("#backendstatus").html("Adalanche backend is idle") - $("#upperstatus").fadeOut("slow") + // Update progressbar + pb.attr("aria-valuenow", progressbar.Percent.toFixed(0)) + pb.css("width", progressbar.Percent.toFixed(0)+"%") + pb.parent().next().html(progressbar.Percent.toFixed(2)+"%") + } + // remove old progressbars + $("#progressbars .progress-bar").each(function (index) { + id = $(this).attr('id') + if (!keepProgressbars.has(id)) { + $(this).parent().parent().slideUp("slow", function () { $(this).remove(); }) } - lastwasidle = true + }) + + $("#upperstatus").show() + $("#progressbars").show() + $("#backendstatus").html("Adalanche is processing") + } else { + if (!lastwasidle) { + $("#progressbars").empty().hide() + $("#backendstatus").html("Adalanche backend is idle") + $("#upperstatus").fadeOut("slow") } - }, - error: function (xhr, status, error) { - $("#backendstatus").html("Adalanche backend is offline") - $("#progressbars").empty().hide() - $("#offlineblur").show() + lastwasidle = true } - }); - $() + }; +}; - setTimeout(refreshStatus, 1000); -} +refreshProgress(); function toast(title, contents) { toastcontent = $(`