2022-06-03 11:04:30 -05:00
|
|
|
<script lang="ts">
|
2025-04-28 14:21:24 -04:00
|
|
|
import { type DownloadProgress, downloadManager } from '$lib/managers/download-manager.svelte';
|
2023-07-14 21:25:13 -04:00
|
|
|
import { locale } from '$lib/stores/preferences.store';
|
2025-04-28 14:21:24 -04:00
|
|
|
import { mdiClose } from '@mdi/js';
|
|
|
|
|
import { t } from 'svelte-i18n';
|
2023-07-01 00:50:47 -04:00
|
|
|
import { fly, slide } from 'svelte/transition';
|
2024-06-14 19:27:46 +02:00
|
|
|
import { getByteUnitString } from '../../utils/byte-units';
|
2025-06-02 09:47:23 -05:00
|
|
|
import { IconButton } from '@immich/ui';
|
2023-07-14 21:25:13 -04:00
|
|
|
|
|
|
|
|
const abort = (downloadKey: string, download: DownloadProgress) => {
|
|
|
|
|
download.abort?.abort();
|
|
|
|
|
downloadManager.clear(downloadKey);
|
|
|
|
|
};
|
2022-06-03 11:04:30 -05:00
|
|
|
</script>
|
|
|
|
|
|
2025-04-28 14:21:24 -04:00
|
|
|
{#if downloadManager.isDownloading}
|
2023-07-01 00:50:47 -04:00
|
|
|
<div
|
|
|
|
|
transition:fly={{ x: -100, duration: 350 }}
|
2025-05-13 16:10:05 +02:00
|
|
|
class="fixed bottom-10 start-2 max-h-[270px] w-[315px] rounded-2xl border p-4 text-sm shadow-sm bg-light"
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2025-09-16 00:28:42 -03:00
|
|
|
<p class="uppercase mb-2 text-xs text-gray-500">{$t('downloading')}</p>
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="my-2 mb-2 flex max-h-[200px] flex-col overflow-y-auto text-sm">
|
2025-04-28 14:21:24 -04:00
|
|
|
{#each Object.keys(downloadManager.assets) as downloadKey (downloadKey)}
|
|
|
|
|
{@const download = downloadManager.assets[downloadKey]}
|
2023-07-14 21:25:13 -04:00
|
|
|
<div class="mb-2 flex place-items-center" transition:slide>
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="w-full pe-10">
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="flex place-items-center justify-between gap-2 text-xs font-medium">
|
2023-07-14 21:25:13 -04:00
|
|
|
<p class="truncate">■ {downloadKey}</p>
|
|
|
|
|
{#if download.total}
|
2024-06-14 19:27:46 +02:00
|
|
|
<p class="whitespace-nowrap">{getByteUnitString(download.total, $locale)}</p>
|
2023-07-14 21:25:13 -04:00
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex place-items-center gap-2">
|
2025-04-10 11:48:21 -05:00
|
|
|
<div class="h-[7px] w-full rounded-full bg-gray-200">
|
2024-11-02 16:49:07 +01:00
|
|
|
<div class="h-[7px] rounded-full bg-immich-primary" style={`width: ${download.percentage}%`}></div>
|
2023-07-14 21:25:13 -04:00
|
|
|
</div>
|
2023-07-18 13:19:39 -05:00
|
|
|
<p class="min-w-[4em] whitespace-nowrap text-right">
|
2024-07-29 16:38:27 +02:00
|
|
|
<span class="text-immich-primary">
|
|
|
|
|
{(download.percentage / 100).toLocaleString($locale, { style: 'percent' })}
|
|
|
|
|
</span>
|
2023-07-14 21:25:13 -04:00
|
|
|
</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-04-28 09:53:53 -04:00
|
|
|
<div class="absolute end-2">
|
2025-06-02 09:47:23 -05:00
|
|
|
<IconButton
|
|
|
|
|
variant="ghost"
|
|
|
|
|
shape="round"
|
|
|
|
|
color="secondary"
|
|
|
|
|
aria-label={$t('close')}
|
2024-11-14 08:43:25 -06:00
|
|
|
onclick={() => abort(downloadKey, download)}
|
2025-06-02 09:47:23 -05:00
|
|
|
size="large"
|
2024-03-29 12:48:07 +00:00
|
|
|
icon={mdiClose}
|
2024-04-27 22:29:43 +00:00
|
|
|
class="dark:text-immich-dark-gray"
|
2024-03-29 12:48:07 +00:00
|
|
|
/>
|
2023-07-14 21:25:13 -04:00
|
|
|
</div>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-06-03 11:04:30 -05:00
|
|
|
{/if}
|