Merge pull request #3004 from gnestor/issue-1530

Add shutdown button option
pull/3497/head
Thomas Kluyver 8 years ago committed by GitHub
commit 9d4a2da362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -273,6 +273,7 @@ class NotebookWebApplication(web.Application):
websocket_url=jupyter_app.websocket_url,
mathjax_url=jupyter_app.mathjax_url,
mathjax_config=jupyter_app.mathjax_config,
shutdown_button=jupyter_app.quit_button,
config=jupyter_app.config,
config_dir=jupyter_app.config_dir,
allow_password_change=jupyter_app.allow_password_change,
@ -1023,6 +1024,11 @@ class NotebookApp(JupyterApp):
@observe('mathjax_config')
def _update_mathjax_config(self, change):
self.log.info(_("Using MathJax configuration file: %s"), change['new'])
quit_button = Bool(True, config=True,
help="""If True, display a button in the dashboard to quit
(shutdown the notebook server)."""
)
contents_manager_class = Type(
default_value=LargeFileManager,

@ -124,9 +124,10 @@ span#login_widget {
}
span#login_widget > .button,
#logout
#logout, #shutdown
{
.btn-default();
margin-left: 10px;
}
.nav-header {

@ -35,6 +35,7 @@ requirejs([
'tree/js/kernellist',
'tree/js/terminallist',
'tree/js/newnotebook',
'tree/js/shutdownbutton',
'auth/js/loginwidget',
'bidi/bidi',
], function(
@ -52,6 +53,7 @@ requirejs([
kernellist,
terminallist,
newnotebook,
shutdownbutton,
loginwidget,
bidi){
"use strict";
@ -209,4 +211,6 @@ requirejs([
if (window.location.hash) {
$("#tabs").find("a[href=" + window.location.hash + "]").click();
}
shutdownbutton.activate();
});

@ -0,0 +1,48 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/dialog',
'base/js/i18n',
'base/js/utils'
], function(
$,
dialog,
i18n,
utils
){
"use strict";
function display_shutdown_dialog() {
var body = $('<div/>').append(
$('<p/>').text(i18n.msg._("You have shut down Jupyter. You can now close this tab."))
).append(
$('<p/>').text(i18n.msg._("To use Jupyter again, you will need to relaunch it."))
);
dialog.modal({
title: i18n.msg._("Server stopped"),
body: body
})
}
function activate() {
// Add shutdown button
$("button#shutdown").click(function () {
utils.ajax(utils.url_path_join(
utils.get_body_data("baseUrl"),
"api",
"shutdown"
), {
type: "POST",
success: display_shutdown_dialog,
error: function (error) {
console.log(error);
}
});
});
}
return {activate: activate}
});

@ -12,7 +12,15 @@ data-server-root="{{server_root}}"
{% endblock %}
{% block headercontainer %}
<span class="flex-spacer"></span>
<span class="flex-spacer"></span>
{% if shutdown_button %}
<span id="shutdown_widget">
<button id="shutdown" class="btn btn-sm navbar-btn"
title="{% trans %}Stop the Jupyter server{% endtrans %}">
{% trans %}Quit{% endtrans %}
</button>
</span>
{% endif %}
{% endblock %}
{% block site %}

@ -51,6 +51,7 @@ class TreeHandler(IPythonHandler):
breadcrumbs=breadcrumbs,
terminals_available=self.settings['terminals_available'],
server_root=self.settings['server_root_dir'],
shutdown_button=self.settings.get('shutdown_button', False)
))
elif cm.file_exists(path):
# it's not a directory, we have redirecting to do

Loading…
Cancel
Save