Update quota on file upload and deletion
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
0c38c1b2db
commit
0cb45f681f
|
@ -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.
|
* including relative path and file name.
|
||||||
*
|
*
|
||||||
* @return {String} full path
|
* @return {String} full path
|
||||||
|
|
|
@ -3054,6 +3054,7 @@
|
||||||
|
|
||||||
var uploadText = self.$fileList.find('tr .uploadtext');
|
var uploadText = self.$fileList.find('tr .uploadtext');
|
||||||
self.showFileBusyState(uploadText.closest('tr'), false);
|
self.showFileBusyState(uploadText.closest('tr'), false);
|
||||||
|
self.updateStorageStatistics(true);
|
||||||
uploadText.fadeOut();
|
uploadText.fadeOut();
|
||||||
uploadText.attr('currentUploads', 0);
|
uploadText.attr('currentUploads', 0);
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
state.dir = null;
|
state.dir = null;
|
||||||
state.call = null;
|
state.call = null;
|
||||||
Files.updateMaxUploadFilesize(response);
|
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
|
* Fix path name by removing double slash at the beginning, if any
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -56,6 +56,8 @@ class Helper {
|
||||||
'uploadMaxFilesize' => $maxUploadFileSize,
|
'uploadMaxFilesize' => $maxUploadFileSize,
|
||||||
'maxHumanFilesize' => $maxHumanFileSize,
|
'maxHumanFilesize' => $maxHumanFileSize,
|
||||||
'freeSpace' => $storageInfo['free'],
|
'freeSpace' => $storageInfo['free'],
|
||||||
|
'quota' => $storageInfo['quota'],
|
||||||
|
'used' => $storageInfo['used'],
|
||||||
'usedSpacePercent' => (int)$storageInfo['relative'],
|
'usedSpacePercent' => (int)$storageInfo['relative'],
|
||||||
'owner' => $storageInfo['owner'],
|
'owner' => $storageInfo['owner'],
|
||||||
'ownerDisplayName' => $storageInfo['ownerDisplayName'],
|
'ownerDisplayName' => $storageInfo['ownerDisplayName'],
|
||||||
|
|
Loading…
Reference in New Issue