Show More
@@ -0,0 +1,59 | |||||
|
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 | if (len > 0) { | |||
|
39 | for (var i=0; i<len; i++) { | |||
|
40 | var nb_path; | |||
|
41 | if (!data[i].notebook.path) { | |||
|
42 | nb_path = data[i].notebook.name; | |||
|
43 | } | |||
|
44 | else { | |||
|
45 | nb_path = utils.url_path_join( | |||
|
46 | data[i].notebook.path, | |||
|
47 | data[i].notebook.name | |||
|
48 | ); | |||
|
49 | } | |||
|
50 | this.sessions[nb_path] = data[i].id; | |||
|
51 | } | |||
|
52 | } | |||
|
53 | $([IPython.events]).trigger('sessions_loaded.Dashboard', this.sessions); | |||
|
54 | }; | |||
|
55 | IPython.SesssionList = SesssionList; | |||
|
56 | ||||
|
57 | return IPython; | |||
|
58 | ||||
|
59 | }(IPython)); |
@@ -21,22 +21,20 var IPython = (function (IPython) { | |||||
21 | KernelList.prototype = Object.create(IPython.NotebookList.prototype); |
|
21 | KernelList.prototype = Object.create(IPython.NotebookList.prototype); | |
22 |
|
22 | |||
23 | KernelList.prototype.sessions_loaded = function (d) { |
|
23 | KernelList.prototype.sessions_loaded = function (d) { | |
|
24 | this.sessions = d; | |||
24 | // clear out the previous list |
|
25 | // clear out the previous list | |
25 | this.clear_list(); |
|
26 | this.clear_list(); | |
26 | var len = d.length; |
|
|||
27 | var item; |
|
27 | var item; | |
28 |
for (var |
|
28 | for (var path in d) { | |
29 | var path= utils.url_path_join(d[i].notebook.path, d[i].notebook.name); |
|
29 | item = this.new_notebook_item(-1); | |
30 | item = this.new_notebook_item(i); |
|
|||
31 | this.add_link('', path, item); |
|
30 | this.add_link('', path, item); | |
32 | this.sessions[path] = d[i].id; |
|
|||
33 | this.add_shutdown_button(item,this.sessions[path]); |
|
31 | this.add_shutdown_button(item,this.sessions[path]); | |
34 | } |
|
32 | } | |
35 |
|
33 | |||
36 | if (len > 0) { |
|
34 | if ($.isEmptyObject(d)) { | |
37 | $('#' + this.element_name + '_list_header').hide(); |
|
|||
38 | } else { |
|
|||
39 | $('#' + this.element_name + '_list_header').show(); |
|
35 | $('#' + this.element_name + '_list_header').show(); | |
|
36 | } else { | |||
|
37 | $('#' + this.element_name + '_list_header').hide(); | |||
40 | } |
|
38 | } | |
41 | } |
|
39 | } | |
42 |
|
40 |
@@ -22,6 +22,7 $(document).ready(function () { | |||||
22 | base_url : IPython.utils.get_body_data("baseUrl"), |
|
22 | base_url : IPython.utils.get_body_data("baseUrl"), | |
23 | notebook_path : IPython.utils.get_body_data("notebookPath"), |
|
23 | notebook_path : IPython.utils.get_body_data("notebookPath"), | |
24 | }; |
|
24 | }; | |
|
25 | IPython.session_list = new IPython.SesssionList(opts); | |||
25 | IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts); |
|
26 | IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts); | |
26 | IPython.cluster_list = new IPython.ClusterList('#cluster_list', opts); |
|
27 | IPython.cluster_list = new IPython.ClusterList('#cluster_list', opts); | |
27 | IPython.kernel_list = new IPython.KernelList('#running_list', opts); |
|
28 | IPython.kernel_list = new IPython.KernelList('#running_list', opts); | |
@@ -36,16 +37,14 $(document).ready(function () { | |||||
36 | //refresh immediately , then start interval |
|
37 | //refresh immediately , then start interval | |
37 | if($('.upload_button').length == 0) |
|
38 | if($('.upload_button').length == 0) | |
38 | { |
|
39 | { | |
39 |
IPython. |
|
40 | IPython.session_list.load_sessions(); | |
40 | IPython.kernel_list.load_sessions(); |
|
|||
41 | IPython.cluster_list.load_list(); |
|
41 | IPython.cluster_list.load_list(); | |
42 | } |
|
42 | } | |
43 | if (!interval_id){ |
|
43 | if (!interval_id){ | |
44 | interval_id = setInterval(function(){ |
|
44 | interval_id = setInterval(function(){ | |
45 | if($('.upload_button').length == 0) |
|
45 | if($('.upload_button').length == 0) | |
46 | { |
|
46 | { | |
47 |
IPython. |
|
47 | IPython.session_list.load_sessions(); | |
48 | IPython.kernel_list.load_sessions(); |
|
|||
49 | IPython.cluster_list.load_list(); |
|
48 | IPython.cluster_list.load_list(); | |
50 | } |
|
49 | } | |
51 | }, time_refresh*1000); |
|
50 | }, time_refresh*1000); |
@@ -15,6 +15,7 var IPython = (function (IPython) { | |||||
15 | var utils = IPython.utils; |
|
15 | var utils = IPython.utils; | |
16 |
|
16 | |||
17 | var NotebookList = function (selector, options, element_name) { |
|
17 | var NotebookList = function (selector, options, element_name) { | |
|
18 | var that = this | |||
18 | // allow code re-use by just changing element_name in kernellist.js |
|
19 | // allow code re-use by just changing element_name in kernellist.js | |
19 | this.element_name = element_name || 'notebook'; |
|
20 | this.element_name = element_name || 'notebook'; | |
20 | this.selector = selector; |
|
21 | this.selector = selector; | |
@@ -27,6 +28,8 var IPython = (function (IPython) { | |||||
27 | this.sessions = {}; |
|
28 | this.sessions = {}; | |
28 | this.base_url = options.base_url || utils.get_body_data("baseUrl"); |
|
29 | this.base_url = options.base_url || utils.get_body_data("baseUrl"); | |
29 | this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath"); |
|
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); }); | |||
30 | }; |
|
33 | }; | |
31 |
|
34 | |||
32 | NotebookList.prototype.style = function () { |
|
35 | NotebookList.prototype.style = function () { | |
@@ -100,37 +103,12 var IPython = (function (IPython) { | |||||
100 | }; |
|
103 | }; | |
101 |
|
104 | |||
102 | NotebookList.prototype.load_sessions = function(){ |
|
105 | NotebookList.prototype.load_sessions = function(){ | |
103 | var that = this; |
|
106 | IPython.session_list.load_sessions(); | |
104 | var settings = { |
|
|||
105 | processData : false, |
|
|||
106 | cache : false, |
|
|||
107 | type : "GET", |
|
|||
108 | dataType : "json", |
|
|||
109 | success : $.proxy(that.sessions_loaded, this) |
|
|||
110 | }; |
|
|||
111 | var url = utils.url_join_encode(this.base_url, 'api/sessions'); |
|
|||
112 | $.ajax(url,settings); |
|
|||
113 | }; |
|
107 | }; | |
114 |
|
108 | |||
115 |
|
109 | |||
116 | NotebookList.prototype.sessions_loaded = function(data){ |
|
110 | NotebookList.prototype.sessions_loaded = function(data){ | |
117 |
this.sessions = |
|
111 | this.sessions = data; | |
118 | var len = data.length; |
|
|||
119 | if (len > 0) { |
|
|||
120 | for (var i=0; i<len; i++) { |
|
|||
121 | var nb_path; |
|
|||
122 | if (!data[i].notebook.path) { |
|
|||
123 | nb_path = data[i].notebook.name; |
|
|||
124 | } |
|
|||
125 | else { |
|
|||
126 | nb_path = utils.url_path_join( |
|
|||
127 | data[i].notebook.path, |
|
|||
128 | data[i].notebook.name |
|
|||
129 | ); |
|
|||
130 | } |
|
|||
131 | this.sessions[nb_path] = data[i].id; |
|
|||
132 | } |
|
|||
133 | } |
|
|||
134 | this.load_list(); |
|
112 | this.load_list(); | |
135 | }; |
|
113 | }; | |
136 |
|
114 |
@@ -115,6 +115,7 data-base-kernel-url="{{base_kernel_url}}" | |||||
115 | {{super()}} |
|
115 | {{super()}} | |
116 | <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script> |
|
116 | <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script> | |
117 | <script src="{{static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script> |
|
117 | <script src="{{static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script> | |
|
118 | <script src="{{static_url("tree/js/sessionlist.js") }}" type="text/javascript" charset="utf-8"></script> | |||
118 | <script src="{{static_url("tree/js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script> |
|
119 | <script src="{{static_url("tree/js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script> | |
119 | <script src="{{static_url("tree/js/kernellist.js") }}" type="text/javascript" charset="utf-8"></script> |
|
120 | <script src="{{static_url("tree/js/kernellist.js") }}" type="text/javascript" charset="utf-8"></script> | |
120 | <script src="{{static_url("tree/js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script> |
|
121 | <script src="{{static_url("tree/js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script> |
General Comments 0
You need to be logged in to leave comments.
Login now