feat: webui confirm on exit while uploading (#693)

This commit is contained in:
florinm03
2026-04-25 15:59:23 +02:00
committed by GitHub
parent 30b2979d0a
commit b87f87646a
+11
View File
@@ -106,6 +106,15 @@ let $logoutBtn;
*/ */
let $userName; let $userName;
// manage unload event to prevent leaving with uploads in progress
const beforeUnloadHandler = (event) => {
if (Uploader.queues.length > 0 || Uploader.runnings > 0) {
event.preventDefault();
event.returnValue = '';
return ''; // for some browsers
}
};
// Produce table when window loads // Produce table when window loads
window.addEventListener("DOMContentLoaded", async () => { window.addEventListener("DOMContentLoaded", async () => {
const $indexData = document.getElementById('index-data'); const $indexData = document.getElementById('index-data');
@@ -131,6 +140,8 @@ async function ready() {
$logoutBtn = document.querySelector(".logout-btn"); $logoutBtn = document.querySelector(".logout-btn");
$userName = document.querySelector(".user-name"); $userName = document.querySelector(".user-name");
window.addEventListener('beforeunload', beforeUnloadHandler);
addBreadcrumb(DATA.href, DATA.uri_prefix); addBreadcrumb(DATA.href, DATA.uri_prefix);
if (DATA.kind === "Index") { if (DATA.kind === "Index") {