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