aboutsummaryrefslogtreecommitdiff
path: root/uploader/templates/phenotypes/add-phenotypes-raw-files.html
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/templates/phenotypes/add-phenotypes-raw-files.html')
-rw-r--r--uploader/templates/phenotypes/add-phenotypes-raw-files.html47
1 files changed, 40 insertions, 7 deletions
diff --git a/uploader/templates/phenotypes/add-phenotypes-raw-files.html b/uploader/templates/phenotypes/add-phenotypes-raw-files.html
index 8de67a0..7f8d8b0 100644
--- a/uploader/templates/phenotypes/add-phenotypes-raw-files.html
+++ b/uploader/templates/phenotypes/add-phenotypes-raw-files.html
@@ -564,20 +564,53 @@
};
};
+ var processForm = (form) => {
+ var formdata = new FormData(form);
+ uploaded_files.forEach((msg) => {
+ formdata.delete(msg["file-input-name"]);
+ formdata.append(msg["file-input-name"], JSON.stringify({
+ "uploaded-file": msg["uploaded-file"],
+ "original-name": msg["original-name"]
+ }));
+ });
+ formdata.append("resumable-upload", "true");
+ return formdata;
+ }
+
var uploaded_files = new Set();
var submitForm = (new_file) => {
uploaded_files.add(new_file);
if(uploaded_files.size === resumables.length) {
- //TODO: build up the new form from existing form and uploaded files
- //TODO: submit the form to appropriate endpoint
+ var form = $("#frm-add-phenotypes");
+ if(form.length !== 1) {
+ // TODO: Handle error somehow?
+ alert("Could not find form!!!");
+ return false;
+ }
+
+ $.ajax({
+ "url": form.attr("action"),
+ "type": "POST",
+ "data": processForm(form[0]),
+ "processData": false,
+ "contentType": false,
+ "success": (data, textstatus, jqxhr) => {
+ // TODO: Redirect to endpoint that should come as part of the
+ // success/error message.
+ console.log("SUCCESS DATA: ", data);
+ console.log("SUCCESS STATUS: ", textstatus);
+ console.log("SUCCESS jqXHR: ", jqxhr);
+ window.location.assign(window.location.origin + data["redirect-to"]);
+ },
+ });
+ return false;
}
+ return false;
};
- var uploadSuccess = () => {
+ var uploadSuccess = (file_input_name) => {
return (file, message) => {
- console.log("THE FILE:", file);
- console.log("THE SUCCESS MESSAGE:", message);
- submitForm(file.file.name);
+ submitForm({...JSON.parse(message), "file-input-name": file_input_name});
};
};
@@ -628,7 +661,7 @@
startUpload($("#" + resumable_element_id + "-browse-button"),
$("#" + resumable_element_id + "-retry-button"),
$("#" + resumable_element_id + "-cancel-button"))),
- uploadSuccess()),
+ uploadSuccess(file_input.attr("name"))),
uploadError());
/** Setup progress indicator **/