Add shutdown button option

pull/3004/head
Grant Nestor 9 years ago committed by Thomas Kluyver
parent faa0cab302
commit 86e45ab9f4

@ -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.shutdown_button,
config=jupyter_app.config,
config_dir=jupyter_app.config_dir,
allow_password_change=jupyter_app.allow_password_change,
@ -1023,6 +1024,10 @@ class NotebookApp(JupyterApp):
@observe('mathjax_config')
def _update_mathjax_config(self, change):
self.log.info(_("Using MathJax configuration file: %s"), change['new'])
shutdown_button = Bool(False, config=True,
help="""Whether or not to display a shutdown server button in the dashboard"""
)
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 {

@ -209,4 +209,21 @@ requirejs([
if (window.location.hash) {
$("#tabs").find("a[href=" + window.location.hash + "]").click();
}
// Add shutdown button
$("button#shutdown").click(function () {
utils.ajax(utils.url_path_join(
utils.get_body_data("baseUrl"),
"api",
"shutdown"
), {
type: "POST",
success: function() {
console.log('server shutdown');
},
error: function(error) {
console.log(error);
}
});
});
});

@ -12,7 +12,12 @@ 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">Shutdown</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