aboutsummaryrefslogtreecommitdiff
path: root/qc_app/static/js/upload_progress.js
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 /qc_app/static/js/upload_progress.js
parentee5c11fb5146ac1b18aa24ec4dd7a43aaf35033a (diff)
downloadgn-uploader-6377ed8375b7a9cd05c7cb4c5d97fd2e4599b680.tar.gz
ui: Don't show upload progress indicator if file is not selected.
Diffstat (limited to 'qc_app/static/js/upload_progress.js')
-rw-r--r--qc_app/static/js/upload_progress.js16
1 files changed, 10 insertions, 6 deletions
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;