Skip to content
Closed
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
6 changes: 6 additions & 0 deletions changelog/unreleased/40477
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add per-user storage view

Adding option for displaying used storage on per-user basis

https://github.com/owncloud/enterprise/issues/5468
https://github.com/owncloud/core/pull/40477
12 changes: 12 additions & 0 deletions settings/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ private function formatUserForIndex(IUser $user, array $userGroups = null) {
];
}

// we are going to setup a different FS and not reverting it back. There shouldn't anyway be any code needed to access the FS after this
try {
\OC_Util::tearDownFS();
\OC_Util::setupFS($user->getUID());
$storage = \OC_Helper::getStorageInfo('/');
$storageUsed = \sprintf("%.1f MB", $storage['used'] / 1024 / 1024);
} catch (\Exception $e) {
$this->log->error("Can't compute used storage for user " . $user->getUID() . ": " . $e->getMessage(), ['app' => 'settings']);
$storageUsed = "0 MB";
}

return [
'name' => $user->getUID(),
'displayname' => $user->getDisplayName(),
Expand All @@ -235,6 +246,7 @@ private function formatUserForIndex(IUser $user, array $userGroups = null) {
'isEnabled' => $user->isEnabled(),
'quota' => $user->getQuota(),
'storageLocation' => $user->getHome(),
'storageUsed' => $storageUsed,
'lastLogin' => $user->getLastLogin() * 1000,
'backend' => $user->getBackendClassName(),
'email' => $displayName,
Expand Down
3 changes: 2 additions & 1 deletion settings/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ span.usersLastLoginTooltip { white-space: nowrap; }
#userlist .mailAddress,
#userlist .enabled,
#userlist .storageLocation,
#userlist .storageUsed,
#userlist .userBackend,
#userlist .lastLogin {
display : none;
Expand Down Expand Up @@ -789,4 +790,4 @@ div.app-settings .section {
background-color: #041e42;
cursor: pointer;
clear: both;
}
}
19 changes: 19 additions & 0 deletions settings/js/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ var UserList = {
*/
$tr.find('td.storageLocation').text(user.storageLocation);

/**
* storage used
*/
$tr.find('td.storageUsed').text(user.storageUsed);

/**
* user backend
*/
Expand Down Expand Up @@ -1077,6 +1082,20 @@ $(document).ready(function () {
}
});

if ($('#CheckboxStorageUsed').is(':checked')) {
$("#userlist .storageUsed").show();
}
// Option to display/hide the "Storage used" column
$('#CheckboxStorageUsed').click(function() {
if ($('#CheckboxStorageUsed').is(':checked')) {
$("#userlist .storageUsed").show();
OC.AppConfig.setValue('core', 'umgmt_show_storage_used', 'true');
} else {
$("#userlist .storageUsed").hide();
OC.AppConfig.setValue('core', 'umgmt_show_storage_used', 'false');
}
});

if ($('#CheckboxLastLogin').is(':checked')) {
$("#userlist .lastLogin").show();
}
Expand Down
9 changes: 9 additions & 0 deletions settings/templates/users/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ class="checkbox" <?php if ($_['show_storage_location'] === 'true') {
<?php p($l->t('Show storage location')) ?>
</label>
</p>
<p>
<input type="checkbox" name="StorageUsed" value="StorageUsed" id="CheckboxStorageUsed"
class="checkbox" <?php if ($_['show_storage_used'] === 'true') {
print_unescaped('checked="checked"');
} ?> />
<label for="CheckboxStorageUsed">
<?php p($l->t('Show storage used')) ?>
</label>
</p>
<p>
<input type="checkbox" name="LastLogin" value="LastLogin" id="CheckboxLastLogin"
class="checkbox" <?php if ($_['show_last_login'] === 'true') {
Expand Down
2 changes: 2 additions & 0 deletions settings/templates/users/part.userlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<th class="enabled" scope="col"><?php p($l->t('Enabled')); ?></th>
<th class="quota" id="headerQuota" scope="col"><?php p($l->t('Quota')); ?></th>
<th class="storageLocation" scope="col"><?php p($l->t('Storage Location')); ?></th>
<th class="storageUsed" scope="col"><?php p($l->t('Storage Used')); ?></th>
<th class="userBackend" scope="col"><?php p($l->t('User Backend')); ?></th>
<th class="lastLogin" scope="col"><?php p($l->t('Last Login')); ?></th>
<th id="headerResendInvitationEmail">&nbsp;</th>
Expand Down Expand Up @@ -70,6 +71,7 @@
</select>
</td>
<td class="storageLocation"></td>
<td class="storageUsed"></td>
<td class="userBackend"></td>
<td class="lastLogin"></td>
<td class="resendInvitationEmail"></td>
Expand Down
1 change: 1 addition & 0 deletions settings/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@

$tmpl->assign('show_is_enabled', $config->getAppValue('core', 'umgmt_show_is_enabled', 'false'));
$tmpl->assign('show_storage_location', $config->getAppValue('core', 'umgmt_show_storage_location', 'false'));
$tmpl->assign('show_storage_used', $config->getAppValue('core', 'umgmt_show_storage_used', 'false'));
$tmpl->assign('show_last_login', $config->getAppValue('core', 'umgmt_show_last_login', 'false'));
$tmpl->assign('show_email', $config->getAppValue('core', 'umgmt_show_email', 'false'));
$tmpl->assign('show_backend', $config->getAppValue('core', 'umgmt_show_backend', 'false'));
Expand Down