diff --git a/notebook/static/notebook/js/actions.js b/notebook/static/notebook/js/actions.js index 4f7aeb882..b0990a622 100644 --- a/notebook/static/notebook/js/actions.js +++ b/notebook/static/notebook/js/actions.js @@ -59,6 +59,30 @@ define(function(require){ env.notebook.execute_cell_and_insert_below(); } }, + 'run-all': { + help: 'run all cells', + help_index: 'bd', + handler: function (env) { + env.notebook.execute_all_cells(); + } + }, + 'restart-run-all': { + help: 'restart the kernel, then re-run the whole notebook', + help_index: 'be', + handler: function (env) { + var notebook = env.notebook; + notebook.restart_kernel().then(function() { + notebook.execute_all_cells(); + }); + } + }, + 'restart': { + help: 'restart the kernel', + help_index: 'bf', + handler: function (env) { + env.notebook.restart_kernel(); + } + }, 'go-to-command-mode': { help : 'command mode', help_index : 'aa', diff --git a/notebook/static/notebook/js/menubar.js b/notebook/static/notebook/js/menubar.js index a53ecaf81..914990849 100644 --- a/notebook/static/notebook/js/menubar.js +++ b/notebook/static/notebook/js/menubar.js @@ -35,6 +35,7 @@ define([ this.base_url = options.base_url || utils.get_body_data("baseUrl"); this.selector = selector; this.notebook = options.notebook; + this.actions = this.notebook.keyboard_manager.actions; this.contents = options.contents; this.events = options.events; this.save_widget = options.save_widget; @@ -298,6 +299,9 @@ define([ this.element.find('#restart_kernel').click(function () { that.notebook.restart_kernel(); }); + this.element.find('#restart_run_all').click(function () { + that.actions.call('ipython.restart-run-all'); + }); this.element.find('#reconnect_kernel').click(function () { that.notebook.kernel.reconnect(); }); diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 2a02c5e17..22d2a5eb1 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -323,7 +323,7 @@ define(function (require) { Notebook.prototype.show_command_palette = function() { var x = new commandpalette.CommandPalette(this); - } + }; /** * Trigger a warning dialog about missing functionality from newer minor versions @@ -667,11 +667,11 @@ define(function (require) { } var current_selection = this.get_selected_cells(); for (var i=0; i").text( 'Do you want to restart the current kernel? You will lose all variables defined in it.' @@ -1806,17 +1819,18 @@ define(function (require) { "class" : "btn-danger", "click" : function(){ that.clear_all_output(); - that.kernel.restart(); + restart_and_resolve(); }, }, "Restart" : { "class" : "btn-warning", "click" : function() { - that.kernel.restart(); + restart_and_resolve(); } }, } }); + return promise; }; /** diff --git a/notebook/templates/notebook.html b/notebook/templates/notebook.html index 444c4b15f..15a2634a1 100644 --- a/notebook/templates/notebook.html +++ b/notebook/templates/notebook.html @@ -239,6 +239,10 @@ data-notebook-path="{{notebook_path}}" title="Restart the Kernel"> Restart +
  • + Restart & Run All +
  • Reconnect