diff options
| -rw-r--r-- | uploader/__init__.py | 1 | ||||
| -rw-r--r-- | uploader/base_routes.py | 37 | ||||
| -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/species.js | 2 | ||||
| -rw-r--r-- | uploader/templates/index2.html | 48 | ||||
| -rw-r--r-- | uploader/templates/sui-base.html (renamed from uploader/templates/base2.html) | 0 | ||||
| -rw-r--r-- | uploader/templates/sui-index.html | 111 |
9 files changed, 152 insertions, 66 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/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/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/base2.html b/uploader/templates/sui-base.html index 4c5d613..4c5d613 100644 --- a/uploader/templates/base2.html +++ b/uploader/templates/sui-base.html diff --git a/uploader/templates/sui-index.html b/uploader/templates/sui-index.html new file mode 100644 index 0000000..a589148 --- /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 - a")}} 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%} |
