website update version display and ota handler

This commit is contained in:
2026-05-10 16:45:06 +02:00
parent 08ee9018cf
commit e3b7648a3f
4 changed files with 103 additions and 28 deletions

View File

@@ -201,15 +201,22 @@ export class Controller {
}, false);
ajax.addEventListener("load", () => {
controller.progressview.removeProgress("ota_upload")
controller.reboot();
const status = ajax.status;
if (status >= 200 && status < 300) {
controller.reboot();
} else {
const statusText = ajax.statusText || "";
const body = ajax.responseText || "";
toast.error(`OTA update error (${status}${statusText ? ' ' + statusText : ''}): ${body}`);
}
}, false);
ajax.addEventListener("error", () => {
alert("Error ota")
controller.progressview.removeProgress("ota_upload")
toast.error("OTA upload failed due to a network error.");
}, false);
ajax.addEventListener("abort", () => {
alert("abort ota")
controller.progressview.removeProgress("ota_upload")
toast.error("OTA upload was aborted.");
}, false);
ajax.open("POST", PUBLIC_URL + "/ota");
ajax.send(file);
@@ -570,4 +577,4 @@ window.addEventListener("beforeunload", (event) => {
event.returnValue = confirmationMessage; // This will trigger the browser's default dialog
return confirmationMessage;
}
});
});