mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Add cancellation of zipping
This commit is contained in:
parent
ec4eb22a72
commit
f1a2cf7efc
1 changed files with 23 additions and 11 deletions
|
@ -435,7 +435,12 @@ class OutputWaiter {
|
||||||
* Saves all outputs to a single archvie file
|
* Saves all outputs to a single archvie file
|
||||||
*/
|
*/
|
||||||
saveAllClick() {
|
saveAllClick() {
|
||||||
|
const downloadButton = document.getElementById("save-all-to-file");
|
||||||
|
if (downloadButton.firstElementChild.innerHTML === "archive") {
|
||||||
this.downloadAllFiles();
|
this.downloadAllFiles();
|
||||||
|
} else if (window.confirm("Cancel zipping of outputs?")) {
|
||||||
|
this.terminateZipWorker();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -448,6 +453,7 @@ class OutputWaiter {
|
||||||
const inputNums = Object.keys(this.outputs);
|
const inputNums = Object.keys(this.outputs);
|
||||||
for (let i = 0; i < inputNums.length; i++) {
|
for (let i = 0; i < inputNums.length; i++) {
|
||||||
const iNum = inputNums[i];
|
const iNum = inputNums[i];
|
||||||
|
log.error(this.outputs[iNum]);
|
||||||
if (this.outputs[iNum].status !== "baked" ||
|
if (this.outputs[iNum].status !== "baked" ||
|
||||||
this.outputs[iNum].bakeId !== this.manager.worker.bakeId) {
|
this.outputs[iNum].bakeId !== this.manager.worker.bakeId) {
|
||||||
if (window.confirm("Not all outputs have been baked yet. Continue downloading outputs?")) {
|
if (window.confirm("Not all outputs have been baked yet. Continue downloading outputs?")) {
|
||||||
|
@ -458,7 +464,7 @@ class OutputWaiter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileName = window.prompt("Please enter a filename: ", "download.zip");
|
let fileName = window.prompt("Please enter a filename: ", "download.zip");
|
||||||
|
|
||||||
if (fileName === null || fileName === "") {
|
if (fileName === null || fileName === "") {
|
||||||
// Don't zip the files if there isn't a filename
|
// Don't zip the files if there isn't a filename
|
||||||
|
@ -466,6 +472,10 @@ class OutputWaiter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fileName.match(/.zip$/)) {
|
||||||
|
fileName += ".zip";
|
||||||
|
}
|
||||||
|
|
||||||
let fileExt = window.prompt("Please enter a file extension for the files: ", ".txt");
|
let fileExt = window.prompt("Please enter a file extension for the files: ", ".txt");
|
||||||
|
|
||||||
if (fileExt === null) {
|
if (fileExt === null) {
|
||||||
|
@ -479,9 +489,9 @@ class OutputWaiter {
|
||||||
|
|
||||||
const downloadButton = document.getElementById("save-all-to-file");
|
const downloadButton = document.getElementById("save-all-to-file");
|
||||||
|
|
||||||
downloadButton.disabled = true;
|
|
||||||
downloadButton.classList.add("spin");
|
downloadButton.classList.add("spin");
|
||||||
$("[data-toggle='tooltip']").tooltip("hide");
|
downloadButton.title = `Downloading ${inputNums.length} files...`;
|
||||||
|
downloadButton.setAttribute("data-original-title", `Downloading ${inputNums.length} files...`);
|
||||||
|
|
||||||
downloadButton.firstElementChild.innerHTML = "autorenew";
|
downloadButton.firstElementChild.innerHTML = "autorenew";
|
||||||
|
|
||||||
|
@ -506,6 +516,15 @@ class OutputWaiter {
|
||||||
|
|
||||||
this.zipWorker.terminate();
|
this.zipWorker.terminate();
|
||||||
this.zipWorker = null;
|
this.zipWorker = null;
|
||||||
|
|
||||||
|
const downloadButton = document.getElementById("save-all-to-file");
|
||||||
|
|
||||||
|
downloadButton.classList.remove("spin");
|
||||||
|
downloadButton.title = "Save all outputs to a zip file";
|
||||||
|
downloadButton.setAttribute("data-original-title", "Save all outputs to a zip file");
|
||||||
|
|
||||||
|
downloadButton.firstElementChild.innerHTML = "archive";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -529,13 +548,6 @@ class OutputWaiter {
|
||||||
FileSaver.saveAs(file, r.filename, false);
|
FileSaver.saveAs(file, r.filename, false);
|
||||||
|
|
||||||
this.terminateZipWorker();
|
this.terminateZipWorker();
|
||||||
|
|
||||||
const downloadButton = document.getElementById("save-all-to-file");
|
|
||||||
|
|
||||||
downloadButton.disabled = false;
|
|
||||||
downloadButton.classList.remove("spin");
|
|
||||||
|
|
||||||
downloadButton.firstElementChild.innerHTML = "archive";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue