Update quota on file upload and deletion

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2017-12-21 10:48:43 +01:00
parent 0c38c1b2db
commit 0cb45f681f
No known key found for this signature in database
GPG Key ID: FB5ACEED51955BF8
4 changed files with 32 additions and 1 deletions

View File

@ -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

View File

@ -3054,6 +3054,7 @@
var uploadText = self.$fileList.find('tr .uploadtext');
self.showFileBusyState(uploadText.closest('tr'), false);
self.updateStorageStatistics(true);
uploadText.fadeOut();
uploadText.attr('currentUploads', 0);
});

View File

@ -29,6 +29,7 @@
state.dir = null;
state.call = null;
Files.updateMaxUploadFilesize(response);
Files.updateQuota(response);
});
},
/**
@ -77,6 +78,33 @@
},
updateQuota:function(response) {
console.log('updateQuota');
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
*/

View File

@ -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'],