2022-10-23 16:54:54 -05:00
|
|
|
<script lang="ts">
|
2025-09-16 16:58:47 -04:00
|
|
|
import StatsCard from '$lib/components/server-statistics/ServerStatisticsCard.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
import { locale } from '$lib/stores/preferences.store';
|
2024-06-14 19:27:46 +02:00
|
|
|
import { getByteUnitString, getBytesWithUnit } from '$lib/utils/byte-units';
|
2024-02-14 08:09:49 -05:00
|
|
|
import type { ServerStatsResponseDto } from '@immich/sdk';
|
2025-09-16 21:40:43 +02:00
|
|
|
import { Icon } from '@immich/ui';
|
2024-01-12 18:43:36 -06:00
|
|
|
import { mdiCameraIris, mdiChartPie, mdiPlayCircle } from '@mdi/js';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2023-01-09 22:40:54 +02:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
stats?: ServerStatsResponseDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let {
|
|
|
|
|
stats = {
|
|
|
|
|
photos: 0,
|
|
|
|
|
videos: 0,
|
|
|
|
|
usage: 0,
|
2024-11-15 23:38:57 +01:00
|
|
|
usagePhotos: 0,
|
|
|
|
|
usageVideos: 0,
|
2024-11-14 08:43:25 -06:00
|
|
|
usageByUser: [],
|
|
|
|
|
},
|
|
|
|
|
}: Props = $props();
|
2022-10-25 21:41:46 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
const zeros = (value: number) => {
|
2023-07-01 00:50:47 -04:00
|
|
|
const maxLength = 13;
|
|
|
|
|
const valueLength = value.toString().length;
|
|
|
|
|
const zeroLength = maxLength - valueLength;
|
2023-04-15 03:41:52 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
return '0'.repeat(zeroLength);
|
|
|
|
|
};
|
2023-04-15 03:41:52 +02:00
|
|
|
|
2023-11-28 15:50:23 -05:00
|
|
|
const TiB = 1024 ** 4;
|
2024-11-14 08:43:25 -06:00
|
|
|
let [statsUsage, statsUsageUnit] = $derived(getBytesWithUnit(stats.usage, stats.usage > TiB ? 2 : 0));
|
2022-10-23 16:54:54 -05:00
|
|
|
</script>
|
|
|
|
|
|
2022-10-25 21:41:46 -05:00
|
|
|
<div class="flex flex-col gap-5">
|
2023-07-01 00:50:47 -04:00
|
|
|
<div>
|
2025-09-16 00:28:42 -03:00
|
|
|
<p class="text-sm dark:text-immich-dark-fg uppercase">{$t('total_usage')}</p>
|
2022-10-25 21:41:46 -05:00
|
|
|
|
2025-05-09 18:56:41 -04:00
|
|
|
<div class="mt-5 hidden justify-between lg:flex gap-4">
|
2025-09-16 00:28:42 -03:00
|
|
|
<StatsCard icon={mdiCameraIris} title={$t('photos')} value={stats.photos} />
|
|
|
|
|
<StatsCard icon={mdiPlayCircle} title={$t('videos')} value={stats.videos} />
|
|
|
|
|
<StatsCard icon={mdiChartPie} title={$t('storage')} value={statsUsage} unit={statsUsageUnit} />
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="mt-5 flex lg:hidden">
|
2025-05-05 17:39:52 -05:00
|
|
|
<div class="flex flex-col justify-between rounded-3xl bg-subtle p-5 dark:bg-immich-dark-gray">
|
2023-07-01 00:50:47 -04:00
|
|
|
<div class="flex flex-wrap gap-x-12">
|
|
|
|
|
<div class="flex place-items-center gap-4 text-immich-primary dark:text-immich-dark-primary">
|
2025-09-16 21:40:43 +02:00
|
|
|
<Icon icon={mdiCameraIris} size="25" />
|
2025-09-16 00:28:42 -03:00
|
|
|
<p class="uppercase">{$t('photos')}</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
2023-04-15 03:41:52 +02:00
|
|
|
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="relative text-center font-mono text-2xl font-semibold">
|
2023-07-01 00:50:47 -04:00
|
|
|
<span class="text-[#DCDADA] dark:text-[#525252]">{zeros(stats.photos)}</span><span
|
|
|
|
|
class="text-immich-primary dark:text-immich-dark-primary">{stats.photos}</span
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-wrap gap-x-12">
|
|
|
|
|
<div class="flex place-items-center gap-4 text-immich-primary dark:text-immich-dark-primary">
|
2025-09-16 21:40:43 +02:00
|
|
|
<Icon icon={mdiPlayCircle} size="25" />
|
2025-09-16 00:28:42 -03:00
|
|
|
<p class="uppercase">{$t('videos')}</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
2023-04-15 03:41:52 +02:00
|
|
|
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="relative text-center font-mono text-2xl font-semibold">
|
2023-07-01 00:50:47 -04:00
|
|
|
<span class="text-[#DCDADA] dark:text-[#525252]">{zeros(stats.videos)}</span><span
|
|
|
|
|
class="text-immich-primary dark:text-immich-dark-primary">{stats.videos}</span
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex flex-wrap gap-x-7">
|
|
|
|
|
<div class="flex place-items-center gap-4 text-immich-primary dark:text-immich-dark-primary">
|
2025-09-16 21:40:43 +02:00
|
|
|
<Icon icon={mdiChartPie} size="25" />
|
2025-09-16 00:28:42 -03:00
|
|
|
<p class="uppercase">{$t('storage')}</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
2023-04-15 03:41:52 +02:00
|
|
|
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="relative flex text-center font-mono text-2xl font-semibold">
|
2023-07-01 00:50:47 -04:00
|
|
|
<span class="text-[#DCDADA] dark:text-[#525252]">{zeros(statsUsage)}</span><span
|
|
|
|
|
class="text-immich-primary dark:text-immich-dark-primary">{statsUsage}</span
|
|
|
|
|
>
|
2025-04-28 09:53:53 -04:00
|
|
|
<span class="my-auto ms-2 text-center text-base font-light text-gray-400">{statsUsageUnit}</span>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-10-23 16:54:54 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
<div>
|
2025-09-16 00:28:42 -03:00
|
|
|
<p class="text-sm dark:text-immich-dark-fg uppercase">{$t('user_usage_detail')}</p>
|
2025-04-28 09:53:53 -04:00
|
|
|
<table class="mt-5 w-full text-start">
|
2023-07-01 00:50:47 -04:00
|
|
|
<thead
|
2023-07-18 13:19:39 -05:00
|
|
|
class="mb-4 flex h-12 w-full rounded-md border bg-gray-50 text-immich-primary dark:border-immich-dark-gray dark:bg-immich-dark-gray dark:text-immich-dark-primary"
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
|
|
|
|
<tr class="flex w-full place-items-center">
|
2024-06-04 21:53:00 +02:00
|
|
|
<th class="w-1/4 text-center text-sm font-medium">{$t('user')}</th>
|
|
|
|
|
<th class="w-1/4 text-center text-sm font-medium">{$t('photos')}</th>
|
|
|
|
|
<th class="w-1/4 text-center text-sm font-medium">{$t('videos')}</th>
|
|
|
|
|
<th class="w-1/4 text-center text-sm font-medium">{$t('usage')}</th>
|
2023-07-01 00:50:47 -04:00
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody
|
2023-07-18 13:19:39 -05:00
|
|
|
class="block max-h-[320px] w-full overflow-y-auto rounded-md border dark:border-immich-dark-gray dark:text-immich-dark-fg"
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
|
|
|
|
{#each stats.usageByUser as user (user.userId)}
|
2025-05-12 23:17:01 +02:00
|
|
|
<tr class="flex h-[50px] w-full place-items-center text-center even:bg-subtle/20 odd:bg-subtle/80">
|
2023-11-11 20:03:32 -05:00
|
|
|
<td class="w-1/4 text-ellipsis px-2 text-sm">{user.userName}</td>
|
2024-11-15 23:38:57 +01:00
|
|
|
<td class="w-1/4 text-ellipsis px-2 text-sm"
|
|
|
|
|
>{user.photos.toLocaleString($locale)} ({getByteUnitString(user.usagePhotos, $locale, 0)})</td
|
|
|
|
|
>
|
|
|
|
|
<td class="w-1/4 text-ellipsis px-2 text-sm"
|
|
|
|
|
>{user.videos.toLocaleString($locale)} ({getByteUnitString(user.usageVideos, $locale, 0)})</td
|
|
|
|
|
>
|
2024-01-12 18:43:36 -06:00
|
|
|
<td class="w-1/4 text-ellipsis px-2 text-sm">
|
2024-06-14 19:27:46 +02:00
|
|
|
{getByteUnitString(user.usage, $locale, 0)}
|
2025-06-23 23:00:41 +08:00
|
|
|
{#if user.quotaSizeInBytes !== null}
|
2024-06-14 19:27:46 +02:00
|
|
|
/ {getByteUnitString(user.quotaSizeInBytes, $locale, 0)}
|
2024-03-03 15:47:00 -05:00
|
|
|
{/if}
|
2024-01-12 18:43:36 -06:00
|
|
|
<span class="text-immich-primary dark:text-immich-dark-primary">
|
2025-06-23 23:00:41 +08:00
|
|
|
{#if user.quotaSizeInBytes !== null && user.quotaSizeInBytes >= 0}
|
|
|
|
|
({(user.quotaSizeInBytes === 0 ? 1 : user.usage / user.quotaSizeInBytes).toLocaleString($locale, {
|
2024-07-29 16:38:27 +02:00
|
|
|
style: 'percent',
|
|
|
|
|
maximumFractionDigits: 0,
|
|
|
|
|
})})
|
2024-01-12 18:43:36 -06:00
|
|
|
{:else}
|
2024-06-12 12:54:40 +02:00
|
|
|
({$t('unlimited')})
|
2024-01-12 18:43:36 -06:00
|
|
|
{/if}
|
|
|
|
|
</span>
|
|
|
|
|
</td>
|
2023-07-01 00:50:47 -04:00
|
|
|
</tr>
|
|
|
|
|
{/each}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
2022-10-23 16:54:54 -05:00
|
|
|
</div>
|