aboutsummaryrefslogtreecommitdiff
path: root/uploader/templates
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-08-29 15:21:27 -0500
committerFrederick Muriuki Muriithi2024-08-30 15:06:24 -0500
commite49b4367f1dab1c3acb3cd5d71ba09359c5ab4ee (patch)
tree63035669dd9a82bccee60b572a565d028cf3ef38 /uploader/templates
parentf95037b93329d5a4953b81ba1b58e4028a6274e8 (diff)
downloadgn-uploader-e49b4367f1dab1c3acb3cd5d71ba09359c5ab4ee.tar.gz
Initialise package for dealing with Species.
Diffstat (limited to 'uploader/templates')
-rw-r--r--uploader/templates/base.html10
-rw-r--r--uploader/templates/species/base.html11
-rw-r--r--uploader/templates/species/create-species.html116
-rw-r--r--uploader/templates/species/list-species.html68
4 files changed, 204 insertions, 1 deletions
diff --git a/uploader/templates/base.html b/uploader/templates/base.html
index 58227f4..7431767 100644
--- a/uploader/templates/base.html
+++ b/uploader/templates/base.html
@@ -44,6 +44,7 @@
<aside id="nav-sidebar" class="container-fluid">
<ul class="nav flex-column">
<li><a href="/" >Home</a></li>
+ <li><a href="{{url_for('species.list_species')}}" >Species</a></li>
<li><a href="{{url_for('expression-data.index.index')}}" >Expression Data</a></li>
</ul>
</aside>
@@ -54,7 +55,14 @@
<h1>GN Uploader: {%block pagetitle%}{%endblock%}</h1>
<nav>
<ol class="breadcrumb">
- {%block breadcrumb%}{%endblock%}
+ <li {%if activelink is not defined or activelink=="home"%}
+ class="breadcrumb-item active"
+ {%else%}
+ class="breadcrumb-item"
+ {%endif%}>
+ <a href="{{url_for('base.index')}}">Home</a>
+ </li>
+ {%block breadcrumbs%}{%endblock%}
</ol>
</nav>
</div>
diff --git a/uploader/templates/species/base.html b/uploader/templates/species/base.html
new file mode 100644
index 0000000..b77cc8b
--- /dev/null
+++ b/uploader/templates/species/base.html
@@ -0,0 +1,11 @@
+{%extends "base.html"%}
+
+{%block breadcrumbs%}
+<li {%if activelink=="species"%}
+ class="breadcrumb-item active"
+ {%else%}
+ class="breadcrumb-item"
+ {%endif%}>
+ <a href="{{url_for('species.list_species')}}">Species</a>
+</li>
+{%endblock%}
diff --git a/uploader/templates/species/create-species.html b/uploader/templates/species/create-species.html
new file mode 100644
index 0000000..b96e2d3
--- /dev/null
+++ b/uploader/templates/species/create-species.html
@@ -0,0 +1,116 @@
+{%extends "species/base.html"%}
+{%from "flash_messages.html" import flash_all_messages%}
+
+{%block title%}Create Species{%endblock%}
+
+{%block pagetitle%}Create Species{%endblock%}
+
+{%block breadcrumbs%}
+<li {%if activelink=="create-species"%}
+ class="breadcrumb-item active"
+ {%else%}
+ class="breadcrumb-item"
+ {%endif%}>
+ <a href="{{url_for('species.create_species')}}">Species</a>
+</li>
+{%endblock%}
+
+{%block contents%}
+<div class="row">
+ <form id="frm-create-species"
+ method="POST"
+ action="{{url_for('species.create_species')}}">
+ <legend>Create Species</legend>
+
+ {{flash_all_messages()}}
+
+ <div class="form-group">
+ <label for="txt-taxonomy-id" class="form-label">
+ Taxonomy ID</label>
+ <div class="input-group">
+ <input id="txt-taxonomy-id"
+ name="species_taxonomy_id"
+ type="text"
+ class="form-control" />
+ <span class="input-group-btn">
+ <button id="btn-search-taxonid" class="btn btn-info">Search</button>
+ </span>
+ </div>
+ <small class="form-text text-small text-muted">Provide the taxonomy ID for
+ your species that can be used to link to external sites like NCBI. Enter
+ the taxonomy ID and click "Search" to auto-fill the form with data.
+ <br />
+ While it is recommended to provide a value for this field, doing so is
+ optional.
+ </small>
+ </div>
+
+ <div class="form-group">
+ <label for="txt-species-name" class="form-label">Common Name</label>
+ <input id="txt-species-name"
+ name="common_name"
+ type="text"
+ class="form-control"
+ required="required" />
+ <small class="form-text text-muted">Provide the common, possibly
+ non-scientific name for the species here, e.g. Human, Mouse, etc.</small>
+ </div>
+
+ <div class="form-group">
+ <label for="txt-species-scientific" class="form-label">
+ Scientific Name</label>
+ <input id="txt-species-scientific"
+ name="scientific_name"
+ type="text"
+ class="form-control"
+ required="required" />
+ <small class="form-text text-muted">Provide the scientific name for the
+ species you are creating, e.g. Homo sapiens, Mus musculus, etc.</small>
+ </div>
+
+ <div class="form-group">
+ <input type="submit"
+ value="create new species"
+ class="btn btn-primary" />
+ </div>
+
+ </form>
+</div>
+{%endblock%}
+
+{%block javascript%}
+<script>
+ var lastTaxonId = null;
+
+ var fetch_taxonomy = (taxonId) => {
+ var uri = (
+ "https://rest.uniprot.org/taxonomy/" + encodeURIComponent(taxonId));
+ $.get(
+ uri,
+ {},
+ (data, textStatus, jqXHR) => {
+ if(textStatus == "success") {
+ lastTaxonId = taxonId;
+ $("#txt-species-scientific").val(data.scientificName);
+ $("#txt-species-name").val(data.commonName);
+ return false;
+ }
+ msg = (
+ "Request to '${uri}' failed with message '${textStatus}'. "
+ + "Please try again later, or fill the details manually.");
+ alert(msg);
+ console.error(msg, data, textStatus);
+ return false;
+ },
+ "json");
+ };
+
+ $("#btn-search-taxonid").on("click", (event) => {
+ event.preventDefault();
+ taxonId = $("#txt-taxonomy-id").val();
+ if((taxonId !== "") && (taxonId !== lastTaxonId)) {
+ fetch_taxonomy(taxonId);
+ }
+ });
+</script>
+{%endblock%}
diff --git a/uploader/templates/species/list-species.html b/uploader/templates/species/list-species.html
new file mode 100644
index 0000000..42094c1
--- /dev/null
+++ b/uploader/templates/species/list-species.html
@@ -0,0 +1,68 @@
+{%extends "species/base.html"%}
+{%from "flash_messages.html" import flash_all_messages%}
+
+{%block title%}List Species{%endblock%}
+
+{%block pagetitle%}List Species{%endblock%}
+
+{%block contents%}
+<div class="row">
+ <p>
+ All data in GeneNetwork revolves around species. This is the core of the
+ system.</p>
+ <p>Here you can see a list of all the species available in GeneNetwork.
+ Click on the link besides each species to view greater detail on the species,
+ and access further operations that are possible for said species.</p>
+</div>
+
+<div class="row">
+ <p>If you cannot find the species you are looking for below, click the button
+ below to create it</p>
+ <p><a href="{{url_for('species.create_species')}}"
+ title="Add a new species to GeneNetwork"
+ class="btn btn-danger">Create Species</a></p>
+</div>
+
+<div class="row">
+ <table class="table">
+ <caption>Available Species</caption>
+ <thead>
+ <tr>
+ <th>Common Name</th>
+ <th>Scientific Name</th>
+ <th>TaxonId</th>
+ <th>Use</th>
+ </tr>
+ </thead>
+ <tbody>
+ {%for species in allspecies%}
+ <tr>
+ <td>{{species["SpeciesName"]}}</td>
+ <td>{{species["FullName"]}}</td>
+ <td>
+ <a href="https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id={{species['TaxonomyId']}}"
+ title="View species details on NCBI"
+ target="_blank">{{species["TaxonomyId"]}}</a>
+ </td>
+ <td>
+ <a href="{{url_for('species.view_species',
+ species_id=species['SpeciesId'])}}"
+ title="">
+ {{species["SpeciesName"]}} ({{species["FullName"]}})
+ </a>
+ </td>
+ </tr>
+ {%else%}
+ <tr>
+ <td colspan="3">
+ <p class="text-danger">
+ <span class="glyphicon glyphicon-exclamation-mark"></span>
+ There were no species found!
+ </p>
+ </td>
+ </tr>
+ {%endfor%}
+ </tbody>
+ </table>
+</div>
+{%endblock%}