Now updating storage utilization on client in "realtime" as a result of user actions.
This commit is contained in:
parent
ae329d771a
commit
c9bd2ae576
|
@ -104,6 +104,9 @@ Wiki.prototype.display_user = function ( result ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Wiki.prototype.display_storage_usage = function( storage_bytes ) {
|
Wiki.prototype.display_storage_usage = function( storage_bytes ) {
|
||||||
|
if ( !storage_bytes )
|
||||||
|
return;
|
||||||
|
|
||||||
// display the user's current storage usage
|
// display the user's current storage usage
|
||||||
var MEGABYTE = 1024 * 1024;
|
var MEGABYTE = 1024 * 1024;
|
||||||
function bytes_to_megabytes( storage_bytes ) {
|
function bytes_to_megabytes( storage_bytes ) {
|
||||||
|
@ -702,11 +705,12 @@ Wiki.prototype.delete_editor = function ( event, editor ) {
|
||||||
|
|
||||||
this.save_editor( editor, true );
|
this.save_editor( editor, true );
|
||||||
|
|
||||||
|
var self = this;
|
||||||
if ( this.read_write && editor.read_write ) {
|
if ( this.read_write && editor.read_write ) {
|
||||||
this.invoker.invoke( "/notebooks/delete_note", "POST", {
|
this.invoker.invoke( "/notebooks/delete_note", "POST", {
|
||||||
"notebook_id": this.notebook_id,
|
"notebook_id": this.notebook_id,
|
||||||
"note_id": editor.id
|
"note_id": editor.id
|
||||||
} );
|
}, function ( result ) { self.display_storage_usage( result.storage_bytes ); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( editor == this.focused_editor )
|
if ( editor == this.focused_editor )
|
||||||
|
@ -750,10 +754,11 @@ Wiki.prototype.undelete_editor_via_trash = function ( event, editor ) {
|
||||||
this.save_editor( editor, true );
|
this.save_editor( editor, true );
|
||||||
|
|
||||||
if ( this.read_write && editor.read_write ) {
|
if ( this.read_write && editor.read_write ) {
|
||||||
|
var self = this;
|
||||||
this.invoker.invoke( "/notebooks/undelete_note", "POST", {
|
this.invoker.invoke( "/notebooks/undelete_note", "POST", {
|
||||||
"notebook_id": editor.deleted_from,
|
"notebook_id": editor.deleted_from,
|
||||||
"note_id": editor.id
|
"note_id": editor.id
|
||||||
} );
|
}, function ( result ) { self.display_storage_usage( result.storage_bytes ); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( editor == this.focused_editor )
|
if ( editor == this.focused_editor )
|
||||||
|
@ -772,10 +777,11 @@ Wiki.prototype.undelete_editor_via_undo = function( event, editor ) {
|
||||||
|
|
||||||
if ( editor ) {
|
if ( editor ) {
|
||||||
if ( this.read_write && editor.read_write ) {
|
if ( this.read_write && editor.read_write ) {
|
||||||
|
var self = this;
|
||||||
this.invoker.invoke( "/notebooks/undelete_note", "POST", {
|
this.invoker.invoke( "/notebooks/undelete_note", "POST", {
|
||||||
"notebook_id": this.notebook_id,
|
"notebook_id": this.notebook_id,
|
||||||
"note_id": editor.id
|
"note_id": editor.id
|
||||||
} );
|
}, function ( result ) { self.display_storage_usage( result.storage_bytes ); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.startup_notes[ editor.id ] = true;
|
this.startup_notes[ editor.id ] = true;
|
||||||
|
@ -806,7 +812,10 @@ Wiki.prototype.save_editor = function ( editor, fire_and_forget ) {
|
||||||
"contents": editor.contents(),
|
"contents": editor.contents(),
|
||||||
"startup": editor.startup,
|
"startup": editor.startup,
|
||||||
"previous_revision": revisions.length ? revisions[ revisions.length - 1 ] : "None"
|
"previous_revision": revisions.length ? revisions[ revisions.length - 1 ] : "None"
|
||||||
}, function ( result ) { self.update_editor_revisions( result, editor ); }, null, fire_and_forget );
|
}, function ( result ) {
|
||||||
|
self.update_editor_revisions( result, editor );
|
||||||
|
self.display_storage_usage( result.storage_bytes );
|
||||||
|
}, null, fire_and_forget );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,9 +1050,10 @@ Wiki.prototype.delete_all_editors = function ( event ) {
|
||||||
this.startup_notes = new Array();
|
this.startup_notes = new Array();
|
||||||
|
|
||||||
if ( this.read_write ) {
|
if ( this.read_write ) {
|
||||||
|
var self = this;
|
||||||
this.invoker.invoke( "/notebooks/delete_all_notes", "POST", {
|
this.invoker.invoke( "/notebooks/delete_all_notes", "POST", {
|
||||||
"notebook_id": this.notebook_id
|
"notebook_id": this.notebook_id
|
||||||
} );
|
}, function ( result ) { self.display_storage_usage( result.storage_bytes ); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.focused_editor = null;
|
this.focused_editor = null;
|
||||||
|
|
Reference in New Issue