add auto refresh

This commit is contained in:
C4illin 2024-05-25 02:33:24 +02:00
parent d5628dcfab
commit dcf360b7d2
9 changed files with 164 additions and 29 deletions

35
src/public/results.js Normal file
View file

@ -0,0 +1,35 @@
window.downloadAll = function () {
// Get all download links
const downloadLinks = document.querySelectorAll("a[download]");
// Trigger download for each link
downloadLinks.forEach((link, index) => {
// We add a delay for each download to prevent them from starting at the same time
setTimeout(() => {
const event = new MouseEvent("click");
link.dispatchEvent(event);
}, index * 100);
});
};
const jobId = window.location.pathname.split("/").pop();
const main = document.querySelector("main");
const progressElem = document.querySelector("progress");
const refreshData = () => {
console.log("Refreshing data...");
console.log(progressElem.value);
console.log(progressElem.max);
if (progressElem.value !== progressElem.max) {
fetch(`/progress/${jobId}`)
.then((res) => res.text())
.then((html) => {
main.innerHTML = html;
})
.catch((err) => console.log(err));
setTimeout(refreshData, 1000);
}
};
refreshData();