diff options
author | Morris Jobke <morris.jobke@gmail.com> | 2013-11-06 06:49:42 -0800 |
---|---|---|
committer | Morris Jobke <morris.jobke@gmail.com> | 2013-11-06 06:49:42 -0800 |
commit | 1fa1cf46bd02f5a453d491d752828193d463067a (patch) | |
tree | 33b0b13551fa95a2682e17ff2977697cc2cc22a1 | |
parent | 6b6a46589ef9dbd2646327e85f0e8c78fde302ae (diff) | |
parent | 31181e4348b9af2625cf4d6ad38cf4cd81db3c1f (diff) | |
download | nextcloud-server-1fa1cf46bd02f5a453d491d752828193d463067a.tar.gz nextcloud-server-1fa1cf46bd02f5a453d491d752828193d463067a.zip |
Merge pull request #5711 from owncloud/quota-refreshquotainclientafteroperations
Fixes for "max upload size" value showed in the UI
-rw-r--r-- | apps/files/ajax/getstoragestats.php | 8 | ||||
-rw-r--r-- | apps/files/js/file-upload.js | 2 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 8 | ||||
-rw-r--r-- | apps/files/js/files.js | 55 |
4 files changed, 59 insertions, 14 deletions
diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php index 32a77bff6c3..dd7c7dc5571 100644 --- a/apps/files/ajax/getstoragestats.php +++ b/apps/files/ajax/getstoragestats.php @@ -3,7 +3,13 @@ // only need filesystem apps $RUNTIME_APPTYPES = array('filesystem'); +$dir = '/'; + +if (isset($_GET['dir'])) { + $dir = $_GET['dir']; +} + OCP\JSON::checkLoggedIn(); // send back json -OCP\JSON::success(array('data' => \OCA\Files\Helper::buildFileStorageStatistics('/'))); +OCP\JSON::success(array('data' => \OCA\Files\Helper::buildFileStorageStatistics($dir))); diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 94290895ebd..553ca036360 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -404,7 +404,7 @@ $(document).ready(function() { $('#uploadprogresswrapper input.stop').fadeOut(); $('#uploadprogressbar').fadeOut(); - + Files.updateStorageStatistics(); }); fileupload.on('fileuploadfail', function(e, data) { OC.Upload.log('progress handle fileuploadfail', e, data); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 3ef3c2c1766..006bd1f4966 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -152,6 +152,9 @@ var FileList={ FileActions.display(tr.find('td.filename'), true); return tr; }, + getCurrentDirectory: function(){ + return $('#dir').val() || '/'; + }, /** * @brief Changes the current directory and reload the file list. * @param targetDir target directory (non URL encoded) @@ -224,6 +227,10 @@ var FileList={ return; } + // TODO: should rather return upload file size through + // the files list ajax call + Files.updateStorageStatistics(true); + if (result.data.permissions) { FileList.setDirectoryPermissions(result.data.permissions); } @@ -554,6 +561,7 @@ var FileList={ checkTrashStatus(); FileList.updateFileSummary(); FileList.updateEmptyContent(); + Files.updateStorageStatistics(); } else { $.each(files,function(index,file) { var deleteAction = $('tr[data-file="'+files[i]+'"]').children("td.date").children(".action.delete"); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index eb30ddfda0f..2947512ece5 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -1,4 +1,40 @@ Files={ + // file space size sync + _updateStorageStatistics: function() { + Files._updateStorageStatisticsTimeout = null; + var currentDir = FileList.getCurrentDirectory(), + state = Files.updateStorageStatistics; + if (state.dir){ + if (state.dir === currentDir) { + return; + } + // cancel previous call, as it was for another dir + state.call.abort(); + } + state.dir = currentDir; + state.call = $.getJSON(OC.filePath('files','ajax','getstoragestats.php') + '?dir=' + encodeURIComponent(currentDir),function(response) { + state.dir = null; + state.call = null; + Files.updateMaxUploadFilesize(response); + }); + }, + updateStorageStatistics: function(force) { + if (!OC.currentUser) { + return; + } + + // debounce to prevent calling too often + if (Files._updateStorageStatisticsTimeout) { + clearTimeout(Files._updateStorageStatisticsTimeout); + } + if (force) { + Files._updateStorageStatistics(); + } + else { + Files._updateStorageStatisticsTimeout = setTimeout(Files._updateStorageStatistics, 250); + } + }, + updateMaxUploadFilesize:function(response) { if (response === undefined) { return; @@ -351,29 +387,23 @@ $(document).ready(function() { setTimeout ( "Files.displayStorageWarnings()", 100 ); 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 if (OC.currentUser) { // start on load - we ask the server every 5 minutes - var update_storage_statistics_interval = 5*60*1000; - var update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval); + var updateStorageStatisticsInterval = 5*60*1000; + var updateStorageStatisticsIntervalId = setInterval(Files.updateStorageStatistics, updateStorageStatisticsInterval); // Use jquery-visibility to de-/re-activate file stats sync if ($.support.pageVisibility) { $(document).on({ 'show.visibility': function() { - if (!update_storage_statistics_interval_id) { - update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval); + if (!updateStorageStatisticsIntervalId) { + updateStorageStatisticsIntervalId = setInterval(Files.updateStorageStatistics, updateStorageStatisticsInterval); } }, 'hide.visibility': function() { - clearInterval(update_storage_statistics_interval_id); - update_storage_statistics_interval_id = 0; + clearInterval(updateStorageStatisticsIntervalId); + updateStorageStatisticsIntervalId = 0; } }); } @@ -417,6 +447,7 @@ function scanFiles(force, dir, users) { scannerEventSource.listen('done',function(count) { scanFiles.scanning=false; console.log('done after ' + count + ' files'); + Files.updateStorageStatistics(); }); scannerEventSource.listen('user',function(user) { console.log('scanning files for ' + user); |