Update quota value in client after scan and upload

After uploading, the quota value wasn't refreshed.
This fix refreshes the quota value after files have been scanned or
uploaded.
This commit is contained in:
Vincent Petry 2013-11-06 10:15:05 +01:00
parent 3e5a5567eb
commit 5d9ab6e7ac
3 changed files with 33 additions and 13 deletions

View File

@ -404,7 +404,7 @@ $(document).ready(function() {
$('#uploadprogresswrapper input.stop').fadeOut(); $('#uploadprogresswrapper input.stop').fadeOut();
$('#uploadprogressbar').fadeOut(); $('#uploadprogressbar').fadeOut();
Files.updateStorageStatistics();
}); });
fileupload.on('fileuploadfail', function(e, data) { fileupload.on('fileuploadfail', function(e, data) {
OC.Upload.log('progress handle fileuploadfail', e, data); OC.Upload.log('progress handle fileuploadfail', e, data);

View File

@ -554,6 +554,7 @@ var FileList={
checkTrashStatus(); checkTrashStatus();
FileList.updateFileSummary(); FileList.updateFileSummary();
FileList.updateEmptyContent(); FileList.updateEmptyContent();
Files.updateStorageStatistics();
} else { } else {
$.each(files,function(index,file) { $.each(files,function(index,file) {
var deleteAction = $('tr[data-file="'+files[i]+'"]').children("td.date").children(".action.delete"); var deleteAction = $('tr[data-file="'+files[i]+'"]').children("td.date").children(".action.delete");

View File

@ -1,4 +1,28 @@
Files={ Files={
// file space size sync
_updateStorageStatistics: function() {
Files._updateStorageStatisticsTimeout = null;
if (Files.updateStorageStatistics.running){
return;
}
Files.updateStorageStatistics.running = true;
$.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
Files.updateStorageStatistics.running = false;
Files.updateMaxUploadFilesize(response);
});
},
updateStorageStatistics: function() {
if (!OC.currentUser) {
return;
}
// debounce to prevent calling too often
if (Files._updateStorageStatisticsTimeout) {
clearTimeout(Files._updateStorageStatisticsTimeout);
}
Files._updateStorageStatisticsTimeout = setTimeout(Files._updateStorageStatistics, 1000);
},
updateMaxUploadFilesize:function(response) { updateMaxUploadFilesize:function(response) {
if (response === undefined) { if (response === undefined) {
return; return;
@ -351,29 +375,23 @@ $(document).ready(function() {
setTimeout ( "Files.displayStorageWarnings()", 100 ); setTimeout ( "Files.displayStorageWarnings()", 100 );
OC.Notification.setDefault(Files.displayStorageWarnings); OC.Notification.setDefault(Files.displayStorageWarnings);
// file space size sync
function update_storage_statistics() {
$.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
Files.updateMaxUploadFilesize(response);
});
}
// only possible at the moment if user is logged in // only possible at the moment if user is logged in
if (OC.currentUser) { if (OC.currentUser) {
// start on load - we ask the server every 5 minutes // start on load - we ask the server every 5 minutes
var update_storage_statistics_interval = 5*60*1000; var updateStorageStatisticsInterval = 5*60*1000;
var update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval); var updateStorageStatisticsIntervalId = setInterval(Files.updateStorageStatistics, updateStorageStatisticsInterval);
// Use jquery-visibility to de-/re-activate file stats sync // Use jquery-visibility to de-/re-activate file stats sync
if ($.support.pageVisibility) { if ($.support.pageVisibility) {
$(document).on({ $(document).on({
'show.visibility': function() { 'show.visibility': function() {
if (!update_storage_statistics_interval_id) { if (!updateStorageStatisticsIntervalId) {
update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval); updateStorageStatisticsIntervalId = setInterval(Files.updateStorageStatistics, updateStorageStatisticsInterval);
} }
}, },
'hide.visibility': function() { 'hide.visibility': function() {
clearInterval(update_storage_statistics_interval_id); clearInterval(updateStorageStatisticsIntervalId);
update_storage_statistics_interval_id = 0; updateStorageStatisticsIntervalId = 0;
} }
}); });
} }
@ -417,6 +435,7 @@ function scanFiles(force, dir, users) {
scannerEventSource.listen('done',function(count) { scannerEventSource.listen('done',function(count) {
scanFiles.scanning=false; scanFiles.scanning=false;
console.log('done after ' + count + ' files'); console.log('done after ' + count + ' files');
Files.updateStorageStatistics();
}); });
scannerEventSource.listen('user',function(user) { scannerEventSource.listen('user',function(user) {
console.log('scanning files for ' + user); console.log('scanning files for ' + user);