refactor(web): byte unit utils (#10332)

refactor byte unit utils
This commit is contained in:
Daniel Dietzler
2024-06-14 19:27:46 +02:00
committed by GitHub
parent b4b654b53f
commit c896fe393f
15 changed files with 99 additions and 87 deletions

View File

@@ -14,7 +14,7 @@
NotificationType,
} from '$lib/components/shared-components/notification/notification';
import Portal from '$lib/components/shared-components/portal/portal.svelte';
import { getBytesWithUnit } from '$lib/utils/byte-units';
import { ByteUnit, getBytesWithUnit } from '$lib/utils/byte-units';
import { getContextMenuPosition } from '$lib/utils/context-menu';
import { handleError } from '$lib/utils/handle-error';
import {
@@ -49,7 +49,7 @@
let videos: number[] = [];
let totalCount: number[] = [];
let diskUsage: number[] = [];
let diskUsageUnit: string[] = [];
let diskUsageUnit: ByteUnit[] = [];
let confirmDeleteLibrary: LibraryResponseDto | null = null;
let deletedLibrary: LibraryResponseDto | null = null;

View File

@@ -19,7 +19,7 @@
import { user } from '$lib/stores/user.store';
import { websocketEvents } from '$lib/stores/websocket';
import { copyToClipboard } from '$lib/utils';
import { asByteUnitString } from '$lib/utils/byte-units';
import { getByteUnitString } from '$lib/utils/byte-units';
import { UserStatus, searchUsersAdmin, type UserAdminResponseDto } from '@immich/sdk';
import { mdiClose, mdiContentCopy, mdiDeleteRestore, mdiPencilOutline, mdiTrashCanOutline } from '@mdi/js';
import { DateTime } from 'luxon';
@@ -215,7 +215,7 @@
<td class="hidden xl:block w-3/12 2xl:w-2/12 text-ellipsis break-all px-2 text-sm">
<div class="container mx-auto flex flex-wrap justify-center">
{#if immichUser.quotaSizeInBytes && immichUser.quotaSizeInBytes > 0}
{asByteUnitString(immichUser.quotaSizeInBytes, $locale)}
{getByteUnitString(immichUser.quotaSizeInBytes, $locale)}
{:else}
<Icon path={mdiClose} size="16" />
{/if}