##// END OF EJS Templates
Merge pull request #5215 from ivanov/running-kernels...
Paul Ivanov -
r15520:44a94be1 merge
parent child Browse files
Show More
@@ -0,0 +1,40 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2014 The IPython Development Team
3 //
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
7
8 //============================================================================
9 // Running Kernels List
10 //============================================================================
11
12 var IPython = (function (IPython) {
13 "use strict";
14
15 var utils = IPython.utils;
16
17 var KernelList = function (selector, options) {
18 IPython.NotebookList.call(this, selector, options, 'running');
19 };
20
21 KernelList.prototype = Object.create(IPython.NotebookList.prototype);
22
23 KernelList.prototype.sessions_loaded = function (d) {
24 this.sessions = d;
25 this.clear_list();
26 var item;
27 for (var path in d) {
28 item = this.new_notebook_item(-1);
29 this.add_link('', path, item);
30 this.add_shutdown_button(item, this.sessions[path]);
31 }
32
33 $('#running_list_header').toggle($.isEmptyObject(d));
34 }
35
36 IPython.KernelList = KernelList;
37
38 return IPython;
39
40 }(IPython));
@@ -0,0 +1,52 b''
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2014 The IPython Development Team
3 //
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
7
8 //============================================================================
9 // Running Kernels List
10 //============================================================================
11
12 var IPython = (function (IPython) {
13 "use strict";
14
15 var utils = IPython.utils;
16
17 var SesssionList = function (options) {
18 this.sessions = {};
19 this.base_url = options.base_url || utils.get_body_data("baseUrl");
20 };
21
22 SesssionList.prototype.load_sessions = function(){
23 var that = this;
24 var settings = {
25 processData : false,
26 cache : false,
27 type : "GET",
28 dataType : "json",
29 success : $.proxy(that.sessions_loaded, this)
30 };
31 var url = utils.url_join_encode(this.base_url, 'api/sessions');
32 $.ajax(url, settings);
33 };
34
35 SesssionList.prototype.sessions_loaded = function(data){
36 this.sessions = {};
37 var len = data.length;
38 var nb_path;
39 for (var i=0; i<len; i++) {
40 nb_path = utils.url_path_join(
41 data[i].notebook.path,
42 data[i].notebook.name
43 );
44 this.sessions[nb_path] = data[i].id;
45 }
46 $([IPython.events]).trigger('sessions_loaded.Dashboard', this.sessions);
47 };
48 IPython.SesssionList = SesssionList;
49
50 return IPython;
51
52 }(IPython));
@@ -0,0 +1,5 b''
1 Dashboard "Running" Tab
2 -----------------------
3
4 The dashboard now has a "Running" tab which shows all of the running
5 notebooks.
@@ -22,8 +22,10 b' $(document).ready(function () {'
22 22 base_url : IPython.utils.get_body_data("baseUrl"),
23 23 notebook_path : IPython.utils.get_body_data("notebookPath"),
24 24 };
25 IPython.session_list = new IPython.SesssionList(opts);
25 26 IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts);
26 27 IPython.cluster_list = new IPython.ClusterList('#cluster_list', opts);
28 IPython.kernel_list = new IPython.KernelList('#running_list', opts);
27 29 IPython.login_widget = new IPython.LoginWidget('#login_widget', opts);
28 30
29 31 var interval_id=0;
@@ -35,14 +37,14 b' $(document).ready(function () {'
35 37 //refresh immediately , then start interval
36 38 if($('.upload_button').length == 0)
37 39 {
38 IPython.notebook_list.load_sessions();
40 IPython.session_list.load_sessions();
39 41 IPython.cluster_list.load_list();
40 42 }
41 43 if (!interval_id){
42 44 interval_id = setInterval(function(){
43 45 if($('.upload_button').length == 0)
44 46 {
45 IPython.notebook_list.load_sessions();
47 IPython.session_list.load_sessions();
46 48 IPython.cluster_list.load_list();
47 49 }
48 50 }, time_refresh*1000);
@@ -71,7 +73,7 b' $(document).ready(function () {'
71 73
72 74 // bound the upload method to the on change of the file select list
73 75 $("#alternate_upload").change(function (event){
74 IPython.notebook_list.handelFilesUpload(event,'form');
76 IPython.notebook_list.handleFilesUpload(event,'form');
75 77 });
76 78
77 79 // set hash on tab click
@@ -14,7 +14,10 b' var IPython = (function (IPython) {'
14 14
15 15 var utils = IPython.utils;
16 16
17 var NotebookList = function (selector, options) {
17 var NotebookList = function (selector, options, element_name) {
18 var that = this
19 // allow code re-use by just changing element_name in kernellist.js
20 this.element_name = element_name || 'notebook';
18 21 this.selector = selector;
19 22 if (this.selector !== undefined) {
20 23 this.element = $(selector);
@@ -25,32 +28,35 b' var IPython = (function (IPython) {'
25 28 this.sessions = {};
26 29 this.base_url = options.base_url || utils.get_body_data("baseUrl");
27 30 this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
31 $([IPython.events]).on('sessions_loaded.Dashboard',
32 function(e, d) { that.sessions_loaded(d); });
28 33 };
29 34
30 35 NotebookList.prototype.style = function () {
31 $('#notebook_toolbar').addClass('list_toolbar');
32 $('#drag_info').addClass('toolbar_info');
33 $('#notebook_buttons').addClass('toolbar_buttons');
34 $('#notebook_list_header').addClass('list_header');
36 var prefix = '#' + this.element_name
37 $(prefix + '_toolbar').addClass('list_toolbar');
38 $(prefix + '_list_info').addClass('toolbar_info');
39 $(prefix + '_buttons').addClass('toolbar_buttons');
40 $(prefix + '_list_header').addClass('list_header');
35 41 this.element.addClass("list_container");
36 42 };
37 43
38 44
39 45 NotebookList.prototype.bind_events = function () {
40 46 var that = this;
41 $('#refresh_notebook_list').click(function () {
42 that.load_list();
47 $('#refresh_' + this.element_name + '_list').click(function () {
48 that.load_sessions();
43 49 });
44 50 this.element.bind('dragover', function () {
45 51 return false;
46 52 });
47 53 this.element.bind('drop', function(event){
48 that.handelFilesUpload(event,'drop');
54 that.handleFilesUpload(event,'drop');
49 55 return false;
50 56 });
51 57 };
52 58
53 NotebookList.prototype.handelFilesUpload = function(event, dropOrForm) {
59 NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) {
54 60 var that = this;
55 61 var files;
56 62 if(dropOrForm =='drop'){
@@ -98,37 +104,12 b' var IPython = (function (IPython) {'
98 104 };
99 105
100 106 NotebookList.prototype.load_sessions = function(){
101 var that = this;
102 var settings = {
103 processData : false,
104 cache : false,
105 type : "GET",
106 dataType : "json",
107 success : $.proxy(that.sessions_loaded, this)
108 };
109 var url = utils.url_join_encode(this.base_url, 'api/sessions');
110 $.ajax(url,settings);
107 IPython.session_list.load_sessions();
111 108 };
112 109
113 110
114 111 NotebookList.prototype.sessions_loaded = function(data){
115 this.sessions = {};
116 var len = data.length;
117 if (len > 0) {
118 for (var i=0; i<len; i++) {
119 var nb_path;
120 if (!data[i].notebook.path) {
121 nb_path = data[i].notebook.name;
122 }
123 else {
124 nb_path = utils.url_path_join(
125 data[i].notebook.path,
126 data[i].notebook.name
127 );
128 }
129 this.sessions[nb_path] = data[i].id;
130 }
131 }
112 this.sessions = data;
132 113 this.load_list();
133 114 };
134 115
@@ -24,6 +24,7 b' data-notebook-path="{{notebook_path}}"'
24 24 <div id="tab_content" class="tabbable">
25 25 <ul id="tabs" class="nav nav-tabs">
26 26 <li class="active"><a href="#notebooks" data-toggle="tab">Notebooks</a></li>
27 <li><a href="#running" data-toggle="tab">Running</a></li>
27 28 <li><a href="#clusters" data-toggle="tab">Clusters</a></li>
28 29 </ul>
29 30
@@ -32,9 +33,9 b' data-notebook-path="{{notebook_path}}"'
32 33 <div id="notebook_toolbar" class="row-fluid">
33 34 <div class="span8">
34 35 <form id='alternate_upload' class='alternate_upload' >
35 <span id="drag_info" style="position:absolute" >
36 <span id="notebook_list_info" style="position:absolute" >
36 37 To import a notebook, drag the file onto the listing below or <strong>click here</strong>.
37 </span>
38 </span>
38 39 <input type="file" name="datafile" class="fileinput" multiple='multiple'>
39 40 </form>
40 41 </div>
@@ -60,6 +61,26 b' data-notebook-path="{{notebook_path}}"'
60 61 </div>
61 62 </div>
62 63
64 <div id="running" class="tab-pane">
65
66 <div id="running_toolbar" class="row-fluid">
67 <div class="span8">
68 <span id="running_list_info">Currently running IPython notebooks</span>
69 </div>
70 <div class="span4" class="clearfix">
71 <span id="running_buttons" class="pull-right">
72 <button id="refresh_running_list" title="Refresh running list" class="btn btn-small"><i class="icon-refresh"></i></button>
73 </span>
74 </div>
75 </div>
76
77 <div id="running_list">
78 <div id="running_list_header" class="row-fluid list_header">
79 <div> There are no notebooks running. </div>
80 </div>
81 </div>
82 </div>
83
63 84 <div id="clusters" class="tab-pane">
64 85
65 86 <div id="cluster_toolbar" class="row-fluid">
@@ -92,7 +113,9 b' data-notebook-path="{{notebook_path}}"'
92 113 {{super()}}
93 114 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
94 115 <script src="{{static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
116 <script src="{{static_url("tree/js/sessionlist.js") }}" type="text/javascript" charset="utf-8"></script>
95 117 <script src="{{static_url("tree/js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script>
118 <script src="{{static_url("tree/js/kernellist.js") }}" type="text/javascript" charset="utf-8"></script>
96 119 <script src="{{static_url("tree/js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script>
97 120 <script src="{{static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
98 121 {% endblock %}
General Comments 0
You need to be logged in to leave comments. Login now