proof of concept

pull/37/head
Matthias BUSSONNIER 14 years ago
parent 473a3947b0
commit 4af8cb6c9a

@ -338,7 +338,7 @@ class MainKernelHandler(AuthenticatedHandler):
class KernelHandler(AuthenticatedHandler):
SUPPORTED_METHODS = ('DELETE')
SUPPORTED_METHODS = ('POST','DELETE')
@web.authenticated
def delete(self, kernel_id):
@ -347,7 +347,6 @@ class KernelHandler(AuthenticatedHandler):
self.set_status(204)
self.finish()
class KernelActionHandler(AuthenticatedHandler):
@web.authenticated
@ -596,8 +595,9 @@ class NotebookRootHandler(AuthenticatedHandler):
nlist=[]
for f in files :
nid = f['notebook_id']
if km.kernel_for_notebook(nid) is not None:
f['kernel_status']='on'
kid = km.kernel_for_notebook(nid)
if kid is not None:
f['kernel_status']=kid
else:
f['kernel_status']='off'
nlist.append(f)

@ -89,7 +89,6 @@ var IPython = (function (IPython) {
NotebookList.prototype.load_list = function () {
this.clear_list();
var settings = {
processData : false,
cache : false,
@ -104,15 +103,21 @@ var IPython = (function (IPython) {
NotebookList.prototype.list_loaded = function (data, status, xhr) {
var len = data.length;
this.clear_list();
// Todo: remove old children
for (var i=0; i<len; i++) {
var notebook_id = data[i].notebook_id;
var nbname = data[i].name;
var kernel = data[i].kernel_status;
var item = this.new_notebook_item(i);
this.add_link(notebook_id, nbname, item);
if (!IPython.read_only){
// hide delete buttons when readonly
this.add_delete_button(item);
if(kernel == 'off'){
this.add_delete_button(item);
} else {
this.add_shutdown_button(item,kernel);
}
}
};
};
@ -176,6 +181,33 @@ var IPython = (function (IPython) {
};
NotebookList.prototype.add_shutdown_button = function (item,kernel) {
var new_buttons = $('<span/>').addClass('item_buttons');
var that = this;
var shutdown_button = $('<button>Shutdown</button>').button().
click(function (e) {
var settings = {
processData : false,
cache : false,
type : "DELETE",
dataType : "json",
success : function (data, status, xhr) {
console.log('kernel killed');
that.load_list();
}
};
var url = $('body').data('baseProjectUrl') + 'kernels/'+kernel;
$.ajax(url, settings);
});
new_buttons.append(shutdown_button);
var e = item.find('.item_buttons');
if (e.length === 0) {
item.append(new_buttons);
} else {
e.replaceWith(new_buttons);
};
};
NotebookList.prototype.add_delete_button = function (item) {
var new_buttons = $('<span/>').addClass('item_buttons');
var delete_button = $('<button>Delete</button>').button().

Loading…
Cancel
Save