aboutsummaryrefslogtreecommitdiff
path: root/uploader/templates/phenotypes/add-phenotypes-raw-files.html
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-01-06 13:11:01 -0600
committerFrederick Muriuki Muriithi2025-01-06 13:11:01 -0600
commit32c18631c0e5a49c7b368eb349ea2dabc9c7150f (patch)
tree6e5d9d82b3663c13965e175cd845f0cda4b8d291 /uploader/templates/phenotypes/add-phenotypes-raw-files.html
parent11d0a651a44d886a65aa99127e595780031c8028 (diff)
downloadgn-uploader-32c18631c0e5a49c7b368eb349ea2dabc9c7150f.tar.gz
Generalise creation of resumable objects.
Diffstat (limited to 'uploader/templates/phenotypes/add-phenotypes-raw-files.html')
-rw-r--r--uploader/templates/phenotypes/add-phenotypes-raw-files.html78
1 files changed, 43 insertions, 35 deletions
diff --git a/uploader/templates/phenotypes/add-phenotypes-raw-files.html b/uploader/templates/phenotypes/add-phenotypes-raw-files.html
index e283726..8d29823 100644
--- a/uploader/templates/phenotypes/add-phenotypes-raw-files.html
+++ b/uploader/templates/phenotypes/add-phenotypes-raw-files.html
@@ -548,42 +548,50 @@
};
- var r = errorHandler(
- fileSuccessHandler(
- uploadStartHandler(
- filesAddedHandler(
- markResumableDragAndDropElement(
- makeResumableElement(
- $("#frm-add-phenotypes").attr("data-resumable-target"),
- $("#finput-phenotype-descriptions").parent(),
- $("#resumable-phenotype-descriptions"),
- $("#frm-add-phenotypes input[type=submit]"),
- ["csv", "tsv"]),
- $("#finput-phenotype-descriptions").parent(),
- $("#resumable-phenotype-descriptions"),
- $("#resumable-phenotype-descriptions-browse-button")),
- (files) => {
- // TODO: Also trigger preview!
- resumableDisplayFiles(
- $("#resumable-phenotype-descriptions-selected-files"), files);
- files.forEach((file) => {
- readFirstNLines(
- file.file,
- 10,
- [makePreviewUpdater(
- $("#tbl-preview-pheno-desc"))])
- });
- }),
- startUpload($("#resumable-phenotype-descriptions-browse-button"),
- $("#resumable-phenotype-descriptions-retry-button"),
- $("#resumable-phenotype-descriptions-cancel-button"))),
- uploadSuccess()),
- uploadError());
-
- progressHandler(
- r,
- indicateProgress(r, $("#resumable-phenotype-descriptions-progress-bar")));
+ var makeResumableObject = (form_id, file_input_id, resumable_element_id, preview_table_id) => {
+ var the_form = $("#" + form_id);
+ var file_input = $("#" + file_input_id);
+ var submit_button = the_form.find("input[type=submit]");
+ var r = errorHandler(
+ fileSuccessHandler(
+ uploadStartHandler(
+ filesAddedHandler(
+ markResumableDragAndDropElement(
+ makeResumableElement(
+ the_form.attr("data-resumable-target"),
+ file_input.parent(),
+ $("#" + resumable_element_id),
+ submit_button,
+ ["csv", "tsv"]),
+ file_input.parent(),
+ $("#" + resumable_element_id),
+ $("#" + resumable_element_id + "-browse-button")),
+ (files) => {
+ // TODO: Also trigger preview!
+ resumableDisplayFiles(
+ $("#" + resumable_element_id + "-selected-files"), files);
+ files.forEach((file) => {
+ readFirstNLines(
+ file.file,
+ 10,
+ [makePreviewUpdater(
+ $("#" + preview_table_id))])
+ });
+ }),
+ startUpload($("#" + resumable_element_id + "-browse-button"),
+ $("#" + resumable_element_id + "-retry-button"),
+ $("#" + resumable_element_id + "-cancel-button"))),
+ uploadSuccess()),
+ uploadError());
+
+ /** Setup progress indicator **/
+ progressHandler(
+ r,
+ indicateProgress(r, $("#" + resumable_element_id + "-progress-bar")));
+
+ return r;
+ };
$("#frm-add-phenotypes input[type=submit]").on("click", (event) => {
event.preventDefault();