Hello,
I want to tweak , the front page by adding Quota information. I did my best to get the information from the hidden fields such as “usedSpacePercent” and “free_space” displayed on the main-page. For this , I learned a little from /apps/files/js/files.js with the relevant section looks like:-
if (response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
$(‘#max_upload’).val(response.data.uploadMaxFilesize);
$(‘#free_space’).val(response.data.freeSpace);
$(‘#upload.button’).attr(‘data-original-title’, response.data.maxHumanFilesize);
$(‘#usedSpacePercent’).val(response.data.usedSpacePercent);
$(‘#owner’).val(response.data.owner);
$(‘#ownerDisplayName’).val(response.data.ownerDisplayName);
Files.displayStorageWarnings();
The problem is that there is no ‘quota’ information present in the files.js, getJSON call to “getstoragestats.php” which lands to “/apps/files/lib/Helper.php” contains
public static function buildFileStorageStatistics($dir) {
// information about storage capacities
$storageInfo = \OC_Helper::getStorageInfo($dir);
$l = new \OC_L10N(‘files’);
$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo[‘free’]);
$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
$maxHumanFileSize = $l->t(‘Upload (max. %s)’, array($maxHumanFileSize));
return [
‘uploadMaxFilesize’ => $maxUploadFileSize,
‘maxHumanFilesize’ => $maxHumanFileSize,
‘freeSpace’ => $storageInfo[‘free’],
‘usedSpacePercent’ => (int)$storageInfo[‘relative’],
‘owner’ => $storageInfo[‘owner’],
‘ownerDisplayName’ => $storageInfo[‘ownerDisplayName’],
];
no return of ‘Quota’ value from “getStorageInfo()” defined here "lib/private/legacy/helper.php’ as
$ownerId = $storage->getOwner($path);
$ownerDisplayName = ‘’;
$owner = \OC::$server->getUserManager()->get($ownerId);
if($owner) {
$ownerDisplayName = $owner->getDisplayName();
}
return [
‘free’ => $free,
‘used’ => $used,
‘quota’ => $quota,
‘total’ => $total,
‘relative’ => $relative,
‘owner’ => $ownerId,
‘ownerDisplayName’ => $ownerDisplayName,
];
}
I’m thinking of thus patching the files.js as
$(‘quota’).val(response.data.quota);
and files/lib/Helper.php as
‘quota’ => $storageInfo[‘quota’],
After, that I can use JS, to call the id against whatever HTML element i.e span or div on the main-page. Please suggest?
UPDATE
using firebug in files.js
state.call = $.getJSON(OC.filePath('files','ajax','getstoragestats.php') + '?dir=' + encodeURIComponent(currentDir),function(response) {
I get response as
{“data”:{“uploadMaxFilesize”:537919488,“maxHumanFilesize”:“Upload (max. 513 MB)”,“freeSpace”:1069113360
,“usedSpacePercent”:0,“owner”:“6A5DE276-3FEF-4B08-A8DB-79D8C9A8200E”,“ownerDisplayName”:“XYZ”},“status”
:“success”}
No quota is returned?
regards
asad