From f0dd283c31acfcc34b967b7a81167e0543d06364 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Thu, 16 Jul 2020 10:53:19 +0100 Subject: Add edit icon to text on github Closes #76 --- bh20simplewebuploader/static/main.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'bh20simplewebuploader/static/main.css') diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css index b9b27f4..47fb408 100644 --- a/bh20simplewebuploader/static/main.css +++ b/bh20simplewebuploader/static/main.css @@ -377,3 +377,17 @@ div.status { vertical-align: top; border-bottom: 1px solid #ddd; } + +.editbutton { + float: right; + text-align: right; + background-color: lightgrey; + border: 2px solid #4CAF50; + border-radius: 12px; + color: black; + padding: 5px 32px; + // text-decoration: none; + display: inline-block; + font-size: 16px; + box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19); +} -- cgit v1.2.3 From 15624e038e0f368d2be4c9a76ace77da4d673fdd Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 16 Jul 2020 14:21:40 -0400 Subject: Improve upload form layout. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- bh20simplewebuploader/main.py | 86 ++++++++++++++++------------- bh20simplewebuploader/static/main.css | 17 ++++-- bh20simplewebuploader/templates/footer.html | 5 +- 3 files changed, 64 insertions(+), 44 deletions(-) (limited to 'bh20simplewebuploader/static/main.css') diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 3173d60..62b68d9 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -8,7 +8,7 @@ import os import sys import re import string -import yaml +import ruamel.yaml as yaml import pkg_resources from flask import Flask, request, redirect, send_file, send_from_directory, render_template, jsonify import os.path @@ -16,6 +16,9 @@ import requests import io import arvados from markupsafe import Markup +from schema_salad.sourceline import add_lc_filename +from schema_salad.schema import shortname +from typing import MutableSequence, MutableMapping ARVADOS_API = 'lugli.arvadosapi.com' ANONYMOUS_TOKEN = '5o42qdxpxp5cj15jqjf7vnxx5xduhm4ret703suuoa3ivfglfh' @@ -47,6 +50,8 @@ def type_to_heading(type_name): Turn a type name like "sampleSchema" from the metadata schema into a human-readable heading. """ + type_name = shortname(type_name) + print(type_name,file=sys.stderr) # Remove camel case decamel = re.sub('([A-Z])', r' \1', type_name) @@ -78,7 +83,7 @@ def is_iri(string): return string.startswith('http') -def generate_form(schema, options): +def generate_form(components, options): """ Linearize the schema into a list of dicts. @@ -101,9 +106,6 @@ def generate_form(schema, options): IRI. """ - # Get the list of form components, one of which is the root - components = schema.get('$graph', []) - # Find the root root_name = None # And also index components by type name @@ -131,14 +133,25 @@ def generate_form(schema, options): # First make a heading, if we aren't the very root of the form yield {'heading': type_to_heading(type_name)} - for field_name, field_type in by_name.get(type_name, {}).get('fields', {}).items(): + for field in by_name.get(type_name, {}).get('fields', []): + field_name = shortname(field["name"]) + field_type = field["type"] # For each field ref_iri = None docstring = None - if not isinstance(field_type, str): - # If the type isn't a string + optional = False + is_list = False + + if isinstance(field_type, MutableSequence): + if field_type[0] == "null" and len(field_type) == 2: + optional = True + field_type = field_type[1] + else: + raise Exception("Can't handle it") + + if isinstance(field_type, MutableMapping): # It may have documentation docstring = field_type.get('doc', None) @@ -161,25 +174,13 @@ def generate_form(schema, options): ref_iri = field_value break - - # Now overwrite the field type with the actual type string - field_type = field_type.get('type', '') - - # Decide if the field is optional (type ends in ?) - optional = False - if field_type.endswith('?'): - # It's optional - optional = True - # Drop the ? - field_type = field_type[:-1] - - # Decide if the field is a list (type ends in []) - is_list = False - if field_type.endswith('[]'): - # It's a list - is_list = True - # Reduce to the normal type - field_type = field_type[:-2] + if field_type["type"] == "array": + # Now replace the field type with the actual type string + is_list = True + field_type = field_type.get('items', '') + else: + field_type = field_type.get('type', '') + pass if field_type in by_name: # This is a subrecord. We need to recurse @@ -227,15 +228,24 @@ def generate_form(schema, options): return list(walk_fields(root_name)) -# At startup, we need to load the metadata schema from the uploader module, so we can make a form for it -if os.path.isfile("bh20sequploader/bh20seq-schema.yml"): - METADATA_SCHEMA = yaml.safe_load(open("bh20sequploader/bh20seq-schema.yml","r").read()) - METADATA_OPTION_DEFINITIONS = yaml.safe_load(open("bh20sequploader/bh20seq-options.yml","r").read()) -else: - METADATA_SCHEMA = yaml.safe_load(pkg_resources.resource_stream("bh20sequploader", "bh20seq-schema.yml")) - METADATA_OPTION_DEFINITIONS = yaml.safe_load(pkg_resources.resource_stream("bh20sequploader", "bh20seq-options.yml")) -# print(METADATA_SCHEMA,file=sys.stderr) -FORM_ITEMS = generate_form(METADATA_SCHEMA, METADATA_OPTION_DEFINITIONS) +import schema_salad.schema +def load_schema_generate_form(): + # At startup, we need to load the metadata schema from the uploader module, so we can make a form for it + if os.path.isfile("bh20sequploader/bh20seq-schema.yml"): + METADATA_SCHEMA = yaml.round_trip_load(open("bh20sequploader/bh20seq-schema.yml","r").read()) + METADATA_OPTION_DEFINITIONS = yaml.safe_load(open("bh20sequploader/bh20seq-options.yml","r").read()) + else: + METADATA_SCHEMA = yaml.round_trip_load(pkg_resources.resource_stream("bh20sequploader", "bh20seq-schema.yml")) + METADATA_OPTION_DEFINITIONS = yaml.safe_load(pkg_resources.resource_stream("bh20sequploader", "bh20seq-options.yml")) + + METADATA_SCHEMA["name"] = "bh20seq-schema.yml" + add_lc_filename(METADATA_SCHEMA, "bh20seq-schema.yml") + metaschema_names, _metaschema_doc, metaschema_loader = schema_salad.schema.get_metaschema() + schema_doc, schema_metadata = metaschema_loader.resolve_ref(METADATA_SCHEMA, "") + + return generate_form(schema_doc, METADATA_OPTION_DEFINITIONS) + +FORM_ITEMS = load_schema_generate_form() @app.route('/') def send_home(): @@ -543,10 +553,10 @@ def status_page(): for s in (("passed", "/download"), ("pending", "#pending"), ("rejected", "#rejected")): output.write("

