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