From 42a75a1f6e38822c570aebce7fe6bac9dafe67b9 Mon Sep 17 00:00:00 2001 From: Mary Salvi Date: Tue, 3 Oct 2023 13:17:36 -0400 Subject: [PATCH] Disable redaction button and add redaction message on submit --- imagedephi/gui.py | 1 + imagedephi/js/redaction.js | 11 +++ imagedephi/redact/redact.py | 5 +- imagedephi/templates/HomePage.html.j2 | 99 +++++++++++++++------------ 4 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 imagedephi/js/redaction.js diff --git a/imagedephi/gui.py b/imagedephi/gui.py index 4d2870cb..982f4b21 100644 --- a/imagedephi/gui.py +++ b/imagedephi/gui.py @@ -67,6 +67,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]: shutdown_event = asyncio.Event() app.mount("/assets", StaticFiles(directory="imagedephi/assets"), name="assets") +app.mount("/js", StaticFiles(directory="imagedephi/js"), name="js") class DirectoryData: diff --git a/imagedephi/js/redaction.js b/imagedephi/js/redaction.js new file mode 100644 index 00000000..71dee49b --- /dev/null +++ b/imagedephi/js/redaction.js @@ -0,0 +1,11 @@ +window.onload = (event) => { + +const redactBanner = document.getElementById("redacting"); +const redactButton = document.getElementById("dephi"); +const redactForm = document.getElementById('redact') +redactForm.addEventListener("submit", () => { + redactButton.setAttribute("disabled", "true") + redactBanner.classList.remove("hidden") +}) + +} diff --git a/imagedephi/redact/redact.py b/imagedephi/redact/redact.py index 5ad66d87..ca97fc01 100644 --- a/imagedephi/redact/redact.py +++ b/imagedephi/redact/redact.py @@ -81,7 +81,10 @@ def redact_images( show_redaction_plan(input_path) with click.progressbar(images_to_redact, label="Redacting Images") as bar: for image_file in bar: - logger.info(f"Redacting {image_file.name}. Image {output_file_counter} of {output_file_max} images") + logger.info( + f"""Redacting {image_file.name}. + Image {output_file_counter} of {output_file_max} images""" + ) if image_file.suffix in FILE_EXTENSION_MAP: redaction_plan = build_redaction_plan(image_file, base_rules, override_rules) if not redaction_plan.is_comprehensive(): diff --git a/imagedephi/templates/HomePage.html.j2 b/imagedephi/templates/HomePage.html.j2 index 99b96902..8c0d9724 100644 --- a/imagedephi/templates/HomePage.html.j2 +++ b/imagedephi/templates/HomePage.html.j2 @@ -67,63 +67,74 @@ ], }, } - - - - -
+ + + + +
- - - -
-
-
-
-
- -
+ + + +
+
+
+
+
+ +
+ {% include "InputStep.html.j2" %} + {% include "OutputStep.html.j2" %} + {% include "RulesetStep.html.j2" %} +
- {% include "InputStep.html.j2" %} - {% include "OutputStep.html.j2" %} - {% include "RulesetStep.html.j2" %} -
-
- - {% include "InputSelectorWidget.html.j2" %} - - {% include "OutputSelectorWidget.html.j2" %} - - {# TODO make into a separate component #} - {% if redacted %} -
-
-
-
-

Redaction Successful

-

- We successfully performed a redaction on the images in {{ - input_directory_data.directory - }}. - The redacted images are now in a new folder created in {{ output_directory_data.directory }} -

+ + {% include "InputSelectorWidget.html.j2" %} + + {% include "OutputSelectorWidget.html.j2" %} + + {# TODO make into a separate component #} + + {% if redacted %} +
+
+
+
+

Redaction Successful

+

+ We successfully performed a redaction on the images in {{ + input_directory_data.directory + }}. + The redacted images are now in a new folder created in {{ output_directory_data.directory }} +

+
+
+
+
+ {% endif %}
- {% endif %} -
- - +