##// END OF EJS Templates
fix restart/interrupt kernel buttons
Zachary Sailer -
Show More
@@ -77,7 +77,7 b' class KernelActionHandler(IPythonHandler):'
77 if action == 'restart':
77 if action == 'restart':
78 km.restart_kernel(kernel_id)
78 km.restart_kernel(kernel_id)
79 model = km.kernel_model(kernel_id,self.ws_url)
79 model = km.kernel_model(kernel_id,self.ws_url)
80 self.set_header('Location', '{0}kernels/{1}'.format(self.base_kernel_url, kernel_id))
80 self.set_header('Location', '{0}api/kernels/{1}'.format(self.base_kernel_url, kernel_id))
81 self.write(jsonapi.dumps(model))
81 self.write(jsonapi.dumps(model))
82 self.finish()
82 self.finish()
83
83
@@ -112,7 +112,7 b' var IPython = (function (IPython) {'
112 label : 'Interrupt',
112 label : 'Interrupt',
113 icon : 'icon-stop',
113 icon : 'icon-stop',
114 callback : function () {
114 callback : function () {
115 IPython.notebook.kernel.interrupt();
115 IPython.notebook.session.interrupt_kernel();
116 }
116 }
117 }
117 }
118 ],'run_int');
118 ],'run_int');
@@ -227,7 +227,7 b' var IPython = (function (IPython) {'
227 });
227 });
228 // Kernel
228 // Kernel
229 this.element.find('#int_kernel').click(function () {
229 this.element.find('#int_kernel').click(function () {
230 IPython.notebook.kernel.interrupt();
230 IPython.notebook.session.interrupt_kernel();
231 });
231 });
232 this.element.find('#restart_kernel').click(function () {
232 this.element.find('#restart_kernel').click(function () {
233 IPython.notebook.restart_kernel();
233 IPython.notebook.restart_kernel();
@@ -311,7 +311,7 b' var IPython = (function (IPython) {'
311 return false;
311 return false;
312 } else if (event.which === 73 && that.control_key_active) {
312 } else if (event.which === 73 && that.control_key_active) {
313 // Interrupt kernel = i
313 // Interrupt kernel = i
314 that.kernel.interrupt();
314 that.session.interrupt_kernel();
315 that.control_key_active = false;
315 that.control_key_active = false;
316 return false;
316 return false;
317 } else if (event.which === 190 && that.control_key_active) {
317 } else if (event.which === 190 && that.control_key_active) {
@@ -1395,7 +1395,30 b' var IPython = (function (IPython) {'
1395 this.session.start();
1395 this.session.start();
1396 };
1396 };
1397
1397
1398
1398 /**
1399 * Prompt the user to restart the IPython kernel.
1400 *
1401 * @method restart_kernel
1402 */
1403 Notebook.prototype.restart_kernel = function () {
1404 var that = this;
1405 IPython.dialog.modal({
1406 title : "Restart kernel or continue running?",
1407 body : $("<p/>").html(
1408 'Do you want to restart the current kernel? You will lose all variables defined in it.'
1409 ),
1410 buttons : {
1411 "Continue running" : {},
1412 "Restart" : {
1413 "class" : "btn-danger",
1414 "click" : function() {
1415 that.session.restart_kernel();
1416 }
1417 }
1418 }
1419 });
1420 };
1421
1399 /**
1422 /**
1400 * Run the selected cell.
1423 * Run the selected cell.
1401 *
1424 *
@@ -59,27 +59,13 b' var IPython = (function (IPython) {'
59 * @method restart_kernel
59 * @method restart_kernel
60 */
60 */
61 Session.prototype.restart_kernel = function () {
61 Session.prototype.restart_kernel = function () {
62 var that = this;
62 this.kernel.restart();
63 var dialog = $('<div/>');
64 dialog.html('Do you want to restart the current kernel? You will lose all variables defined in it.');
65 $(document).append(dialog);
66 dialog.dialog({
67 resizable: false,
68 modal: true,
69 title: "Restart kernel or continue running?",
70 closeText: '',
71 buttons : {
72 "Restart": function () {
73 that.kernel.restart();
74 $(this).dialog('close');
75 },
76 "Continue running": function () {
77 $(this).dialog('close');
78 }
79 }
80 });
81 };
63 };
82
64
65 Session.prototype.interrupt_kernel = function() {
66 this.kernel.interrupt();
67 }
68
83 IPython.Session = Session;
69 IPython.Session = Session;
84
70
85
71
General Comments 0
You need to be logged in to leave comments. Login now