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. |
@@ -1,89 +1,91 b'' | |||
|
1 | 1 | //---------------------------------------------------------------------------- |
|
2 | 2 | // Copyright (C) 2008-2011 The IPython Development Team |
|
3 | 3 | // |
|
4 | 4 | // Distributed under the terms of the BSD License. The full license is in |
|
5 | 5 | // the file COPYING, distributed as part of this software. |
|
6 | 6 | //---------------------------------------------------------------------------- |
|
7 | 7 | |
|
8 | 8 | //============================================================================ |
|
9 | 9 | // On document ready |
|
10 | 10 | //============================================================================ |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | $(document).ready(function () { |
|
14 | 14 | |
|
15 | 15 | IPython.page = new IPython.Page(); |
|
16 | 16 | |
|
17 | 17 | $('#new_notebook').button().click(function (e) { |
|
18 | 18 | IPython.notebook_list.new_notebook() |
|
19 | 19 | }); |
|
20 | 20 | |
|
21 | 21 | var opts = { |
|
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; |
|
30 | 32 | // auto refresh every xx secondes, no need to be fast, |
|
31 | 33 | // update is done at least when page get focus |
|
32 | 34 | var time_refresh = 60; // in sec |
|
33 | 35 | |
|
34 | 36 | var enable_autorefresh = function(){ |
|
35 | 37 | //refresh immediately , then start interval |
|
36 | 38 | if($('.upload_button').length == 0) |
|
37 | 39 | { |
|
38 |
IPython. |
|
|
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. |
|
|
47 | IPython.session_list.load_sessions(); | |
|
46 | 48 | IPython.cluster_list.load_list(); |
|
47 | 49 | } |
|
48 | 50 | }, time_refresh*1000); |
|
49 | 51 | } |
|
50 | 52 | } |
|
51 | 53 | |
|
52 | 54 | var disable_autorefresh = function(){ |
|
53 | 55 | clearInterval(interval_id); |
|
54 | 56 | interval_id = 0; |
|
55 | 57 | } |
|
56 | 58 | |
|
57 | 59 | // stop autorefresh when page lose focus |
|
58 | 60 | $(window).blur(function() { |
|
59 | 61 | disable_autorefresh(); |
|
60 | 62 | }) |
|
61 | 63 | |
|
62 | 64 | //re-enable when page get focus back |
|
63 | 65 | $(window).focus(function() { |
|
64 | 66 | enable_autorefresh(); |
|
65 | 67 | }); |
|
66 | 68 | |
|
67 | 69 | // finally start it, it will refresh immediately |
|
68 | 70 | enable_autorefresh(); |
|
69 | 71 | |
|
70 | 72 | IPython.page.show(); |
|
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.hand |
|
|
76 | IPython.notebook_list.handleFilesUpload(event,'form'); | |
|
75 | 77 | }); |
|
76 | 78 | |
|
77 | 79 | // set hash on tab click |
|
78 | 80 | $("#tabs").find("a").click(function() { |
|
79 | 81 | window.location.hash = $(this).attr("href"); |
|
80 | 82 | }) |
|
81 | 83 | |
|
82 | 84 | // load tab if url hash |
|
83 | 85 | if (window.location.hash) { |
|
84 | 86 | $("#tabs").find("a[href=" + window.location.hash + "]").click(); |
|
85 | 87 | } |
|
86 | 88 | |
|
87 | 89 | |
|
88 | 90 | }); |
|
89 | 91 |
@@ -1,431 +1,412 b'' | |||
|
1 | 1 | //---------------------------------------------------------------------------- |
|
2 | 2 | // Copyright (C) 2011 The IPython Development Team |
|
3 | 3 | // |
|
4 | 4 | // Distributed under the terms of the BSD License. The full license is in |
|
5 | 5 | // the file COPYING, distributed as part of this software. |
|
6 | 6 | //---------------------------------------------------------------------------- |
|
7 | 7 | |
|
8 | 8 | //============================================================================ |
|
9 | 9 | // NotebookList |
|
10 | 10 | //============================================================================ |
|
11 | 11 | |
|
12 | 12 | var IPython = (function (IPython) { |
|
13 | 13 | "use strict"; |
|
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); |
|
21 | 24 | this.style(); |
|
22 | 25 | this.bind_events(); |
|
23 | 26 | } |
|
24 | 27 | this.notebooks_list = []; |
|
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 |
$( |
|
|
33 |
$( |
|
|
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_ |
|
|
42 |
that.load_ |
|
|
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.hand |
|
|
54 | that.handleFilesUpload(event,'drop'); | |
|
49 | 55 | return false; |
|
50 | 56 | }); |
|
51 | 57 | }; |
|
52 | 58 | |
|
53 |
NotebookList.prototype.hand |
|
|
59 | NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) { | |
|
54 | 60 | var that = this; |
|
55 | 61 | var files; |
|
56 | 62 | if(dropOrForm =='drop'){ |
|
57 | 63 | files = event.originalEvent.dataTransfer.files; |
|
58 | 64 | } else |
|
59 | 65 | { |
|
60 | 66 | files = event.originalEvent.target.files; |
|
61 | 67 | } |
|
62 | 68 | for (var i = 0; i < files.length; i++) { |
|
63 | 69 | var f = files[i]; |
|
64 | 70 | var reader = new FileReader(); |
|
65 | 71 | reader.readAsText(f); |
|
66 | 72 | var name_and_ext = utils.splitext(f.name); |
|
67 | 73 | var file_ext = name_and_ext[1]; |
|
68 | 74 | if (file_ext === '.ipynb') { |
|
69 | 75 | var item = that.new_notebook_item(0); |
|
70 | 76 | that.add_name_input(f.name, item); |
|
71 | 77 | // Store the notebook item in the reader so we can use it later |
|
72 | 78 | // to know which item it belongs to. |
|
73 | 79 | $(reader).data('item', item); |
|
74 | 80 | reader.onload = function (event) { |
|
75 | 81 | var nbitem = $(event.target).data('item'); |
|
76 | 82 | that.add_notebook_data(event.target.result, nbitem); |
|
77 | 83 | that.add_upload_button(nbitem); |
|
78 | 84 | }; |
|
79 | 85 | } else { |
|
80 | 86 | var dialog = 'Uploaded notebooks must be .ipynb files'; |
|
81 | 87 | IPython.dialog.modal({ |
|
82 | 88 | title : 'Invalid file type', |
|
83 | 89 | body : dialog, |
|
84 | 90 | buttons : {'OK' : {'class' : 'btn-primary'}} |
|
85 | 91 | }); |
|
86 | 92 | } |
|
87 | 93 | } |
|
88 | 94 | // Replace the file input form wth a clone of itself. This is required to |
|
89 | 95 | // reset the form. Otherwise, if you upload a file, delete it and try to |
|
90 | 96 | // upload it again, the changed event won't fire. |
|
91 | 97 | var form = $('input.fileinput'); |
|
92 | 98 | form.replaceWith(form.clone(true)); |
|
93 | 99 | return false; |
|
94 | 100 | }; |
|
95 | 101 | |
|
96 | 102 | NotebookList.prototype.clear_list = function () { |
|
97 | 103 | this.element.children('.list_item').remove(); |
|
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 | |
|
135 | 116 | NotebookList.prototype.load_list = function () { |
|
136 | 117 | var that = this; |
|
137 | 118 | var settings = { |
|
138 | 119 | processData : false, |
|
139 | 120 | cache : false, |
|
140 | 121 | type : "GET", |
|
141 | 122 | dataType : "json", |
|
142 | 123 | success : $.proxy(this.list_loaded, this), |
|
143 | 124 | error : $.proxy( function(){ |
|
144 | 125 | that.list_loaded([], null, null, {msg:"Error connecting to server."}); |
|
145 | 126 | },this) |
|
146 | 127 | }; |
|
147 | 128 | |
|
148 | 129 | var url = utils.url_join_encode( |
|
149 | 130 | this.base_url, |
|
150 | 131 | 'api', |
|
151 | 132 | 'notebooks', |
|
152 | 133 | this.notebook_path |
|
153 | 134 | ); |
|
154 | 135 | $.ajax(url, settings); |
|
155 | 136 | }; |
|
156 | 137 | |
|
157 | 138 | |
|
158 | 139 | NotebookList.prototype.list_loaded = function (data, status, xhr, param) { |
|
159 | 140 | var message = 'Notebook list empty.'; |
|
160 | 141 | if (param !== undefined && param.msg) { |
|
161 | 142 | message = param.msg; |
|
162 | 143 | } |
|
163 | 144 | var item = null; |
|
164 | 145 | var len = data.length; |
|
165 | 146 | this.clear_list(); |
|
166 | 147 | if (len === 0) { |
|
167 | 148 | item = this.new_notebook_item(0); |
|
168 | 149 | var span12 = item.children().first(); |
|
169 | 150 | span12.empty(); |
|
170 | 151 | span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message)); |
|
171 | 152 | } |
|
172 | 153 | var path = this.notebook_path; |
|
173 | 154 | var offset = 0; |
|
174 | 155 | if (path !== '') { |
|
175 | 156 | item = this.new_notebook_item(0); |
|
176 | 157 | this.add_dir(path, '..', item); |
|
177 | 158 | offset = 1; |
|
178 | 159 | } |
|
179 | 160 | for (var i=0; i<len; i++) { |
|
180 | 161 | if (data[i].type === 'directory') { |
|
181 | 162 | var name = data[i].name; |
|
182 | 163 | item = this.new_notebook_item(i+offset); |
|
183 | 164 | this.add_dir(path, name, item); |
|
184 | 165 | } else { |
|
185 | 166 | var name = data[i].name; |
|
186 | 167 | item = this.new_notebook_item(i+offset); |
|
187 | 168 | this.add_link(path, name, item); |
|
188 | 169 | name = utils.url_path_join(path, name); |
|
189 | 170 | if(this.sessions[name] === undefined){ |
|
190 | 171 | this.add_delete_button(item); |
|
191 | 172 | } else { |
|
192 | 173 | this.add_shutdown_button(item,this.sessions[name]); |
|
193 | 174 | } |
|
194 | 175 | } |
|
195 | 176 | } |
|
196 | 177 | }; |
|
197 | 178 | |
|
198 | 179 | |
|
199 | 180 | NotebookList.prototype.new_notebook_item = function (index) { |
|
200 | 181 | var item = $('<div/>').addClass("list_item").addClass("row-fluid"); |
|
201 | 182 | // item.addClass('list_item ui-widget ui-widget-content ui-helper-clearfix'); |
|
202 | 183 | // item.css('border-top-style','none'); |
|
203 | 184 | item.append($("<div/>").addClass("span12").append( |
|
204 | 185 | $('<i/>').addClass('item_icon') |
|
205 | 186 | ).append( |
|
206 | 187 | $("<a/>").addClass("item_link").append( |
|
207 | 188 | $("<span/>").addClass("item_name") |
|
208 | 189 | ) |
|
209 | 190 | ).append( |
|
210 | 191 | $('<div/>').addClass("item_buttons btn-group pull-right") |
|
211 | 192 | )); |
|
212 | 193 | |
|
213 | 194 | if (index === -1) { |
|
214 | 195 | this.element.append(item); |
|
215 | 196 | } else { |
|
216 | 197 | this.element.children().eq(index).after(item); |
|
217 | 198 | } |
|
218 | 199 | return item; |
|
219 | 200 | }; |
|
220 | 201 | |
|
221 | 202 | |
|
222 | 203 | NotebookList.prototype.add_dir = function (path, name, item) { |
|
223 | 204 | item.data('name', name); |
|
224 | 205 | item.data('path', path); |
|
225 | 206 | item.find(".item_name").text(name); |
|
226 | 207 | item.find(".item_icon").addClass('icon-folder-open'); |
|
227 | 208 | item.find("a.item_link") |
|
228 | 209 | .attr('href', |
|
229 | 210 | utils.url_join_encode( |
|
230 | 211 | this.base_url, |
|
231 | 212 | "tree", |
|
232 | 213 | path, |
|
233 | 214 | name |
|
234 | 215 | ) |
|
235 | 216 | ); |
|
236 | 217 | }; |
|
237 | 218 | |
|
238 | 219 | |
|
239 | 220 | NotebookList.prototype.add_link = function (path, nbname, item) { |
|
240 | 221 | item.data('nbname', nbname); |
|
241 | 222 | item.data('path', path); |
|
242 | 223 | item.find(".item_name").text(nbname); |
|
243 | 224 | item.find(".item_icon").addClass('icon-book'); |
|
244 | 225 | item.find("a.item_link") |
|
245 | 226 | .attr('href', |
|
246 | 227 | utils.url_join_encode( |
|
247 | 228 | this.base_url, |
|
248 | 229 | "notebooks", |
|
249 | 230 | path, |
|
250 | 231 | nbname |
|
251 | 232 | ) |
|
252 | 233 | ).attr('target','_blank'); |
|
253 | 234 | }; |
|
254 | 235 | |
|
255 | 236 | |
|
256 | 237 | NotebookList.prototype.add_name_input = function (nbname, item) { |
|
257 | 238 | item.data('nbname', nbname); |
|
258 | 239 | item.find(".item_icon").addClass('icon-book'); |
|
259 | 240 | item.find(".item_name").empty().append( |
|
260 | 241 | $('<input/>') |
|
261 | 242 | .addClass("nbname_input") |
|
262 | 243 | .attr('value', utils.splitext(nbname)[0]) |
|
263 | 244 | .attr('size', '30') |
|
264 | 245 | .attr('type', 'text') |
|
265 | 246 | ); |
|
266 | 247 | }; |
|
267 | 248 | |
|
268 | 249 | |
|
269 | 250 | NotebookList.prototype.add_notebook_data = function (data, item) { |
|
270 | 251 | item.data('nbdata', data); |
|
271 | 252 | }; |
|
272 | 253 | |
|
273 | 254 | |
|
274 | 255 | NotebookList.prototype.add_shutdown_button = function (item, session) { |
|
275 | 256 | var that = this; |
|
276 | 257 | var shutdown_button = $("<button/>").text("Shutdown").addClass("btn btn-mini btn-danger"). |
|
277 | 258 | click(function (e) { |
|
278 | 259 | var settings = { |
|
279 | 260 | processData : false, |
|
280 | 261 | cache : false, |
|
281 | 262 | type : "DELETE", |
|
282 | 263 | dataType : "json", |
|
283 | 264 | success : function () { |
|
284 | 265 | that.load_sessions(); |
|
285 | 266 | } |
|
286 | 267 | }; |
|
287 | 268 | var url = utils.url_join_encode( |
|
288 | 269 | that.base_url, |
|
289 | 270 | 'api/sessions', |
|
290 | 271 | session |
|
291 | 272 | ); |
|
292 | 273 | $.ajax(url, settings); |
|
293 | 274 | return false; |
|
294 | 275 | }); |
|
295 | 276 | // var new_buttons = item.find('a'); // shutdown_button; |
|
296 | 277 | item.find(".item_buttons").text("").append(shutdown_button); |
|
297 | 278 | }; |
|
298 | 279 | |
|
299 | 280 | NotebookList.prototype.add_delete_button = function (item) { |
|
300 | 281 | var new_buttons = $('<span/>').addClass("btn-group pull-right"); |
|
301 | 282 | var notebooklist = this; |
|
302 | 283 | var delete_button = $("<button/>").text("Delete").addClass("btn btn-mini"). |
|
303 | 284 | click(function (e) { |
|
304 | 285 | // $(this) is the button that was clicked. |
|
305 | 286 | var that = $(this); |
|
306 | 287 | // We use the nbname and notebook_id from the parent notebook_item element's |
|
307 | 288 | // data because the outer scopes values change as we iterate through the loop. |
|
308 | 289 | var parent_item = that.parents('div.list_item'); |
|
309 | 290 | var nbname = parent_item.data('nbname'); |
|
310 | 291 | var message = 'Are you sure you want to permanently delete the notebook: ' + nbname + '?'; |
|
311 | 292 | IPython.dialog.modal({ |
|
312 | 293 | title : "Delete notebook", |
|
313 | 294 | body : message, |
|
314 | 295 | buttons : { |
|
315 | 296 | Delete : { |
|
316 | 297 | class: "btn-danger", |
|
317 | 298 | click: function() { |
|
318 | 299 | var settings = { |
|
319 | 300 | processData : false, |
|
320 | 301 | cache : false, |
|
321 | 302 | type : "DELETE", |
|
322 | 303 | dataType : "json", |
|
323 | 304 | success : function (data, status, xhr) { |
|
324 | 305 | parent_item.remove(); |
|
325 | 306 | } |
|
326 | 307 | }; |
|
327 | 308 | var url = utils.url_join_encode( |
|
328 | 309 | notebooklist.base_url, |
|
329 | 310 | 'api/notebooks', |
|
330 | 311 | notebooklist.notebook_path, |
|
331 | 312 | nbname |
|
332 | 313 | ); |
|
333 | 314 | $.ajax(url, settings); |
|
334 | 315 | } |
|
335 | 316 | }, |
|
336 | 317 | Cancel : {} |
|
337 | 318 | } |
|
338 | 319 | }); |
|
339 | 320 | return false; |
|
340 | 321 | }); |
|
341 | 322 | item.find(".item_buttons").text("").append(delete_button); |
|
342 | 323 | }; |
|
343 | 324 | |
|
344 | 325 | |
|
345 | 326 | NotebookList.prototype.add_upload_button = function (item) { |
|
346 | 327 | var that = this; |
|
347 | 328 | var upload_button = $('<button/>').text("Upload") |
|
348 | 329 | .addClass('btn btn-primary btn-mini upload_button') |
|
349 | 330 | .click(function (e) { |
|
350 | 331 | var nbname = item.find('.item_name > input').val(); |
|
351 | 332 | if (nbname.slice(nbname.length-6, nbname.length) != ".ipynb") { |
|
352 | 333 | nbname = nbname + ".ipynb"; |
|
353 | 334 | } |
|
354 | 335 | var path = that.notebook_path; |
|
355 | 336 | var nbdata = item.data('nbdata'); |
|
356 | 337 | var content_type = 'application/json'; |
|
357 | 338 | var model = { |
|
358 | 339 | content : JSON.parse(nbdata), |
|
359 | 340 | }; |
|
360 | 341 | var settings = { |
|
361 | 342 | processData : false, |
|
362 | 343 | cache : false, |
|
363 | 344 | type : 'PUT', |
|
364 | 345 | dataType : 'json', |
|
365 | 346 | data : JSON.stringify(model), |
|
366 | 347 | headers : {'Content-Type': content_type}, |
|
367 | 348 | success : function (data, status, xhr) { |
|
368 | 349 | that.add_link(path, nbname, item); |
|
369 | 350 | that.add_delete_button(item); |
|
370 | 351 | }, |
|
371 | 352 | error : function (data, status, xhr) { |
|
372 | 353 | console.log(data, status); |
|
373 | 354 | } |
|
374 | 355 | }; |
|
375 | 356 | |
|
376 | 357 | var url = utils.url_join_encode( |
|
377 | 358 | that.base_url, |
|
378 | 359 | 'api/notebooks', |
|
379 | 360 | that.notebook_path, |
|
380 | 361 | nbname |
|
381 | 362 | ); |
|
382 | 363 | $.ajax(url, settings); |
|
383 | 364 | return false; |
|
384 | 365 | }); |
|
385 | 366 | var cancel_button = $('<button/>').text("Cancel") |
|
386 | 367 | .addClass("btn btn-mini") |
|
387 | 368 | .click(function (e) { |
|
388 | 369 | console.log('cancel click'); |
|
389 | 370 | item.remove(); |
|
390 | 371 | return false; |
|
391 | 372 | }); |
|
392 | 373 | item.find(".item_buttons").empty() |
|
393 | 374 | .append(upload_button) |
|
394 | 375 | .append(cancel_button); |
|
395 | 376 | }; |
|
396 | 377 | |
|
397 | 378 | |
|
398 | 379 | NotebookList.prototype.new_notebook = function(){ |
|
399 | 380 | var path = this.notebook_path; |
|
400 | 381 | var base_url = this.base_url; |
|
401 | 382 | var settings = { |
|
402 | 383 | processData : false, |
|
403 | 384 | cache : false, |
|
404 | 385 | type : "POST", |
|
405 | 386 | dataType : "json", |
|
406 | 387 | async : false, |
|
407 | 388 | success : function (data, status, xhr) { |
|
408 | 389 | var notebook_name = data.name; |
|
409 | 390 | window.open( |
|
410 | 391 | utils.url_join_encode( |
|
411 | 392 | base_url, |
|
412 | 393 | 'notebooks', |
|
413 | 394 | path, |
|
414 | 395 | notebook_name), |
|
415 | 396 | '_blank' |
|
416 | 397 | ); |
|
417 | 398 | } |
|
418 | 399 | }; |
|
419 | 400 | var url = utils.url_join_encode( |
|
420 | 401 | base_url, |
|
421 | 402 | 'api/notebooks', |
|
422 | 403 | path |
|
423 | 404 | ); |
|
424 | 405 | $.ajax(url, settings); |
|
425 | 406 | }; |
|
426 | 407 | |
|
427 | 408 | IPython.NotebookList = NotebookList; |
|
428 | 409 | |
|
429 | 410 | return IPython; |
|
430 | 411 | |
|
431 | 412 | }(IPython)); |
@@ -1,98 +1,121 b'' | |||
|
1 | 1 | {% extends "page.html" %} |
|
2 | 2 | |
|
3 | 3 | {% block title %}{{page_title}}{% endblock %} |
|
4 | 4 | |
|
5 | 5 | |
|
6 | 6 | {% block stylesheet %} |
|
7 | 7 | {{super()}} |
|
8 | 8 | <link rel="stylesheet" href="{{ static_url("tree/css/override.css") }}" type="text/css" /> |
|
9 | 9 | {% endblock %} |
|
10 | 10 | |
|
11 | 11 | {% block params %} |
|
12 | 12 | |
|
13 | 13 | data-project="{{project}}" |
|
14 | 14 | data-base-url="{{base_url}}" |
|
15 | 15 | data-notebook-path="{{notebook_path}}" |
|
16 | 16 | |
|
17 | 17 | {% endblock %} |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | {% block site %} |
|
21 | 21 | |
|
22 | 22 | <div id="ipython-main-app" class="container"> |
|
23 | 23 | |
|
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 | |
|
30 | 31 | <div class="tab-content"> |
|
31 | 32 | <div id="notebooks" class="tab-pane active"> |
|
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=" |
|
|
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 | 38 |
|
|
38 | 39 | <input type="file" name="datafile" class="fileinput" multiple='multiple'> |
|
39 | 40 | </form> |
|
40 | 41 | </div> |
|
41 | 42 | <div class="span4 clearfix"> |
|
42 | 43 | <span id="notebook_buttons" class="pull-right"> |
|
43 | 44 | <button id="new_notebook" title="Create new notebook" class="btn btn-small">New Notebook</button> |
|
44 | 45 | <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-small"><i class="icon-refresh"></i></button> |
|
45 | 46 | </span> |
|
46 | 47 | </div> |
|
47 | 48 | </div> |
|
48 | 49 | |
|
49 | 50 | <div id="notebook_list"> |
|
50 | 51 | <div id="notebook_list_header" class="row-fluid list_header"> |
|
51 | 52 | <div id="project_name"> |
|
52 | 53 | <ul class="breadcrumb"> |
|
53 | 54 | <li><a href="{{breadcrumbs[0][0]}}"><i class="icon-home"></i></a><span>/</span></li> |
|
54 | 55 | {% for crumb in breadcrumbs[1:] %} |
|
55 | 56 | <li><a href="{{crumb[0]}}">{{crumb[1]}}</a> <span>/</span></li> |
|
56 | 57 | {% endfor %} |
|
57 | 58 | </ul> |
|
58 | 59 | </div> |
|
59 | 60 | </div> |
|
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"> |
|
66 | 87 | <div class="span8"> |
|
67 | 88 | <span id="cluster_list_info">IPython parallel computing clusters</span> |
|
68 | 89 | </div> |
|
69 | 90 | <div class="span4" class="clearfix"> |
|
70 | 91 | <span id="cluster_buttons" class="pull-right"> |
|
71 | 92 | <button id="refresh_cluster_list" title="Refresh cluster list" class="btn btn-small"><i class="icon-refresh"></i></button> |
|
72 | 93 | </span> |
|
73 | 94 | </div> |
|
74 | 95 | </div> |
|
75 | 96 | |
|
76 | 97 | <div id="cluster_list"> |
|
77 | 98 | <div id="cluster_list_header" class="row-fluid list_header"> |
|
78 | 99 | <div class="profile_col span4">profile</div> |
|
79 | 100 | <div class="status_col span3">status</div> |
|
80 | 101 | <div class="engines_col span3" title="Enter the number of engines to start or empty for default"># of engines</div> |
|
81 | 102 | <div class="action_col span2">action</div> |
|
82 | 103 | </div> |
|
83 | 104 | </div> |
|
84 | 105 | </div> |
|
85 | 106 | </div> |
|
86 | 107 | |
|
87 | 108 | </div> |
|
88 | 109 | |
|
89 | 110 | {% endblock %} |
|
90 | 111 | |
|
91 | 112 | {% block script %} |
|
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