diff options
| author | Frederick Muriuki Muriithi | 2025-12-29 11:42:58 -0600 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2025-12-29 11:45:52 -0600 |
| commit | b40f14bb409d54fda957e2d8269f1bc86bd34e58 (patch) | |
| tree | 89eebf97435dda555b9e58653f233afa54e14b4b | |
| parent | 9a00a08487d0d2b2f8b4363bb76fdad3336b747e (diff) | |
| download | gn-uploader-b40f14bb409d54fda957e2d8269f1bc86bd34e58.tar.gz | |
Samples: Move feature to new UI templates.
| -rw-r--r-- | uploader/samples/views.py | 12 | ||||
| -rw-r--r-- | uploader/templates/samples/base.html | 29 | ||||
| -rw-r--r-- | uploader/templates/samples/list-samples.html | 50 | ||||
| -rw-r--r-- | uploader/templates/samples/sui-base.html | 25 | ||||
| -rw-r--r-- | uploader/templates/samples/sui-list-samples.html | 98 | ||||
| -rw-r--r-- | uploader/templates/samples/sui-upload-failure.html | 32 | ||||
| -rw-r--r-- | uploader/templates/samples/sui-upload-progress.html | 26 | ||||
| -rw-r--r-- | uploader/templates/samples/sui-upload-samples.html | 153 | ||||
| -rw-r--r-- | uploader/templates/samples/sui-upload-success.html | 31 | ||||
| -rw-r--r-- | uploader/templates/samples/upload-failure.html | 5 | ||||
| -rw-r--r-- | uploader/templates/samples/upload-progress.html | 5 | ||||
| -rw-r--r-- | uploader/templates/samples/upload-samples.html | 81 | ||||
| -rw-r--r-- | uploader/templates/samples/upload-success.html | 5 |
13 files changed, 72 insertions, 480 deletions
diff --git a/uploader/samples/views.py b/uploader/samples/views.py index 93f0c29..f8baf7e 100644 --- a/uploader/samples/views.py +++ b/uploader/samples/views.py @@ -11,8 +11,6 @@ from flask import (flash, Blueprint, current_app as app) -from uploader.sui import sui_template - from uploader import jobs from uploader.files import save_file from uploader.flask_extensions import url_for @@ -88,7 +86,7 @@ def list_samples(species: dict, population: dict, **kwargs):# pylint: disable=[u total_samples = len(all_samples) offset = max(safe_int(request.args.get("from") or 0), 0) count = int(request.args.get("count") or 20) - return render_template(sui_template("samples/list-samples.html"), + return render_template("samples/list-samples.html", species=species, population=population, samples=all_samples[offset:offset+count], @@ -149,7 +147,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(sui_template("samples/upload-samples.html"), + return render_template("samples/upload-samples.html", species=species, population=population) @@ -216,7 +214,7 @@ def upload_status(species: dict, population: dict, job_id: uuid.UUID, **kwargs): if job: status = job["status"] if status == "success": - return render_template(sui_template("samples/upload-success.html"), + return render_template("samples/upload-success.html", job=job, species=species, population=population,) @@ -236,7 +234,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(sui_template("samples/upload-progress.html"), + return render_template("samples/upload-progress.html", species=species, population=population, job=job) # maybe also handle this? @@ -267,7 +265,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(sui_template("samples/upload-failure.html"), + return render_template("samples/upload-failure.html", species=species, population=population, job=job) diff --git a/uploader/templates/samples/base.html b/uploader/templates/samples/base.html index 291782b..7fd5020 100644 --- a/uploader/templates/samples/base.html +++ b/uploader/templates/samples/base.html @@ -1,12 +1,25 @@ {%extends "populations/base.html"%} +{%from "populations/macro-display-population-card.html" import display_sui_population_card%} -{%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> +{%block breadcrumbs%} +{{super()}} +<li class="breadcrumb-item"> + <a href="{{url_for('species.populations.samples.list_samples', + species_id=species['SpeciesId'], + population_id=population.Id)}}"> + Samples + </a> </li> -{%block lvl4_breadcrumbs%}{%endblock%} +{%endblock%} + +{%block contents%} +<div class="row"> + <h2 class="heading">{{population.FullName}} ({{population.Name}})</h2> +</div> +{%endblock%} + + + +{%block sidebarcontents%} +{{display_sui_population_card(species, population)}} {%endblock%} diff --git a/uploader/templates/samples/list-samples.html b/uploader/templates/samples/list-samples.html index aed27c3..3aac984 100644 --- a/uploader/templates/samples/list-samples.html +++ b/uploader/templates/samples/list-samples.html @@ -1,53 +1,34 @@ {%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 — List Samples{%endblock%} -{%block pagetitle%}Samples — 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()}} +{{super()}} <div class="row"> - <p> - You selected the population "{{population.FullName}}" from the - "{{species.FullName}}" species. - </p> + <h3 class="subheading">manage samples</h3> + {{flash_all_messages()}} </div> <div class="row"> - <p> + <div class="col"> <a href="{{url_for('species.populations.samples.upload_samples', species_id=species.SpeciesId, population_id=population.Id)}}" title="Add samples for population '{{population.FullName}}' from species '{{species.FullName}}'." - class="btn btn-primary"> - add samples - </a> - </p> + class="btn btn-primary">add new samples</a> + </div> </div> {%if samples | length > 0%} <div class="row"> <p> - This population already has <strong>{{total_samples}}</strong> - samples/individuals entered. You can explore the list of samples in this - population in the table below. + Population "{{population.FullName}} ({{population.Name}})" already has + <strong>{{total_samples}}</strong> samples/individuals entered. You can + explore the list of samples in the table below. </p> </div> @@ -106,15 +87,6 @@ {%endfor%} </tbody> </table> - - <p> - <a href="#" - title="Delete samples from population '{{population.FullName}}' from species - '{{species.FullName}}'." - class="btn btn-danger not-implemented"> - delete all samples - </a> - </p> </div> {%else%} <div class="row"> @@ -124,7 +96,3 @@ {%endif%} {%endblock%} - -{%block sidebarcontents%} -{{display_population_card(species, population)}} -{%endblock%} diff --git a/uploader/templates/samples/sui-base.html b/uploader/templates/samples/sui-base.html deleted file mode 100644 index 8ec7505..0000000 --- a/uploader/templates/samples/sui-base.html +++ /dev/null @@ -1,25 +0,0 @@ -{%extends "populations/sui-base.html"%} -{%from "populations/macro-display-population-card.html" import display_sui_population_card%} - -{%block breadcrumbs%} -{{super()}} -<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%} -<div class="row"> - <h2 class="heading">{{population.FullName}} ({{population.Name}})</h2> -</div> -{%endblock%} - - - -{%block sidebarcontents%} -{{display_sui_population_card(species, population)}} -{%endblock%} diff --git a/uploader/templates/samples/sui-list-samples.html b/uploader/templates/samples/sui-list-samples.html deleted file mode 100644 index e9ed71a..0000000 --- a/uploader/templates/samples/sui-list-samples.html +++ /dev/null @@ -1,98 +0,0 @@ -{%extends "samples/sui-base.html"%} -{%from "flash_messages.html" import flash_all_messages%} -{%from "populations/macro-select-population.html" import select_population_form%} - -{%block title%}Samples — List Samples{%endblock%} - -{%block contents%} -{{super()}} - -<div class="row"> - <h3 class="subheading">manage samples</h3> - {{flash_all_messages()}} -</div> - -<div class="row"> - <div class="col"> - <a href="{{url_for('species.populations.samples.upload_samples', - species_id=species.SpeciesId, - population_id=population.Id)}}" - title="Add samples for population '{{population.FullName}}' from species - '{{species.FullName}}'." - class="btn btn-primary">add new samples</a> - </div> -</div> - -{%if samples | length > 0%} -<div class="row"> - <p> - Population "{{population.FullName}} ({{population.Name}})" already has - <strong>{{total_samples}}</strong> samples/individuals entered. You can - explore the list of samples in the table below. - </p> -</div> - -<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}} — {{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> -<div class="row"> - <table class="table"> - <thead> - <tr> - <th></th> - <th>Name</th> - <th>Auxilliary Name</th> - <th>Symbol</th> - <th>Alias</th> - </tr> - </thead> - - <tbody> - {%for sample in samples%} - <tr> - <td>{{sample.sequence_number}}</td> - <td>{{sample.Name}}</td> - <td>{{sample.Name2}}</td> - <td>{{sample.Symbol or "-"}}</td> - <td>{{sample.Alias or "-"}}</td> - </tr> - {%endfor%} - </tbody> - </table> -</div> -{%else%} -<div class="row"> - <p>There are no samples entered for this population. Click the "Add Samples" - button above, to add some new samples.</p> -</div> -{%endif%} - -{%endblock%} diff --git a/uploader/templates/samples/sui-upload-failure.html b/uploader/templates/samples/sui-upload-failure.html deleted file mode 100644 index d950c50..0000000 --- a/uploader/templates/samples/sui-upload-failure.html +++ /dev/null @@ -1,32 +0,0 @@ -{%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]}}…</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 deleted file mode 100644 index 8412c46..0000000 --- a/uploader/templates/samples/sui-upload-progress.html +++ /dev/null @@ -1,26 +0,0 @@ -{%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]}}…</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 deleted file mode 100644 index 83c2061..0000000 --- a/uploader/templates/samples/sui-upload-samples.html +++ /dev/null @@ -1,153 +0,0 @@ -{%extends "samples/sui-base.html"%} -{%from "flash_messages.html" import flash_all_messages%} - -{%block title%}Samples — 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="	">TAB</option> - <option value=" ">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 deleted file mode 100644 index 054bde8..0000000 --- a/uploader/templates/samples/sui-upload-success.html +++ /dev/null @@ -1,31 +0,0 @@ -{%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]}}…</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%} diff --git a/uploader/templates/samples/upload-failure.html b/uploader/templates/samples/upload-failure.html index 2cf8053..75192ec 100644 --- a/uploader/templates/samples/upload-failure.html +++ b/uploader/templates/samples/upload-failure.html @@ -1,6 +1,5 @@ {%extends "base.html"%} {%from "cli-output.html" import cli_output%} -{%from "populations/macro-display-population-card.html" import display_population_card%} {%block title%}Samples Upload Failure{%endblock%} @@ -31,7 +30,3 @@ {{cli_output(job, "stderr")}} </div> {%endblock%} - -{%block sidebarcontents%} -{{display_population_card(species, population)}} -{%endblock%} diff --git a/uploader/templates/samples/upload-progress.html b/uploader/templates/samples/upload-progress.html index 677d457..38f931b 100644 --- a/uploader/templates/samples/upload-progress.html +++ b/uploader/templates/samples/upload-progress.html @@ -1,6 +1,5 @@ {%extends "samples/base.html"%} {%from "cli-output.html" import cli_output%} -{%from "populations/macro-display-population-card.html" import display_population_card%} {%block extrameta%} <meta http-equiv="refresh" content="5"> @@ -25,7 +24,3 @@ </div> {%endblock%} - -{%block sidebarcontents%} -{{display_population_card(species, population)}} -{%endblock%} diff --git a/uploader/templates/samples/upload-samples.html b/uploader/templates/samples/upload-samples.html index 4aa2f7f..1f665a3 100644 --- a/uploader/templates/samples/upload-samples.html +++ b/uploader/templates/samples/upload-samples.html @@ -1,21 +1,16 @@ {%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 — Upload Samples{%endblock%} -{%block pagetitle%}Samples — Upload Samples{%endblock%} - -{%block lvl4_breadcrumbs%} -<li {%if activelink=="uploade-samples"%} - class="breadcrumb-item active" - {%else%} - class="breadcrumb-item" - {%endif%}> +{%block breadcrumbs%} +{{super()}} +<li class="breadcrumb-item"> <a href="{{url_for('species.populations.samples.upload_samples', - species_id=species.SpeciesId, - population_id=population.Id)}}">List</a> + species_id=species['SpeciesId'], + population_id=population.Id)}}"> + Upload + </a> </li> {%endblock%} @@ -23,35 +18,6 @@ {{flash_all_messages()}} <div class="row"> - <p> - You can now upload the samples for the "{{population.FullName}}" population - from the "{{species.FullName}}" species here. - </p> - <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> - -<div class="row"> <form id="form-samples" method="POST" action="{{url_for('species.populations.samples.upload_samples', @@ -68,6 +34,9 @@ <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"> @@ -149,10 +118,34 @@ </tbody> </table> </div> -{%endblock%} -{%block sidebarcontents%} -{{display_population_card(species, population)}} + + +<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%} diff --git a/uploader/templates/samples/upload-success.html b/uploader/templates/samples/upload-success.html index 881d466..d6318e9 100644 --- a/uploader/templates/samples/upload-success.html +++ b/uploader/templates/samples/upload-success.html @@ -1,6 +1,5 @@ {%extends "samples/base.html"%} {%from "cli-output.html" import cli_output%} -{%from "populations/macro-display-population-card.html" import display_population_card%} {%block title%}Job Status{%endblock%} @@ -30,7 +29,3 @@ </div> {%endblock%} - -{%block sidebarcontents%} -{{display_population_card(species, population)}} -{%endblock%} |
