Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webworkflow warn before leaving page during upload #9625

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion supervisor/shared/web_workflow/static/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,17 @@ async function mkdir(e) {
}
}

const beforeUnloadHandler = function(event){
// Recommended
event.preventDefault();

// Included for legacy support, e.g. Chrome/Edge < 119
event.returnValue = true;
}

async function upload(e) {
const upload_path = current_path;
window.addEventListener("beforeunload", beforeUnloadHandler);
set_upload_enabled(false);
let progress = document.querySelector("#progress");
let made_dirs = new Set();
Expand All @@ -213,7 +223,7 @@ async function upload(e) {
made_dirs.add(parent_dir);
}
}
let file_path = new URL("/fs" + current_path + file_name, url_base);
let file_path = new URL("/fs" + upload_path + file_name, url_base);
const response = await fetch(file_path,
{
method: "PUT",
Expand Down Expand Up @@ -242,6 +252,7 @@ async function upload(e) {
files.value = "";
dirs.value = "";
set_upload_enabled(true);
window.removeEventListener("beforeunload", beforeUnloadHandler);
}

async function del(e) {
Expand Down