diff options
-rwxr-xr-x | scripts/authentication/editors.py | 46 | ||||
-rwxr-xr-x | scripts/authentication/group.py | 1 | ||||
-rw-r--r-- | wqflask/wqflask/__init__.py | 3 | ||||
-rw-r--r-- | wqflask/wqflask/jupyter_notebooks.py | 21 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/css/jupyter_notebooks.css | 16 | ||||
-rw-r--r-- | wqflask/wqflask/templates/base.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/display_files.html | 119 | ||||
-rw-r--r-- | wqflask/wqflask/templates/jupyter_notebooks.html | 28 |
8 files changed, 235 insertions, 1 deletions
diff --git a/scripts/authentication/editors.py b/scripts/authentication/editors.py new file mode 100755 index 00000000..dc3b1075 --- /dev/null +++ b/scripts/authentication/editors.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +"""Manually add editors users""" +import redis +import json +import uuid +import datetime + +if __name__ == "__main__": + conn = redis.Redis(decode_responses=True) + group_uid = "" + for guid in conn.hgetall("groups"): + group_details = json.loads(conn.hget("groups", guid)) + if group_details.get("name") == "editors": + group_uid = guid + break + + if not group_uid: + group_uid = str(uuid.uuid4()) + timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p') + conn.hset( + "groups", + group_uid, + json.dumps( + { + "name": "editors", + "admins": [], + "members": ["8ad942fe-490d-453e-bd37-56f252e41603"], + "created_timestamp": timestamp, + "changed_timestamp": timestamp, + })) + + for resource in conn.hgetall("resources"): + _resource = json.loads(conn.hget("resources", resource)) + _resource["default_mask"] = { + 'data': 'view', + 'metadata': 'view', + 'admin': 'not-admin', + } + _resource["group_masks"] = { + group_uid: { + 'metadata': 'edit', + 'data': 'edit', + 'admin': 'edit-admins', + }} + conn.hset("resources", resource, json.dumps(_resource)) + print("Done adding editor's group to resources!") diff --git a/scripts/authentication/group.py b/scripts/authentication/group.py index 08652454..dd9ba808 100755 --- a/scripts/authentication/group.py +++ b/scripts/authentication/group.py @@ -123,6 +123,7 @@ def create_group_data(users: Dict, target_group: str, "name": target_group, "admins": list(admin_ids), "members": list(member_ids), + "created_timestamp": timestamp, "changed_timestamp": timestamp, })} diff --git a/wqflask/wqflask/__init__.py b/wqflask/wqflask/__init__.py index 7d46fbad..fbf1c9f5 100644 --- a/wqflask/wqflask/__init__.py +++ b/wqflask/wqflask/__init__.py @@ -23,6 +23,8 @@ from wqflask.api.markdown import facilities_blueprint from wqflask.api.markdown import blogs_blueprint from wqflask.api.markdown import news_blueprint +from wqflask.jupyter_notebooks import jupyter_notebooks + app = Flask(__name__) @@ -60,6 +62,7 @@ app.register_blueprint(environments_blueprint, url_prefix="/environments") app.register_blueprint(facilities_blueprint, url_prefix="/facilities") app.register_blueprint(blogs_blueprint, url_prefix="/blogs") app.register_blueprint(news_blueprint, url_prefix="/news") +app.register_blueprint(jupyter_notebooks, url_prefix="/jupyter_notebooks") app.register_blueprint(resource_management, url_prefix="/resource-management") diff --git a/wqflask/wqflask/jupyter_notebooks.py b/wqflask/wqflask/jupyter_notebooks.py new file mode 100644 index 00000000..dbea04dd --- /dev/null +++ b/wqflask/wqflask/jupyter_notebooks.py @@ -0,0 +1,21 @@ +from flask import Blueprint, render_template + +jupyter_notebooks = Blueprint('jupyter_notebooks', __name__) + +@jupyter_notebooks.route("/launcher", methods=("GET",)) +def launcher(): + links = ( + { + "main_url": "http://notebook.genenetwork.org/51091/tree?", + "notebook_name": "COVID-19 in mybinder.org federation", + "src_link_url": "https://github.com/jgarte/covid19_in_binder"}, + { + "main_url": "http://notebook.genenetwork.org/35639/tree?", + "notebook_name": "Simple requirements.txt based example", + "src_link_url": "https://github.com/jgarte/requirements"}, + { + "main_url": "http://notebook.genenetwork.org/40733/tree?", + "notebook_name": "Guile Jupyter Notebook Querying GeneNetwork API", + "src_link_url": "https://github.com/jgarte/guile-notebook-genenetwork-api"}) + + return render_template("jupyter_notebooks.html", links=links) diff --git a/wqflask/wqflask/static/new/css/jupyter_notebooks.css b/wqflask/wqflask/static/new/css/jupyter_notebooks.css new file mode 100644 index 00000000..db972a17 --- /dev/null +++ b/wqflask/wqflask/static/new/css/jupyter_notebooks.css @@ -0,0 +1,16 @@ +.jupyter-links { + padding: 1.5em; +} + +.jupyter-links:nth-of-type(2n) { + background: #EEEEEE; +} + +.jupyter-links .main-link { + font-size: larger; + display: block; +} + +.jupyter-links .src-link { + font-size: smaller; +} diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 4a6674c6..6e922f24 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -87,7 +87,7 @@ <li><a href="https://systems-genetics.org/">Systems Genetics PheWAS</a></li> <li><a href="http://ucscbrowser.genenetwork.org/">Genome Browser</a></li> <li><a href="http://power.genenetwork.org">BXD Power Calculator</a></li> - <li><a href="http://notebook.genenetwork.org/">Jupyter Notebook Launcher</a></li> + <li><a href="{{url_for('jupyter_notebooks.launcher')}}">Jupyter Notebook Launcher</a></li> <li><a href="http://datafiles.genenetwork.org">Interplanetary File System</a></li> </ul> </li> diff --git a/wqflask/wqflask/templates/display_files.html b/wqflask/wqflask/templates/display_files.html new file mode 100644 index 00000000..d5295fb4 --- /dev/null +++ b/wqflask/wqflask/templates/display_files.html @@ -0,0 +1,119 @@ +{% extends "base.html" %} +{% block title %}Trait Submission{% endblock %} +{% block content %} +<!-- Start of body --> +{% with messages = get_flashed_messages(with_categories=true) %} +{% if messages %} +{% for category, message in messages %} +<div class="container-fluid bg-{{ category }}"> + <p>{{ message }}</p> +</div> +{% endfor %} +{% endif %} +{% endwith %} + + +<div class="container"> + + {% if waiting %} + <div class="row"> + Files for approval: + <div class="table-responsive"> + <table class="table m-0"> + <thead> + <th scope="col">Resource Id</</th> + <th scope="col">Author</th> + <th scope="col">TimeStamp</th> + <th scope="col"></th> + <th scope="col"></th> + </thead> + <tbody> + {% for data in waiting %} + <tr> + {% set file_url = url_for('metadata_edit.show_diff', name=data.get('file_name')) %} + <td><a href="{{ file_url }}" target="_blank">{{ data.get("resource_id") }}</a></td> + <td>{{ data.get("author")}}</td> + <td>{{ data.get("time_stamp")}}</td> + {% if data.get("roles").get("admin") > AdminRole.EDIT_ACCESS %} + {% set reject_url = url_for('metadata_edit.reject_data', resource_id=data.get('resource_id'), file_name=data.get('file_name')) %} + {% set approve_url = url_for('metadata_edit.approve_data', resource_id=data.get('resource_id'), file_name=data.get('file_name')) %} + <td> + <button type="button" + class="btn btn-secondary btn-sm"> + <a href="{{ reject_url }}">Reject</a> + </button> + </td> + <td> + <button type="button" + class="btn btn-warning btn-sm"> + <a href="{{ approve_url }}">Approve</a> + </button> + </td> + {% endif %} + </tr> + {% endfor %} + </tbody> + </table> + </div> + </div> + {% endif %} + + {% if rejected %} + <div class="row"> + Rejected Files: + <div class="table-responsive"> + <table class="table m-0"> + <thead> + <th scope="col">Resource Id</</th> + <th scope="col">Author</th> + <th scope="col">TimeStamp</th> + </thead> + <tbody> + {% for data in rejected %} + <tr> + {% set file_url = url_for('metadata_edit.show_diff', name=data.get('file_name')) %} + <td><a href="{{ file_url }}" target="_blank">{{ data.get("resource_id") }}</a></td> + <td>{{ data.get("author")}}</td> + <td>{{ data.get("time_stamp")}}</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> + </div> + {% endif %} + + {% if approved %} + <div class="row"> + Approved Data: + <div class="table-responsive"> + <table class="table m-0"> + <thead> + <th scope="col">Resource Id</</th> + <th scope="col">Author</th> + <th scope="col">TimeStamp</th> + </thead> + <tbody> + {% for data in approved %} + <tr> + {% set file_url = url_for('metadata_edit.show_diff', name=data.get('file_name')) %} + <td><a href="{{ file_url }}" target="_blank">{{ data.get("resource_id") }}</a></td> + <td>{{ data.get("author")}}</td> + <td>{{ data.get("time_stamp")}}</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> + </div> + {% endif %} +</div> + +{%endblock%} + +{% block js %} +<script> + gn_server_url = "{{ gn_server_url }}"; + +</script> +{% endblock %} diff --git a/wqflask/wqflask/templates/jupyter_notebooks.html b/wqflask/wqflask/templates/jupyter_notebooks.html new file mode 100644 index 00000000..afc95a15 --- /dev/null +++ b/wqflask/wqflask/templates/jupyter_notebooks.html @@ -0,0 +1,28 @@ +{%extends "base.html"%} + +{%block title%} +Jupyter Notebooks +{%endblock%} + +{%block css%} +<link rel="stylesheet" type="text/css" href="/static/new/css/jupyter_notebooks.css" /> +{%endblock%} + +{%block content%} + +<div class="container"> + <h1>Current Notebooks</h1> + + {%for item in links:%} + <div class="jupyter-links"> + <a href="{{item.get('main_url')}}" + title="Access running notebook for '{{item.get('notebook_name')}}' on GeneNetwork" + class="main-link">{{item.get("notebook_name")}}</a> + <a href="{{item.get('src_link_url')}}" + title="Link to the notebook repository for {{item.get('notebook_name', '_')}}" + class="src-link">View Source</a> + </div> + {%endfor%} +</div> + +{%endblock%} |