Merge pull request #6916 from minrk/finish-5659

add Duplicate button to dashboard
Jonathan Frederic 11 years ago
commit 8d8bf43fb9

@ -77,7 +77,6 @@ define([
notebook: options.notebook,
keyboard_manager: this.keyboard_manager,
buttons : {
"Cancel": {},
"OK": {
class: "btn-primary",
click: function () {
@ -92,7 +91,8 @@ define([
} else {
that.notebook.rename(new_name);
}
}}
}},
"Cancel": {}
},
open : function (event, ui) {
var that = $(this);

@ -8070,6 +8070,9 @@ ul.breadcrumb span {
.item_buttons {
line-height: 1em;
}
.item_buttons .btn {
min-width: 13ex;
}
.toolbar_info {
height: 24px;
line-height: 24px;

@ -25,22 +25,25 @@ define([
KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
KernelList.prototype.add_duplicate_button = function () {
// do nothing
};
KernelList.prototype.sessions_loaded = function (d) {
this.sessions = d;
this.clear_list();
var item, path_name;
for (path_name in d) {
if (!d.hasOwnProperty(path_name)) {
var item, path;
for (path in d) {
if (!d.hasOwnProperty(path)) {
// nothing is safe in javascript
continue;
}
item = this.new_item(-1);
this.add_link({
name: path_name,
path: '',
name: path,
path: path,
type: 'notebook',
}, item);
this.add_shutdown_button(item, this.sessions[path_name]);
}
$('#running_list_header').toggle($.isEmptyObject(d));
};

@ -248,14 +248,16 @@ define([
if (model.type !== "directory") {
link.attr('target','_blank');
}
var path_name = utils.url_path_join(path, name);
if (model.type !== 'directory') {
this.add_duplicate_button(item);
}
if (model.type == 'file') {
this.add_delete_button(item);
} else if (model.type == 'notebook') {
if(this.sessions[path_name] === undefined){
if (this.sessions[path] === undefined){
this.add_delete_button(item);
} else {
this.add_shutdown_button(item, this.sessions[path_name]);
this.add_shutdown_button(item, this.sessions[path]);
}
}
};
@ -305,8 +307,37 @@ define([
$.ajax(url, settings);
return false;
});
// var new_buttons = item.find('a'); // shutdown_button;
item.find(".item_buttons").text("").append(shutdown_button);
item.find(".item_buttons").append(shutdown_button);
};
NotebookList.prototype.add_duplicate_button = function (item) {
var notebooklist = this;
var duplicate_button = $("<button/>").text("Duplicate").addClass("btn btn-default btn-xs").
click(function (e) {
// $(this) is the button that was clicked.
var that = $(this);
var name = item.data('name');
var path = item.data('path');
var message = 'Are you sure you want to duplicate ' + name + '?';
var copy_from = {copy_from : path};
IPython.dialog.modal({
title : "Duplicate " + name,
body : message,
buttons : {
Duplicate : {
class: "btn-primary",
click: function() {
notebooklist.contents.copy(path, notebooklist.notebook_path).then(function () {
notebooklist.load_list();
});
}
},
Cancel : {}
}
});
return false;
});
item.find(".item_buttons").append(duplicate_button);
};
NotebookList.prototype.add_delete_button = function (item) {
@ -340,7 +371,7 @@ define([
});
return false;
});
item.find(".item_buttons").text("").append(delete_button);
item.find(".item_buttons").append(delete_button);
};
NotebookList.prototype.notebook_deleted = function(path) {

@ -40,10 +40,7 @@ define([
var len = data.length;
var nb_path;
for (var i=0; i<len; i++) {
nb_path = utils.url_path_join(
data[i].notebook.path,
data[i].notebook.name
);
nb_path = data[i].notebook.path;
this.sessions[nb_path] = data[i].id;
}
this.events.trigger('sessions_loaded.Dashboard', this.sessions);

@ -103,6 +103,9 @@ ul.breadcrumb {
.item_buttons {
line-height: 1em;
.btn {
min-width: 13ex;
}
}
.toolbar_info {

Loading…
Cancel
Save