diff options
author | Frederick Muriuki Muriithi | 2025-01-15 16:56:26 -0600 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-01-15 16:56:26 -0600 |
commit | eabd73ccb930d19cdb29fb6677e0cde0490f36ad (patch) | |
tree | 40b46f7216a94345a70f321a57b54f14c618dfcc /uploader/templates/phenotypes | |
parent | 7f3adf39e586f970cc2d9aebec50f5461a923e81 (diff) | |
download | gn-uploader-eabd73ccb930d19cdb29fb6677e0cde0490f36ad.tar.gz |
Check that all files are provided and there're no duplicates.
Diffstat (limited to 'uploader/templates/phenotypes')
-rw-r--r-- | uploader/templates/phenotypes/add-phenotypes-raw-files.html | 36 |
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"); |