From e89dac03ea9becadafc70c47ea6fec9b360f429f Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Sun, 24 Feb 2019 11:14:22 +0000 Subject: [PATCH] Use document attribute for blocking firmware downloads, fixing #17 --- static/js/devices.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/static/js/devices.js b/static/js/devices.js index 689e10c..03ad52d 100644 --- a/static/js/devices.js +++ b/static/js/devices.js @@ -13,11 +13,11 @@ function urlStatus(url, cb){ function checkDownload(url){ urlStatus(url, function(status) { if (status === 200){ - var working = false; + document.buildingfw = false; document.getElementById("download").src=url; } else { - var working = true; + document.buildingfw = true; checkDownload(url); } }); @@ -101,10 +101,13 @@ function askreboot(device_id) { }; function downloadnotice(device_id) { - if (!working) { + if (!document.buildingfw) { alert("Your file is being prepared. This might take a minute or two, the download will start automatically when the file is ready. You may close this page and click the download button again later to pick the file up – we will store it for you."); checkDownload('/devices/' + device_id + '/download/'); }; + else { + alert("You are currently building another firmware. Please wait for this to finish and try again."); + }; }; function showdevices() { @@ -223,3 +226,5 @@ $("div[id$='-indicator']").each(function() { $("#orgaselect").on('change', function() { filtertables(); }); + +document.buildingfw = false;