Progress modal for handleExtractZip
This commit is contained in:
@@ -168,6 +168,16 @@ export function handleExtractZipSelected(e) {
|
|||||||
showToast("No zip files selected.");
|
showToast("No zip files selected.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change progress modal text to "Extracting files..."
|
||||||
|
const progressText = document.querySelector("#downloadProgressModal p");
|
||||||
|
if (progressText) {
|
||||||
|
progressText.textContent = "Extracting files...";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the progress modal.
|
||||||
|
document.getElementById("downloadProgressModal").style.display = "block";
|
||||||
|
|
||||||
fetch("extractZip.php", {
|
fetch("extractZip.php", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
@@ -182,6 +192,8 @@ export function handleExtractZipSelected(e) {
|
|||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
// Hide the progress modal once the request has completed.
|
||||||
|
document.getElementById("downloadProgressModal").style.display = "none";
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
let toastMessage = "Zip file(s) extracted successfully!";
|
let toastMessage = "Zip file(s) extracted successfully!";
|
||||||
if (data.extractedFiles && Array.isArray(data.extractedFiles) && data.extractedFiles.length) {
|
if (data.extractedFiles && Array.isArray(data.extractedFiles) && data.extractedFiles.length) {
|
||||||
@@ -194,6 +206,8 @@ export function handleExtractZipSelected(e) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
// Hide the progress modal on error.
|
||||||
|
document.getElementById("downloadProgressModal").style.display = "none";
|
||||||
console.error("Error extracting zip files:", error);
|
console.error("Error extracting zip files:", error);
|
||||||
showToast("Error extracting zip files.");
|
showToast("Error extracting zip files.");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user