Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update quota on files upload #7592

Merged
merged 3 commits into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,6 @@
return true;
}

// TODO: parse remaining quota from PROPFIND response
this.updateStorageStatistics(true);

// first entry is the root
Expand Down
27 changes: 27 additions & 0 deletions apps/files/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
state.dir = null;
state.call = null;
Files.updateMaxUploadFilesize(response);
Files.updateQuota(response);
});
},
/**
Expand Down Expand Up @@ -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
*/
Expand Down
2 changes: 2 additions & 0 deletions apps/files/lib/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public static function buildFileStorageStatistics($dir) {
'uploadMaxFilesize' => $maxUploadFileSize,
'maxHumanFilesize' => $maxHumanFileSize,
'freeSpace' => $storageInfo['free'],
'quota' => $storageInfo['quota'],
'used' => $storageInfo['used'],
'usedSpacePercent' => (int)$storageInfo['relative'],
'owner' => $storageInfo['owner'],
'ownerDisplayName' => $storageInfo['ownerDisplayName'],
Expand Down
2 changes: 1 addition & 1 deletion apps/files/templates/appnavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class="nav-icon-<?php p($item['icon'] !== '' ? $item['icon'] : $item['id']) ?> s
</a>
</li>
<?php } ?>
<li id="quota" class="pinned <?php
<li id="quota" class="pinned <?php p($pinned===0?'first-pinned ':'') ?><?php
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the pinned position of the quota if the files_trashbin app is disabled (meaning no other apps have registered another app-navigation pinned entry)

if ($_['quota'] !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
?>has-tooltip" title="<?php p($_['usage_relative'] . '%');
} ?>">
Expand Down