diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py
index 5e73c504a9..7dc610ae5d 100755
--- a/notebook/notebookapp.py
+++ b/notebook/notebookapp.py
@@ -264,6 +264,7 @@ def init_settings(self, jupyter_app, kernel_manager, contents_manager,
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,
server_root_dir=root_dir,
@@ -916,6 +917,10 @@ def _update_mathjax_url(self, change):
@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,
diff --git a/notebook/static/base/less/page.less b/notebook/static/base/less/page.less
index 85e7f825a9..d2720b386e 100644
--- a/notebook/static/base/less/page.less
+++ b/notebook/static/base/less/page.less
@@ -124,9 +124,10 @@ span#login_widget {
}
span#login_widget > .button,
-#logout
+#logout, #shutdown
{
.btn-default();
+ margin-left: 10px;
}
.nav-header {
diff --git a/notebook/static/tree/js/main.js b/notebook/static/tree/js/main.js
index 8aa1f4ab2c..366acbc672 100644
--- a/notebook/static/tree/js/main.js
+++ b/notebook/static/tree/js/main.js
@@ -209,4 +209,21 @@ require([
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);
+ }
+ });
+ });
});
diff --git a/notebook/templates/tree.html b/notebook/templates/tree.html
index 2ee88e2dc1..b10b0600f7 100644
--- a/notebook/templates/tree.html
+++ b/notebook/templates/tree.html
@@ -12,7 +12,12 @@
{% endblock %}
{% block headercontainer %}
-
+
+ {% if shutdown_button %}
+
+
+
+ {% endif %}
{% endblock %}
{% block site %}
diff --git a/notebook/tree/handlers.py b/notebook/tree/handlers.py
index 4d7a6f191d..7178c4c8a9 100644
--- a/notebook/tree/handlers.py
+++ b/notebook/tree/handlers.py
@@ -51,6 +51,7 @@ def get(self, path=''):
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