Skip to content

Commit

Permalink
Add a placebo "flashing" progress bar for ESP uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
pkendall64 committed Nov 10, 2021
1 parent 9bf46fb commit 6a7b3d7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
41 changes: 30 additions & 11 deletions html/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,30 @@ function uploaded(event) {
var data = JSON.parse(event.data);
if (data.status === 'ok') {
source.close();
cuteAlert({
type: 'success',
title: "Update Succeeded",
message: data.msg
});
function show_message() {
cuteAlert({
type: 'success',
title: "Update Succeeded",
message: data.msg
});
}
if (type_suffix === 'bp') {
// This is basically a delayed display of the success dialog with a fake progress
var percent = 0;
var interval = setInterval(()=>{
percent = percent + 1;
_("progressBar_" + uploading.type).value = percent;
_("status_" + uploading.type).innerHTML = percent + "% flashed... please wait";
if (percent == 100) {
clearInterval(interval);
_("status_" + type_suffix).innerHTML = "";
_("progressBar_" + type_suffix).value = 0;
show_message();
}
}, 100);
} else {
show_message();
}
} else if (data.status === 'cancelled') {
source.close();
cuteAlert({
Expand Down Expand Up @@ -252,9 +271,9 @@ function errorHandler(type_suffix) {
_("status_" + type_suffix).innerHTML = "";
_("progressBar_" + type_suffix).value = 0;
cuteAlert({
type: "error",
title: "Update Failed",
message: event.target.responseText
type: "error",
title: "Update Failed",
message: event.target.responseText
});
}
}
Expand All @@ -264,9 +283,9 @@ function abortHandler(type_suffix) {
_("status_" + type_suffix).innerHTML = "";
_("progressBar_" + type_suffix).value = 0;
cuteAlert({
type: "info",
title: "Update Aborted",
message: event.target.responseText
type: "info",
title: "Update Aborted",
message: event.target.responseText
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/WIFI/devWIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static void flash()
{
String message;
if (updater.end(true)) { //true to set the size to the current progress
DBGLN("Flasd Succeeded: %ubytes\nThe module will be restarted.", totalSize);
DBGLN("Flash Succeeded: %ubytes\nThe module will be restarted.", totalSize);
message = "{\"status\": \"ok\", \"msg\": \"Flashing complete. The module will be restarted.\"}";
updater.finish();
} else {
Expand Down

0 comments on commit 6a7b3d7

Please sign in to comment.