added ability to upload new firmware from the browser.

This commit is contained in:
Sebastien
2020-02-14 13:33:50 -05:00
parent 69120bb4de
commit 8c3a52d40c
16 changed files with 432 additions and 351 deletions

View File

@@ -367,7 +367,31 @@ $(document).ready(function(){
console.log('sent config JSON with headers:', JSON.stringify(headers));
console.log('sent config JSON with data:', JSON.stringify(data));
});
$("#fwUpload").on("click", function() {
var upload_path = "/flash.json";
var fileInput = document.getElementById("flashfilename").files;
if (fileInput.length == 0) {
alert("No file selected!");
} else {
var file = fileInput[0];
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4) {
if (xhttp.status == 200) {
showMessage(xhttp.responseText, 'INFO')
} else if (xhttp.status == 0) {
showMessage("Upload connection was closed abruptly!", 'ERROR');
} else {
showMessage(xhttp.status + " Error!\n" + xhttp.responseText, 'ERROR');
}
}
};
xhttp.open("POST", upload_path, true);
xhttp.send(file);
}
enableStatusTimer = true;
});
$("#flash").on("click", function() {
var data = { 'timestamp': Date.now() };
if (blockFlashButton) return;
@@ -732,6 +756,8 @@ function checkStatus(){
$("footer.footer").addClass('sl');
$("#boot-button").html('Recovery');
$("#boot-form").attr('action', '/recovery.json');
$('#uploaddiv"]').hide();
enableStatusTimer = false;
}
}
@@ -874,3 +900,6 @@ function showMessage(message, severity) {
function inRange(x, min, max) {
return ((x-min)*(x-max) <= 0);
}