##// END OF EJS Templates
update add_duplicate_button with API changes...
Min RK -
Show More
@@ -25,22 +25,25 b' define(['
25 25
26 26 KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
27 27
28 KernelList.prototype.add_duplicate_button = function () {
29 // do nothing
30 };
31
28 32 KernelList.prototype.sessions_loaded = function (d) {
29 33 this.sessions = d;
30 34 this.clear_list();
31 var item, path_name;
32 for (path_name in d) {
33 if (!d.hasOwnProperty(path_name)) {
35 var item, path;
36 for (path in d) {
37 if (!d.hasOwnProperty(path)) {
34 38 // nothing is safe in javascript
35 39 continue;
36 40 }
37 41 item = this.new_item(-1);
38 42 this.add_link({
39 name: path_name,
40 path: '',
43 name: path,
44 path: path,
41 45 type: 'notebook',
42 46 }, item);
43 this.add_shutdown_button(item, this.sessions[path_name]);
44 47 }
45 48 $('#running_list_header').toggle($.isEmptyObject(d));
46 49 };
@@ -248,15 +248,16 b' define(['
248 248 if (model.type !== "directory") {
249 249 link.attr('target','_blank');
250 250 }
251 var path_name = utils.url_path_join(path, name);
251 if (model.type !== 'directory') {
252 this.add_duplicate_button(item);
253 }
252 254 if (model.type == 'file') {
253 255 this.add_delete_button(item);
254 256 } else if (model.type == 'notebook') {
255 if(this.sessions[path_name] === undefined){
257 if (this.sessions[path] === undefined){
256 258 this.add_delete_button(item);
257 this.add_duplicate_button(item);
258 259 } else {
259 this.add_shutdown_button(item, this.sessions[path_name]);
260 this.add_shutdown_button(item, this.sessions[path]);
260 261 }
261 262 }
262 263 };
@@ -311,7 +312,6 b' define(['
311 312 };
312 313
313 314 NotebookList.prototype.add_duplicate_button = function (item) {
314 var new_buttons = $('<span/>').addClass("btn-group pull-right");
315 315 var notebooklist = this;
316 316 var duplicate_button = $("<button/>").text("Duplicate").addClass("btn btn-defaultbtn-xs").
317 317 click(function (e) {
@@ -320,11 +320,12 b' define(['
320 320 // We use the nbname and notebook_id from the parent notebook_item element's
321 321 // data because the outer scopes values change as we iterate through the loop.
322 322 var parent_item = that.parents('div.list_item');
323 var nbname = parent_item.data('nbname');
324 var message = 'Are you sure you want to duplicate the notebook: ' + nbname + '?';
325 var copy_from = {'copy_from' : nbname}
323 var name = parent_item.data('name');
324 var path = parent_item.data('path');
325 var message = 'Are you sure you want to duplicate ' + name + '?';
326 var copy_from = {copy_from : path};
326 327 IPython.dialog.modal({
327 title : "Duplicate notebook",
328 title : "Duplicate " + name,
328 329 body : message,
329 330 buttons : {
330 331 Duplicate : {
@@ -336,13 +337,13 b' define(['
336 337 type : "POST",
337 338 dataType : "json",
338 339 data : JSON.stringify(copy_from),
339 success : function (data, status, xhr) {
340 success : function () {
340 341 notebooklist.load_list();
341 342 }
342 343 };
343 344 var url = utils.url_join_encode(
344 345 notebooklist.base_url,
345 'api/notebooks',
346 'api/contents',
346 347 notebooklist.notebook_path
347 348 );
348 349 $.ajax(url, settings);
@@ -40,10 +40,7 b' define(['
40 40 var len = data.length;
41 41 var nb_path;
42 42 for (var i=0; i<len; i++) {
43 nb_path = utils.url_path_join(
44 data[i].notebook.path,
45 data[i].notebook.name
46 );
43 nb_path = data[i].notebook.path;
47 44 this.sessions[nb_path] = data[i].id;
48 45 }
49 46 this.events.trigger('sessions_loaded.Dashboard', this.sessions);
General Comments 0
You need to be logged in to leave comments. Login now