diff --git a/ipsportal/run.py b/ipsportal/run.py index 0daff6b..8adb64b 100644 --- a/ipsportal/run.py +++ b/ipsportal/run.py @@ -1,4 +1,6 @@ from typing import Tuple +from urllib3.util import parse_url + from flask import Blueprint, render_template from ipsportal.db import get_run, get_runid, get_data_information @@ -21,4 +23,8 @@ def run(runid: int) -> Tuple[str, int]: else: run['parent_runid'] = None data_info, jupyter_urls = get_data_information(run['portal_runid']) - return render_template("events.html", run=run, data_info=data_info, jupyter_urls=jupyter_urls), 200 + if jupyter_urls: + resolved_jupyter_urls = [[jupyter_url, parse_url(jupyter_url).host] for jupyter_url in jupyter_urls] + else: + resolved_jupyter_urls = None + return render_template("events.html", run=run, data_info=data_info, jupyter_urls=resolved_jupyter_urls), 200 diff --git a/ipsportal/static/events.css b/ipsportal/static/events.css index 8ff311d..435a6b2 100644 --- a/ipsportal/static/events.css +++ b/ipsportal/static/events.css @@ -23,3 +23,13 @@ details[open] summary { ol { padding-left: 4rem; } + +.jupyter-url-btn { + font-size: 100%; + font-family: inherit; + border: 0; + padding: 0; + text-decoration: underline; + background-color: inherit; + color: rgba(var(--bs-link-color-rgb),var(--bs-link-opacity,1)); +} diff --git a/ipsportal/static/jupyter_url.js b/ipsportal/static/jupyter_url.js new file mode 100644 index 0000000..fd0e27e --- /dev/null +++ b/ipsportal/static/jupyter_url.js @@ -0,0 +1,22 @@ +// in a URL for jupyter.nersc.gov , users must provide NERSC Shibboleth (auth manager) credentials in the URL, but this will only work for a single user. +// We can dynamically create this URL on the frontend. + +const NERSC_URL_HELPER_STORAGE_KEY = "username__jupyter.nersc.gov"; + +function onJupyterUrlBtnClick() { + const nersc_username = prompt( + "Enter the username you authenticate with on NERSC Shibboleth.", + window.localStorage.getItem(NERSC_URL_HELPER_STORAGE_KEY) || "" + ); + if (nersc_username != null) { + window.localStorage.setItem(NERSC_URL_HELPER_STORAGE_KEY, nersc_username); + const result = jupyterUrlBtn + .getAttribute("data-original-url") + .replace(new RegExp("/user/[^/]+/"), `/user/${nersc_username}/`); + window.location.href = result; + } +} + +for (jupyterUrlBtn of document.getElementsByClassName("jupyter-url-btn")) { + jupyterUrlBtn.addEventListener("click", onJupyterUrlBtnClick); +} diff --git a/ipsportal/templates/events.html b/ipsportal/templates/events.html index 12f65b8..23d3d26 100644 --- a/ipsportal/templates/events.html +++ b/ipsportal/templates/events.html @@ -2,6 +2,7 @@ {% block head %} + {% endblock %} @@ -65,7 +66,7 @@

{% block title %}Run - {{ run.runid }}{% endblock %}

Monitor {% if run.vizurl %} - monitor + monitor {% else %} {% endif %} @@ -104,11 +105,15 @@

{% block title %}Run - {{ run.runid }}{% endblock %}

Associated JupyterHub Notebooks