shutdownbutton.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. define([
  4. 'jquery',
  5. 'base/js/dialog',
  6. 'base/js/i18n',
  7. 'base/js/utils'
  8. ], function(
  9. $,
  10. dialog,
  11. i18n,
  12. utils
  13. ){
  14. "use strict";
  15. function display_shutdown_dialog() {
  16. var body = $('<div/>').append(
  17. $('<p/>').text(i18n.msg._("You have shut down Jupyter. You can now close this tab."))
  18. ).append(
  19. $('<p/>').text(i18n.msg._("To use Jupyter again, you will need to relaunch it."))
  20. );
  21. dialog.modal({
  22. title: i18n.msg._("Server stopped"),
  23. body: body
  24. })
  25. }
  26. function activate() {
  27. // Add shutdown button
  28. $("button#shutdown").click(function () {
  29. utils.ajax(utils.url_path_join(
  30. utils.get_body_data("baseUrl"),
  31. "api",
  32. "shutdown"
  33. ), {
  34. type: "POST",
  35. success: display_shutdown_dialog,
  36. error: function (error) {
  37. console.log(error);
  38. }
  39. });
  40. });
  41. }
  42. return {activate: activate}
  43. });