aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-06-13 12:02:36 -0500
committerFrederick Muriuki Muriithi2024-06-13 12:09:40 -0500
commit0a8fdbf4084c064c6839e6283781ede09983e742 (patch)
tree00d3d04b410f6454f42d9a4e2cac9c0770f10be2
parentf726c71bf1636a838f45363d1613763a2926e34f (diff)
downloadgn-uploader-0a8fdbf4084c064c6839e6283781ede09983e742.tar.gz
Clean up landing page
Leave only data upload type selection on landing page.
-rw-r--r--qc_app/entry.py12
-rw-r--r--qc_app/static/js/select_platform.js2
-rw-r--r--qc_app/templates/index.html80
-rw-r--r--qc_app/templates/select_species.html87
4 files changed, 99 insertions, 82 deletions
diff --git a/qc_app/entry.py b/qc_app/entry.py
index 94bbd53..d23a45a 100644
--- a/qc_app/entry.py
+++ b/qc_app/entry.py
@@ -84,20 +84,24 @@ def zip_file_errors(filepath, upload_dir) -> Tuple[str, ...]:
return zfile_errors
-@entrybp.route("/", methods=["GET", "POST"])
+@entrybp.route("/", methods=["GET"])
+def index():
+ """Load the landing page"""
+ return render_template("index.html")
+
+@entrybp.route("/upload", methods=["GET", "POST"])
def upload_file():
"""Enables uploading the files"""
if request.method == "GET":
return render_template(
- "index.html", species=with_db_connection(species))
+ "select_species.html", species=with_db_connection(species))
upload_dir = app.config["UPLOAD_FOLDER"]
request_errors = errors(request)
if request_errors:
for error in request_errors:
flash(error, "alert-error error-expr-data")
- return render_template(
- "index.html", species=with_db_connection(species)), 400
+ return redirect(url_for("entry.upload_file"))
filename = secure_filename(request.files["qc_text_file"].filename)
if not os.path.exists(upload_dir):
diff --git a/qc_app/static/js/select_platform.js b/qc_app/static/js/select_platform.js
index 456cfcf..4fdd865 100644
--- a/qc_app/static/js/select_platform.js
+++ b/qc_app/static/js/select_platform.js
@@ -12,7 +12,7 @@ function radio_column(chip) {
function setup_genechips(genechip_data) {
columns = ["GeneChipId", "GeneChipName"]
submit_button = document.querySelector(
- "#select-platform-form input[type='submit']");
+ "#select-platform-form button[type='submit']");
elt = document.getElementById(
"genechips-table").getElementsByTagName("tbody")[0];
remove_children(elt);
diff --git a/qc_app/templates/index.html b/qc_app/templates/index.html
index 0d301f5..997c1e5 100644
--- a/qc_app/templates/index.html
+++ b/qc_app/templates/index.html
@@ -60,59 +60,9 @@
</ol>
</div>
- <form action="{{url_for('entry.upload_file')}}"
- method="POST"
- enctype="multipart/form-data"
- id="frm-upload-expression-data">
- <legend class="heading">upload expression data</legend>
- {{flash_messages("error-expr-data")}}
-
- <div class="form-group">
- <label for="select_species01" class="form-label">Species</label>
- <select id="select_species01"
- name="speciesid"
- required="required"
- class="form-control">
- <option value="">Select species</option>
- {%for aspecies in species%}
- <option value="{{aspecies.SpeciesId}}">{{aspecies.MenuName}}</option>
- {%endfor%}
- </select>
- </div>
-
- <div class="form-group">
- <legend class="heading">file type</legend>
-
- <div class="form-check">
- <input type="radio" name="filetype" value="average" id="filetype_average"
- required="required" class="form-check-input" />
- <label for="filetype_average" class="form-check-label">average</label>
- </div>
-
- <div class="form-check">
- <input type="radio" name="filetype" value="standard-error"
- id="filetype_standard_error" required="required"
- class="form-check-input" />
- <label for="filetype_standard_error" class="form-check-label">
- standard error
- </label>
- </div>
- </div>
-
- <div class="form-group">
- <span id="no-file-error" class="alert-danger" style="display: none;">
- No file selected
- </span>
- <label for="file_upload" class="form-label">select file</label>
- <input type="file" name="qc_text_file" id="file_upload"
- accept="text/plain, text/tab-separated-values, application/zip"
- class="form-control"/>
- </div>
-
- <button type="submit" class="btn btn-primary" />upload file</button>
-</form>
-
-{{upload_progress_indicator()}}
+ <a href={{url_for("entry.upload_file")}}
+ title="Upload your expression data"
+ class="btn btn-primary">upload Samples/Cases</a>
</div>
<div class="row">
@@ -131,27 +81,3 @@
</div>
{%endblock%}
-
-
-{%block javascript%}
-<script type="text/javascript" src="static/js/upload_progress.js"></script>
-<script type="text/javascript">
- function setup_formdata(form) {
- var formdata = new FormData();
- formdata.append(
- "speciesid",
- form.querySelector("#select_species01").value)
- formdata.append(
- "qc_text_file",
- form.querySelector("input[type='file']").files[0]);
- formdata.append(
- "filetype",
- selected_filetype(
- Array.from(form.querySelectorAll("input[type='radio']"))));
- return formdata;
- }
-
- setup_upload_handlers(
- "frm-upload-expression-data", make_data_uploader(setup_formdata));
-</script>
-{%endblock%}
diff --git a/qc_app/templates/select_species.html b/qc_app/templates/select_species.html
new file mode 100644
index 0000000..30f99b4
--- /dev/null
+++ b/qc_app/templates/select_species.html
@@ -0,0 +1,87 @@
+{%extends "base.html"%}
+{%from "flash_messages.html" import flash_messages%}
+{%from "upload_progress_indicator.html" import upload_progress_indicator%}
+
+{%block title%}Data Upload{%endblock%}
+
+{%block contents%}
+<div class="row">
+ <form action="{{url_for('entry.upload_file')}}"
+ method="POST"
+ enctype="multipart/form-data"
+ id="frm-upload-expression-data">
+ <legend class="heading">upload expression data</legend>
+ {{flash_messages("error-expr-data")}}
+
+ <div class="form-group">
+ <label for="select_species01" class="form-label">Species</label>
+ <select id="select_species01"
+ name="speciesid"
+ required="required"
+ class="form-control">
+ <option value="">Select species</option>
+ {%for aspecies in species%}
+ <option value="{{aspecies.SpeciesId}}">{{aspecies.MenuName}}</option>
+ {%endfor%}
+ </select>
+ </div>
+
+ <div class="form-group">
+ <legend class="heading">file type</legend>
+
+ <div class="form-check">
+ <input type="radio" name="filetype" value="average" id="filetype_average"
+ required="required" class="form-check-input" />
+ <label for="filetype_average" class="form-check-label">average</label>
+ </div>
+
+ <div class="form-check">
+ <input type="radio" name="filetype" value="standard-error"
+ id="filetype_standard_error" required="required"
+ class="form-check-input" />
+ <label for="filetype_standard_error" class="form-check-label">
+ standard error
+ </label>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <span id="no-file-error" class="alert-danger" style="display: none;">
+ No file selected
+ </span>
+ <label for="file_upload" class="form-label">select file</label>
+ <input type="file" name="qc_text_file" id="file_upload"
+ accept="text/plain, text/tab-separated-values, application/zip"
+ class="form-control"/>
+ </div>
+
+ <button type="submit" class="btn btn-primary">upload file</button>
+ </form>
+
+ {{upload_progress_indicator()}}
+</div>
+{%endblock%}
+
+
+{%block javascript%}
+<script type="text/javascript" src="static/js/upload_progress.js"></script>
+<script type="text/javascript">
+ function setup_formdata(form) {
+ var formdata = new FormData();
+ formdata.append(
+ "speciesid",
+ form.querySelector("#select_species01").value)
+ formdata.append(
+ "qc_text_file",
+ form.querySelector("input[type='file']").files[0]);
+ formdata.append(
+ "filetype",
+ selected_filetype(
+ Array.from(form.querySelectorAll("input[type='radio']"))));
+ return formdata;
+ }
+
+ setup_upload_handlers(
+ "frm-upload-expression-data", make_data_uploader(setup_formdata));
+</script>
+{%endblock%}