This commit is contained in:
2026-07-25 14:51:48 -05:00
parent 1ea21c065e
commit 69cc236635
18 changed files with 770 additions and 106 deletions
+32
View File
@@ -14,3 +14,35 @@ document.addEventListener("click", async (event) => {
button.textContent = "Copy failed";
}
});
document.addEventListener("submit", async (event) => {
const form = event.target.closest("[data-upload-form]");
if (!form) return;
event.preventDefault();
const button = form.querySelector("button[type=submit]");
const status = form.querySelector("[data-upload-status]");
const csrfToken = form.querySelector('input[name="csrf_token"]').value;
button.disabled = true;
status.textContent = "Uploading package… keep this page open.";
try {
const response = await fetch(form.action, {
method: "POST",
body: new FormData(form),
headers: {"X-CSRF-Token": csrfToken},
credentials: "same-origin",
});
const result = await response.json().catch(() => ({}));
if (!response.ok) {
throw new Error(result.error || `Upload failed with HTTP ${response.status}`);
}
status.textContent = `Uploaded ${result.filename}; SHA-256 ${result.sha256}`;
window.setTimeout(() => {
window.location.assign("/portal?notice=Package+uploaded+and+registered");
}, 900);
} catch (error) {
status.textContent = error.message;
button.disabled = false;
}
});