diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2017-12-28 10:53:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-28 10:53:14 +0100 |
commit | 08cbfb6c6b554eed221aafe185c02dc2e7841d95 (patch) | |
tree | 50453d85567e332879a31a34412c1749ded4ad32 | |
parent | 46958e4c3f2b44ee6acfd95a94bee0f3be19f00a (diff) | |
parent | c8db1ed74138e727013fb6712374844829277ae6 (diff) | |
download | nextcloud-server-08cbfb6c6b554eed221aafe185c02dc2e7841d95.tar.gz nextcloud-server-08cbfb6c6b554eed221aafe185c02dc2e7841d95.zip |
Merge pull request #7592 from nextcloud/update-quota-on-files-upload
Update quota on files upload
-rw-r--r-- | apps/files/js/file-upload.js | 2 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 1 | ||||
-rw-r--r-- | apps/files/js/files.js | 27 | ||||
-rw-r--r-- | apps/files/lib/Helper.php | 2 | ||||
-rw-r--r-- | apps/files/templates/appnavigation.php | 2 |
5 files changed, 31 insertions, 3 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index d1730fa7bc7..e9534111e10 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -130,7 +130,7 @@ OC.FileUpload.prototype = { }, /** - * Get full path for the target file, + * Get full path for the target file, * including relative path and file name. * * @return {String} full path diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 7735e9357b1..61e9432dce3 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1768,7 +1768,6 @@ return true; } - // TODO: parse remaining quota from PROPFIND response this.updateStorageStatistics(true); // first entry is the root diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 479a2817f44..153307fec52 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -29,6 +29,7 @@ state.dir = null; state.call = null; Files.updateMaxUploadFilesize(response); + Files.updateQuota(response); }); }, /** @@ -77,6 +78,32 @@ }, + updateQuota:function(response) { + if (response === undefined) { + return; + } + if (response.data !== undefined + && response.data.quota !== undefined + && response.data.used !== undefined + && response.data.usedSpacePercent !== undefined) { + var humanUsed = OC.Util.humanFileSize(response.data.used, true); + var humanQuota = OC.Util.humanFileSize(response.data.quota, true); + if (response.data.quota > 0) { + $('#quota').attr('data-original-title', Math.floor(response.data.used/response.data.quota*1000)/10 + '%'); + $('#quota progress').val(response.data.usedSpacePercent); + $('#quotatext').text(t('files', '{used} of {quota} used', {used: humanUsed, quota: humanQuota})); + } else { + $('#quotatext').text(t('files', '{used} used', {used: humanUsed})); + } + if (response.data.usedSpacePercent > 80) { + $('#quota progress').addClass('warn'); + } else { + $('#quota progress').removeClass('warn'); + } + } + + }, + /** * Fix path name by removing double slash at the beginning, if any */ diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index ab952c97dfb..9d9717c9401 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -56,6 +56,8 @@ class Helper { 'uploadMaxFilesize' => $maxUploadFileSize, 'maxHumanFilesize' => $maxHumanFileSize, 'freeSpace' => $storageInfo['free'], + 'quota' => $storageInfo['quota'], + 'used' => $storageInfo['used'], 'usedSpacePercent' => (int)$storageInfo['relative'], 'owner' => $storageInfo['owner'], 'ownerDisplayName' => $storageInfo['ownerDisplayName'], diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 955cd03a019..5d270914ff1 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -11,7 +11,7 @@ </a> </li> <?php } ?> - <li id="quota" class="pinned <?php + <li id="quota" class="pinned <?php p($pinned===0?'first-pinned ':'') ?><?php if ($_['quota'] !== \OCP\Files\FileInfo::SPACE_UNLIMITED) { ?>has-tooltip" title="<?php p($_['usage_relative'] . '%'); } ?>"> |