mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-07-05 21:58:53 +00:00
implemented loading animation during requests
This commit is contained in:
parent
b8b87db0f2
commit
f0204c2477
6 changed files with 178 additions and 53 deletions
|
@ -1,4 +1,4 @@
|
|||
import { writeDataToInput } from "/load-data.js";
|
||||
import { updateConfig } from "/submit.js";
|
||||
|
||||
const form = document.querySelector("form");
|
||||
|
||||
|
@ -9,22 +9,8 @@ form.addEventListener("reset", async (event) => {
|
|||
"Sicher, dass du alle Einstellungen zurücksetzen möchtest?"
|
||||
);
|
||||
if (ok) {
|
||||
reset();
|
||||
}
|
||||
});
|
||||
|
||||
async function reset() {
|
||||
try {
|
||||
const res = await fetch("/config", {
|
||||
updateConfig({
|
||||
method: "DELETE",
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error(`Response status: ${res.status}`);
|
||||
}
|
||||
|
||||
const json = await res.json();
|
||||
writeDataToInput(json);
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue