Show mailbox usage as percentage
- Add formatUsed() showing 'X GB (Y%)' format - Fallback to 'Unknown' if quota data unavailable
This commit is contained in:
parent
9f77540c7b
commit
19360e9a9f
1 changed files with 9 additions and 1 deletions
|
|
@ -97,6 +97,14 @@
|
|||
return formatBytes(limit);
|
||||
}
|
||||
|
||||
function formatUsed(used: number | undefined | null, limit: number): string {
|
||||
const usedStr = formatBytes(used ?? null);
|
||||
if (limit === 0) return usedStr;
|
||||
if (used === undefined || used === null) return usedStr + ' (Unknown)';
|
||||
const pct = (used / limit * 100).toFixed(1);
|
||||
return usedStr + ' (' + pct + '%)';
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
const name = $page.params.name;
|
||||
if (name) {
|
||||
|
|
@ -131,7 +139,7 @@
|
|||
<tr>
|
||||
<td>{user.email}</td>
|
||||
<td>{formatQuota(user.quota)}</td>
|
||||
<td>{formatBytes(user.usedQuota ?? null)}</td>
|
||||
<td>{formatUsed(user.usedQuota, user.quota)}</td>
|
||||
<td>
|
||||
<button class="danger" onclick={() => deleteUser(user.id)}>Delete</button>
|
||||
</td>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue