mirror of https://github.com/jeelabs/esp-link.git
Upgrade firmware from web interface (#174)
* enable firmware flashing from the web UI * remove mqtt reference from flash JS * remove dependency on nanoajaxpull/193/head
parent
c5513d063d
commit
8c4c4928b1
@ -0,0 +1,43 @@ |
|||||||
|
<div id="main"> |
||||||
|
<div class="header"> |
||||||
|
<h1>Upgrade Firmware</h1> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="content"> |
||||||
|
<div class="pure-g"> |
||||||
|
<div class="pure-u-1 pure-u-md-1-2"> |
||||||
|
<div class="card"> |
||||||
|
<h1>Upgrade Firmware |
||||||
|
<div id="fw-spinner" class="spinner spinner-small"></div> |
||||||
|
</h1> |
||||||
|
<form action="#" id="fw-form" class="pure-form" hidden> |
||||||
|
<legend>Firmware Info</legend> |
||||||
|
<p> |
||||||
|
Current firmware: <span style="font-weight: bold;" id="current-fw"></span> |
||||||
|
</p> |
||||||
|
<div class="pure-form-stacked"> |
||||||
|
<p> |
||||||
|
Make sure you upload the file called: <span style="font-weight: bold;" id="fw-slot"></span> |
||||||
|
</p> |
||||||
|
<label>Firmware File</label> |
||||||
|
<input type="file" name="fw-file" id="fw-file"/> |
||||||
|
</div> |
||||||
|
<button id="fw-button" type="submit" class="pure-button button-primary"> |
||||||
|
Update the firmware |
||||||
|
</button> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<script src="flash.js"></script> |
||||||
|
<script type="text/javascript"> |
||||||
|
onLoad(function() { |
||||||
|
fetchFlash(); |
||||||
|
bnd($("#fw-form"), "submit", flashFirmware); |
||||||
|
}); |
||||||
|
</script> |
||||||
|
</body></html> |
@ -0,0 +1,33 @@ |
|||||||
|
//===== FLASH cards
|
||||||
|
|
||||||
|
function flashFirmware(e) { |
||||||
|
e.preventDefault(); |
||||||
|
var fw_data = document.getElementById('fw-file').files[0]; |
||||||
|
|
||||||
|
$("#fw-form").setAttribute("hidden", ""); |
||||||
|
$("#fw-spinner").removeAttribute("hidden"); |
||||||
|
showNotification("Firmware is being updated ..."); |
||||||
|
|
||||||
|
ajaxReq("POST", "/flash/upload", function (resp) { |
||||||
|
ajaxReq("GET", "/flash/reboot", function (resp) { |
||||||
|
showNotification("Firmware has been successfully updated!"); |
||||||
|
setTimeout(function(){ window.location.reload()}, 4000); |
||||||
|
|
||||||
|
$("#fw-spinner").setAttribute("hidden", ""); |
||||||
|
$("#fw-form").removeAttribute("hidden"); |
||||||
|
}); |
||||||
|
}, null, fw_data) |
||||||
|
} |
||||||
|
|
||||||
|
function fetchFlash() { |
||||||
|
ajaxReq("GET", "/flash/next", function (resp) { |
||||||
|
$("#fw-slot").innerHTML = resp; |
||||||
|
$("#fw-spinner").setAttribute("hidden", ""); |
||||||
|
$("#fw-form").removeAttribute("hidden"); |
||||||
|
}); |
||||||
|
ajaxJson("GET", "/menu", function(data) { |
||||||
|
var v = $("#current-fw"); |
||||||
|
if (v != null) { v.innerHTML = data.version; } |
||||||
|
} |
||||||
|
); |
||||||
|
} |
Loading…
Reference in new issue