aboutsummaryrefslogtreecommitdiff
path: root/uploader/templates
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-01-15 16:56:26 -0600
committerFrederick Muriuki Muriithi2025-01-15 16:56:26 -0600
commiteabd73ccb930d19cdb29fb6677e0cde0490f36ad (patch)
tree40b46f7216a94345a70f321a57b54f14c618dfcc /uploader/templates
parent7f3adf39e586f970cc2d9aebec50f5461a923e81 (diff)
downloadgn-uploader-eabd73ccb930d19cdb29fb6677e0cde0490f36ad.tar.gz
Check that all files are provided and there're no duplicates.
Diffstat (limited to 'uploader/templates')
-rw-r--r--uploader/templates/phenotypes/add-phenotypes-raw-files.html36
1 files changed, 36 insertions, 0 deletions
diff --git a/uploader/templates/phenotypes/add-phenotypes-raw-files.html b/uploader/templates/phenotypes/add-phenotypes-raw-files.html
index cb857ac..15c2da8 100644
--- a/uploader/templates/phenotypes/add-phenotypes-raw-files.html
+++ b/uploader/templates/phenotypes/add-phenotypes-raw-files.html
@@ -643,6 +643,42 @@
event.preventDefault();
// TODO: Check all the relevant files exist
// TODO: Verify that files are not duplicated
+ var filenames = [];
+ var nondupfiles = [];
+ resumables.forEach((r) => {
+ var fname = r.files[0].file.name;
+ filenames.push(fname);
+ if(!nondupfiles.includes(fname)) {
+ nondupfiles.push(fname);
+ }
+ });
+
+ // Check that all files were provided
+ if(resumables.length !== filenames.length) {
+ window.alert("You MUST provide all the files requested.");
+ event.target.removeAttribute("disabled");
+ return false;
+ }
+
+ // Check that there are no duplicate files
+ var duplicates = Object.entries(filenames.reduce(
+ (acc, curr, idx, arr) => {
+ acc[curr] = (acc[curr] || 0) + 1;
+ return acc;
+ },
+ {})).filter((entry) => {return entry[1] !== 1;});
+ if(duplicates.length > 0) {
+ var msg = "The file(s):\r\n";
+ msg = msg + duplicates.reduce(
+ (msgstr, afile) => {
+ return msgstr + " • " + afile[0] + "\r\n";
+ },
+ "");
+ msg = msg + "is(are) duplicated. Please fix and try again.";
+ window.alert(msg);
+ event.target.removeAttribute("disabled");
+ return false;
+ }
// TODO: Check all fields
// Start the uploads.
event.target.setAttribute("disabled", "disabled");