New module for shutdownbutton

pull/3004/head
Thomas Kluyver 8 years ago
parent ae1b6fb835
commit 8a97003a6a

@ -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";
@ -210,20 +212,5 @@ requirejs([
$("#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);
}
});
});
shutdownbutton.activate();
});

@ -0,0 +1,52 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/dialog',
'base/js/events',
'base/js/promises',
'base/js/page',
'base/js/utils'
], function(
$,
dialog,
events,
promises,
page,
utils
){
"use strict";
function display_shutdown_dialog() {
var body = $('<div/>').append(
$('<p/>').text("You have shut down Jupyter. You can now close this tab.")
).append(
$('<p/>').text("To use Jupyter again, you will need to relaunch it.")
);
dialog.modal({
title: "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}
});
Loading…
Cancel
Save