2023-01-09 14:16:08 -06:00
|
|
|
<script lang="ts">
|
2024-07-01 00:34:52 +02:00
|
|
|
import Badge from '$lib/components/elements/badge.svelte';
|
2024-02-14 08:09:49 -05:00
|
|
|
import Icon from '$lib/components/elements/icon.svelte';
|
2024-07-01 00:34:52 +02:00
|
|
|
import ShareCover from '$lib/components/sharedlinks-page/covers/share-cover.svelte';
|
2024-01-28 01:54:31 +01:00
|
|
|
import { AppRoute } from '$lib/constants';
|
2024-07-01 00:34:52 +02:00
|
|
|
import { locale } from '$lib/stores/preferences.store';
|
2024-04-05 21:19:26 +02:00
|
|
|
import { SharedLinkType, type SharedLinkResponseDto } from '@immich/sdk';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { mdiCircleEditOutline, mdiContentCopy, mdiDelete, mdiOpenInNew } from '@mdi/js';
|
2024-07-01 00:34:52 +02:00
|
|
|
import { DateTime, type ToRelativeUnit } from 'luxon';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { createEventDispatcher } from 'svelte';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-07-01 00:34:52 +02:00
|
|
|
import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
|
|
|
|
|
export let link: SharedLinkResponseDto;
|
|
|
|
|
|
2023-12-15 03:54:21 +01:00
|
|
|
const dispatch = createEventDispatcher<{
|
|
|
|
|
delete: void;
|
|
|
|
|
copy: void;
|
|
|
|
|
edit: void;
|
|
|
|
|
}>();
|
2023-07-01 00:50:47 -04:00
|
|
|
|
2024-07-01 00:34:52 +02:00
|
|
|
let now = DateTime.now();
|
|
|
|
|
$: expiresAt = link.expiresAt ? DateTime.fromISO(link.expiresAt) : undefined;
|
|
|
|
|
$: isExpired = expiresAt ? now > expiresAt : false;
|
2023-07-01 00:50:47 -04:00
|
|
|
|
2024-07-01 00:34:52 +02:00
|
|
|
const getCountDownExpirationDate = (expiresAtDate: DateTime, now: DateTime) => {
|
|
|
|
|
const relativeUnits: ToRelativeUnit[] = ['days', 'hours', 'minutes', 'seconds'];
|
|
|
|
|
const expirationCountdown = expiresAtDate.diff(now, relativeUnits).toObject();
|
2023-07-01 00:50:47 -04:00
|
|
|
|
2024-07-01 00:34:52 +02:00
|
|
|
for (const unit of relativeUnits) {
|
|
|
|
|
const value = expirationCountdown[unit];
|
|
|
|
|
if (value && value > 0) {
|
|
|
|
|
return expiresAtDate.toRelativeCalendar({ base: now, locale: $locale, unit });
|
|
|
|
|
}
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
|
|
|
|
};
|
2023-01-09 14:16:08 -06:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div
|
2023-07-18 13:19:39 -05:00
|
|
|
class="flex w-full gap-4 border-b border-gray-200 py-4 transition-all hover:border-immich-primary dark:border-gray-600 dark:text-immich-gray dark:hover:border-immich-dark-primary"
|
2023-01-09 14:16:08 -06:00
|
|
|
>
|
2024-07-01 00:34:52 +02:00
|
|
|
<ShareCover class="size-24 transition-all duration-300 hover:shadow-lg" {link} />
|
2023-07-01 00:50:47 -04:00
|
|
|
|
|
|
|
|
<div class="flex flex-col justify-between">
|
|
|
|
|
<div class="info-top">
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="font-mono text-xs font-semibold text-gray-500 dark:text-gray-400">
|
2024-07-01 00:34:52 +02:00
|
|
|
{#if isExpired}
|
|
|
|
|
<p class="font-bold text-red-600 dark:text-red-400">{$t('expired')}</p>
|
|
|
|
|
{:else if expiresAt}
|
|
|
|
|
<p>
|
|
|
|
|
{$t('expires_date', { values: { date: getCountDownExpirationDate(expiresAt, now) } })}
|
|
|
|
|
</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
{:else}
|
2024-06-24 15:50:01 +02:00
|
|
|
<p>{$t('expires_date', { values: { date: '∞' } })}</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="text-sm">
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="flex place-items-center gap-2 text-immich-primary dark:text-immich-dark-primary">
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if link.type === SharedLinkType.Album}
|
|
|
|
|
<p>
|
|
|
|
|
{link.album?.albumName.toUpperCase()}
|
|
|
|
|
</p>
|
|
|
|
|
{:else if link.type === SharedLinkType.Individual}
|
2024-06-04 21:53:00 +02:00
|
|
|
<p>{$t('individual_share').toUpperCase()}</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
|
|
|
|
|
2024-07-01 00:34:52 +02:00
|
|
|
{#if !isExpired}
|
2024-06-04 21:53:00 +02:00
|
|
|
<a href="{AppRoute.SHARE}/{link.key}" title={$t('go_to_share_page')}>
|
2023-10-25 09:48:25 -04:00
|
|
|
<Icon path={mdiOpenInNew} />
|
2024-03-12 20:30:19 +01:00
|
|
|
</a>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<p class="text-sm">{link.description ?? ''}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-07-01 00:34:52 +02:00
|
|
|
<div class="info-bottom flex gap-4 text-xl">
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if link.allowUpload}
|
2024-07-01 00:34:52 +02:00
|
|
|
<Badge rounded="full"><span class="text-xs px-1">{$t('upload')}</span></Badge>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{#if link.allowDownload}
|
2024-07-01 00:34:52 +02:00
|
|
|
<Badge rounded="full"><span class="text-xs px-1">{$t('download')}</span></Badge>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
|
|
|
|
|
2023-10-14 03:46:30 +02:00
|
|
|
{#if link.showMetadata}
|
2024-07-01 00:34:52 +02:00
|
|
|
<Badge rounded="full"><span class="text-xs px-1">{$t('exif').toUpperCase()}</span></Badge>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
2023-10-29 13:50:43 -05:00
|
|
|
|
|
|
|
|
{#if link.password}
|
2024-07-01 00:34:52 +02:00
|
|
|
<Badge rounded="full"><span class="text-xs px-1">{$t('password')}</span></Badge>
|
2023-10-29 13:50:43 -05:00
|
|
|
{/if}
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="flex flex-auto flex-col place-content-center place-items-end text-right">
|
2023-07-01 00:50:47 -04:00
|
|
|
<div class="flex">
|
2024-06-04 21:53:00 +02:00
|
|
|
<CircleIconButton title={$t('delete_link')} icon={mdiDelete} on:click={() => dispatch('delete')} />
|
|
|
|
|
<CircleIconButton title={$t('edit_link')} icon={mdiCircleEditOutline} on:click={() => dispatch('edit')} />
|
|
|
|
|
<CircleIconButton title={$t('copy_link')} icon={mdiContentCopy} on:click={() => dispatch('copy')} />
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-01-09 14:16:08 -06:00
|
|
|
</div>
|