Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions html/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ <h3>Installed Packages<br></h3>
</div>
</div>

<div class="container pt-5 pb-4 pl-0">
<button id="erase-flash-button" type="button" onclick="eraseFlash()" class="btn btn-primary">Erase Flash</button>
</div>

</div>

Expand Down
29 changes: 29 additions & 0 deletions static/js/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,32 @@ async function setEnvironment() {
function downloadTemperatureCsv() {
window.location.href = "/temperature-csv";
}

async function eraseFlash() {
if (!confirm("Are you sure you want to erase flash? This cannot be undone. Device must stay on for at least 2 minutes.")) {
return;
}
$("#erase-flash-button").attr("disabled", true);
$("#erase-flash-button").html("Erasing Flash...");
try {
const response = await fetch("/api/erase-flash", {
method: "POST",
headers: {
Authorization: "Basic " + btoa("admin:feathers"),
"Content-Type": "application/json",
},
});

if (response.ok) {
alert("Flash erase done.");
} else {
alert("Error erasing flash");
console.error("Error with response:", await response.text());
}
} catch (error) {
alert("Error erasing flash");
console.error("Error erasing flash:", error);
}
$("#erase-flash-button").attr("disabled", false);
$("#erase-flash-button").html("Erase Flash");
}
Loading