Skip to content

Commit

Permalink
Adjust config page firmware timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ssemtner committed Jan 3, 2024
1 parent 0e79504 commit ee4c453
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions web/configuration_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,21 +266,20 @@ <h1>Firmware Upload</h1>
result[prefix].setAttribute("class", `alert alert-${color}`)
}

async function doRequest(prefix, endpoint, body) {
async function doRequest(prefix, endpoint, body, timeout) {
setLoading(prefix, true);
setResult(prefix);
setResultStatus(prefix, "secondary");

try {
// TODO reset to /configuration
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 10000);
const timeoutId = setTimeout(() => controller.abort(), timeout * 1000);
const res = await fetch(endpoint, {
method: "POST",
body: body,
signal: controller.signal,
});
clearTimeout(timeout);
clearTimeout(timeoutId);

setLoading(prefix, false);

Expand Down Expand Up @@ -311,7 +310,6 @@ <h1>Firmware Upload</h1>
}

async function getCurrentConfig() {
// TODO change to /status
try {
const res = await fetch("/status");
const json = await res.json();
Expand All @@ -333,16 +331,6 @@ <h1>Firmware Upload</h1>
}
}

async function doFirmwareRequest(data) {
const res = await fetch("/firmware", {
method: "POST",
body: data
});
console.log(res.status)
const text = await res.text()
console.log(text)
}

form.config.addEventListener("submit", (event) => {
event.preventDefault();
const formData = new FormData(event.target);
Expand All @@ -351,13 +339,13 @@ <h1>Firmware Upload</h1>
data.channel = +data.channel;
if (data.mode === "TEAM_ROBOT_RADIO") { delete data.channel; }
else if (data.mode === "TEAM_ACCESS_POINT") { data.wpaKey24 = "placeholder"; }
doRequest("config", "/configuration", JSON.stringify(data));
doRequest("config", "/configuration", JSON.stringify(data), 10);
});

form.firmware.addEventListener("submit", (event) => {
event.preventDefault();
const formData = new FormData(event.target);
doRequest("firmware", "/firmware", formData);
doRequest("firmware", "/firmware", formData, 60);
})

setLoading("config", true);
Expand Down

0 comments on commit ee4c453

Please sign in to comment.