%s sequences QC %s

" % (s[1], status.get(s[0], 0), s[0])) - output.write("

Pending

") + output.write("

Pending

") pending_table(output, out) - output.write("

Rejected

") + output.write("

Rejected

") rejected_table(output, out) return render_template('status.html', table=Markup(output.getvalue()), menu='STATUS') diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css index 47fb408..b28ee9c 100644 --- a/bh20simplewebuploader/static/main.css +++ b/bh20simplewebuploader/static/main.css @@ -178,7 +178,7 @@ span.dropt:hover {text-decoration: none; background: #ffffff; z-index: 6; } .about { display: grid; - grid-template-columns: repeat(2, 1fr); + grid-template-columns: 1fr 1fr; grid-auto-flow: row; } @@ -229,7 +229,7 @@ a { #metadata_fill_form { column-count: 4; margin-top: 0.5em; - column-width: 250px; + column-width: 15em; } .record, .record .field-group, .record .field-group .field { @@ -238,6 +238,8 @@ a { -webkit-column-break-inside: avoid; /* Chrome, Safari, Opera */ page-break-inside: avoid; /* Firefox */ break-inside: avoid; + display: block; + width: 90%; } .record { @@ -258,6 +260,10 @@ a { width: max-content; } +.control { + width: 100%; +} + .filter-options { width: 100%; } @@ -304,9 +310,10 @@ footer { } .sponsors img { - width: 80%; - display:block; - margin:auto; + width: auto; + display: block; + margin: auto; + height: 4em; } .loader { diff --git a/bh20simplewebuploader/templates/footer.html b/bh20simplewebuploader/templates/footer.html index 37a6b64..5a1f3c9 100644 --- a/bh20simplewebuploader/templates/footer.html +++ b/bh20simplewebuploader/templates/footer.html @@ -21,11 +21,14 @@
- +
+
+ +
-- cgit v1.2.3 From 7565f72b1bf0d70426947a50d1b9a62edc48071d Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 09:45:58 +0100 Subject: Map is back --- bh20simplewebuploader/static/main.css | 2 +- bh20simplewebuploader/static/map.js | 71 +++++++++++++++---------------- bh20simplewebuploader/templates/demo.html | 27 +++++++++++- bh20simplewebuploader/templates/map.html | 49 --------------------- 4 files changed, 61 insertions(+), 88 deletions(-) (limited to 'bh20simplewebuploader/static/main.css') diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css index b28ee9c..9f89045 100644 --- a/bh20simplewebuploader/static/main.css +++ b/bh20simplewebuploader/static/main.css @@ -47,7 +47,7 @@ h2 > svg { float: right; } -#map { +#mapid { width: 800px; height: 440px; border: 1px solid #AAA; diff --git a/bh20simplewebuploader/static/map.js b/bh20simplewebuploader/static/map.js index afc6c3f..e1a4289 100644 --- a/bh20simplewebuploader/static/map.js +++ b/bh20simplewebuploader/static/map.js @@ -1,43 +1,40 @@ -let map = L.map( 'map', { - center: [37.0902, -95.7129], // Default to U.S.A - minZoom: 3, - zoom: 0 + +var map = L.map( 'mapid', { + center: [51.505, -0.09], // Default to U.S.A + minZoom: 2, + zoom: 0 }); + L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap', - subdomains: ['a','b','c'] -}).addTo( map ); + attribution: '© OpenStreetMap', + subdomains: ['a','b','c'] +}).addTo(map); -let markers = L.markerClusterGroup().addTo(map) +var markers = L.markerClusterGroup().addTo(mapid) function drawMap(){ + var mymap = map; -// initialize the map on the "map" div with a given center and zoom -var mymap = L.map('mapid').setView([51.505, -0.09], 1); - -L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap contributors' -}).addTo(mymap); - -fetch(scriptRoot + "api/getCountByGPS") - .then(response => { - console.log(response) - return response.json(); - }) - .then(data => { - - for (var i=0; i { + console.log(response) + return response.json(); + }) + .then(data => { + for (var i=0; i" + label + "
" + "FastaCount: " +fastaCount); - markers.addLayer(marker) + // markers.addLayer(marker) }} + */ // Reload the map map.invalidateSize(); - document.getElementById("map_view").classList.add("invisible"); - document.getElementById("loader").classList.add("invisible"); + // document.getElementById("map_view").classList.add("invisible"); + // document.getElementById("loader").classList.add("invisible"); } diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html index 2e290c6..3a80abf 100644 --- a/bh20simplewebuploader/templates/demo.html +++ b/bh20simplewebuploader/templates/demo.html @@ -1,10 +1,30 @@ {% include 'header.html' %} + + + + + + + + + {% include 'banner.html' %} {% include 'menu.html' %} {% include 'search.html' %} +

