##// END OF EJS Templates
Move deleting a notebook to contentmanager.js...
Jeff Hemmelgarn -
Show More
@@ -74,8 +74,7 b' define(['
74 74 $.ajax(url,settings);
75 75 };
76 76
77 ContentManager.prototype.delete_notebook = function(notebook) {
78 var that = notebook;
77 ContentManager.prototype.delete_notebook = function(name, path, base_url) {
79 78 var settings = {
80 79 processData : false,
81 80 cache : false,
@@ -84,10 +83,10 b' define(['
84 83 error : utils.log_ajax_error,
85 84 };
86 85 var url = utils.url_join_encode(
87 that.base_url,
86 base_url,
88 87 'api/notebooks',
89 that.notebook_path,
90 that.notebook_name
88 path,
89 name
91 90 );
92 91 $.ajax(url, settings);
93 92 };
@@ -45,6 +45,7 b' require(['
45 45 events: events},
46 46 common_options));
47 47 notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
48 content_manager: content_manager,
48 49 session_list: session_list},
49 50 common_options));
50 51 cluster_list = new clusterlist.ClusterList('#cluster_list', common_options);
@@ -124,4 +125,13 b' require(['
124 125 $("#tabs").find("a[href=" + window.location.hash + "]").click();
125 126 }
126 127
128 // For backwards compatability.
129 IPython.page = page;
130 IPython.content_manager = content_manager;
131 IPython.notebook_list = notebook_list;
132 IPython.cluster_list = cluster_list;
133 IPython.session_list = session_list;
134 IPython.kernel_list = kernel_list;
135 IPython.login_widget = login_widget;
136 IPython.events = events;
127 137 });
@@ -34,6 +34,7 b' define(['
34 34 this.sessions = {};
35 35 this.base_url = options.base_url || utils.get_body_data("baseUrl");
36 36 this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
37 this.content_manager = options.content_manager;
37 38 if (this.session_list && this.session_list.events) {
38 39 this.session_list.events.on('sessions_loaded.Dashboard',
39 40 function(e, d) { that.sessions_loaded(d); });
@@ -329,8 +330,10 b' define(['
329 330 // We use the filename from the parent list_item element's
330 331 // data because the outer scope's values change as we iterate through the loop.
331 332 var parent_item = that.parents('div.list_item');
332 var name = parent_item.data('name');
333 var message = 'Are you sure you want to permanently delete the file: ' + name + '?';
333 var nbname = parent_item.data('nbname');
334 var path = parent_item.data('path');
335 var base_url = utils.get_body_data("baseUrl");
336 var message = 'Are you sure you want to permanently delete the notebook: ' + nbname + '?';
334 337 dialog.modal({
335 338 title : "Delete file",
336 339 body : message,
@@ -338,23 +341,7 b' define(['
338 341 Delete : {
339 342 class: "btn-danger",
340 343 click: function() {
341 var settings = {
342 processData : false,
343 cache : false,
344 type : "DELETE",
345 dataType : "json",
346 success : function (data, status, xhr) {
347 parent_item.remove();
348 },
349 error : utils.log_ajax_error,
350 };
351 var url = utils.url_join_encode(
352 notebooklist.base_url,
353 'api/contents',
354 notebooklist.notebook_path,
355 name
356 );
357 $.ajax(url, settings);
344 notebooklist.content_manager.delete_notebook(nbname, path, base_url);
358 345 }
359 346 },
360 347 Cancel : {}
General Comments 0
You need to be logged in to leave comments. Login now