feat: Polishing the frontend ota. Updated tdds and documentation
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
let status = $state("loading");
|
||||
let errorMsg = $state("");
|
||||
let showRebootConfirm = $state(false);
|
||||
let isRecovering = $state(false);
|
||||
|
||||
let systemInfo = $state({
|
||||
chip: "—",
|
||||
@@ -42,14 +43,17 @@
|
||||
status = "ok";
|
||||
errorMsg = "";
|
||||
} catch (e) {
|
||||
status = "error";
|
||||
errorMsg = e.message || "Connection failed";
|
||||
if (!isRecovering) {
|
||||
status = "error";
|
||||
errorMsg = e.message || "Connection failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function handleReboot() {
|
||||
showRebootConfirm = false;
|
||||
status = "rebooting";
|
||||
isRecovering = true;
|
||||
try {
|
||||
await reboot();
|
||||
} catch (e) {
|
||||
@@ -61,6 +65,25 @@
|
||||
fetchInfo();
|
||||
});
|
||||
|
||||
// Resilient recovery polling: Only poll when we are waiting for a reboot
|
||||
$effect(() => {
|
||||
if (isRecovering) {
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
const info = await getSystemInfo();
|
||||
if (info) {
|
||||
console.log("Device back online! Refreshing UI...");
|
||||
window.location.reload();
|
||||
}
|
||||
} catch (e) {
|
||||
// Still offline or rebooting, just keep waiting
|
||||
console.log("Waiting for device...");
|
||||
}
|
||||
}, 2000);
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
});
|
||||
|
||||
const infoItems = $derived([
|
||||
{ label: "Chip", value: systemInfo.chip, icon: "🔧" },
|
||||
{ label: "Free Heap", value: formatBytes(systemInfo.freeHeap), icon: "💾" },
|
||||
@@ -168,7 +191,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Frontend Info & OTA Section -->
|
||||
<OTAUpdate />
|
||||
<OTAUpdate onReboot={() => (status = "rebooting")} />
|
||||
|
||||
<!-- Reboot Confirmation Modal -->
|
||||
{#if showRebootConfirm}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script>
|
||||
let { onReboot = null } = $props();
|
||||
import { getOTAStatus, uploadOTAFrontend } from "./api.js";
|
||||
|
||||
const IS_DEV = import.meta.env.DEV;
|
||||
@@ -76,6 +77,7 @@
|
||||
clearInterval(progressInterval);
|
||||
uploadProgress = 100;
|
||||
status = "success";
|
||||
if (onReboot) onReboot();
|
||||
} catch (e) {
|
||||
clearInterval(progressInterval);
|
||||
uploadProgress = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"major": 0,
|
||||
"minor": 1,
|
||||
"revision": 4
|
||||
"revision": 7
|
||||
}
|
||||
Reference in New Issue
Block a user