plasmabio / tljh-repo2docker

Plugin for The Littlest JupyterHub to build multiple user environments with repo2docker
BSD 3-Clause "New" or "Revised" License
60 stars 15 forks source link

Improve the spawn page when there is no environment #26

Open jtpio opened 4 years ago

jtpio commented 4 years ago

On a fresh install, the spawn page displays the following:

image

When there is no user environment, the Start button is not needed.

We could extend the spawn.html base template and modify it to show a message.

The template will be added to: https://github.com/plasmabio/tljh-repo2docker/tree/master/tljh_repo2docker/templates

The custom template will override the base JupyterHub template: https://github.com/jupyterhub/jupyterhub/blob/77edffd695bbef3b132fb3e9f1c6f080a84977e2/share/jupyterhub/templates/spawn.html

jtpio commented 4 years ago

Maybe the simplest for now would be to define a custom spawn.yml in tljh_repo2docker/templates with a content similar to the following:

{% extends "templates/spawn.html" %}

{% block main %}
<div class="container">
  {% block heading %}
  <div class="row text-center">
    <h1>User Environments</h1>
  </div>
  {% endblock %}
  <div class="row col-sm-offset-2 col-sm-8">
    {% if for_user and user.name != for_user.name -%}
      <p>Spawning server for {{ for_user.name }}</p>
    {% endif -%}
    {% if error_message -%}
      <p class="spawn-error-msg text-danger">
        Error: {{error_message}}
      </p>
    {% endif %}
    {% if 'label' in spawner_options_form -%}
    <form enctype="multipart/form-data" id="spawn_form" action="{{url}}" method="post" role="form">
      {{spawner_options_form | safe}}
      <br>
      <input type="submit" value="Start" class="btn btn-jupyter form-control">
    </form>
    {% else %}
      <p class="text-info">
        No user environment available
      </p>
    {% endif %}
  </div>
</div>
{% endblock %}