import spinner working

This commit is contained in:
0ceanSlim 2024-08-07 11:54:26 -04:00
parent a2f7f0a5b4
commit 41c7998831
2 changed files with 9 additions and 7 deletions

View File

@ -63,7 +63,7 @@ func ImportEvents(w http.ResponseWriter, r *http.Request) {
renderResult(w, true, "Events imported successfully", totalEvents) renderResult(w, true, "Events imported successfully", totalEvents)
case err := <-errorChan: case err := <-errorChan:
renderResult(w, false, err.Error(), 0) renderResult(w, false, err.Error(), 0)
case <-time.After(5 * time.Minute): case <-time.After(10 * time.Minute): // Increase timeout for large imports
renderResult(w, false, "Timeout importing events", 0) renderResult(w, false, "Timeout importing events", 0)
} }
} }

View File

@ -39,7 +39,7 @@
</button> </button>
</form> </form>
</div> </div>
<div id="spinner" class="spinner"></div> <div id="spinner" class="spinner" style="display: none"></div>
<div id="result" class="p-2 m-2 text-xl font-bold"></div> <div id="result" class="p-2 m-2 text-xl font-bold"></div>
<button <button
hx-get="/" hx-get="/"
@ -56,11 +56,13 @@
document.getElementById("spinner").style.display = "block"; document.getElementById("spinner").style.display = "block";
}); });
document document.addEventListener("htmx:afterRequest", function () {
.getElementById("result") document.getElementById("spinner").style.display = "none";
.addEventListener("htmx:afterRequest", function () { });
document.getElementById("spinner").style.display = "none";
}); document.addEventListener("htmx:requestError", function () {
document.getElementById("spinner").style.display = "none";
});
</script> </script>
</main> </main>
{{end}} {{end}}