mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 15:33:02 +00:00
simplify start-server links as pure links to /spawn/:user/:server
instead of API requests this gets better progress-page loading and options form rendering
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
require(["jquery", "moment", "jhapi"], function($, moment, JHAPI) {
|
||||
require(["jquery", "moment", "jhapi", "utils"], function(
|
||||
$,
|
||||
moment,
|
||||
JHAPI,
|
||||
utils
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
var base_url = window.jhdata.base_url;
|
||||
var prefix = window.jhdata.prefix;
|
||||
var user = window.jhdata.user;
|
||||
var api = new JHAPI(base_url);
|
||||
|
||||
@@ -28,7 +34,6 @@ require(["jquery", "moment", "jhapi"], function($, moment, JHAPI) {
|
||||
// enable buttons on a server row
|
||||
// once the server is running or not
|
||||
row.find(".btn").attr("disabled", false);
|
||||
row.find(".start-server").click(startServer);
|
||||
row.find(".stop-server").click(stopServer);
|
||||
row.find(".delete-server").click(deleteServer);
|
||||
|
||||
@@ -58,25 +63,6 @@ require(["jquery", "moment", "jhapi"], function($, moment, JHAPI) {
|
||||
});
|
||||
}
|
||||
|
||||
function startServer() {
|
||||
var row = getRow($(this));
|
||||
var serverName = row.data("server-name");
|
||||
|
||||
// before request
|
||||
disableRow(row);
|
||||
|
||||
// request
|
||||
api.start_named_server(user, serverName, {
|
||||
success: function(reply) {
|
||||
enableRow(row, true);
|
||||
// TODO: this may 404 on the wrong server
|
||||
// in case of slow startup
|
||||
// it should really redirect to a `/spawn?server=...` page
|
||||
window.location.href = row.find(".server-link").attr("href");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function deleteServer() {
|
||||
var row = getRow($(this));
|
||||
var serverName = row.data("server-name");
|
||||
@@ -122,7 +108,6 @@ require(["jquery", "moment", "jhapi"], function($, moment, JHAPI) {
|
||||
});
|
||||
});
|
||||
|
||||
$(".start-server").click(startServer);
|
||||
$(".stop-server").click(stopServer);
|
||||
$(".delete-server").click(deleteServer);
|
||||
|
||||
|
@@ -72,6 +72,7 @@
|
||||
<td>
|
||||
<a role="button" class="stop-server btn btn-xs btn-danger{% if not spawner.active %} hidden{% endif %}" id="stop-{{ spawner.name }}">stop</a>
|
||||
<a role="button" class="start-server btn btn-xs btn-primary {% if spawner.active %} hidden{% endif %}" id="start-{{ spawner.name }}"
|
||||
href="{{ base_url }}spawn/{{ user.name }}/{{ spawner.name }}"
|
||||
>
|
||||
start
|
||||
</a>
|
||||
|
Reference in New Issue
Block a user