Move deleting a notebook to contentmanager.js

Move code to handle deleting a notebook from notebooklist to
contentmanager.
pull/37/head
Jeff Hemmelgarn 12 years ago committed by Thomas Kluyver
parent 993833d018
commit 728c6f005f

@ -74,8 +74,7 @@ define([
$.ajax(url,settings);
};
ContentManager.prototype.delete_notebook = function(notebook) {
var that = notebook;
ContentManager.prototype.delete_notebook = function(name, path, base_url) {
var settings = {
processData : false,
cache : false,
@ -84,10 +83,10 @@ define([
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(
that.base_url,
base_url,
'api/notebooks',
that.notebook_path,
that.notebook_name
path,
name
);
$.ajax(url, settings);
};

@ -45,6 +45,7 @@ require([
events: events},
common_options));
notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
content_manager: content_manager,
session_list: session_list},
common_options));
cluster_list = new clusterlist.ClusterList('#cluster_list', common_options);
@ -124,4 +125,13 @@ require([
$("#tabs").find("a[href=" + window.location.hash + "]").click();
}
// For backwards compatability.
IPython.page = page;
IPython.content_manager = content_manager;
IPython.notebook_list = notebook_list;
IPython.cluster_list = cluster_list;
IPython.session_list = session_list;
IPython.kernel_list = kernel_list;
IPython.login_widget = login_widget;
IPython.events = events;
});

@ -34,6 +34,7 @@ define([
this.sessions = {};
this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
this.content_manager = options.content_manager;
if (this.session_list && this.session_list.events) {
this.session_list.events.on('sessions_loaded.Dashboard',
function(e, d) { that.sessions_loaded(d); });
@ -329,8 +330,10 @@ define([
// We use the filename from the parent list_item element's
// data because the outer scope's values change as we iterate through the loop.
var parent_item = that.parents('div.list_item');
var name = parent_item.data('name');
var message = 'Are you sure you want to permanently delete the file: ' + name + '?';
var nbname = parent_item.data('nbname');
var path = parent_item.data('path');
var base_url = utils.get_body_data("baseUrl");
var message = 'Are you sure you want to permanently delete the notebook: ' + nbname + '?';
dialog.modal({
title : "Delete file",
body : message,
@ -338,23 +341,7 @@ define([
Delete : {
class: "btn-danger",
click: function() {
var settings = {
processData : false,
cache : false,
type : "DELETE",
dataType : "json",
success : function (data, status, xhr) {
parent_item.remove();
},
error : utils.log_ajax_error,
};
var url = utils.url_join_encode(
notebooklist.base_url,
'api/contents',
notebooklist.notebook_path,
name
);
$.ajax(url, settings);
notebooklist.content_manager.delete_notebook(nbname, path, base_url);
}
},
Cancel : {}

Loading…
Cancel
Save