##// END OF EJS Templates
Fix terminals with Tornado 3...
Fix terminals with Tornado 3 The websocket handler auth checking was calling clear_cookie(), which threw an error because it doesn't make sense for Websockets. It doesn't seem important, and we silence it in our other websocket handlers, so silencing it here too.

File last commit:

r18352:8a12dee8
r18546:2b2243ed
Show More
notebooklist.js
540 lines | 19.3 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Started work to make tree requirejs friendly.
r17189 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'base/js/namespace',
Jonathan Frederic
MWE,...
r17200 'jquery',
Jonathan Frederic
Started work to make tree requirejs friendly.
r17189 'base/js/utils',
'base/js/dialog',
Jonathan Frederic
Fix imports of "modules",...
r17202 ], function(IPython, $, utils, dialog) {
MinRK
add utils.url_path_join...
r13063 "use strict";
jon
In person review with @ellisonbg
r17210 var NotebookList = function (selector, options) {
jon
Added some nice comments,...
r17211 // Constructor
//
// Parameters:
// selector: string
// options: dictionary
// Dictionary of keyword arguments.
// session_list: SessionList instance
// element_name: string
// base_url: string
// notebook_path: string
Jonathan Frederic
Started work to make tree requirejs friendly.
r17189 var that = this;
jon
In person review with @ellisonbg
r17210 this.session_list = options.session_list;
Paul Ivanov
ok, Running tab is working now
r15454 // allow code re-use by just changing element_name in kernellist.js
jon
In person review with @ellisonbg
r17210 this.element_name = options.element_name || 'notebook';
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 this.selector = selector;
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
this.bind_events();
}
MinRK
add utils.url_path_join...
r13063 this.notebooks_list = [];
this.sessions = {};
Jonathan Frederic
Almost done!...
r17198 this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
Jonathan Frederic
Fixed events
r17195 if (this.session_list && this.session_list.events) {
this.session_list.events.on('sessions_loaded.Dashboard',
function(e, d) { that.sessions_loaded(d); });
}
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 };
NotebookList.prototype.style = function () {
Jonathan Frederic
Started work to make tree requirejs friendly.
r17189 var prefix = '#' + this.element_name;
Paul Ivanov
small whitespace cleanup, renamed drag_info...
r15518 $(prefix + '_toolbar').addClass('list_toolbar');
$(prefix + '_list_info').addClass('toolbar_info');
$(prefix + '_buttons').addClass('toolbar_buttons');
$(prefix + '_list_header').addClass('list_header');
MinRK
use row-fluid for cluster list
r10920 this.element.addClass("list_container");
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 };
NotebookList.prototype.bind_events = function () {
Brian E. Granger
File upload/import working from notebook browser.
r4491 var that = this;
Paul Ivanov
refresh of Notebook list should reload sessions
r15456 $('#refresh_' + this.element_name + '_list').click(function () {
that.load_sessions();
Brian Granger
Draft of the cluster list UI....
r6195 });
Brian E. Granger
File upload/import working from notebook browser.
r4491 this.element.bind('dragover', function () {
return false;
});
Matthias BUSSONNIER
alternate notebook upload methods...
r6838 this.element.bind('drop', function(event){
Paul Ivanov
fix typo in method name
r15455 that.handleFilesUpload(event,'drop');
Brian E. Granger
File upload/import working from notebook browser.
r4491 return false;
});
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 };
Paul Ivanov
fix typo in method name
r15455 NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) {
Matthias BUSSONNIER
alternate notebook upload methods...
r6838 var that = this;
var files;
if(dropOrForm =='drop'){
files = event.originalEvent.dataTransfer.files;
} else
{
MinRK
add utils.url_path_join...
r13063 files = event.originalEvent.target.files;
Matthias BUSSONNIER
alternate notebook upload methods...
r6838 }
MinRK
add utils.url_path_join...
r13063 for (var i = 0; i < files.length; i++) {
var f = files[i];
Jonathan Frederic
Almost done!...
r17198 var name_and_ext = utils.splitext(f.name);
Matthias BUSSONNIER
fix notebook upload...
r13322 var file_ext = name_and_ext[1];
MinRK
various upload fixes...
r17536
var reader = new FileReader();
MinRK
use splitext in notebook_list...
r13121 if (file_ext === '.ipynb') {
MinRK
various upload fixes...
r17536 reader.readAsText(f);
Brian E. Granger
Fully removing .py file upload....
r13115 } else {
MinRK
various upload fixes...
r17536 // read non-notebook files as binary
reader.readAsArrayBuffer(f);
MinRK
add utils.url_path_join...
r13063 }
MinRK
various upload fixes...
r17536 var item = that.new_item(0);
item.addClass('new-file');
Jeffrey Bush
Minor improvements to file upload....
r17643 that.add_name_input(f.name, item, file_ext == '.ipynb' ? 'notebook' : 'file');
MinRK
various upload fixes...
r17536 // Store the list item in the reader so we can use it later
// to know which item it belongs to.
$(reader).data('item', item);
reader.onload = function (event) {
var item = $(event.target).data('item');
that.add_file_data(event.target.result, item);
that.add_upload_button(item);
};
Jeffrey Bush
Fixed many edge cases in file uploads....
r17650 reader.onerror = function (event) {
var item = $(event.target).data('item');
var name = item.data('name')
item.remove();
dialog.modal({
title : 'Failed to read file',
body : "Failed to read file '" + name + "'",
buttons : {'OK' : { 'class' : 'btn-primary' }}
});
};
Matthias BUSSONNIER
alternate notebook upload methods...
r6838 }
Brian E. Granger
Reset file upload form after an upload.
r14926 // Replace the file input form wth a clone of itself. This is required to
// reset the form. Otherwise, if you upload a file, delete it and try to
// upload it again, the changed event won't fire.
var form = $('input.fileinput');
form.replaceWith(form.clone(true));
Matthias BUSSONNIER
alternate notebook upload methods...
r6838 return false;
MinRK
add utils.url_path_join...
r13063 };
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488
Jonathan Frederic
Don't remove upload items unless explicitly requested.
r16213 NotebookList.prototype.clear_list = function (remove_uploads) {
// Clears the navigation tree.
//
// Parameters
// remove_uploads: bool=False
// Should upload prompts also be removed from the tree.
if (remove_uploads) {
this.element.children('.list_item').remove();
} else {
this.element.children('.list_item:not(.new-file)').remove();
}
Matthias BUSSONNIER
pep8
r7941 };
Brian Granger
Draft of the cluster list UI....
r6195
Zachary Sailer
manual rebase static/tree/
r12988 NotebookList.prototype.load_sessions = function(){
Jonathan Frederic
Started work to make tree requirejs friendly.
r17189 this.session_list.load_sessions();
Zachary Sailer
manual rebase static/tree/
r12988 };
NotebookList.prototype.sessions_loaded = function(data){
Paul Ivanov
added IPython.session_list...
r15479 this.sessions = data;
Zachary Sailer
manual rebase static/tree/
r12988 this.load_list();
};
Brian Granger
Draft of the cluster list UI....
r6195
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 NotebookList.prototype.load_list = function () {
Matthias BUSSONNIER
show message on notebook list if server is unreachable...
r7881 var that = this;
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 var settings = {
processData : false,
cache : false,
type : "GET",
dataType : "json",
Matthias BUSSONNIER
show message on notebook list if server is unreachable...
r7881 success : $.proxy(this.list_loaded, this),
MinRK
log all failed ajax API requests
r16445 error : $.proxy( function(xhr, status, error){
Jonathan Frederic
Almost done!...
r17198 utils.log_ajax_error(xhr, status, error);
Matthias BUSSONNIER
pep8
r7941 that.list_loaded([], null, null, {msg:"Error connecting to server."});
},this)
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 };
Matthias BUSSONNIER
show message on notebook list if server is unreachable...
r7881
Jonathan Frederic
Almost done!...
r17198 var url = utils.url_join_encode(
MinRK
s/base_project_url/base_url/...
r15238 this.base_url,
MinRK
add utils.url_path_join...
r13063 'api',
MinRK
rename notebooks service to contents service...
r17524 'contents',
MinRK
various unicode fixes...
r15234 this.notebook_path
MinRK
add utils.url_path_join...
r13063 );
Brian E. Granger
Updating JS URL scheme to use embedded data....
r5106 $.ajax(url, settings);
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 };
Matthias BUSSONNIER
show message on notebook list if server is unreachable...
r7881 NotebookList.prototype.list_loaded = function (data, status, xhr, param) {
MinRK
handle undefined param in notebooklist...
r7976 var message = 'Notebook list empty.';
if (param !== undefined && param.msg) {
MinRK
add utils.url_path_join...
r13063 message = param.msg;
MinRK
handle undefined param in notebooklist...
r7976 }
Brian E. Granger
Cleaning up the dashboard CSS and fixing small visual problems.
r15078 var item = null;
MinRK
teach tree view about non-notebook files
r17526 var model = null;
var list = data.content;
var len = list.length;
Matthias BUSSONNIER
proof of concept
r6842 this.clear_list();
Jeffrey Bush
File list refreshes no longer move the upload filename boxes....
r17651 var n_uploads = this.element.children('.list_item').length;
MinRK
add utils.url_path_join...
r13063 if (len === 0) {
MinRK
teach tree view about non-notebook files
r17526 item = this.new_item(0);
Brian E. Granger
Cleaning up the dashboard CSS and fixing small visual problems.
r15078 var span12 = item.children().first();
span12.empty();
MinRK
don't strip '.ipynb' from notebook names in nblist...
r15094 span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message));
Matthias BUSSONNIER
Drag target bigger for empty notebook dashboard...
r6857 }
MinRK
various unicode fixes...
r15234 var path = this.notebook_path;
Jeffrey Bush
File list refreshes no longer move the upload filename boxes....
r17651 var offset = n_uploads;
Brian E. Granger
Add directory browsing to the dashboard.
r15071 if (path !== '') {
Jeffrey Bush
File list refreshes no longer move the upload filename boxes....
r17651 item = this.new_item(offset);
MinRK
teach tree view about non-notebook files
r17526 model = {
type: 'directory',
name: '..',
path: path,
};
this.add_link(model, item);
Jeffrey Bush
File list refreshes no longer move the upload filename boxes....
r17651 offset += 1;
Brian E. Granger
Add directory browsing to the dashboard.
r15071 }
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 for (var i=0; i<len; i++) {
MinRK
teach tree view about non-notebook files
r17526 model = list[i];
item = this.new_item(i+offset);
this.add_link(model, item);
MinRK
add utils.url_path_join...
r13063 }
Brian E. Granger
File upload/import working from notebook browser.
r4491 };
Brian E. Granger
Implemented delete functionality in nb browser....
r4490
Brian E. Granger
File upload/import working from notebook browser.
r4491
MinRK
teach tree view about non-notebook files
r17526 NotebookList.prototype.new_item = function (index) {
Jonathan Frederic
Ran jdfreder/bootstrap2to3
r16913 var item = $('<div/>').addClass("list_item").addClass("row");
MinRK
bootstrap tree
r10891 // item.addClass('list_item ui-widget ui-widget-content ui-helper-clearfix');
// item.css('border-top-style','none');
Jonathan Frederic
Change the nav bar to nav-pills
r16923 item.append($("<div/>").addClass("col-md-12").append(
Brian E. Granger
Add directory browsing to the dashboard.
r15071 $('<i/>').addClass('item_icon')
).append(
MinRK
use row-fluid for tree_list
r10919 $("<a/>").addClass("item_link").append(
MinRK
bootstrap tree
r10891 $("<span/>").addClass("item_name")
)
MinRK
use row-fluid for tree_list
r10919 ).append(
$('<div/>').addClass("item_buttons btn-group pull-right")
));
MinRK
bootstrap tree
r10891
Brian E. Granger
File upload/import working from notebook browser.
r4491 if (index === -1) {
Brian E. Granger
Implemented delete functionality in nb browser....
r4490 this.element.append(item);
Brian E. Granger
File upload/import working from notebook browser.
r4491 } else {
this.element.children().eq(index).after(item);
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 }
Brian E. Granger
File upload/import working from notebook browser.
r4491 return item;
};
MinRK
teach tree view about non-notebook files
r17526 NotebookList.icons = {
directory: 'folder_icon',
notebook: 'notebook_icon',
file: 'file_icon',
};
NotebookList.uri_prefixes = {
directory: 'tree',
notebook: 'notebooks',
file: 'files',
};
NotebookList.prototype.add_link = function (model, item) {
var path = model.path,
name = model.name;
Brian E. Granger
Add directory browsing to the dashboard.
r15071 item.data('name', name);
item.data('path', path);
item.find(".item_name").text(name);
MinRK
teach tree view about non-notebook files
r17526 var icon = NotebookList.icons[model.type];
var uri_prefix = NotebookList.uri_prefixes[model.type];
item.find(".item_icon").addClass(icon).addClass('icon-fixed-width');
MinRK
updates per review...
r17535 var link = item.find("a.item_link")
Brian E. Granger
Add directory browsing to the dashboard.
r15071 .attr('href',
Jonathan Frederic
Almost done!...
r17198 utils.url_join_encode(
MinRK
s/base_project_url/base_url/...
r15238 this.base_url,
MinRK
teach tree view about non-notebook files
r17526 uri_prefix,
Brian E. Granger
Add directory browsing to the dashboard.
r15071 path,
name
)
);
MinRK
updates per review...
r17535 // directory nav doesn't open new tabs
// files, notebooks do
if (model.type !== "directory") {
link.attr('target','_blank');
}
MinRK
teach tree view about non-notebook files
r17526 var path_name = utils.url_path_join(path, name);
if (model.type == 'file') {
this.add_delete_button(item);
} else if (model.type == 'notebook') {
if(this.sessions[path_name] === undefined){
this.add_delete_button(item);
} else {
this.add_shutdown_button(item, this.sessions[path_name]);
}
}
Brian E. Granger
Add directory browsing to the dashboard.
r15071 };
Jeffrey Bush
Minor improvements to file upload....
r17643 NotebookList.prototype.add_name_input = function (name, item, icon_type) {
MinRK
teach tree view about non-notebook files
r17526 item.data('name', name);
Jeffrey Bush
Minor improvements to file upload....
r17643 item.find(".item_icon").addClass(NotebookList.icons[icon_type]).addClass('icon-fixed-width');
MinRK
use row-fluid for tree_list
r10919 item.find(".item_name").empty().append(
MinRK
tree style tweaks
r10896 $('<input/>')
MinRK
various upload fixes...
r17536 .addClass("filename_input")
.attr('value', name)
MinRK
tree style tweaks
r10896 .attr('size', '30')
.attr('type', 'text')
Jeffrey Bush
Added ESC keep to upload textbox to cancel.
r17646 .keyup(function(event){
if(event.keyCode == 13){item.find('.upload_button').click();}
else if(event.keyCode == 27){item.remove();}
})
Brian E. Granger
File upload/import working from notebook browser.
r4491 );
};
MinRK
various upload fixes...
r17536 NotebookList.prototype.add_file_data = function (data, item) {
item.data('filedata', data);
Brian E. Granger
File upload/import working from notebook browser.
r4491 };
Zachary Sailer
manual rebase static/tree/
r12988 NotebookList.prototype.add_shutdown_button = function (item, session) {
Matthias BUSSONNIER
proof of concept
r6842 var that = this;
Jonathan Frederic
Fix automation errors.
r16914 var shutdown_button = $("<button/>").text("Shutdown").addClass("btn btn-xs btn-danger").
Matthias BUSSONNIER
proof of concept
r6842 click(function (e) {
var settings = {
processData : false,
cache : false,
type : "DELETE",
dataType : "json",
Zachary Sailer
fixed shutdown button refresh on dashboard
r12996 success : function () {
Zachary Sailer
manual rebase static/tree/
r12988 that.load_sessions();
MinRK
log all failed ajax API requests
r16445 },
Jonathan Frederic
Almost done!...
r17198 error : utils.log_ajax_error,
Matthias BUSSONNIER
proof of concept
r6842 };
Jonathan Frederic
Almost done!...
r17198 var url = utils.url_join_encode(
MinRK
s/base_project_url/base_url/...
r15238 that.base_url,
MinRK
add utils.url_path_join...
r13063 'api/sessions',
session
);
Matthias BUSSONNIER
proof of concept
r6842 $.ajax(url, settings);
MinRK
bootstrap tree
r10891 return false;
Matthias BUSSONNIER
proof of concept
r6842 });
MinRK
bootstrap tree
r10891 // var new_buttons = item.find('a'); // shutdown_button;
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 item.find(".item_buttons").text("").append(shutdown_button);
Matthias BUSSONNIER
proof of concept
r6842 };
Brian E. Granger
File upload/import working from notebook browser.
r4491 NotebookList.prototype.add_delete_button = function (item) {
MinRK
bootstrap tree
r10891 var new_buttons = $('<span/>').addClass("btn-group pull-right");
Matthias BUSSONNIER
fix notebook deletion....
r9787 var notebooklist = this;
Jonathan Frederic
Ran jdfreder/bootstrap2to3
r16913 var delete_button = $("<button/>").text("Delete").addClass("btn btn-default btn-xs").
Brian E. Granger
File upload/import working from notebook browser.
r4491 click(function (e) {
// $(this) is the button that was clicked.
var that = $(this);
MinRK
various upload fixes...
r17536 // 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.
Brian Granger
Draft of the cluster list UI....
r6195 var parent_item = that.parents('div.list_item');
MinRK
teach tree view about non-notebook files
r17526 var name = parent_item.data('name');
var message = 'Are you sure you want to permanently delete the file: ' + name + '?';
Jonathan Frederic
Fix imports of "modules",...
r17202 dialog.modal({
MinRK
teach tree view about non-notebook files
r17526 title : "Delete file",
MinRK
bootstrapify delete dialog
r10921 body : message,
Brian E. Granger
File upload/import working from notebook browser.
r4491 buttons : {
MinRK
bootstrapify delete dialog
r10921 Delete : {
class: "btn-danger",
click: function() {
var settings = {
processData : false,
cache : false,
type : "DELETE",
dataType : "json",
success : function (data, status, xhr) {
parent_item.remove();
MinRK
log all failed ajax API requests
r16445 },
Jonathan Frederic
Almost done!...
r17198 error : utils.log_ajax_error,
MinRK
bootstrapify delete dialog
r10921 };
Jonathan Frederic
Almost done!...
r17198 var url = utils.url_join_encode(
MinRK
s/base_project_url/base_url/...
r15238 notebooklist.base_url,
MinRK
rename notebooks service to contents service...
r17524 'api/contents',
MinRK
various unicode fixes...
r15234 notebooklist.notebook_path,
MinRK
teach tree view about non-notebook files
r17526 name
MinRK
add utils.url_path_join...
r13063 );
MinRK
bootstrapify delete dialog
r10921 $.ajax(url, settings);
}
Brian E. Granger
File upload/import working from notebook browser.
r4491 },
MinRK
bootstrapify delete dialog
r10921 Cancel : {}
Brian E. Granger
File upload/import working from notebook browser.
r4491 }
});
MinRK
bootstrap tree
r10891 return false;
Brian E. Granger
File upload/import working from notebook browser.
r4491 });
Matthias BUSSONNIER
some $.html( -> $.text(...
r14634 item.find(".item_buttons").text("").append(delete_button);
Brian E. Granger
File upload/import working from notebook browser.
r4491 };
MinRK
various upload fixes...
r17536 NotebookList.prototype.add_upload_button = function (item, type) {
Brian E. Granger
File upload/import working from notebook browser.
r4491 var that = this;
MinRK
tree style tweaks
r10896 var upload_button = $('<button/>').text("Upload")
Jonathan Frederic
Fix automation errors.
r16914 .addClass('btn btn-primary btn-xs upload_button')
MinRK
tree style tweaks
r10896 .click(function (e) {
MinRK
various unicode fixes...
r15234 var path = that.notebook_path;
MinRK
various upload fixes...
r17536 var filename = item.find('.item_name > input').val();
var filedata = item.data('filedata');
var format = 'text';
Jeffrey Bush
Fixed many edge cases in file uploads....
r17650 if (filename.length === 0 || filename[0] === '.') {
dialog.modal({
title : 'Invalid file name',
body : "File names must be at least one character and not start with a dot",
buttons : {'OK' : { 'class' : 'btn-primary' }}
});
return false;
}
MinRK
various upload fixes...
r17536 if (filedata instanceof ArrayBuffer) {
// base64-encode binary file data
var bytes = '';
var buf = new Uint8Array(filedata);
var nbytes = buf.byteLength;
for (var i=0; i<nbytes; i++) {
bytes += String.fromCharCode(buf[i]);
}
filedata = btoa(bytes);
format = 'base64';
}
MinRK
fix dashboard upload
r13072 var model = {
MinRK
updates per review...
r17535 path: path,
MinRK
various upload fixes...
r17536 name: filename
MinRK
fix dashboard upload
r13072 };
MinRK
various upload fixes...
r17536
var name_and_ext = utils.splitext(filename);
var file_ext = name_and_ext[1];
var content_type;
if (file_ext === '.ipynb') {
model.type = 'notebook';
model.format = 'json';
MinRK
update contents per further review...
r17537 try {
model.content = JSON.parse(filedata);
} catch (e) {
dialog.modal({
title : 'Cannot upload invalid Notebook',
body : "The error was: " + e,
buttons : {'OK' : {
'class' : 'btn-primary',
click: function () {
item.remove();
}
}}
});
Jeffrey Bush
Fixed many edge cases in file uploads....
r17650 return false;
MinRK
update contents per further review...
r17537 }
MinRK
various upload fixes...
r17536 content_type = 'application/json';
} else {
model.type = 'file';
model.format = format;
model.content = filedata;
content_type = 'application/octet-stream';
}
var filedata = item.data('filedata');
Brian E. Granger
File upload/import working from notebook browser.
r4491 var settings = {
processData : false,
cache : false,
Matthias BUSSONNIER
fix notebook upload...
r13322 type : 'PUT',
MinRK
fix dashboard upload
r13072 data : JSON.stringify(model),
MinRK
set contentType='application/json'...
r18352 contentType: content_type,
Brian E. Granger
File upload/import working from notebook browser.
r4491 success : function (data, status, xhr) {
MinRK
various upload fixes...
r17536 item.removeClass('new-file');
MinRK
updates per review...
r17535 that.add_link(model, item);
Brian E. Granger
File upload/import working from notebook browser.
r4491 that.add_delete_button(item);
Jeffrey Bush
Minor improvements to file upload....
r17643 that.session_list.load_sessions();
MinRK
fix dashboard upload
r13072 },
Jonathan Frederic
Almost done!...
r17198 error : utils.log_ajax_error,
Brian E. Granger
File upload/import working from notebook browser.
r4491 };
Jonathan Frederic
Almost done!...
r17198 var url = utils.url_join_encode(
MinRK
s/base_project_url/base_url/...
r15238 that.base_url,
MinRK
rename notebooks service to contents service...
r17524 'api/contents',
MinRK
various unicode fixes...
r15234 that.notebook_path,
MinRK
various upload fixes...
r17536 filename
MinRK
add utils.url_path_join...
r13063 );
Jeffrey Bush
Uploading a file with a name that already exists asks the user if they want to overwrite....
r17648
var exists = false;
$.each(that.element.find('.list_item:not(.new-file)'), function(k,v){
if ($(v).data('name') === filename) { exists = true; return false; }
});
if (exists) {
dialog.modal({
title : "Replace file",
body : 'There is already a file named ' + filename + ', do you want to replace it?',
buttons : {
Overwrite : {
class: "btn-danger",
click: function() { $.ajax(url, settings); }
},
Cancel : {
click: function() { item.remove(); }
}
}
});
} else {
$.ajax(url, settings);
}
MinRK
bootstrap tree
r10891 return false;
Brian E. Granger
File upload/import working from notebook browser.
r4491 });
MinRK
tree style tweaks
r10896 var cancel_button = $('<button/>').text("Cancel")
Jonathan Frederic
Ran jdfreder/bootstrap2to3
r16913 .addClass("btn btn-default btn-xs")
MinRK
tree style tweaks
r10896 .click(function (e) {
Brian E. Granger
File upload/import working from notebook browser.
r4491 item.remove();
MinRK
bootstrap tree
r10891 return false;
Brian E. Granger
File upload/import working from notebook browser.
r4491 });
MinRK
tree style tweaks
r10896 item.find(".item_buttons").empty()
MinRK
bootstrap tree
r10891 .append(upload_button)
.append(cancel_button);
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 };
Zachary Sailer
Change new/copy URLS to POST requests
r13017 NotebookList.prototype.new_notebook = function(){
MinRK
various unicode fixes...
r15234 var path = this.notebook_path;
MinRK
s/base_project_url/base_url/...
r15238 var base_url = this.base_url;
Zachary Sailer
Change new/copy URLS to POST requests
r13017 var settings = {
processData : false,
cache : false,
type : "POST",
dataType : "json",
MinRK
use `async : false` to avoid pop-up blocker on New / Copy notebook
r13075 async : false,
success : function (data, status, xhr) {
MinRK
add utils.url_path_join...
r13063 var notebook_name = data.name;
window.open(
Jonathan Frederic
Almost done!...
r17198 utils.url_join_encode(
MinRK
s/base_project_url/base_url/...
r15238 base_url,
MinRK
add utils.url_path_join...
r13063 'notebooks',
MinRK
mixup notebook_list
r13069 path,
MinRK
add utils.url_path_join...
r13063 notebook_name),
'_blank'
);
MinRK
log all failed ajax API requests
r16445 },
MinRK
dialog on New Notebook failure
r16446 error : $.proxy(this.new_notebook_failed, this),
Zachary Sailer
Change new/copy URLS to POST requests
r13017 };
Jonathan Frederic
Almost done!...
r17198 var url = utils.url_join_encode(
MinRK
s/base_project_url/base_url/...
r15238 base_url,
MinRK
rename notebooks service to contents service...
r17524 'api/contents',
MinRK
add utils.url_path_join...
r13063 path
);
$.ajax(url, settings);
Zachary Sailer
Change new/copy URLS to POST requests
r13017 };
MinRK
dialog on New Notebook failure
r16446
NotebookList.prototype.new_notebook_failed = function (xhr, status, error) {
Jonathan Frederic
Almost done!...
r17198 utils.log_ajax_error(xhr, status, error);
MinRK
dialog on New Notebook failure
r16446 var msg;
if (xhr.responseJSON && xhr.responseJSON.message) {
msg = xhr.responseJSON.message;
} else {
msg = xhr.statusText;
}
Jonathan Frederic
Fix imports of "modules",...
r17202 dialog.modal({
MinRK
dialog on New Notebook failure
r16446 title : 'Creating Notebook Failed',
body : "The error was: " + msg,
buttons : {'OK' : {'class' : 'btn-primary'}}
});
Jonathan Frederic
Started work to make tree requirejs friendly.
r17189 };
MinRK
teach tree view about non-notebook files
r17526
// Backwards compatability.
Brian E. Granger
Implemented basic notebook browser and fixed numerous bugs.
r4488 IPython.NotebookList = NotebookList;
Jonathan Frederic
Return dicts instead of classes,...
r17201 return {'NotebookList': NotebookList};
Jonathan Frederic
Started work to make tree requirejs friendly.
r17189 });