aboutsummaryrefslogtreecommitdiff
path: root/uploader/templates/samples
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-09 14:06:31 -0500
committerFrederick Muriuki Muriithi2024-09-09 16:41:46 -0500
commit9cd33ddac3d6848c5443962d66494635feadef51 (patch)
tree385a559380f4d6a961fefb38ad410ad9ca27b052 /uploader/templates/samples
parent707c715d1e336ee45bdcced031881ed603b9297a (diff)
downloadgn-uploader-9cd33ddac3d6848c5443962d66494635feadef51.tar.gz
Initialise samples uploads
* Move existing code to new module * Rework the UI: create new templates * Rework the routes: Select species and populations before attempting an upload.
Diffstat (limited to 'uploader/templates/samples')
-rw-r--r--uploader/templates/samples/base.html12
-rw-r--r--uploader/templates/samples/index.html21
-rw-r--r--uploader/templates/samples/list-samples.html114
-rw-r--r--uploader/templates/samples/select-population.html117
-rw-r--r--uploader/templates/samples/select-species.html30
-rw-r--r--uploader/templates/samples/upload-failure.html27
-rw-r--r--uploader/templates/samples/upload-progress.html22
-rw-r--r--uploader/templates/samples/upload-samples.html139
-rw-r--r--uploader/templates/samples/upload-success.html18
9 files changed, 173 insertions, 327 deletions
diff --git a/uploader/templates/samples/base.html b/uploader/templates/samples/base.html
new file mode 100644
index 0000000..291782b
--- /dev/null
+++ b/uploader/templates/samples/base.html
@@ -0,0 +1,12 @@
+{%extends "populations/base.html"%}
+
+{%block lvl3_breadcrumbs%}
+<li {%if activelink=="samples"%}
+ class="breadcrumb-item active"
+ {%else%}
+ class="breadcrumb-item"
+ {%endif%}>
+ <a href="{{url_for('species.populations.samples.index')}}">Samples</a>
+</li>
+{%block lvl4_breadcrumbs%}{%endblock%}
+{%endblock%}
diff --git a/uploader/templates/samples/index.html b/uploader/templates/samples/index.html
new file mode 100644
index 0000000..7c88c01
--- /dev/null
+++ b/uploader/templates/samples/index.html
@@ -0,0 +1,21 @@
+{%extends "samples/base.html"%}
+{%from "flash_messages.html" import flash_all_messages%}
+{%from "species/macro-select-species.html" import select_species_form%}
+
+{%block title%}Populations{%endblock%}
+
+{%block pagetitle%}Populations{%endblock%}
+
+
+{%block contents%}
+{{flash_all_messages()}}
+
+<div class="row">
+ <p>Here, you can upload the samples/individuals that were used in your
+ experiments.</p>
+ <p>Since the samples are linked to specific species and populations, we will
+ need to first select them in the next few steps.</p>
+
+ {{select_species_form(url_for("species.populations.samples.index"), species)}}
+</div>
+{%endblock%}
diff --git a/uploader/templates/samples/list-samples.html b/uploader/templates/samples/list-samples.html
new file mode 100644
index 0000000..a29dc1c
--- /dev/null
+++ b/uploader/templates/samples/list-samples.html
@@ -0,0 +1,114 @@
+{%extends "samples/base.html"%}
+{%from "flash_messages.html" import flash_all_messages%}
+{%from "populations/macro-select-population.html" import select_population_form%}
+{%from "populations/macro-display-population-card.html" import display_population_card%}
+
+{%block title%}Samples &mdash; List Samples{%endblock%}
+
+{%block pagetitle%}Samples &mdash; List Samples{%endblock%}
+
+{%block lvl4_breadcrumbs%}
+<li {%if activelink=="list-samples"%}
+ class="breadcrumb-item active"
+ {%else%}
+ class="breadcrumb-item"
+ {%endif%}>
+ <a href="{{url_for('species.populations.samples.list_samples',
+ species_id=species.SpeciesId,
+ population_id=population.Id)}}">List</a>
+</li>
+{%endblock%}
+
+{%block contents%}
+{{flash_all_messages()}}
+
+<div class="row">
+ <p>
+ Samples for population "{{population.FullName}}" from the
+ "{{species.FullName}}" species.
+ </p>
+
+ {%if samples | length > 0%}
+ <div class="row">
+ <div class="col-md-2">
+ {%if offset > 0:%}
+ <a href="{{url_for('species.populations.samples.list_samples',
+ species_id=species.SpeciesId,
+ population_id=population.Id,
+ from=offset-count,
+ count=count)}}">
+ <span class="glyphicon glyphicon-backward"></span>
+ Previous
+ </a>
+ {%endif%}
+ </div>
+
+ <div class="col-md-8" style="text-align: center;">
+ Samples {{offset}} &mdash; {{offset+(count if offset + count < total_samples else total_samples - offset)}} / {{total_samples}}
+ </div>
+
+ <div class="col-md-2">
+ {%if offset + count < total_samples:%}
+ <a href="{{url_for('species.populations.samples.list_samples',
+ species_id=species.SpeciesId,
+ population_id=population.Id,
+ from=offset+count,
+ count=count)}}">
+ Next
+ <span class="glyphicon glyphicon-forward"></span>
+ </a>
+ {%endif%}
+ </div>
+ </div>
+ <table class="table">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Auxilliary Name</th>
+ <th>Symbol</th>
+ <th>Alias</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {%for sample in samples%}
+ <tr>
+ <td>{{sample.Name}}</td>
+ <td>{{sample.Name2}}</td>
+ <td>{{sample.Symbol or "-"}}</td>
+ <td>{{sample.Alias or "-"}}</td>
+ </tr>
+ {%endfor%}
+ </tbody>
+ </table>
+
+ <p>
+ <a href="#"
+ title="Add samples for population '{{population.FullName}}' from species
+ '{{species.FullName}}'."
+ class="btn btn-danger">
+ delete all samples
+ </a>
+ </p>
+ {%else%}
+ <p class="text-danger">
+ <span class="glyphicon glyphicon-exclamation-sign"></span>
+ There are no samples for this population at this time.
+ </p>
+
+ <p>
+ <a href="#"
+ title="Add samples for population '{{population.FullName}}' from species
+ '{{species.FullName}}'."
+ class="btn btn-primary">
+ add samples
+ </a>
+ </p>
+ {%endif%}
+</div>
+{%endblock%}
+
+{%block sidebarcontents%}
+{{display_population_card(species, population)}}
+{%endblock%}
+
diff --git a/uploader/templates/samples/select-population.html b/uploader/templates/samples/select-population.html
index da19ddc..8e22ac1 100644
--- a/uploader/templates/samples/select-population.html
+++ b/uploader/templates/samples/select-population.html
@@ -1,99 +1,34 @@
-{%extends "base.html"%}
-{%from "flash_messages.html" import flash_messages%}
+{%extends "samples/base.html"%}
+{%from "flash_messages.html" import flash_all_messages%}
+{%from "populations/macro-select-population.html" import select_population_form%}
+{%from "species/macro-display-species-card.html" import display_species_card%}
-{%block title%}Select Grouping/Population{%endblock%}
+{%block title%}Samples &mdash; Select Population{%endblock%}
-{%block contents%}
-<h1 class="heading">Select grouping/population</h1>
-
-<div>
- <p>We organise the samples/cases/strains in a hierarchichal form, starting
- with <strong>species</strong> at the very top. Under species, we have a
- grouping in terms of the relevant population
- (e.g. Inbred populations, cell tissue, etc.)</p>
-</div>
-
-<form method="POST" action="{{url_for('samples.select_population',
- species_id=species.SpeciesId)}}">
- <legend class="heading">select grouping/population</legend>
- {{flash_messages("error-select-population")}}
-
- <input type="hidden" name="species_id" value="{{species.SpeciesId}}" />
-
- <div class="form-group">
- <label for="select:inbredset" class="form-label">grouping/population</label>
- <select id="select:inbredset"
- name="inbredset_id"
- required="required"
- class="form-control">
- <option value="">Select a grouping/population</option>
- {%for pop in populations%}
- <option value="{{pop.InbredSetId}}">
- {{pop.InbredSetName}} ({{pop.FullName}})</option>
- {%endfor%}
- </select>
- </div>
-
- <button type="submit" class="btn btn-primary">select population</button>
-</form>
-
-<p style="color:#FE3535; padding-left:20em; font-weight:bolder;">OR</p>
-
-<form method="POST" action="{{url_for('samples.create_population',
- species_id=species.SpeciesId)}}">
- <legend class="heading">create new grouping/population</legend>
- {{flash_messages("error-create-population")}}
+{%block pagetitle%}Samples &mdash; Select Population{%endblock%}
- <input type="hidden" name="species_id" value="{{species.SpeciesId}}" />
- <div class="form-group">
- <legend>mandatory</legend>
- <label for="txt:inbredset-name" class="form-label">name</label>
- <input id="txt:inbredset-name"
- name="inbredset_name"
- type="text"
- required="required"
- placeholder="Enter grouping/population name"
- class="form-control" />
-
- <label for="txt:" class="form-label">full name</label>
- <input id="txt:inbredset-fullname"
- name="inbredset_fullname"
- type="text"
- required = "required"
- placeholder="Enter the grouping/population's full name"
- class="form-control" />
- </div>
- <div class="form-group">
- <legend>Optional</legend>
-
- <label for="num:public" class="form-label">public?</label>
- <input id="num:public"
- name="public"
- type="number"
- min="0" max="2" value="2"
- class="form-control" />
-
- <label for="txt:inbredset-family" class="form-label">family</label>
- <input id="txt:inbredset-family"
- name="inbredset_family"
- type="text"
- placeholder="I am not sure what this is about."
- class="form-control" />
-
- <label for="txtarea:" class="form-label">Description</label>
- <textarea id="txtarea:description"
- name="description"
- rows="5"
- placeholder="Enter a description of this grouping/population"
- class="form-control"></textarea>
- </div>
-
- <button type="submit" class="btn btn-primary">create grouping/population</button>
-</form>
+{%block contents%}
+{{flash_all_messages()}}
+<div class="row">
+ <p>Select the population to use with your samples:</p>
+ {{select_population_form(
+ url_for("species.populations.samples.select_population", species_id=species.SpeciesId),
+ populations)}}
+</div>
+<div class="row">
+ <p><strong>Cannot find your population in the list?</strong></p>
+
+ <p>If you cannot find the population you want in the drop-down above, you can
+ instead,
+ <a href="{{url_for('species.populations.create_population',
+ species_id=species.SpeciesId)}}"
+ title="Create a new population for species '{{species.FullName}},">
+ create a new population</a>.
+</div>
{%endblock%}
-
-{%block javascript%}
+{%block sidebarcontents%}
+{{display_species_card(species)}}
{%endblock%}
diff --git a/uploader/templates/samples/select-species.html b/uploader/templates/samples/select-species.html
deleted file mode 100644
index aa64ecf..0000000
--- a/uploader/templates/samples/select-species.html
+++ /dev/null
@@ -1,30 +0,0 @@
-{%extends "base.html"%}
-{%from "flash_messages.html" import flash_all_messages%}
-
-{%block title%}Select Grouping/Population{%endblock%}
-
-{%block contents%}
-<h2 class="heading">upload samples/cases</h2>
-
-<p>We need to know what species your data belongs to.</p>
-
-{{flash_all_messages()}}
-
-<form method="POST" action="{{url_for('expression-data.samples.select_species')}}">
- <legend class="heading">upload samples</legend>
- <div class="form-group">
- <label for="select_species02" class="form-label">Species</label>
- <select id="select_species02"
- name="species_id"
- required="required"
- class="form-control">
- <option value="">Select species</option>
- {%for spec in species%}
- <option value="{{spec.SpeciesId}}">{{spec.MenuName}}</option>
- {%endfor%}
- </select>
- </div>
-
- <button type="submit" class="btn btn-primary">submit</button>
-</form>
-{%endblock%}
diff --git a/uploader/templates/samples/upload-failure.html b/uploader/templates/samples/upload-failure.html
deleted file mode 100644
index 09e2ecf..0000000
--- a/uploader/templates/samples/upload-failure.html
+++ /dev/null
@@ -1,27 +0,0 @@
-{%extends "base.html"%}
-{%from "cli-output.html" import cli_output%}
-
-{%block title%}Samples Upload Failure{%endblock%}
-
-{%block contents%}
-<h1 class="heading">{{job.job_name}}</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.job_id}}</li>
- <li><strong>status</strong>: {{job.status}}</li>
- <li><strong>job type</strong>: {{job["job-type"]}}</li>
-</ul>
-
-<h4>stdout</h4>
-{{cli_output(job, "stdout")}}
-
-<h4>stderr</h4>
-{{cli_output(job, "stderr")}}
-
-{%endblock%}
diff --git a/uploader/templates/samples/upload-progress.html b/uploader/templates/samples/upload-progress.html
deleted file mode 100644
index 7bb02be..0000000
--- a/uploader/templates/samples/upload-progress.html
+++ /dev/null
@@ -1,22 +0,0 @@
-{%extends "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%}
-<h1 class="heading">{{job.job_name}}</h2>
-
-<p>
-<strong>status</strong>:
-<span>{{job["status"]}} ({{job.get("message", "-")}})</span><br />
-</p>
-
-<p>saving to database...</p>
-
-{{cli_output(job, "stdout")}}
-
-{%endblock%}
diff --git a/uploader/templates/samples/upload-samples.html b/uploader/templates/samples/upload-samples.html
deleted file mode 100644
index e62de57..0000000
--- a/uploader/templates/samples/upload-samples.html
+++ /dev/null
@@ -1,139 +0,0 @@
-{%extends "base.html"%}
-{%from "flash_messages.html" import flash_messages%}
-
-{%block title%}Upload Samples{%endblock%}
-
-{%block css%}{%endblock%}
-
-{%block contents%}
-<h1 class="heading">upload samples</h1>
-
-{{flash_messages("alert-success")}}
-
-<p>You can now upload a character-separated value (CSV) file that contains
- details about your samples. The CSV file should have the following fields:
- <dl>
- <dt>Name</dt>
- <dd>The primary name for the sample</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. Can be an empty field.</dd>
-
- <dt>Alias</dt>
- <dd>An alias for the sample. Can be an empty field.</dd>
- </dl>
-</p>
-
-<form id="form-samples"
- method="POST"
- action="{{url_for('samples.upload_samples',
- species_id=species.SpeciesId,
- population_id=population.InbredSetId)}}"
- enctype="multipart/form-data">
- <legend class="heading">upload samples</legend>
-
- <div class="form-group">
- <input type="hidden" name="species_id" value="{{species.SpeciesId}}" />
- <label class="form-label">species:</label>
- <span class="form-text">{{species.SpeciesName}} [{{species.MenuName}}]</span>
- </div>
-
- <div class="form-group">
- <input type="hidden" name="inbredset_id" value="{{population.InbredSetId}}" />
- <label class="form-label">grouping/population:</label>
- <span class="form-text">{{population.Name}} [{{population.FullName}}]</span>
- </div>
-
- <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"
- class="form-control" />
- </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>
-
-<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 to preview the data.</td>
- </tr>
- </tbody>
-</table>
-
-{%endblock%}
-
-
-{%block javascript%}
-<script src="/static/js/upload_samples.js" type="text/javascript"></script>
-{%endblock%}
diff --git a/uploader/templates/samples/upload-success.html b/uploader/templates/samples/upload-success.html
deleted file mode 100644
index cb745c3..0000000
--- a/uploader/templates/samples/upload-success.html
+++ /dev/null
@@ -1,18 +0,0 @@
-{%extends "base.html"%}
-{%from "cli-output.html" import cli_output%}
-
-{%block title%}Job Status{%endblock%}
-
-{%block contents%}
-<h1 class="heading">{{job.job_name}}</h2>
-
-<p>
-<strong>status</strong>:
-<span>{{job["status"]}} ({{job.get("message", "-")}})</span><br />
-</p>
-
-<p>Successfully uploaded the samples.</p>
-
-{{cli_output(job, "stdout")}}
-
-{%endblock%}