The Virtuoso database contains public sequences!

@@ -26,14 +46,14 @@
- {% include 'footer.html' %} + {% include 'footer.html' %} + diff --git a/bh20simplewebuploader/templates/map.html b/bh20simplewebuploader/templates/map.html index 4aa22b9..e69de29 100644 --- a/bh20simplewebuploader/templates/map.html +++ b/bh20simplewebuploader/templates/map.html @@ -1,49 +0,0 @@ - - - {% include 'header.html' %} - - - - - - - - - - - - {% include 'banner.html' %} - {% include 'menu.html' %} -
- - {% include 'footer.html' %} - - - - - - - - - - - -- cgit v1.2.3 From 108a96f8608c3d82c8cfe1d33ebb37501c01413b Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 10:38:23 +0100 Subject: Align map a bit --- bh20simplewebuploader/static/main.css | 5 +++++ bh20simplewebuploader/templates/demo.html | 2 +- bh20simplewebuploader/templates/home.html | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'bh20simplewebuploader/static/main.css') diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css index 9f89045..6e651a4 100644 --- a/bh20simplewebuploader/static/main.css +++ b/bh20simplewebuploader/static/main.css @@ -385,6 +385,11 @@ div.status { border-bottom: 1px solid #ddd; } +.map { + padding: 20px 32px; + // display: inline-block; +} + .editbutton { float: right; text-align: right; diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html index 04bf877..75bc0e2 100644 --- a/bh20simplewebuploader/templates/demo.html +++ b/bh20simplewebuploader/templates/demo.html @@ -37,7 +37,7 @@ - -