detail-panel.svelte 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <script lang="ts">
  2. import Close from 'svelte-material-icons/Close.svelte';
  3. import Calendar from 'svelte-material-icons/Calendar.svelte';
  4. import ImageOutline from 'svelte-material-icons/ImageOutline.svelte';
  5. import CameraIris from 'svelte-material-icons/CameraIris.svelte';
  6. import MapMarkerOutline from 'svelte-material-icons/MapMarkerOutline.svelte';
  7. import { createEventDispatcher } from 'svelte';
  8. import { AssetResponseDto, AlbumResponseDto } from '@api';
  9. import { asByteUnitString } from '../../utils/byte-units';
  10. import { locale } from '$lib/stores/preferences.store';
  11. import type { LatLngTuple } from 'leaflet';
  12. export let asset: AssetResponseDto;
  13. export let albums: AlbumResponseDto[] = [];
  14. $: latlng = (() => {
  15. const lat = asset.exifInfo?.latitude;
  16. const lng = asset.exifInfo?.longitude;
  17. if (lat && lng) {
  18. return [lat, lng] as LatLngTuple;
  19. }
  20. })();
  21. const dispatch = createEventDispatcher();
  22. const getMegapixel = (width: number, height: number): number | undefined => {
  23. const megapixel = Math.round((height * width) / 1_000_000);
  24. if (megapixel) {
  25. return megapixel;
  26. }
  27. return undefined;
  28. };
  29. </script>
  30. <section class="p-2 dark:bg-immich-dark-bg dark:text-immich-dark-fg">
  31. <div class="flex place-items-center gap-2">
  32. <button
  33. class="rounded-full p-3 flex place-items-center place-content-center hover:bg-gray-200 transition-colors dark:text-immich-dark-fg dark:hover:bg-gray-900"
  34. on:click={() => dispatch('close')}
  35. >
  36. <Close size="24" />
  37. </button>
  38. <p class="text-immich-fg dark:text-immich-dark-fg text-lg">Info</p>
  39. </div>
  40. <div class="px-4 py-4">
  41. {#if !asset.exifInfo}
  42. <p class="text-sm pb-4">NO EXIF INFO AVAILABLE</p>
  43. {:else}
  44. <p class="text-sm pb-4">DETAILS</p>
  45. {/if}
  46. {#if asset.exifInfo?.dateTimeOriginal}
  47. {@const assetDateTimeOriginal = new Date(asset.exifInfo.dateTimeOriginal)}
  48. <div class="flex gap-4 py-4">
  49. <div>
  50. <Calendar size="24" />
  51. </div>
  52. <div>
  53. <p>
  54. {assetDateTimeOriginal.toLocaleDateString($locale, {
  55. month: 'short',
  56. day: 'numeric',
  57. year: 'numeric'
  58. })}
  59. </p>
  60. <div class="flex gap-2 text-sm">
  61. <p>
  62. {assetDateTimeOriginal.toLocaleString($locale, {
  63. weekday: 'short',
  64. hour: 'numeric',
  65. minute: '2-digit',
  66. timeZoneName: 'longOffset'
  67. })}
  68. </p>
  69. </div>
  70. </div>
  71. </div>{/if}
  72. {#if asset.exifInfo?.fileSizeInByte}
  73. <div class="flex gap-4 py-4">
  74. <div><ImageOutline size="24" /></div>
  75. <div>
  76. <p>{`${asset.exifInfo.imageName}.${asset.originalPath.split('.')[1]}` || ''}</p>
  77. <div class="flex text-sm gap-2">
  78. {#if asset.exifInfo.exifImageHeight && asset.exifInfo.exifImageWidth}
  79. {#if getMegapixel(asset.exifInfo.exifImageHeight, asset.exifInfo.exifImageWidth)}
  80. <p>
  81. {getMegapixel(asset.exifInfo.exifImageHeight, asset.exifInfo.exifImageWidth)} MP
  82. </p>
  83. {/if}
  84. <p>{asset.exifInfo.exifImageHeight} x {asset.exifInfo.exifImageWidth}</p>
  85. {/if}
  86. <p>{asByteUnitString(asset.exifInfo.fileSizeInByte, $locale)}</p>
  87. </div>
  88. </div>
  89. </div>
  90. {/if}
  91. {#if asset.exifInfo?.fNumber}
  92. <div class="flex gap-4 py-4">
  93. <div><CameraIris size="24" /></div>
  94. <div>
  95. <p>{asset.exifInfo.make || ''} {asset.exifInfo.model || ''}</p>
  96. <div class="flex text-sm gap-2">
  97. <p>{`ƒ/${asset.exifInfo.fNumber.toLocaleString($locale)}` || ''}</p>
  98. {#if asset.exifInfo.exposureTime}
  99. <p>{`${asset.exifInfo.exposureTime}`}</p>
  100. {/if}
  101. {#if asset.exifInfo.focalLength}
  102. <p>{`${asset.exifInfo.focalLength.toLocaleString($locale)} mm`}</p>
  103. {/if}
  104. {#if asset.exifInfo.iso}
  105. <p>
  106. {`ISO${asset.exifInfo.iso}`}
  107. </p>
  108. {/if}
  109. </div>
  110. </div>
  111. </div>
  112. {/if}
  113. {#if asset.exifInfo?.city}
  114. <div class="flex gap-4 py-4">
  115. <div><MapMarkerOutline size="24" /></div>
  116. <div>
  117. <p>{asset.exifInfo.city}</p>
  118. <div class="flex text-sm gap-2">
  119. <p>{asset.exifInfo.state}</p>
  120. </div>
  121. <div class="flex text-sm gap-2">
  122. <p>{asset.exifInfo.country}</p>
  123. </div>
  124. </div>
  125. </div>
  126. {/if}
  127. </div>
  128. </section>
  129. {#if latlng}
  130. <div class="h-[360px]">
  131. {#await import('../shared-components/leaflet') then { Map, TileLayer, Marker }}
  132. <Map {latlng} zoom={14}>
  133. <TileLayer
  134. urlTemplate={'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'}
  135. options={{
  136. attribution:
  137. '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
  138. }}
  139. />
  140. <Marker {latlng} popupContent="{latlng[0].toFixed(7)},{latlng[1].toFixed(7)}" />
  141. </Map>
  142. {/await}
  143. </div>
  144. {/if}
  145. <section class="p-2 dark:text-immich-dark-fg">
  146. <div class="px-4 py-4">
  147. {#if albums.length > 0}
  148. <p class="text-sm pb-4 ">APPEARS IN</p>
  149. {/if}
  150. {#each albums as album}
  151. <a data-sveltekit-preload-data="hover" href={`/albums/${album.id}`}>
  152. <div
  153. class="flex gap-4 py-2 hover:cursor-pointer"
  154. on:click={() => dispatch('click', album)}
  155. on:keydown={() => dispatch('click', album)}
  156. >
  157. <div>
  158. <img
  159. alt={album.albumName}
  160. class="w-[50px] h-[50px] object-cover rounded"
  161. src={`/api/asset/thumbnail/${album.albumThumbnailAssetId}?format=JPEG`}
  162. draggable="false"
  163. />
  164. </div>
  165. <div class="mt-auto mb-auto">
  166. <p class="dark:text-immich-dark-primary">{album.albumName}</p>
  167. <div class="flex gap-2 text-sm">
  168. <p>{album.assetCount} items</p>
  169. {#if album.shared}
  170. <p>· Shared</p>
  171. {/if}
  172. </div>
  173. </div>
  174. </div>
  175. </a>
  176. {/each}
  177. </div>
  178. </section>