diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-01-18 14:06:00 -0800 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-01-18 14:06:00 -0800 |
commit | 31cc9aa80d4284e13dc95d2ef1428bed78c22d65 (patch) | |
tree | 3b42e3a95bc0a92cd75bba16438e9dcf55f49e89 /apps/files/js/files.js | |
parent | edf3572835ac5a6584fdde7ba7bb1faa64251e2d (diff) | |
parent | 5ff29b4348a1dcb9ed32273133b1c787aaf5c72c (diff) | |
download | nextcloud-server-31cc9aa80d4284e13dc95d2ef1428bed78c22d65.tar.gz nextcloud-server-31cc9aa80d4284e13dc95d2ef1428bed78c22d65.zip |
Merge pull request #986 from owncloud/fixing-784-master
the maximum upload size is now part of the response of the upload and de...
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r-- | apps/files/js/files.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 3a4af6416e9..0488062dbca 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -26,6 +26,23 @@ Files={ }); procesSelection(); }, + updateMaxUploadFilesize:function(response) { + if(response == undefined) { + return; + } + if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { + $('#max_upload').val(response.data.uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize); + } + if(response[0] == undefined) { + return; + } + if(response[0].uploadMaxFilesize !== undefined) { + $('#max_upload').val(response[0].uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize); + } + + }, isFileNameValid:function (name) { if (name === '.') { $('#notification').text(t('files', '\'.\' is an invalid file name.')); @@ -317,6 +334,7 @@ $(document).ready(function() { $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); } + Files.updateMaxUploadFilesize(response); var file=response[0]; // TODO: this doesn't work if the file name has been changed server side delete uploadingFiles[dirName][file.name]; @@ -369,6 +387,8 @@ $(document).ready(function() { .success(function(result, textStatus, jqXHR) { var response; response=jQuery.parseJSON(result); + Files.updateMaxUploadFilesize(response); + if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; delete uploadingFiles[file.name]; @@ -402,6 +422,7 @@ $(document).ready(function() { data.submit().success(function(data, status) { // in safari data is a string response = jQuery.parseJSON(typeof data === 'string' ? data : data[0].body.innerText); + Files.updateMaxUploadFilesize(response); if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; delete uploadingFiles[file.name]; @@ -712,6 +733,32 @@ $(document).ready(function() { }); resizeBreadcrumbs(true); + + // file space size sync + function update_storage_statistics() { + $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) { + Files.updateMaxUploadFilesize(response); + }); + } + + // 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); + + // 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); + } + }, + 'hide.visibility': function() { + clearInterval(update_storage_statistics_interval_id); + update_storage_statistics_interval_id = 0; + } + }); + } }); function scanFiles(force,dir){ @@ -741,6 +788,7 @@ scanFiles.scanning=false; function boolOperationFinished(data, callback) { result = jQuery.parseJSON(data.responseText); + Files.updateMaxUploadFilesize(result); if(result.status == 'success'){ callback.call(); } else { |