diff options
Diffstat (limited to 'uploader')
| -rw-r--r-- | uploader/__init__.py | 1 | ||||
| -rw-r--r-- | uploader/base_routes.py | 37 | ||||
| -rw-r--r-- | uploader/species/views.py | 25 | ||||
| -rw-r--r-- | uploader/static/css/layout-large.css | 3 | ||||
| -rw-r--r-- | uploader/static/css/layout-small.css | 10 | ||||
| -rw-r--r-- | uploader/static/css/theme.css | 6 | ||||
| -rw-r--r-- | uploader/static/js/populations.js | 2 | ||||
| -rw-r--r-- | uploader/static/js/species.js | 2 | ||||
| -rw-r--r-- | uploader/templates/index2.html | 48 | ||||
| -rw-r--r-- | uploader/templates/species/macro-display-species-card.html | 27 | ||||
| -rw-r--r-- | uploader/templates/species/sui-base.html | 10 | ||||
| -rw-r--r-- | uploader/templates/species/sui-view-species.html | 91 | ||||
| -rw-r--r-- | uploader/templates/sui-base.html (renamed from uploader/templates/base2.html) | 12 | ||||
| -rw-r--r-- | uploader/templates/sui-index.html | 111 |
14 files changed, 304 insertions, 81 deletions
diff --git a/uploader/__init__.py b/uploader/__init__.py index 98e8141..b7f0ab9 100644 --- a/uploader/__init__.py +++ b/uploader/__init__.py @@ -108,6 +108,7 @@ def create_app(config: Optional[dict] = None): setup_logging(app) setup_modules_logging(app.logger, ( + "uploader.base_routes", "uploader.publications.models", "uploader.publications.datatables", "uploader.phenotypes.models")) diff --git a/uploader/base_routes.py b/uploader/base_routes.py index 74a3b90..3d0e1b2 100644 --- a/uploader/base_routes.py +++ b/uploader/base_routes.py @@ -1,15 +1,23 @@ """Basic routes required for all pages""" import os +import logging from urllib.parse import urljoin -from flask import (Blueprint, +from gn_libs.mysqldb import database_connection +from flask import (flash, + request, + url_for, + redirect, + Blueprint, current_app as app, send_from_directory) from uploader.ui import make_template_renderer from uploader.oauth2.client import user_logged_in +from uploader.species.models import all_species, species_by_id base = Blueprint("base", __name__) +logger = logging.getLogger(__name__) render_template = make_template_renderer("home") @@ -24,9 +32,30 @@ def favicon(): @base.route("/", methods=["GET"]) def index(): """Load the landing page""" - return render_template("index.html" if user_logged_in() else "login.html", - gn2server_intro=urljoin(app.config["GN2_SERVER_URL"], - "/intro")) + streamlined_ui = request.args.get("streamlined_ui") + if not bool(streamlined_ui):# TODO: Remove this section + return render_template( + "index.html" if user_logged_in() else "login.html", + gn2server_intro=urljoin(app.config["GN2_SERVER_URL"], "/intro")) + + with database_connection(app.config["SQL_URI"]) as conn: + print("We found a species ID. Processing...") + if not bool(request.args.get("species_id")): + return render_template( + "sui-index.html",# TODO: Rename: sui-index.html, sui_base.html + gn2server_intro=urljoin(app.config["GN2_SERVER_URL"], "/intro"), + species=all_species(conn), + streamlined_ui=streamlined_ui) + + species = species_by_id(conn, request.args.get("species_id")) + if not bool(species): + flash("Selected species was not found!", "alert alert-danger") + return redirect(url_for("base.index", streamlined_ui=streamlined_ui)) + + return redirect(url_for("species.view_species", + species_id=species["SpeciesId"], + streamlined_ui=streamlined_ui)) + def appenv(): """Get app's guix environment path.""" diff --git a/uploader/species/views.py b/uploader/species/views.py index cea2f68..a490b0f 100644 --- a/uploader/species/views.py +++ b/uploader/species/views.py @@ -15,6 +15,8 @@ from uploader.ui import make_template_renderer from uploader.oauth2.client import oauth2_get, oauth2_post from uploader.authorisation import require_login, require_token from uploader.datautils import order_by_family, enumerate_sequence +from uploader.population.models import (populations_by_species, + population_by_species_and_id) from .models import (all_species, save_species, @@ -41,15 +43,30 @@ def list_species(): @require_login def view_species(species_id: int): """View details of a particular species and menus to act upon it.""" + streamlined_ui = request.args.get("streamlined_ui") with database_connection(app.config["SQL_URI"]) as conn: species = species_by_id(conn, species_id) if bool(species): - return render_template("species/view-species.html", - species=species, - activelink="view-species") + population = population_by_species_and_id( + conn, species_id, request.args.get("population_id")) + if bool(population): + return redirect(url_for("species.populations.view_population", + species_id=species_id, + population_id=population["Id"], + streamlined_ui=streamlined_ui)) + return render_template( + ("species/sui-view-species.html" + if bool(streamlined_ui) + else "species/view-species.html"), + species=species, + activelink="view-species", + streamlined_ui=streamlined_ui, + populations=populations_by_species(conn, species["SpeciesId"])) flash("Could not find a species with the given identifier.", "alert-danger") - return redirect(url_for("species.view_species")) + return redirect(url_for( + ("base.index" if streamlined_ui else "species.view_species"), + streamlined_ui=streamlined_ui)) @speciesbp.route("/create", methods=["GET", "POST"]) @require_login diff --git a/uploader/static/css/layout-large.css b/uploader/static/css/layout-large.css index d1b3aa1..f1740de 100644 --- a/uploader/static/css/layout-large.css +++ b/uploader/static/css/layout-large.css @@ -52,8 +52,7 @@ } #main #main-content { - /*background: #FFFFFF;*/ - /*max-width: 80%;*/ + max-width: 950px; grid-column-start: 1; grid-column-end: 2; diff --git a/uploader/static/css/layout-small.css b/uploader/static/css/layout-small.css index cd32a71..3a7d18f 100644 --- a/uploader/static/css/layout-small.css +++ b/uploader/static/css/layout-small.css @@ -53,14 +53,12 @@ } #main #main-content { - grid-row-start: 2; - grid-row-end: 3; - } - - #main #sidebar-content { grid-row-start: 3; grid-row-end: 4; + } - background: #E5E5FF; + #main #sidebar-content { + grid-row-start: 2; + grid-row-end: 3; } } diff --git a/uploader/static/css/theme.css b/uploader/static/css/theme.css index 09e5a52..184999d 100644 --- a/uploader/static/css/theme.css +++ b/uploader/static/css/theme.css @@ -3,7 +3,6 @@ body { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; - background: black; } #header { @@ -25,20 +24,17 @@ body { } #main #breadcrumbs { - background: #eaeaea; border-radius:3px; text-align: center; } #main #main-content { - background: #e5e5ff; - border-radius: 5px; padding: 0 5px; } #main #sidebar-content { - background: red; + background: #E5E5FF; border-radius: 5px; padding: 0 5px; diff --git a/uploader/static/js/populations.js b/uploader/static/js/populations.js index 89ededa..111ebb7 100644 --- a/uploader/static/js/populations.js +++ b/uploader/static/js/populations.js @@ -22,7 +22,7 @@ $(() => { { select: "single", paging: true, - scrollY: 700, + scrollY: 500, deferRender: true, scroller: true, scrollCollapse: true, diff --git a/uploader/static/js/species.js b/uploader/static/js/species.js index d42e081..fb0d2d2 100644 --- a/uploader/static/js/species.js +++ b/uploader/static/js/species.js @@ -20,7 +20,7 @@ $(() => { { select: "single", paging: true, - scrollY: 700, + scrollY: 500, deferRender: true, scroller: true, scrollCollapse: true, diff --git a/uploader/templates/index2.html b/uploader/templates/index2.html deleted file mode 100644 index 72fea2f..0000000 --- a/uploader/templates/index2.html +++ /dev/null @@ -1,48 +0,0 @@ -{%extends "base2.html"%} -{%from "flash_messages.html" import flash_all_messages%} - -{%block title%}Home{%endblock%} - -{%block pagetitle%}Home{%endblock%} - -{%block extra_breadcrumbs%}{%endblock%} - -{%block contents%} - -<div class="row">{{flash_all_messages()}}</div> - -{%if user_logged_in()%} -<div class="row"> - <p>Select from:</p> - <ul> - <li>Species</li> - <li>Publications</li> - </ul> -</div> -{%else%} -<div class="row"> - <p> - <a href="{{authserver_authorise_uri()}}" - title="Sign in to the system" - class="btn btn-primary">Sign in</a> - to continue.</p> -</div> -{%endif%} - -{%endblock%} - - - -{%block sidebarcontents%} -<div class="row"> - <form id="frm-quick-navigation"> - <legend>Quick Navigation</legend> - <div class="form-group"> - <label for="fqn-species-id">Species</label> - <select name="species_id"> - <option value="">Select species</option> - </select> - </div> - </form> -</div> -{%endblock%} diff --git a/uploader/templates/species/macro-display-species-card.html b/uploader/templates/species/macro-display-species-card.html index 166c7b9..d7c4082 100644 --- a/uploader/templates/species/macro-display-species-card.html +++ b/uploader/templates/species/macro-display-species-card.html @@ -20,3 +20,30 @@ </div> </div> {%endmacro%} + + +{%macro display_sui_species_card(species)%} +<div class="row"> + <table> + <caption>Selected Species</caption> + <tr> + <th>Name</th> + <td>{{species["Name"] | title}}</td> + </tr> + <tr> + <th>Scientific</th> + <td>{{species["FullName"]}}</td> + </tr> + {%if species["TaxonomyId"]%} + <tr> + <th>Taxonomy ID</th> + <td> + <a href="https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id={{species.TaxonomyId}}" + title="NCBI's Taxonomy Browser page for {{species.Name}}"> + {{species.TaxonomyId}}</a> + </td> + </tr> + {%endif%} + </table> +</div> +{%endmacro%} diff --git a/uploader/templates/species/sui-base.html b/uploader/templates/species/sui-base.html new file mode 100644 index 0000000..5d2e6e3 --- /dev/null +++ b/uploader/templates/species/sui-base.html @@ -0,0 +1,10 @@ +{%extends "sui-base.html"%} + +{%block breadcrumbs%} +{{super()}} +<li class="breadcrumb-item"> + <a href="{{url_for('species.view_species', species_id=species['SpeciesId'], streamlined_ui=streamlined_ui)}}"> + {{species["Name"]|title}} + </a> +</li> +{%endblock%} diff --git a/uploader/templates/species/sui-view-species.html b/uploader/templates/species/sui-view-species.html new file mode 100644 index 0000000..5373766 --- /dev/null +++ b/uploader/templates/species/sui-view-species.html @@ -0,0 +1,91 @@ +{%extends "species/sui-base.html"%} +{%from "flash_messages.html" import flash_all_messages%} +{%from "macro-step-indicator.html" import step_indicator%} +{%from "species/macro-display-species-card.html" import display_sui_species_card%} + +{%block title%}View Species{%endblock%} + + +{%block contents%} +<div class="row"> + <h2>{{step_indicator("2(a)")}} Select the Population</h2> + + <p>Data belonging to a particular species is further divided into one or more + populations for easier handling. Please select the population you want to work + with.</p> + + <form method="GET" + action="{{url_for('species.view_species', species_id=species.SpeciesId)}}" + class="form-horizontal"> + <input type="hidden" name="streamlined_ui" value="{{streamlined_ui}}" /> + {%if populations | length != 0%} + + <p class="form-text">Search for, and select the population from the table + below.</p> + + <div style="margin-top:3em;"> + <table id="tbl-select-population" class="table compact stripe" + data-populations-list='{{populations | tojson}}'> + <thead> + <tr> + <th></th> + <th>Population</th> + </tr> + </thead> + + <tbody></tbody> + </table> + </div> + + {%else%} + <p class="form-text"> + There are no populations currently defined for {{species['FullName']}} + ({{species['SpeciesName']}}).</p> + {%endif%} + + <div class="row form-buttons"> + <div class="col"> + <input type="submit" + value="use selected population" + class="btn btn-primary" /> + </div> + + <div class="col"><strong>OR</strong></div> + + <div class="col"> + <a href="url_for('species.population.create_population', + species_id=species.SpeciesId, + return_to='species.view_species', + streamlined_ui=streamlined_ui)" + title="Create a new population for species '{{species.Name}}'." + class="btn btn-outline-info"> + Create a new population + </a> + </div> + </div> + + </form> +</div> + +<div class="row"> </div> + +<div class="row"> + <h2>{{step_indicator("2(b)")}} Manage sequencing platforms</h2> + <p>Upload and manage the sequencing platforms for species + '{{species.Name | title}} ({{species.FullName}})' + <a href="{{url_for('species.platforms.list_platforms', + species_id=species.SpeciesId, + streamlined_ui=streamlined_ui)}}" + title="Manage sequencing platforms for {{species.Name}}">here</a>. + </p> +</div> +{%endblock%} + +{%block sidebarcontents%} +{{display_sui_species_card(species)}} +{%endblock%} + + +{%block javascript%} +<script type="text/javascript" src="/static/js/populations.js"></script> +{%endblock%} diff --git a/uploader/templates/base2.html b/uploader/templates/sui-base.html index 4c5d613..b247c3c 100644 --- a/uploader/templates/base2.html +++ b/uploader/templates/sui-base.html @@ -50,17 +50,9 @@ <main id="main" class="main"> <nav id="breadcrumbs" aria-label="breadcrumb"> <ol class="breadcrumb"> + {%block breadcrumbs%} <li class="breadcrumb-item"> - <a href="{{url_for('base.index')}}">Home</a></li> - {%block extra_breadcrumbs%} - <li class="breadcrumb-item"> - <a href="{{url_for('base.index')}}">Page01</a></li> - <li class="breadcrumb-item"> - <a href="{{url_for('base.index')}}">Page02</a></li> - <li class="breadcrumb-item"> - <a href="{{url_for('base.index')}}">Page03</a></li> - <li class="breadcrumb-item"> - <a href="{{url_for('base.index')}}">Page04</a></li> + <a href="{{url_for('base.index', streamlined_ui='true')}}">Home</a></li> {%endblock%} </ol> </nav> diff --git a/uploader/templates/sui-index.html b/uploader/templates/sui-index.html new file mode 100644 index 0000000..e6873e2 --- /dev/null +++ b/uploader/templates/sui-index.html @@ -0,0 +1,111 @@ +{%extends "sui-base.html"%} +{%from "flash_messages.html" import flash_all_messages%} +{%from "macro-step-indicator.html" import step_indicator%} + +{%block title%}Home{%endblock%} + +{%block pagetitle%}Home{%endblock%} + +{%block extra_breadcrumbs%}{%endblock%} + +{%block contents%} + +<div class="row">{{flash_all_messages()}}</div> + +{%if user_logged_in()%} + +<div class="row"> + <div class="row"> + <h2>{{step_indicator("1")}} Select the Species</h2> + + <p>The data in Genenetwork is related to one species or another. To get + started, please select the species you want to work with.</p> + </div> +</div> + +<div class="row"> + <form method="GET" action="{{url_for('base.index')}}" class="form-horizontal"> + <input type="hidden" name="streamlined_ui", value="{{streamlined_ui}}" /> + + {%if species | length != 0%} + <div style="margin-top:3em;"> + <table id="tbl-select-species" class="table compact stripe" + data-species-list='{{species | tojson}}'> + <thead> + <tr> + <th></th> + <th>Species Name</th> + </tr> + </thead> + + <tbody></tbody> + </table> + </div> + + {%else%} + + <label class="control-label" for="rdo-cant-find-species"> + <input id="rdo-cant-find-species" type="radio" name="species_id" + value="CREATE-SPECIES" /> + There are no species to select from. Create the first one.</label> + + <div class="col-sm-offset-10 col-sm-2"> + <input type="submit" + class="btn btn-primary col-sm-offset-1" + value="continue" /> + </div> + + {%endif%} + + <div class="row form-buttons"> + <div class="col"> + <input type="submit" + class="btn btn-primary" + value="continue with selected" /> + </div> + <div class="col"><strong>OR</strong></div> + <div class="col"> + <a href="{{url_for('species.create_species', return_to='base.index')}}" + title="Create a new species.">Create a new Species</a> + </div> + </div> + + </form> +</div> + +{%else%} + +<div class="row"> + <p>The Genenetwork Uploader (<em>gn-uploader</em>) enables upload of new data + into the Genenetwork System. It provides Quality Control over data, and + guidance in case you data does not meet the standards for acceptance.</p> + <p> + <a href="{{authserver_authorise_uri()}}" + title="Sign in to the system" + class="btn btn-primary">Sign in</a> + to get started.</p> +</div> +{%endif%} + +{%endblock%} + + + +{%block sidebarcontents%} +<div class="row"> + <form id="frm-quick-navigation"> + <legend>Quick Navigation</legend> + <div class="form-group"> + <label for="fqn-species-id">Species</label> + <select name="species_id"> + <option value="">Select species</option> + </select> + </div> + </form> +</div> +{%endblock%} + + +{%block javascript%} +<script type="text/javascript" src="/static/js/species.js"></script> +{%endblock%} |
