Show 0 bytes instead of 'Default' for used storage
- Separate formatBytes() for used storage - formatQuota() keeps 'Default' only for unlimited quota
This commit is contained in:
parent
c5a9149220
commit
9f77540c7b
1 changed files with 7 additions and 3 deletions
|
|
@ -84,15 +84,19 @@
|
|||
}
|
||||
}
|
||||
|
||||
function formatQuota(bytes: number | undefined | null): string {
|
||||
function formatBytes(bytes: number | undefined | null): string {
|
||||
if (bytes === undefined || bytes === null || isNaN(bytes)) return 'Unknown';
|
||||
if (bytes === 0) return 'Default';
|
||||
if (bytes < 1024) return bytes + ' B';
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
||||
if (bytes < 1024 * 1024 * 1024) return (bytes / 1024 / 1024).toFixed(1) + ' MB';
|
||||
return (bytes / 1024 / 1024 / 1024).toFixed(2) + ' GB';
|
||||
}
|
||||
|
||||
function formatQuota(limit: number): string {
|
||||
if (limit === 0) return 'Default';
|
||||
return formatBytes(limit);
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
const name = $page.params.name;
|
||||
if (name) {
|
||||
|
|
@ -127,7 +131,7 @@
|
|||
<tr>
|
||||
<td>{user.email}</td>
|
||||
<td>{formatQuota(user.quota)}</td>
|
||||
<td>{formatQuota(user.usedQuota)}</td>
|
||||
<td>{formatBytes(user.usedQuota ?? null)}</td>
|
||||
<td>
|
||||
<button class="danger" onclick={() => deleteUser(user.id)}>Delete</button>
|
||||
</td>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue