Notify the user of errors when saving a notebook.

This commit is contained in:
Felix Werner 2011-10-16 18:24:12 +02:00
parent a89d947322
commit f5b52442aa
2 changed files with 15 additions and 1 deletions

View File

@ -871,7 +871,8 @@ var IPython = (function (IPython) {
type : "PUT",
data : JSON.stringify(data),
headers : {'Content-Type': 'application/json'},
success : $.proxy(this.notebook_saved,this)
success : $.proxy(this.notebook_saved,this),
error : $.proxy(this.notebook_save_failed,this)
};
IPython.save_widget.status_saving();
$.ajax("/notebooks/" + notebook_id, settings);
@ -886,6 +887,14 @@ var IPython = (function (IPython) {
}
Notebook.prototype.notebook_save_failed = function (xhr, status, error_msg) {
// Notify the user and reset the save button
// TODO: Handle different types of errors (timeout etc.)
alert('An unexpected error occured while saving the notebook.');
setTimeout($.proxy(IPython.save_widget.reset_status,IPython.save_widget),500);
}
Notebook.prototype.load_notebook = function (callback) {
var that = this;
var notebook_id = IPython.save_widget.get_notebook_id();

View File

@ -115,6 +115,11 @@ var IPython = (function (IPython) {
};
SaveWidget.prototype.reset_status = function () {
this.is_renaming();
};
SaveWidget.prototype.status_save = function () {
this.element.find('button#save_notebook').button('option', 'label', '<u>S</u>ave');
this.element.find('button#save_notebook').button('enable');