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