From b3c116479844e9ee46138d8fc9468d60fc840ea4 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Thu, 20 Feb 2014 17:01:51 -0800 Subject: [PATCH 01/12] put Running tab on the page --- IPython/html/templates/tree.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/IPython/html/templates/tree.html b/IPython/html/templates/tree.html index c8d1193a5..a85eb5941 100644 --- a/IPython/html/templates/tree.html +++ b/IPython/html/templates/tree.html @@ -25,6 +25,7 @@ data-base-kernel-url="{{base_kernel_url}}"
@@ -61,6 +62,25 @@ data-base-kernel-url="{{base_kernel_url}}"
+
+ +
+
+ Currently running IPython notebooks +
+
+ + + +
+
+ +
+
+
+
+
+
@@ -94,6 +114,7 @@ data-base-kernel-url="{{base_kernel_url}}" + {% endblock %} From 3b109de563818801a551fd51e2c3cdf2437a37e6 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Thu, 20 Feb 2014 17:37:46 -0800 Subject: [PATCH 02/12] minimal KernelList --- IPython/html/static/tree/js/kernellist.js | 26 +++++++++++++++++++++++ IPython/html/static/tree/js/main.js | 1 + 2 files changed, 27 insertions(+) create mode 100644 IPython/html/static/tree/js/kernellist.js diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js new file mode 100644 index 000000000..0fdccf8b5 --- /dev/null +++ b/IPython/html/static/tree/js/kernellist.js @@ -0,0 +1,26 @@ +//---------------------------------------------------------------------------- +// Copyright (C) 2014 The IPython Development Team +// +// Distributed under the terms of the BSD License. The full license is in +// the file COPYING, distributed as part of this software. +//---------------------------------------------------------------------------- + +//============================================================================ +// Running Kernels List +//============================================================================ + +var IPython = (function (IPython) { + "use strict"; + + + var KernelList = function (selector, options) { + IPython.NotebookList.call(this, selector, options); + }; + + KernelList.prototype = IPython.NotebookList.prototype; + + IPython.KernelList = KernelList; + + return IPython; + +}(IPython)); diff --git a/IPython/html/static/tree/js/main.js b/IPython/html/static/tree/js/main.js index d66bb680d..9fada6301 100644 --- a/IPython/html/static/tree/js/main.js +++ b/IPython/html/static/tree/js/main.js @@ -24,6 +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.login_widget = new IPython.LoginWidget('#login_widget', opts); var interval_id=0; From cb1bb622726a845d8b36b048ed95c9b5caf63ce1 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Mon, 24 Feb 2014 13:11:13 -0800 Subject: [PATCH 03/12] ok, Running tab is working now --- IPython/html/static/tree/js/kernellist.js | 28 ++++++++++++++++++--- IPython/html/static/tree/js/main.js | 4 ++- IPython/html/static/tree/js/notebooklist.js | 10 +++++--- IPython/html/templates/tree.html | 8 +++--- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js index 0fdccf8b5..70c2eaef9 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 9fada6301..17a74772a 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 fbfed9d07..9135997c1 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 a85eb5941..c56b22c0f 100644 --- a/IPython/html/templates/tree.html +++ b/IPython/html/templates/tree.html @@ -70,14 +70,16 @@ data-base-kernel-url="{{base_kernel_url}}"
- +
-
-
+
From af90cd8c626faef344402fc3412801b6b978f040 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Mon, 24 Feb 2014 13:11:50 -0800 Subject: [PATCH 04/12] fix typo in method name --- IPython/html/static/tree/js/main.js | 2 +- IPython/html/static/tree/js/notebooklist.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/IPython/html/static/tree/js/main.js b/IPython/html/static/tree/js/main.js index 17a74772a..ee48102f9 100644 --- a/IPython/html/static/tree/js/main.js +++ b/IPython/html/static/tree/js/main.js @@ -74,7 +74,7 @@ $(document).ready(function () { // bound the upload method to the on change of the file select list $("#alternate_upload").change(function (event){ - IPython.notebook_list.handelFilesUpload(event,'form'); + IPython.notebook_list.handleFilesUpload(event,'form'); }); // set hash on tab click diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index 9135997c1..159df7375 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -47,12 +47,12 @@ var IPython = (function (IPython) { return false; }); this.element.bind('drop', function(event){ - that.handelFilesUpload(event,'drop'); + that.handleFilesUpload(event,'drop'); return false; }); }; - NotebookList.prototype.handelFilesUpload = function(event, dropOrForm) { + NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) { var that = this; var files; if(dropOrForm =='drop'){ From a27168ae3b583c14bde14a3af49e9b523f08f421 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Mon, 24 Feb 2014 13:12:15 -0800 Subject: [PATCH 05/12] refresh of Notebook list should reload sessions --- IPython/html/static/tree/js/notebooklist.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index 159df7375..c6da89b9c 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -40,8 +40,8 @@ var IPython = (function (IPython) { NotebookList.prototype.bind_events = function () { var that = this; - $('#refresh_notebook_list').click(function () { - that.load_list(); + $('#refresh_' + this.element_name + '_list').click(function () { + that.load_sessions(); }); this.element.bind('dragover', function () { return false; From a2b9c75e936a81bd750bb859e7f76b4f922ab1eb Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Mon, 24 Feb 2014 14:18:22 -0800 Subject: [PATCH 06/12] don't double-join the notebook path --- IPython/html/static/tree/js/kernellist.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js index 70c2eaef9..7177d921f 100644 --- a/IPython/html/static/tree/js/kernellist.js +++ b/IPython/html/static/tree/js/kernellist.js @@ -26,10 +26,9 @@ var IPython = (function (IPython) { 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; + var path= utils.url_path_join(d[i].notebook.path, d[i].notebook.name); item = this.new_notebook_item(i); - this.add_link(path, path, item); + this.add_link('', path, item); this.sessions[path] = d[i].id; this.add_shutdown_button(item,this.sessions[path]); } From 06c689caa32fd24c084a290755b3b3e2152a7da6 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Mon, 24 Feb 2014 15:02:08 -0800 Subject: [PATCH 07/12] remove reiterated repetitively redundant "actively" --- IPython/html/templates/tree.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/html/templates/tree.html b/IPython/html/templates/tree.html index c56b22c0f..fac67bbfd 100644 --- a/IPython/html/templates/tree.html +++ b/IPython/html/templates/tree.html @@ -77,7 +77,7 @@ data-base-kernel-url="{{base_kernel_url}}"
From b74b10e308ff96056a2c73b8ce4830a4e76e9a28 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Tue, 25 Feb 2014 18:09:16 -0800 Subject: [PATCH 08/12] added IPython.session_list before this, kernel_list and notebook_list each fetched and held onto their own copy of the sessions. --- IPython/html/static/tree/js/kernellist.js | 14 +++-- IPython/html/static/tree/js/main.js | 7 ++- IPython/html/static/tree/js/notebooklist.js | 32 ++--------- IPython/html/static/tree/js/sessionlist.js | 59 +++++++++++++++++++++ IPython/html/templates/tree.html | 1 + 5 files changed, 74 insertions(+), 39 deletions(-) create mode 100644 IPython/html/static/tree/js/sessionlist.js diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js index 7177d921f..d52e09c97 100644 --- a/IPython/html/static/tree/js/kernellist.js +++ b/IPython/html/static/tree/js/kernellist.js @@ -21,22 +21,20 @@ var IPython = (function (IPython) { KernelList.prototype = Object.create(IPython.NotebookList.prototype); KernelList.prototype.sessions_loaded = function (d) { + this.sessions = 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); - item = this.new_notebook_item(i); + for (var path in d) { + item = this.new_notebook_item(-1); this.add_link('', 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 { + if ($.isEmptyObject(d)) { $('#' + this.element_name + '_list_header').show(); + } else { + $('#' + this.element_name + '_list_header').hide(); } } diff --git a/IPython/html/static/tree/js/main.js b/IPython/html/static/tree/js/main.js index ee48102f9..92e400d14 100644 --- a/IPython/html/static/tree/js/main.js +++ b/IPython/html/static/tree/js/main.js @@ -22,6 +22,7 @@ $(document).ready(function () { base_url : IPython.utils.get_body_data("baseUrl"), notebook_path : IPython.utils.get_body_data("notebookPath"), }; + IPython.session_list = new IPython.SesssionList(opts); IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts); IPython.cluster_list = new IPython.ClusterList('#cluster_list', opts); IPython.kernel_list = new IPython.KernelList('#running_list', opts); @@ -36,16 +37,14 @@ $(document).ready(function () { //refresh immediately , then start interval if($('.upload_button').length == 0) { - IPython.notebook_list.load_sessions(); - IPython.kernel_list.load_sessions(); + IPython.session_list.load_sessions(); IPython.cluster_list.load_list(); } if (!interval_id){ interval_id = setInterval(function(){ if($('.upload_button').length == 0) { - IPython.notebook_list.load_sessions(); - IPython.kernel_list.load_sessions(); + IPython.session_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 c6da89b9c..4b86310f5 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -15,6 +15,7 @@ var IPython = (function (IPython) { var utils = IPython.utils; var NotebookList = function (selector, options, element_name) { + var that = this // allow code re-use by just changing element_name in kernellist.js this.element_name = element_name || 'notebook'; this.selector = selector; @@ -27,6 +28,8 @@ var IPython = (function (IPython) { this.sessions = {}; this.base_url = options.base_url || utils.get_body_data("baseUrl"); this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath"); + $([IPython.events]).on('sessions_loaded.Dashboard', + function(e, d) { that.sessions_loaded(d); }); }; NotebookList.prototype.style = function () { @@ -100,37 +103,12 @@ var IPython = (function (IPython) { }; NotebookList.prototype.load_sessions = function(){ - var that = this; - var settings = { - processData : false, - cache : false, - type : "GET", - dataType : "json", - success : $.proxy(that.sessions_loaded, this) - }; - var url = utils.url_join_encode(this.base_url, 'api/sessions'); - $.ajax(url,settings); + IPython.session_list.load_sessions(); }; NotebookList.prototype.sessions_loaded = function(data){ - this.sessions = {}; - var len = data.length; - if (len > 0) { - for (var i=0; i 0) { + for (var i=0; i + From 7d1da4c550dfa398e31ff85b775e5e122038ad6d Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Wed, 26 Feb 2014 12:35:20 -0800 Subject: [PATCH 09/12] refer to notebooks, not kernels. --- IPython/html/templates/tree.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/html/templates/tree.html b/IPython/html/templates/tree.html index 589376c88..cf0abad5b 100644 --- a/IPython/html/templates/tree.html +++ b/IPython/html/templates/tree.html @@ -77,7 +77,7 @@ data-base-kernel-url="{{base_kernel_url}}"
From 14239c01e44d2a7a5319918b6946cb73052e6fb3 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Thu, 27 Feb 2014 17:59:16 -0800 Subject: [PATCH 10/12] use explicit running header name + jquery's toggle --- IPython/html/static/tree/js/kernellist.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js index d52e09c97..7ff20dd2d 100644 --- a/IPython/html/static/tree/js/kernellist.js +++ b/IPython/html/static/tree/js/kernellist.js @@ -31,11 +31,7 @@ var IPython = (function (IPython) { this.add_shutdown_button(item,this.sessions[path]); } - if ($.isEmptyObject(d)) { - $('#' + this.element_name + '_list_header').show(); - } else { - $('#' + this.element_name + '_list_header').hide(); - } + $('#running_list_header').toggle($.isEmptyObject(d)); } IPython.KernelList = KernelList; From eb4e6745981c93ed1d9c1bcd829594e7cb1419df Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Thu, 27 Feb 2014 18:13:53 -0800 Subject: [PATCH 11/12] remove redundant checks in code --- IPython/html/static/tree/js/sessionlist.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/IPython/html/static/tree/js/sessionlist.js b/IPython/html/static/tree/js/sessionlist.js index 1b4a72978..dc1f9aa14 100644 --- a/IPython/html/static/tree/js/sessionlist.js +++ b/IPython/html/static/tree/js/sessionlist.js @@ -35,20 +35,13 @@ var IPython = (function (IPython) { SesssionList.prototype.sessions_loaded = function(data){ this.sessions = {}; var len = data.length; - if (len > 0) { - for (var i=0; i Date: Thu, 27 Feb 2014 19:36:42 -0800 Subject: [PATCH 12/12] small whitespace cleanup, renamed drag_info in the dashboard, I've renamed drag_info to notebook_list_info, so applying style to notebook_list_info and running_list_info can be done in one place. --- IPython/html/static/tree/js/kernellist.js | 3 +-- IPython/html/static/tree/js/notebooklist.js | 9 +++++---- IPython/html/static/tree/js/sessionlist.js | 2 +- IPython/html/templates/tree.html | 7 +++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js index 7ff20dd2d..f89d52cb0 100644 --- a/IPython/html/static/tree/js/kernellist.js +++ b/IPython/html/static/tree/js/kernellist.js @@ -22,13 +22,12 @@ var IPython = (function (IPython) { KernelList.prototype.sessions_loaded = function (d) { this.sessions = d; - // clear out the previous list this.clear_list(); var item; for (var path in d) { item = this.new_notebook_item(-1); this.add_link('', path, item); - this.add_shutdown_button(item,this.sessions[path]); + this.add_shutdown_button(item, this.sessions[path]); } $('#running_list_header').toggle($.isEmptyObject(d)); diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index 4b86310f5..2f472de93 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -33,10 +33,11 @@ var IPython = (function (IPython) { }; NotebookList.prototype.style = function () { - $('#' + this.element_name + '_toolbar').addClass('list_toolbar'); - $('#drag_info').addClass('toolbar_info'); - $('#' + this.element_name + '_buttons').addClass('toolbar_buttons'); - $('#' + this.element_name + '_list_header').addClass('list_header'); + var prefix = '#' + this.element_name + $(prefix + '_toolbar').addClass('list_toolbar'); + $(prefix + '_list_info').addClass('toolbar_info'); + $(prefix + '_buttons').addClass('toolbar_buttons'); + $(prefix + '_list_header').addClass('list_header'); this.element.addClass("list_container"); }; diff --git a/IPython/html/static/tree/js/sessionlist.js b/IPython/html/static/tree/js/sessionlist.js index dc1f9aa14..4942ed890 100644 --- a/IPython/html/static/tree/js/sessionlist.js +++ b/IPython/html/static/tree/js/sessionlist.js @@ -29,7 +29,7 @@ var IPython = (function (IPython) { success : $.proxy(that.sessions_loaded, this) }; var url = utils.url_join_encode(this.base_url, 'api/sessions'); - $.ajax(url,settings); + $.ajax(url, settings); }; SesssionList.prototype.sessions_loaded = function(data){ diff --git a/IPython/html/templates/tree.html b/IPython/html/templates/tree.html index cf0abad5b..19a5e2320 100644 --- a/IPython/html/templates/tree.html +++ b/IPython/html/templates/tree.html @@ -34,9 +34,9 @@ data-base-kernel-url="{{base_kernel_url}}"
- + To import a notebook, drag the file onto the listing below or click here. - +
@@ -76,9 +76,8 @@ data-base-kernel-url="{{base_kernel_url}}"
-