diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js index 0fdccf8..70c2eae 100644 --- a/IPython/html/static/tree/js/kernellist.js +++ b/IPython/html/static/tree/js/kernellist.js @@ -12,13 +12,35 @@ var IPython = (function (IPython) { "use strict"; - + var utils = IPython.utils; + var KernelList = function (selector, options) { - IPython.NotebookList.call(this, selector, options); + IPython.NotebookList.call(this, selector, options, 'running'); }; - KernelList.prototype = IPython.NotebookList.prototype; + KernelList.prototype = Object.create(IPython.NotebookList.prototype); + KernelList.prototype.sessions_loaded = function (d) { + // clear out the previous list + this.clear_list(); + var len = d.length; + var item; + for (var i=0; i < d.length; i++) { + var path = utils.url_path_join(d[i].notebook.path, d[i].notebook.name); + var name = d[i].name; + item = this.new_notebook_item(i); + this.add_link(path, path, item); + this.sessions[path] = d[i].id; + this.add_shutdown_button(item,this.sessions[path]); + } + + if (len > 0) { + $('#' + this.element_name + '_list_header').hide(); + } else { + $('#' + this.element_name + '_list_header').show(); + } + } + IPython.KernelList = KernelList; return IPython; diff --git a/IPython/html/static/tree/js/main.js b/IPython/html/static/tree/js/main.js index 9fada63..17a7477 100644 --- a/IPython/html/static/tree/js/main.js +++ b/IPython/html/static/tree/js/main.js @@ -24,7 +24,7 @@ $(document).ready(function () { }; IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts); IPython.cluster_list = new IPython.ClusterList('#cluster_list', opts); - IPython.kernel_list = new IPython.KernelList('#kernel_list', opts); + IPython.kernel_list = new IPython.KernelList('#running_list', opts); IPython.login_widget = new IPython.LoginWidget('#login_widget', opts); var interval_id=0; @@ -37,6 +37,7 @@ $(document).ready(function () { if($('.upload_button').length == 0) { IPython.notebook_list.load_sessions(); + IPython.kernel_list.load_sessions(); IPython.cluster_list.load_list(); } if (!interval_id){ @@ -44,6 +45,7 @@ $(document).ready(function () { if($('.upload_button').length == 0) { IPython.notebook_list.load_sessions(); + IPython.kernel_list.load_sessions(); IPython.cluster_list.load_list(); } }, time_refresh*1000); diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index fbfed9d..9135997 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -14,7 +14,9 @@ var IPython = (function (IPython) { var utils = IPython.utils; - var NotebookList = function (selector, options) { + var NotebookList = function (selector, options, element_name) { + // allow code re-use by just changing element_name in kernellist.js + this.element_name = element_name || 'notebook'; this.selector = selector; if (this.selector !== undefined) { this.element = $(selector); @@ -28,10 +30,10 @@ var IPython = (function (IPython) { }; NotebookList.prototype.style = function () { - $('#notebook_toolbar').addClass('list_toolbar'); + $('#' + this.element_name + '_toolbar').addClass('list_toolbar'); $('#drag_info').addClass('toolbar_info'); - $('#notebook_buttons').addClass('toolbar_buttons'); - $('#notebook_list_header').addClass('list_header'); + $('#' + this.element_name + '_buttons').addClass('toolbar_buttons'); + $('#' + this.element_name + '_list_header').addClass('list_header'); this.element.addClass("list_container"); }; diff --git a/IPython/html/templates/tree.html b/IPython/html/templates/tree.html index a85eb59..c56b22c 100644 --- a/IPython/html/templates/tree.html +++ b/IPython/html/templates/tree.html @@ -70,14 +70,16 @@ data-base-kernel-url="{{base_kernel_url}}"
- +
-
-
+