mirror of
https://github.com/immich-app/immich.git
synced 2024-12-25 10:43:13 +02:00
feat(web): add album to search result (#2900)
* Add album to search result page * Update web/src/routes/(user)/search/+page.svelte Co-authored-by: Thomas <9749173+uhthomas@users.noreply.github.com> * Update web/src/routes/(user)/search/+page.svelte Co-authored-by: Thomas <9749173+uhthomas@users.noreply.github.com> * change font weight * hide context menu in this view --------- Co-authored-by: Thomas <9749173+uhthomas@users.noreply.github.com>
This commit is contained in:
parent
069c68bfe4
commit
0f0375a67e
@ -10,6 +10,8 @@
|
|||||||
export let album: AlbumResponseDto;
|
export let album: AlbumResponseDto;
|
||||||
export let isSharingView = false;
|
export let isSharingView = false;
|
||||||
export let user: UserResponseDto;
|
export let user: UserResponseDto;
|
||||||
|
export let showItemCount = true;
|
||||||
|
export let showContextMenu = true;
|
||||||
|
|
||||||
$: imageData = album.albumThumbnailAssetId
|
$: imageData = album.albumThumbnailAssetId
|
||||||
? api.getAssetThumbnailUrl(album.albumThumbnailAssetId, ThumbnailFormat.Webp)
|
? api.getAssetThumbnailUrl(album.albumThumbnailAssetId, ThumbnailFormat.Webp)
|
||||||
@ -63,7 +65,7 @@
|
|||||||
data-testid="album-card"
|
data-testid="album-card"
|
||||||
>
|
>
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
{#if !isSharingView}
|
{#if showContextMenu}
|
||||||
<div
|
<div
|
||||||
id={`icon-${album.id}`}
|
id={`icon-${album.id}`}
|
||||||
class="absolute top-6 right-6 z-10"
|
class="absolute top-6 right-6 z-10"
|
||||||
@ -101,10 +103,12 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<span class="text-sm flex gap-2 dark:text-immich-dark-fg" data-testid="album-details">
|
<span class="text-sm flex gap-2 dark:text-immich-dark-fg" data-testid="album-details">
|
||||||
<p>
|
{#if showItemCount}
|
||||||
{album.assetCount.toLocaleString($locale)}
|
<p>
|
||||||
{album.assetCount == 1 ? `item` : `items`}
|
{album.assetCount.toLocaleString($locale)}
|
||||||
</p>
|
{album.assetCount == 1 ? `item` : `items`}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if isSharingView || album.shared}
|
{#if isSharingView || album.shared}
|
||||||
<p>·</p>
|
<p>·</p>
|
||||||
|
@ -89,6 +89,10 @@
|
|||||||
if (from?.url.pathname === '/sharing' && album.sharedUsers.length === 0) {
|
if (from?.url.pathname === '/sharing' && album.sharedUsers.length === 0) {
|
||||||
isCreatingSharedAlbum = true;
|
isCreatingSharedAlbum = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (from?.route.id === '/(user)/search') {
|
||||||
|
backUrl = from.url.href;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const albumDateFormat: Intl.DateTimeFormatOptions = {
|
const albumDateFormat: Intl.DateTimeFormatOptions = {
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
<div class="px-5 pt-5 text-xs">
|
<div class="px-5 pt-5 text-xs">
|
||||||
<p>
|
<p>
|
||||||
Smart search is enabled by default, to search for metadata use the syntax <span
|
Smart search is enabled by default, to search for metadata use the syntax <span
|
||||||
class="font-mono p-2 font-semibold text-immich-primary dark:text-immich-dark-primary bg-gray-100 rounded-lg dark:bg-gray-900"
|
class="font-mono p-2 font-semibold text-immich-primary dark:text-immich-dark-primary bg-gray-100 rounded-lg dark:bg-gray-900 leading-7"
|
||||||
>m:your-search-term</span
|
>m:your-search-term</span
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
|
@ -20,19 +20,27 @@
|
|||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
import SelectAll from 'svelte-material-icons/SelectAll.svelte';
|
import SelectAll from 'svelte-material-icons/SelectAll.svelte';
|
||||||
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||||
|
import { AppRoute } from '$lib/constants';
|
||||||
|
import AlbumCard from '$lib/components/album-page/album-card.svelte';
|
||||||
|
import { flip } from 'svelte/animate';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
// The GalleryViewer pushes it's own history state, which causes weird
|
// The GalleryViewer pushes it's own history state, which causes weird
|
||||||
// behavior for history.back(). To prevent that we store the previous page
|
// behavior for history.back(). To prevent that we store the previous page
|
||||||
// manually and navigate back to that.
|
// manually and navigate back to that.
|
||||||
let previousRoute = '/explore';
|
let previousRoute = AppRoute.EXPLORE as string;
|
||||||
|
$: albums = data.results.albums.items;
|
||||||
|
|
||||||
afterNavigate(({ from }) => {
|
afterNavigate(({ from }) => {
|
||||||
// Prevent setting previousRoute to the current page.
|
// Prevent setting previousRoute to the current page.
|
||||||
if (from && from.route.id !== $page.route.id) {
|
if (from && from.route.id !== $page.route.id) {
|
||||||
previousRoute = from.url.href;
|
previousRoute = from.url.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (from?.route.id === '/(user)/albums/[albumId]') {
|
||||||
|
previousRoute = AppRoute.EXPLORE;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$: term = $page.url.searchParams.get('q') || data.term || '';
|
$: term = $page.url.searchParams.get('q') || data.term || '';
|
||||||
@ -79,6 +87,30 @@
|
|||||||
|
|
||||||
<section class="relative pt-32 mb-12 bg-immich-bg dark:bg-immich-dark-bg">
|
<section class="relative pt-32 mb-12 bg-immich-bg dark:bg-immich-dark-bg">
|
||||||
<section class="overflow-y-auto relative immich-scrollbar">
|
<section class="overflow-y-auto relative immich-scrollbar">
|
||||||
|
{#if albums.length}
|
||||||
|
<section>
|
||||||
|
<div class="text-4xl font-medium text-black/70 dark:text-white/80 ml-6">ALBUMS</div>
|
||||||
|
<div class="grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))]">
|
||||||
|
{#each albums as album (album.id)}
|
||||||
|
<a
|
||||||
|
data-sveltekit-preload-data="hover"
|
||||||
|
href={`albums/${album.id}`}
|
||||||
|
animate:flip={{ duration: 200 }}
|
||||||
|
>
|
||||||
|
<AlbumCard
|
||||||
|
{album}
|
||||||
|
user={data.user}
|
||||||
|
isSharingView={false}
|
||||||
|
showItemCount={false}
|
||||||
|
showContextMenu={false}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="m-6 text-4xl font-medium text-black/70 dark:text-white/80">PHOTOS & VIDEOS</div>
|
||||||
|
</section>
|
||||||
|
{/if}
|
||||||
<section id="search-content" class="relative bg-immich-bg dark:bg-immich-dark-bg">
|
<section id="search-content" class="relative bg-immich-bg dark:bg-immich-dark-bg">
|
||||||
{#if data.results?.assets?.items.length > 0}
|
{#if data.results?.assets?.items.length > 0}
|
||||||
<div class="pl-4">
|
<div class="pl-4">
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
href={`albums/${album.id}`}
|
href={`albums/${album.id}`}
|
||||||
animate:flip={{ duration: 200 }}
|
animate:flip={{ duration: 200 }}
|
||||||
>
|
>
|
||||||
<AlbumCard {album} user={data.user} isSharingView />
|
<AlbumCard {album} user={data.user} isSharingView showContextMenu={false} />
|
||||||
</a>
|
</a>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user