2022-06-03 11:04:30 -05:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import { page } from '$app/stores';
|
|
|
|
import { locale } from '$lib/stores/preferences.store';
|
2023-11-09 17:10:56 +01:00
|
|
|
import { featureFlags } from '$lib/stores/server-config.store';
|
2023-09-08 22:51:46 -04:00
|
|
|
import { getAssetFilename } from '$lib/utils/asset-utils';
|
|
|
|
import { AlbumResponseDto, AssetResponseDto, ThumbnailFormat, api } from '@api';
|
2023-07-01 00:50:47 -04:00
|
|
|
import { DateTime } from 'luxon';
|
2023-09-08 22:51:46 -04:00
|
|
|
import { createEventDispatcher } from 'svelte';
|
2023-11-13 15:57:58 -06:00
|
|
|
import { slide } from 'svelte/transition';
|
2023-07-01 00:50:47 -04:00
|
|
|
import { asByteUnitString } from '../../utils/byte-units';
|
|
|
|
import ImageThumbnail from '../assets/thumbnail/image-thumbnail.svelte';
|
2023-09-06 05:14:44 +02:00
|
|
|
import UserAvatar from '../shared-components/user-avatar.svelte';
|
2023-11-13 15:57:58 -06:00
|
|
|
import {
|
|
|
|
mdiCalendar,
|
|
|
|
mdiCameraIris,
|
|
|
|
mdiClose,
|
|
|
|
mdiImageOutline,
|
|
|
|
mdiMapMarkerOutline,
|
|
|
|
mdiInformationOutline,
|
|
|
|
} from '@mdi/js';
|
2023-10-25 09:48:25 -04:00
|
|
|
import Icon from '$lib/components/elements/icon.svelte';
|
2023-11-09 17:10:56 +01:00
|
|
|
import Map from '../shared-components/map/map.svelte';
|
2023-11-14 23:55:03 +01:00
|
|
|
import { AppRoute } from '$lib/constants';
|
2023-07-01 00:50:47 -04:00
|
|
|
|
|
|
|
export let asset: AssetResponseDto;
|
|
|
|
export let albums: AlbumResponseDto[] = [];
|
2023-11-14 23:55:03 +01:00
|
|
|
export let albumId: string | null = null;
|
2023-08-22 07:22:49 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
let textarea: HTMLTextAreaElement;
|
|
|
|
let description: string;
|
|
|
|
|
2023-09-06 05:14:44 +02:00
|
|
|
$: isOwner = $page?.data?.user?.id === asset.ownerId;
|
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
$: {
|
|
|
|
// Get latest description from server
|
2023-08-25 00:03:28 -04:00
|
|
|
if (asset.id && !api.isSharedLink) {
|
2023-07-01 00:50:47 -04:00
|
|
|
api.assetApi.getAssetById({ id: asset.id }).then((res) => {
|
|
|
|
people = res.data?.people || [];
|
|
|
|
textarea.value = res.data?.exifInfo?.description || '';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$: latlng = (() => {
|
|
|
|
const lat = asset.exifInfo?.latitude;
|
|
|
|
const lng = asset.exifInfo?.longitude;
|
|
|
|
|
|
|
|
if (lat && lng) {
|
2023-11-09 17:10:56 +01:00
|
|
|
return { lat: Number(lat.toFixed(7)), lng: Number(lng.toFixed(7)) };
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
|
|
|
$: people = asset.people || [];
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
const getMegapixel = (width: number, height: number): number | undefined => {
|
|
|
|
const megapixel = Math.round((height * width) / 1_000_000);
|
|
|
|
|
|
|
|
if (megapixel) {
|
|
|
|
return megapixel;
|
|
|
|
}
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
};
|
|
|
|
|
|
|
|
const autoGrowHeight = (e: Event) => {
|
|
|
|
const target = e.target as HTMLTextAreaElement;
|
|
|
|
target.style.height = 'auto';
|
|
|
|
target.style.height = `${target.scrollHeight}px`;
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleFocusIn = () => {
|
|
|
|
dispatch('description-focus-in');
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleFocusOut = async () => {
|
|
|
|
dispatch('description-focus-out');
|
|
|
|
try {
|
|
|
|
await api.assetApi.updateAsset({
|
|
|
|
id: asset.id,
|
|
|
|
updateAssetDto: {
|
|
|
|
description: description,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
};
|
2023-11-13 15:57:58 -06:00
|
|
|
|
|
|
|
let showAssetPath = false;
|
|
|
|
const toggleAssetPath = () => (showAssetPath = !showAssetPath);
|
2022-06-03 11:04:30 -05:00
|
|
|
</script>
|
|
|
|
|
2022-10-26 11:10:48 -05:00
|
|
|
<section class="p-2 dark:bg-immich-dark-bg dark:text-immich-dark-fg">
|
2023-07-01 00:50:47 -04:00
|
|
|
<div class="flex place-items-center gap-2">
|
|
|
|
<button
|
2023-07-18 13:19:39 -05:00
|
|
|
class="flex place-content-center place-items-center rounded-full p-3 transition-colors hover:bg-gray-200 dark:text-immich-dark-fg dark:hover:bg-gray-900"
|
2023-07-01 00:50:47 -04:00
|
|
|
on:click={() => dispatch('close')}
|
|
|
|
>
|
2023-10-25 09:48:25 -04:00
|
|
|
<Icon path={mdiClose} size="24" />
|
2023-07-01 00:50:47 -04:00
|
|
|
</button>
|
|
|
|
|
2023-07-18 13:19:39 -05:00
|
|
|
<p class="text-lg text-immich-fg dark:text-immich-dark-fg">Info</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
2023-09-20 13:16:33 +02:00
|
|
|
{#if asset.isOffline}
|
|
|
|
<section class="px-4 py-4">
|
|
|
|
<div role="alert">
|
|
|
|
<div class="rounded-t bg-red-500 px-4 py-2 font-bold text-white">Asset offline</div>
|
|
|
|
<div class="rounded-b border border-t-0 border-red-400 bg-red-100 px-4 py-3 text-red-700">
|
|
|
|
<p>
|
|
|
|
This asset is offline. Immich can not access its file location. Please ensure the asset is available and
|
|
|
|
then rescan the library.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
{/if}
|
|
|
|
|
2023-09-06 05:14:44 +02:00
|
|
|
<section class="mx-4 mt-10" style:display={!isOwner && textarea?.value == '' ? 'none' : 'block'}>
|
2023-07-01 00:50:47 -04:00
|
|
|
<textarea
|
|
|
|
bind:this={textarea}
|
|
|
|
class="max-h-[500px]
|
2023-07-18 13:19:39 -05:00
|
|
|
w-full resize-none overflow-hidden border-b border-gray-500 bg-transparent text-base text-black outline-none transition-all focus:border-b-2 focus:border-immich-primary disabled:border-none dark:text-white dark:focus:border-immich-dark-primary"
|
2023-09-06 05:14:44 +02:00
|
|
|
placeholder={!isOwner ? '' : 'Add a description'}
|
2023-07-01 00:50:47 -04:00
|
|
|
on:focusin={handleFocusIn}
|
|
|
|
on:focusout={handleFocusOut}
|
|
|
|
on:input={autoGrowHeight}
|
|
|
|
bind:value={description}
|
2023-09-06 05:14:44 +02:00
|
|
|
disabled={!isOwner}
|
2023-07-01 00:50:47 -04:00
|
|
|
/>
|
|
|
|
</section>
|
|
|
|
|
2023-08-25 00:03:28 -04:00
|
|
|
{#if !api.isSharedLink && people.length > 0}
|
2023-07-01 00:50:47 -04:00
|
|
|
<section class="px-4 py-4 text-sm">
|
|
|
|
<h2>PEOPLE</h2>
|
|
|
|
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="mt-4 flex flex-wrap gap-2">
|
2023-07-01 00:50:47 -04:00
|
|
|
{#each people as person (person.id)}
|
2023-11-14 23:55:03 +01:00
|
|
|
<a
|
|
|
|
href="/people/{person.id}?previousRoute={albumId ? `${AppRoute.ALBUMS}/${albumId}` : AppRoute.PHOTOS}"
|
|
|
|
class="w-[90px]"
|
|
|
|
on:click={() => dispatch('close-viewer')}
|
|
|
|
>
|
2023-07-01 00:50:47 -04:00
|
|
|
<ImageThumbnail
|
|
|
|
curve
|
|
|
|
shadow
|
|
|
|
url={api.getPeopleThumbnailUrl(person.id)}
|
|
|
|
altText={person.name}
|
2023-09-01 01:25:13 +02:00
|
|
|
title={person.name}
|
2023-07-01 00:50:47 -04:00
|
|
|
widthStyle="90px"
|
|
|
|
heightStyle="90px"
|
|
|
|
thumbhash={null}
|
|
|
|
/>
|
2023-09-01 01:25:13 +02:00
|
|
|
<p class="mt-1 truncate font-medium" title={person.name}>{person.name}</p>
|
|
|
|
{#if person.birthDate}
|
|
|
|
{@const personBirthDate = DateTime.fromISO(person.birthDate)}
|
|
|
|
<p
|
|
|
|
class="font-light"
|
|
|
|
title={personBirthDate.toLocaleString(
|
|
|
|
{
|
|
|
|
month: 'long',
|
|
|
|
day: 'numeric',
|
|
|
|
year: 'numeric',
|
|
|
|
},
|
|
|
|
{ locale: $locale },
|
2023-08-18 22:10:29 +02:00
|
|
|
)}
|
2023-09-01 01:25:13 +02:00
|
|
|
>
|
|
|
|
Age {Math.floor(DateTime.fromISO(asset.fileCreatedAt).diff(personBirthDate, 'years').years)}
|
|
|
|
</p>
|
|
|
|
{/if}
|
2023-07-01 00:50:47 -04:00
|
|
|
</a>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<div class="px-4 py-4">
|
2023-09-20 13:16:33 +02:00
|
|
|
{#if !asset.exifInfo && !asset.isExternal}
|
2023-07-01 00:50:47 -04:00
|
|
|
<p class="text-sm">NO EXIF INFO AVAILABLE</p>
|
2023-09-20 13:16:33 +02:00
|
|
|
{:else if !asset.exifInfo && asset.isExternal}
|
|
|
|
<div class="flex gap-4 py-4">
|
|
|
|
<div>
|
|
|
|
<p class="break-all">
|
|
|
|
Metadata not loaded for {asset.originalPath}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-01 00:50:47 -04:00
|
|
|
{:else}
|
|
|
|
<p class="text-sm">DETAILS</p>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if asset.exifInfo?.dateTimeOriginal}
|
|
|
|
{@const assetDateTimeOriginal = DateTime.fromISO(asset.exifInfo.dateTimeOriginal, {
|
|
|
|
zone: asset.exifInfo.timeZone ?? undefined,
|
|
|
|
})}
|
|
|
|
<div class="flex gap-4 py-4">
|
|
|
|
<div>
|
2023-10-25 09:48:25 -04:00
|
|
|
<Icon path={mdiCalendar} size="24" />
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<p>
|
|
|
|
{assetDateTimeOriginal.toLocaleString(
|
|
|
|
{
|
|
|
|
month: 'short',
|
|
|
|
day: 'numeric',
|
|
|
|
year: 'numeric',
|
|
|
|
},
|
|
|
|
{ locale: $locale },
|
|
|
|
)}
|
|
|
|
</p>
|
|
|
|
<div class="flex gap-2 text-sm">
|
|
|
|
<p>
|
|
|
|
{assetDateTimeOriginal.toLocaleString(
|
|
|
|
{
|
|
|
|
weekday: 'short',
|
|
|
|
hour: 'numeric',
|
|
|
|
minute: '2-digit',
|
|
|
|
timeZoneName: 'longOffset',
|
|
|
|
},
|
|
|
|
{ locale: $locale },
|
|
|
|
)}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>{/if}
|
|
|
|
|
|
|
|
{#if asset.exifInfo?.fileSizeInByte}
|
|
|
|
<div class="flex gap-4 py-4">
|
2023-10-25 09:48:25 -04:00
|
|
|
<div><Icon path={mdiImageOutline} size="24" /></div>
|
2023-07-01 00:50:47 -04:00
|
|
|
|
|
|
|
<div>
|
2023-11-13 15:57:58 -06:00
|
|
|
<p class="break-all flex place-items-center gap-2">
|
|
|
|
{#if isOwner}
|
|
|
|
{asset.originalFileName}
|
|
|
|
<button title="Show File Location" on:click={toggleAssetPath}>
|
|
|
|
<Icon path={mdiInformationOutline} />
|
|
|
|
</button>
|
|
|
|
{:else}
|
|
|
|
{getAssetFilename(asset)}
|
|
|
|
{/if}
|
2023-07-01 00:50:47 -04:00
|
|
|
</p>
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="flex gap-2 text-sm">
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if asset.exifInfo.exifImageHeight && asset.exifInfo.exifImageWidth}
|
|
|
|
{#if getMegapixel(asset.exifInfo.exifImageHeight, asset.exifInfo.exifImageWidth)}
|
|
|
|
<p>
|
|
|
|
{getMegapixel(asset.exifInfo.exifImageHeight, asset.exifInfo.exifImageWidth)} MP
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<p>{asset.exifInfo.exifImageHeight} x {asset.exifInfo.exifImageWidth}</p>
|
|
|
|
{/if}
|
|
|
|
<p>{asByteUnitString(asset.exifInfo.fileSizeInByte, $locale)}</p>
|
|
|
|
</div>
|
2023-11-13 15:57:58 -06:00
|
|
|
{#if showAssetPath}
|
|
|
|
<p class="text-xs opacity-50 break-all" transition:slide={{ duration: 250 }}>
|
|
|
|
{asset.originalPath}
|
|
|
|
</p>
|
|
|
|
{/if}
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
2023-08-29 15:57:20 +02:00
|
|
|
{#if asset.exifInfo?.make || asset.exifInfo?.model || asset.exifInfo?.fNumber}
|
2023-07-01 00:50:47 -04:00
|
|
|
<div class="flex gap-4 py-4">
|
2023-10-25 09:48:25 -04:00
|
|
|
<div><Icon path={mdiCameraIris} size="24" /></div>
|
2023-07-01 00:50:47 -04:00
|
|
|
|
|
|
|
<div>
|
|
|
|
<p>{asset.exifInfo.make || ''} {asset.exifInfo.model || ''}</p>
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="flex gap-2 text-sm">
|
2023-08-29 15:57:20 +02:00
|
|
|
{#if asset.exifInfo?.fNumber}
|
|
|
|
<p>{`ƒ/${asset.exifInfo.fNumber.toLocaleString($locale)}` || ''}</p>
|
|
|
|
{/if}
|
2023-07-01 00:50:47 -04:00
|
|
|
|
|
|
|
{#if asset.exifInfo.exposureTime}
|
|
|
|
<p>{`${asset.exifInfo.exposureTime}`}</p>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if asset.exifInfo.focalLength}
|
|
|
|
<p>{`${asset.exifInfo.focalLength.toLocaleString($locale)} mm`}</p>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if asset.exifInfo.iso}
|
|
|
|
<p>
|
2023-08-29 15:57:20 +02:00
|
|
|
{`ISO ${asset.exifInfo.iso}`}
|
2023-07-01 00:50:47 -04:00
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if asset.exifInfo?.city}
|
|
|
|
<div class="flex gap-4 py-4">
|
2023-10-25 09:48:25 -04:00
|
|
|
<div><Icon path={mdiMapMarkerOutline} size="24" /></div>
|
2023-07-01 00:50:47 -04:00
|
|
|
|
|
|
|
<div>
|
|
|
|
<p>{asset.exifInfo.city}</p>
|
2023-08-29 20:49:51 +02:00
|
|
|
{#if asset.exifInfo?.state}
|
|
|
|
<div class="flex gap-2 text-sm">
|
|
|
|
<p>{asset.exifInfo.state}</p>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{#if asset.exifInfo?.country}
|
|
|
|
<div class="flex gap-2 text-sm">
|
|
|
|
<p>{asset.exifInfo.country}</p>
|
|
|
|
</div>
|
|
|
|
{/if}
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2022-06-03 11:04:30 -05:00
|
|
|
</section>
|
|
|
|
|
2023-09-08 22:51:46 -04:00
|
|
|
{#if latlng && $featureFlags.loaded && $featureFlags.map}
|
2023-07-01 00:50:47 -04:00
|
|
|
<div class="h-[360px]">
|
2023-11-09 17:10:56 +01:00
|
|
|
<Map mapMarkers={[{ lat: latlng.lat, lon: latlng.lng, id: asset.id }]} center={latlng} zoom={14} simplified>
|
|
|
|
<svelte:fragment slot="popup" let:marker>
|
|
|
|
{@const { lat, lon } = marker}
|
|
|
|
<div class="flex flex-col items-center gap-1">
|
|
|
|
<p class="font-bold">{lat.toPrecision(6)}, {lon.toPrecision(6)}</p>
|
|
|
|
<a
|
|
|
|
href="https://www.openstreetmap.org/?mlat={lat}&mlon={lon}&zoom=15#map=15/{lat}/{lon}"
|
|
|
|
target="_blank"
|
|
|
|
class="font-medium text-immich-primary"
|
|
|
|
>
|
2023-08-25 15:19:49 +02:00
|
|
|
Open in OpenStreetMap
|
|
|
|
</a>
|
2023-11-09 17:10:56 +01:00
|
|
|
</div>
|
|
|
|
</svelte:fragment>
|
|
|
|
</Map>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
2023-03-19 20:06:45 +01:00
|
|
|
{/if}
|
2022-06-03 11:04:30 -05:00
|
|
|
|
2023-09-06 05:14:44 +02:00
|
|
|
{#if asset.owner && !isOwner}
|
|
|
|
<section class="px-6 pt-6 dark:text-immich-dark-fg">
|
|
|
|
<p class="text-sm">SHARED BY</p>
|
|
|
|
<div class="flex gap-4 pt-4">
|
|
|
|
<div>
|
2023-11-14 04:10:35 +01:00
|
|
|
<UserAvatar user={asset.owner} size="md" />
|
2023-09-06 05:14:44 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mb-auto mt-auto">
|
|
|
|
<p>
|
2023-11-11 20:03:32 -05:00
|
|
|
{asset.owner.name}
|
2023-09-06 05:14:44 +02:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if albums.length > 0}
|
|
|
|
<section class="p-6 dark:text-immich-dark-fg">
|
|
|
|
<p class="pb-4 text-sm">APPEARS IN</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
{#each albums as album}
|
|
|
|
<a data-sveltekit-preload-data="hover" href={`/albums/${album.id}`}>
|
2023-07-15 20:13:04 -05:00
|
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
2023-07-01 00:50:47 -04:00
|
|
|
<div
|
|
|
|
class="flex gap-4 py-2 hover:cursor-pointer"
|
|
|
|
on:click={() => dispatch('click', album)}
|
|
|
|
on:keydown={() => dispatch('click', album)}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<img
|
|
|
|
alt={album.albumName}
|
2023-07-18 13:19:39 -05:00
|
|
|
class="h-[50px] w-[50px] rounded object-cover"
|
2023-07-01 00:50:47 -04:00
|
|
|
src={album.albumThumbnailAssetId &&
|
|
|
|
api.getAssetThumbnailUrl(album.albumThumbnailAssetId, ThumbnailFormat.Jpeg)}
|
|
|
|
draggable="false"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="mb-auto mt-auto">
|
2023-07-01 00:50:47 -04:00
|
|
|
<p class="dark:text-immich-dark-primary">{album.albumName}</p>
|
|
|
|
<div class="flex gap-2 text-sm">
|
|
|
|
<p>{album.assetCount} items</p>
|
|
|
|
{#if album.shared}
|
|
|
|
<p>· Shared</p>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
{/each}
|
2023-09-06 05:14:44 +02:00
|
|
|
</section>
|
|
|
|
{/if}
|