aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-11-16 04:51:14 +0300
committerFrederick Muriuki Muriithi2022-11-16 04:51:14 +0300
commit6377ed8375b7a9cd05c7cb4c5d97fd2e4599b680 (patch)
tree5a7f46bc931326961d2242cd2065c68a5c098613
parentee5c11fb5146ac1b18aa24ec4dd7a43aaf35033a (diff)
downloadgn-uploader-6377ed8375b7a9cd05c7cb4c5d97fd2e4599b680.tar.gz
ui: Don't show upload progress indicator if file is not selected.
-rw-r--r--qc_app/static/css/styles.css4
-rw-r--r--qc_app/static/js/upload_progress.js16
2 files changed, 14 insertions, 6 deletions
diff --git a/qc_app/static/css/styles.css b/qc_app/static/css/styles.css
index d20c1fb..d2071e6 100644
--- a/qc_app/static/css/styles.css
+++ b/qc_app/static/css/styles.css
@@ -128,6 +128,10 @@ input[disabled="true"],input[disabled="disabled"] {
background-color: #A9A9A9;
}
+.invalid-input{
+ background-color: #F8D7DA;
+}
+
form legend {
padding-left: 3em;
text-transform: capitalize;
diff --git a/qc_app/static/js/upload_progress.js b/qc_app/static/js/upload_progress.js
index d615be4..fdcbe68 100644
--- a/qc_app/static/js/upload_progress.js
+++ b/qc_app/static/js/upload_progress.js
@@ -69,16 +69,20 @@ function upload_data(event) {
event.preventDefault();
var pindicator = document.getElementById("progress-indicator");
- pindicator.setAttribute("class", "modal");
- var form = document.getElementsByTagName("form")[0]
+ var form = document.getElementsByTagName("form")[0];
+ var the_file = form.querySelector("input[type='file']").files[0];
+ if(the_file === undefined) {
+ form.querySelector("#file_upload").parentElement.setAttribute(
+ "class", "invalid-input");
+ return false;
+ }
+ pindicator.setAttribute("class", "modal");
var formdata = setup_formdata(form);
- document.getElementById("progress-filename").innerHTML = (
- form.querySelector("input[type='file']").files[0].name);
+ document.getElementById("progress-filename").innerHTML = the_file.name;
var request = setup_request(
- form.querySelector("input[type='file']").files[0],
- document.getElementById("progress-indicator"));
+ the_file, document.getElementById("progress-indicator"));
request.open(form.getAttribute("method"), form.getAttribute("action"));
request.send(formdata);
return false;