From 8b197410207537c74181d543ddfe481a2ada865f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 10 Aug 2022 11:22:50 +0200 Subject: [PATCH 1/2] Use total available space rather than quota when updating the display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The initial quota display uses the total available space rather than the quota. Moreover, the relative usage is based on the total space rather than the quota. Due to this now the total available space is also used when updating the quota display. Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/files.js | 5 +++-- apps/files/lib/Helper.php | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 5f00ce2cb225f..48c20249ccb02 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -98,14 +98,15 @@ } if (response.data !== undefined && response.data.quota !== undefined + && response.data.total !== 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); + var humanTotal = OC.Util.humanFileSize(response.data.total, 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').html(t('files', '{used} of {quota} used', {used: humanUsed, quota: humanQuota})); + $('#quotatext').html(t('files', '{used} of {quota} used', {used: humanUsed, quota: humanTotal})); } else { $('#quotatext').html(t('files', '{used} used', {used: humanUsed})); } diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index 18fea3aa2a11f..22744e5940f3d 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -58,6 +58,7 @@ public static function buildFileStorageStatistics($dir) { 'maxHumanFilesize' => $maxHumanFileSize, 'freeSpace' => $storageInfo['free'], 'quota' => $storageInfo['quota'], + 'total' => $storageInfo['total'], 'used' => $storageInfo['used'], 'usedSpacePercent' => (int)$storageInfo['relative'], 'owner' => $storageInfo['owner'], From e720034599eff52d045ce160724bcacc4b9ce7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 10 Aug 2022 11:23:27 +0200 Subject: [PATCH 2/2] Show usage percenteage in the tooltip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tooltip of the initial quota display showed the usage percenteage and the total available space. However, the total available space was redundant, as it was shown just below. The tooltip of the updated quota display showed the usage percenteage, but based on the quota rather than the total available space, so there was a mismatch between the tooltip and the bar below. Now the tooltip of the initial and the updated quota display both show just the usage percenteage based on the total available space. Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/files.js | 2 +- apps/files/lib/Helper.php | 2 +- apps/files/templates/appnavigation.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 48c20249ccb02..4a4fa55d69682 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -104,7 +104,7 @@ var humanUsed = OC.Util.humanFileSize(response.data.used, true); var humanTotal = OC.Util.humanFileSize(response.data.total, true); if (response.data.quota > 0) { - $('#quota').attr('data-original-title', Math.floor(response.data.used/response.data.quota*1000)/10 + '%'); + $('#quota').attr('data-original-title', t('files', '{used}%', {used: Math.round(response.data.usedSpacePercent)})); $('#quota progress').val(response.data.usedSpacePercent); $('#quotatext').html(t('files', '{used} of {quota} used', {used: humanUsed, quota: humanTotal})); } else { diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index 22744e5940f3d..1d9591cafe056 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -60,7 +60,7 @@ public static function buildFileStorageStatistics($dir) { 'quota' => $storageInfo['quota'], 'total' => $storageInfo['total'], 'used' => $storageInfo['used'], - 'usedSpacePercent' => (int)$storageInfo['relative'], + 'usedSpacePercent' => $storageInfo['relative'], 'owner' => $storageInfo['owner'], 'ownerDisplayName' => $storageInfo['ownerDisplayName'], 'mountType' => $storageInfo['mountType'], diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 9aea68fef99b0..7b0bc0291bb84 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -17,7 +17,7 @@
  • + title="t('%s%%', [round($_['usage_relative'])])); ?>">

    t('%1$s of %2$s used', [$_['usage'], $_['total_space']])); ?>