From 44a94be197ef221894bc75928a382d3cec161d5d 2014-02-28 03:57:50 From: Paul Ivanov Date: 2014-02-28 03:57:50 Subject: [PATCH] Merge pull request #5215 from ivanov/running-kernels Dashboard "Running" Tab --- diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js new file mode 100644 index 0000000..f89d52c --- /dev/null +++ b/IPython/html/static/tree/js/kernellist.js @@ -0,0 +1,40 @@ +//---------------------------------------------------------------------------- +// 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 utils = IPython.utils; + + var KernelList = function (selector, options) { + IPython.NotebookList.call(this, selector, options, 'running'); + }; + + KernelList.prototype = Object.create(IPython.NotebookList.prototype); + + KernelList.prototype.sessions_loaded = function (d) { + this.sessions = d; + 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]); + } + + $('#running_list_header').toggle($.isEmptyObject(d)); + } + + 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 d66bb68..92e400d 100644 --- a/IPython/html/static/tree/js/main.js +++ b/IPython/html/static/tree/js/main.js @@ -22,8 +22,10 @@ $(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); IPython.login_widget = new IPython.LoginWidget('#login_widget', opts); var interval_id=0; @@ -35,14 +37,14 @@ $(document).ready(function () { //refresh immediately , then start interval if($('.upload_button').length == 0) { - IPython.notebook_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.session_list.load_sessions(); IPython.cluster_list.load_list(); } }, time_refresh*1000); @@ -71,7 +73,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 fbfed9d..2f472de 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -14,7 +14,10 @@ var IPython = (function (IPython) { var utils = IPython.utils; - var NotebookList = function (selector, options) { + 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; if (this.selector !== undefined) { this.element = $(selector); @@ -25,32 +28,35 @@ 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 () { - $('#notebook_toolbar').addClass('list_toolbar'); - $('#drag_info').addClass('toolbar_info'); - $('#notebook_buttons').addClass('toolbar_buttons'); - $('#notebook_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"); }; 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; }); 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'){ @@ -98,37 +104,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 @@ -32,9 +33,9 @@ data-notebook-path="{{notebook_path}}"
- + To import a notebook, drag the file onto the listing below or click here. - +
@@ -60,6 +61,26 @@ data-notebook-path="{{notebook_path}}"
+
+ +
+
+ Currently running IPython notebooks +
+
+ + + +
+
+ +
+
+
There are no notebooks running.
+
+
+
+
@@ -92,7 +113,9 @@ data-notebook-path="{{notebook_path}}" {{super()}} + + {% endblock %} diff --git a/docs/source/whatsnew/pr/running-tab.rst b/docs/source/whatsnew/pr/running-tab.rst new file mode 100644 index 0000000..58df8ff --- /dev/null +++ b/docs/source/whatsnew/pr/running-tab.rst @@ -0,0 +1,5 @@ +Dashboard "Running" Tab +----------------------- + +The dashboard now has a "Running" tab which shows all of the running +notebooks.