about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--uploader/samples/views.py8
-rw-r--r--uploader/static/css/theme.css4
-rw-r--r--uploader/templates/cli-output.html2
-rw-r--r--uploader/templates/samples/sui-base.html8
-rw-r--r--uploader/templates/samples/sui-upload-failure.html32
-rw-r--r--uploader/templates/samples/sui-upload-progress.html26
-rw-r--r--uploader/templates/samples/sui-upload-samples.html153
-rw-r--r--uploader/templates/samples/sui-upload-success.html31
8 files changed, 258 insertions, 6 deletions
diff --git a/uploader/samples/views.py b/uploader/samples/views.py
index fcb895d..93f0c29 100644
--- a/uploader/samples/views.py
+++ b/uploader/samples/views.py
@@ -149,7 +149,7 @@ def upload_samples(species_id: int, population_id: int):#pylint: disable=[too-ma
                         code=307)
 
     if request.method == "GET" or request.files.get("samples_file") is None:
-        return render_template("samples/upload-samples.html",
+        return render_template(sui_template("samples/upload-samples.html"),
                                species=species,
                                population=population)
 
@@ -216,7 +216,7 @@ def upload_status(species: dict, population: dict, job_id: uuid.UUID, **kwargs):
     if job:
         status = job["status"]
         if status == "success":
-            return render_template("samples/upload-success.html",
+            return render_template(sui_template("samples/upload-success.html"),
                                    job=job,
                                    species=species,
                                    population=population,)
@@ -236,7 +236,7 @@ def upload_status(species: dict, population: dict, job_id: uuid.UUID, **kwargs):
                 return redirect(url_for(
                     "samples.upload_failure", job_id=job_id))
 
-        return render_template("samples/upload-progress.html",
+        return render_template(sui_template("samples/upload-progress.html"),
                                species=species,
                                population=population,
                                job=job) # maybe also handle this?
@@ -267,7 +267,7 @@ def upload_failure(species: dict, population: dict, job_id: uuid.UUID, **kwargs)
         if stat.st_size > 0:
             return render_template("worker_failure.html", job_id=job_id)
 
-    return render_template("samples/upload-failure.html",
+    return render_template(sui_template("samples/upload-failure.html"),
                            species=species,
                            population=population,
                            job=job)
diff --git a/uploader/static/css/theme.css b/uploader/static/css/theme.css
index 2acce5f..99b7af3 100644
--- a/uploader/static/css/theme.css
+++ b/uploader/static/css/theme.css
@@ -56,6 +56,10 @@ body {
     text-transform: capitalize;
 }
 
+label {
+    text-transform: Capitalize;
+}
+
 input[type="search"] {
     border-radius: 5px;
 }
diff --git a/uploader/templates/cli-output.html b/uploader/templates/cli-output.html
index 64b1a9a..9cff09d 100644
--- a/uploader/templates/cli-output.html
+++ b/uploader/templates/cli-output.html
@@ -1,7 +1,7 @@
 {%macro cli_output(job, stream)%}
 
 <h4 class="subheading">{{stream | upper}} Output</h4>
-<div class="cli-output" style="max-height: 10em; overflow: auto;">
+<div class="cli-output" style="overflow: auto;">
   <pre>{{job.get(stream, "")}}</pre>
 </div>
 
diff --git a/uploader/templates/samples/sui-base.html b/uploader/templates/samples/sui-base.html
index ee08e2e..8ec7505 100644
--- a/uploader/templates/samples/sui-base.html
+++ b/uploader/templates/samples/sui-base.html
@@ -3,7 +3,13 @@
 
 {%block breadcrumbs%}
 {{super()}}
-<li class="breadcrumb-item">Manage Samples</li>
+<li class="breadcrumb-item">
+  <a href="{{url_for('species.populations.samples.list_samples',
+           species_id=species['SpeciesId'],
+           population_id=population.Id)}}">
+    Samples
+  </a>
+</li>
 {%endblock%}
 
 {%block contents%}
diff --git a/uploader/templates/samples/sui-upload-failure.html b/uploader/templates/samples/sui-upload-failure.html
new file mode 100644
index 0000000..d950c50
--- /dev/null
+++ b/uploader/templates/samples/sui-upload-failure.html
@@ -0,0 +1,32 @@
+{%extends "sui-base.html"%}
+{%from "cli-output.html" import cli_output%}
+
+{%block title%}Samples Upload Failure{%endblock%}
+
+{%block contents%}
+<div class="row">
+<h2 class="heading">{{job.job_name[0:50]}}&hellip;</h2>
+
+<p>There was a failure attempting to upload the samples.</p>
+
+<p>Here is some information to help with debugging the issue. Provide this
+  information to the developer/maintainer.</p>
+
+<h3>Debugging Information</h3>
+<ul>
+  <li><strong>job id</strong>: {{job.jobid}}</li>
+  <li><strong>status</strong>: {{job.status}}</li>
+  <li><strong>job type</strong>: {{job["job-type"]}}</li>
+</ul>
+</div>
+
+<div class="row">
+<h4>stdout</h4>
+{{cli_output(job, "stdout")}}
+</div>
+
+<div class="row">
+<h4>stderr</h4>
+{{cli_output(job, "stderr")}}
+</div>
+{%endblock%}
diff --git a/uploader/templates/samples/sui-upload-progress.html b/uploader/templates/samples/sui-upload-progress.html
new file mode 100644
index 0000000..8412c46
--- /dev/null
+++ b/uploader/templates/samples/sui-upload-progress.html
@@ -0,0 +1,26 @@
+{%extends "samples/sui-base.html"%}
+{%from "cli-output.html" import cli_output%}
+
+{%block extrameta%}
+<meta http-equiv="refresh" content="5">
+{%endblock%}
+
+{%block title%}Job Status{%endblock%}
+
+{%block contents%}
+<div class="row" style="overflow-x: clip;">
+<h2 class="heading">{{job.job_name[0:50]}}&hellip;</h2>
+
+<p>
+<strong>status</strong>:
+<span>{{job["status"]}} ({{job.get("message", "-")}})</span><br />
+</p>
+
+<p>saving to database...</p>
+</div>
+
+<div class="row">
+  {{cli_output(job, "stdout")}}
+</div>
+
+{%endblock%}
diff --git a/uploader/templates/samples/sui-upload-samples.html b/uploader/templates/samples/sui-upload-samples.html
new file mode 100644
index 0000000..83c2061
--- /dev/null
+++ b/uploader/templates/samples/sui-upload-samples.html
@@ -0,0 +1,153 @@
+{%extends "samples/sui-base.html"%}
+{%from "flash_messages.html" import flash_all_messages%}
+
+{%block title%}Samples &mdash; Upload Samples{%endblock%}
+
+{%block breadcrumbs%}
+{{super()}}
+<li class="breadcrumb-item">
+  <a href="{{url_for('species.populations.samples.upload_samples',
+           species_id=species['SpeciesId'],
+           population_id=population.Id)}}">
+    Upload
+  </a>
+</li>
+{%endblock%}
+
+{%block contents%}
+{{flash_all_messages()}}
+
+<div class="row">
+  <form id="form-samples"
+        method="POST"
+        action="{{url_for('species.populations.samples.upload_samples',
+                species_id=species.SpeciesId,
+                population_id=population.InbredSetId)}}"
+        enctype="multipart/form-data">
+    <legend class="heading">upload samples</legend>
+
+    <input type="hidden" name="species_id" value="{{species.SpeciesId}}" />
+    <input type="hidden" name="population_id" value="{{population.Id}}" />
+
+    <div class="form-group">
+      <label for="file-samples" class="form-label">select file</label>
+      <input type="file" name="samples_file" id="file-samples"
+	     accept="text/csv, text/tab-separated-values, text/plain"
+	     class="form-control" />
+      <small class="form-text text-muted">
+        See the <a href="#docs-samples-upload">documentation below</a> for
+        details on expected file format.</small>
+    </div>
+
+    <div class="form-group">
+      <label for="select-separator" class="form-label">field separator</label>
+      <select id="select-separator"
+	      name="separator"
+	      required="required"
+	      class="form-control">
+        <option value="">Select separator for your file: (default is comma)</option>
+        <option value="&#x0009;">TAB</option>
+        <option value="&#x0020;">Space</option>
+        <option value=",">Comma</option>
+        <option value=";">Semicolon</option>
+        <option value="other">Other</option>
+      </select>
+      <input id="txt-separator"
+	     type="text"
+	     name="other_separator"
+	     class="form-control" />
+      <small class="form-text text-muted">
+        If you select '<strong>Other</strong>' for the field separator value,
+        enter the character that separates the fields in your CSV file in the form
+        field below.
+      </small>
+    </div>
+
+    <div class="form-group form-check">
+      <input id="chk-heading"
+	     type="checkbox"
+	     name="first_line_heading"
+	     class="form-check-input" />
+      <label for="chk-heading" class="form-check-label">
+        first line is a heading?</label>
+      <small class="form-text text-muted">
+        Select this if the first line in your file contains headings for the
+        columns.
+      </small>
+    </div>
+
+    <div class="form-group">
+      <label for="txt-delimiter" class="form-label">field delimiter</label>
+      <input id="txt-delimiter"
+	     type="text"
+	     name="field_delimiter"
+	     maxlength="1"
+	     class="form-control" />
+      <small class="form-text text-muted">
+        If there is a character delimiting the string texts within particular
+        fields in your CSV, provide the character here. This can be left blank if
+        no such delimiters exist in your file.
+      </small>
+    </div>
+
+    <button type="submit"
+	    class="btn btn-primary">upload samples file</button>
+  </form>
+</div>
+
+<div class="row">
+  <h3>Preview File Content</h3>
+
+  <table id="tbl:samples-preview" class="table">
+    <caption class="heading">preview content</caption>
+
+    <thead>
+      <tr>
+        <th>Name</th>
+        <th>Name2</th>
+        <th>Symbol</th>
+        <th>Alias</th>
+      </tr>
+    </thead>
+
+    <tbody>
+      <tr id="default-row">
+        <td colspan="4">
+	  Please make some selections in the form above to preview the data.</td>
+      </tr>
+    </tbody>
+  </table>
+</div>
+
+
+
+<div class="row" id="docs-samples-upload">
+  <h3 class="subheading">File Format</h3>
+  <p>
+    Upload a <strong>character-separated value (CSV)</strong> file that contains
+    details about your samples. The CSV file should have the following fields:
+    <dl>
+      <dt>Name</dt>
+      <dd>The primary name/identifier for the sample/individual.</dd>
+
+      <dt>Name2</dt>
+      <dd>A secondary name for the sample. This can simply be the same as
+        <strong>Name</strong> above. This field <strong>MUST</strong> contain a
+        value.</dd>
+
+      <dt>Symbol</dt>
+      <dd>A symbol for the sample. This can be a strain name, e.g. 'BXD60' for
+        species that have strains. This field can be left empty for species like
+        Humans that do not have strains..</dd>
+
+      <dt>Alias</dt>
+      <dd>An alias for the sample. Can be an empty field, or take on the same
+        value as that of the Symbol.</dd>
+    </dl>
+  </p>
+</div>
+{%endblock%}
+
+{%block javascript%}
+<script src="/static/js/upload_samples.js" type="text/javascript"></script>
+{%endblock%}
diff --git a/uploader/templates/samples/sui-upload-success.html b/uploader/templates/samples/sui-upload-success.html
new file mode 100644
index 0000000..054bde8
--- /dev/null
+++ b/uploader/templates/samples/sui-upload-success.html
@@ -0,0 +1,31 @@
+{%extends "samples/sui-base.html"%}
+{%from "cli-output.html" import cli_output%}
+
+{%block title%}Job Status{%endblock%}
+
+{%block contents%}
+
+<div class="row" style="overflow-x: clip;">
+  <h2 class="heading">{{job.job_name[0:50]}}&hellip;</h2>
+
+  <p>
+    <strong>status</strong>:
+    <span>{{job["status"]}} ({{job.get("message", "-")}})</span><br />
+  </p>
+
+  <p>Successfully uploaded the samples.</p>
+  <p>
+    <a href="{{url_for('species.populations.samples.list_samples',
+             species_id=species.SpeciesId,
+             population_id=population.Id)}}"
+       title="View population samples">
+      View samples
+    </a>
+  </p>
+</div>
+
+<div class="row">
+  {{cli_output(job, "stdout")}}
+</div>
+
+{%endblock%}