From 99af299197dfc527155cd3257388b784810518c4 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 8 Jul 2020 00:16:23 -0400 Subject: Split upload tab. Add upload status tab. Add more direct links on download page. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- bh20simplewebuploader/main.py | 63 +++++++++++++++++++++++++-- bh20simplewebuploader/static/main.css | 26 ++++++++--- bh20simplewebuploader/templates/footer.html | 14 ++++++ bh20simplewebuploader/templates/form.html | 49 --------------------- bh20simplewebuploader/templates/home.html | 50 +++++++++++++++++++++ bh20simplewebuploader/templates/menu.html | 4 +- bh20simplewebuploader/templates/resource.html | 26 +++++++++++ bh20simplewebuploader/templates/status.html | 17 ++++++++ 8 files changed, 191 insertions(+), 58 deletions(-) create mode 100644 bh20simplewebuploader/templates/home.html create mode 100644 bh20simplewebuploader/templates/resource.html create mode 100644 bh20simplewebuploader/templates/status.html diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 3100dfd..1c96d36 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -13,12 +13,15 @@ import pkg_resources from flask import Flask, request, redirect, send_file, send_from_directory, render_template, jsonify import os.path import requests +import io +import arvados +from markupsafe import Markup logging.basicConfig(level=logging.DEBUG) log = logging.getLogger(__name__ ) log.debug("Entering web uploader") -if not os.path.isfile('bh20sequploader/mainx.py'): +if not os.path.isfile('bh20sequploader/main.py'): print("WARNING: run FLASK from the root of the source repository!", file=sys.stderr) app = Flask(__name__, static_url_path='/static', static_folder='static') @@ -224,12 +227,21 @@ METADATA_OPTION_DEFINITIONS = yaml.safe_load(pkg_resources.resource_stream("bh20 FORM_ITEMS = generate_form(METADATA_SCHEMA, METADATA_OPTION_DEFINITIONS) @app.route('/') +def send_home(): + """ + Send the front page. + """ + + return render_template('home.html', menu='HOME') + + +@app.route('/upload') def send_form(): """ Send the file upload form/front page. """ - return render_template('form.html', fields=FORM_ITEMS, menu='HOME') + return render_template('form.html', fields=FORM_ITEMS, menu='UPLOAD') class FileTooBigError(RuntimeError): """ @@ -439,7 +451,52 @@ def get_html_body(fn): @app.route('/download') def download_page(): buf = get_html_body('doc/web/download.html') - return render_template('about.html',menu='DOWNLOAD',embed=buf) + return render_template('resource.html',menu='DOWNLOAD',embed=buf) + +@app.route('/status') +def status_page(): + """ + Processing status + """ + + api = arvados.api() + uploader_project = 'lugli-j7d0g-n5clictpuvwk8aa' + pending = arvados.util.list_all(api.collections().list, filters=[["owner_uuid", "=", uploader_project]]) + out = [] + status = {} + for p in pending: + prop = p["properties"] + out.append(prop) + if "status" not in prop: + prop["status"] = "pending" + prop["created_at"] = p["created_at"] + prop["uuid"] = p["uuid"] + status[prop["status"]] = status.get(prop["status"], 0) + 1 + + output = io.StringIO() + for s in status: + output.write("

%s sequences %s QC

" % (status[s], s)) + output.write( +""" + + + + + +""") + for r in out: + output.write("") + output.write("" % (r["uuid"], r["uuid"])) + output.write("" % Markup.escape(r["sequence_label"])) + output.write("" % r["status"]) + output.write("" % Markup.escape("\n".join(r.get("errors", [])))) + output.write("") + output.write( +""" +
CollectionSequence labelStatusErrors
%s%s%s
%s
+""") + + return render_template('status.html', table=Markup(output.getvalue()), menu='STATUS') @app.route('/demo') def demo_page(): diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css index 5a9f231..b9b27f4 100644 --- a/bh20simplewebuploader/static/main.css +++ b/bh20simplewebuploader/static/main.css @@ -168,11 +168,11 @@ span.dropt:hover {text-decoration: none; background: #ffffff; z-index: 6; } grid-template-rows: auto; row-gap:5px; grid-template-areas: - "a a b b" - "a a c c" - "a a d d" - "e e e e" - "f f f f"; + "b b a a" + "b b c c" + "b b d d" + "e e e e" + "f f f f"; grid-auto-flow: column; } @@ -361,3 +361,19 @@ footer { .blog-table-body { display: table-row-group; } + +div.status { + margin: 1em; +} + +.status table { + display: table; + width: 100%; +} + +.status td, th { + padding-left: 1em; + padding-right: 1em; + vertical-align: top; + border-bottom: 1px solid #ddd; +} diff --git a/bh20simplewebuploader/templates/footer.html b/bh20simplewebuploader/templates/footer.html index 9326b1e..a1dd4fd 100644 --- a/bh20simplewebuploader/templates/footer.html +++ b/bh20simplewebuploader/templates/footer.html @@ -41,3 +41,17 @@ + + diff --git a/bh20simplewebuploader/templates/form.html b/bh20simplewebuploader/templates/form.html index 0ad2080..b9b3776 100644 --- a/bh20simplewebuploader/templates/form.html +++ b/bh20simplewebuploader/templates/form.html @@ -7,43 +7,6 @@
-
-

- Make your sequence - data FAIR. Upload - your SARS-CoV-2 sequence (FASTA or FASTQ - formats) with metadata (JSONLD) to - the public sequence - resource. The upload will trigger a - recompute with all available sequences into a - Pangenome available for - download! -

-

- Your uploaded sequence will automatically be - processed and incorporated into the public - pangenome with metadata using worklows from - the High Performance Open Biology Lab - defined here. All - data is published under - a Creative - Commons license You can take the published - (GFA/RDF/FASTA) data and store it in a triple - store for further processing. Clinical - data can be stored - securely - at REDCap. -

-

- Note that form fields contain - web ontology - URI's - for disambiguation - and machine readable metadata. For examples of - use, see the BLOG. -

-
-

@@ -160,18 +123,6 @@ setMode() - document.addEventListener("DOMContentLoaded", function(){ - var count = fetch("/api/getCount") - .then((resp) => resp.json()) - .then(function (data) { - count = data["sequences"]; - console.log(count); - span = document.getElementById("Counter"); - txt = document.createTextNode(count); - span.appendChild(txt); - }); -}); - diff --git a/bh20simplewebuploader/templates/home.html b/bh20simplewebuploader/templates/home.html new file mode 100644 index 0000000..b90a18d --- /dev/null +++ b/bh20simplewebuploader/templates/home.html @@ -0,0 +1,50 @@ + + + {% include 'header.html' %} + + {% include 'banner.html' %} + {% include 'menu.html' %} + +
+
+

+ Make your sequence + data FAIR. Upload + your SARS-CoV-2 sequence (FASTA or FASTQ + formats) with metadata (JSONLD) to + the public sequence + resource. The upload will trigger a + recompute with all available sequences into a + Pangenome available for + download! +

+

+ Your uploaded sequence will automatically be + processed and incorporated into the public + pangenome with metadata using worklows from + the High Performance Open Biology Lab + defined here. All + data is published under + a Creative + Commons license You can take the published + (GFA/RDF/FASTA) data and store it in a triple + store for further processing. Clinical + data can be stored + securely + at REDCap. +

+

+ Note that form fields contain + web ontology + URI's + for disambiguation + and machine readable metadata. For examples of + use, see the BLOG. +

+
+
+ +{% include 'footer.html' %} + + + diff --git a/bh20simplewebuploader/templates/menu.html b/bh20simplewebuploader/templates/menu.html index 6f97e19..0f6003f 100644 --- a/bh20simplewebuploader/templates/menu.html +++ b/bh20simplewebuploader/templates/menu.html @@ -1,7 +1,9 @@