mirror of
https://github.com/immich-app/immich.git
synced 2025-02-04 01:09:14 -05:00
fix(web): broken links to places search (#7208)
This commit is contained in:
parent
5e1498a279
commit
529a83cc72
4 changed files with 16 additions and 6 deletions
|
@ -14,6 +14,7 @@
|
||||||
import SearchHistoryBox from './search-history-box.svelte';
|
import SearchHistoryBox from './search-history-box.svelte';
|
||||||
import SearchFilterBox from './search-filter-box.svelte';
|
import SearchFilterBox from './search-filter-box.svelte';
|
||||||
import type { MetadataSearchDto, SmartSearchDto } from '@immich/sdk';
|
import type { MetadataSearchDto, SmartSearchDto } from '@immich/sdk';
|
||||||
|
import { getMetadataSearchQuery } from '$lib/utils/metadata-search';
|
||||||
export let value = '';
|
export let value = '';
|
||||||
export let grayTheme: boolean;
|
export let grayTheme: boolean;
|
||||||
|
|
||||||
|
@ -24,15 +25,13 @@
|
||||||
$: showClearIcon = value.length > 0;
|
$: showClearIcon = value.length > 0;
|
||||||
|
|
||||||
const onSearch = (payload: SmartSearchDto | MetadataSearchDto) => {
|
const onSearch = (payload: SmartSearchDto | MetadataSearchDto) => {
|
||||||
const parameters = new URLSearchParams({
|
const params = getMetadataSearchQuery(payload);
|
||||||
query: JSON.stringify(payload),
|
|
||||||
});
|
|
||||||
|
|
||||||
showHistory = false;
|
showHistory = false;
|
||||||
showFilter = false;
|
showFilter = false;
|
||||||
$isSearchEnabled = false;
|
$isSearchEnabled = false;
|
||||||
$searchQuery = payload;
|
$searchQuery = payload;
|
||||||
goto(`${AppRoute.SEARCH}?${parameters}`, { invalidateAll: true });
|
goto(`${AppRoute.SEARCH}?${params}`, { invalidateAll: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearSearchTerm = (searchTerm: string) => {
|
const clearSearchTerm = (searchTerm: string) => {
|
||||||
|
|
9
web/src/lib/utils/metadata-search.ts
Normal file
9
web/src/lib/utils/metadata-search.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import { QueryParameter } from '$lib/constants';
|
||||||
|
import type { MetadataSearchDto } from '@immich/sdk';
|
||||||
|
|
||||||
|
export function getMetadataSearchQuery(metadata: MetadataSearchDto) {
|
||||||
|
const searchParams = new URLSearchParams({
|
||||||
|
[QueryParameter.QUERY]: JSON.stringify(metadata),
|
||||||
|
});
|
||||||
|
return searchParams.toString();
|
||||||
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
import { getPeopleThumbnailUrl } from '$lib/utils';
|
import { getPeopleThumbnailUrl } from '$lib/utils';
|
||||||
import type { SearchExploreResponseDto } from '@immich/sdk';
|
import type { SearchExploreResponseDto } from '@immich/sdk';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
import { getMetadataSearchQuery } from '$lib/utils/metadata-search';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row flex-wrap gap-4">
|
<div class="flex flex-row flex-wrap gap-4">
|
||||||
{#each places as item (item.data.id)}
|
{#each places as item (item.data.id)}
|
||||||
<a class="relative" href="{AppRoute.SEARCH}?q={item.value}" draggable="false">
|
<a class="relative" href="{AppRoute.SEARCH}?{getMetadataSearchQuery({ city: item.value })}" draggable="false">
|
||||||
<div
|
<div
|
||||||
class="flex w-[calc((100vw-(72px+5rem))/2)] max-w-[156px] justify-center overflow-hidden rounded-xl brightness-75 filter"
|
class="flex w-[calc((100vw-(72px+5rem))/2)] max-w-[156px] justify-center overflow-hidden rounded-xl brightness-75 filter"
|
||||||
>
|
>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
import type { SearchExploreResponseDto } from '@immich/sdk';
|
import type { SearchExploreResponseDto } from '@immich/sdk';
|
||||||
import { mdiMapMarkerOff } from '@mdi/js';
|
import { mdiMapMarkerOff } from '@mdi/js';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
import { getMetadataSearchQuery } from '$lib/utils/metadata-search';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
{#if hasPlaces}
|
{#if hasPlaces}
|
||||||
<div class="flex flex-row flex-wrap gap-4">
|
<div class="flex flex-row flex-wrap gap-4">
|
||||||
{#each places as item (item.data.id)}
|
{#each places as item (item.data.id)}
|
||||||
<a class="relative" href="{AppRoute.SEARCH}?q={item.value}" draggable="false">
|
<a class="relative" href="{AppRoute.SEARCH}?{getMetadataSearchQuery({ city: item.value })}" draggable="false">
|
||||||
<div
|
<div
|
||||||
class="flex w-[calc((100vw-(72px+5rem))/2)] max-w-[156px] justify-center overflow-hidden rounded-xl brightness-75 filter"
|
class="flex w-[calc((100vw-(72px+5rem))/2)] max-w-[156px] justify-center overflow-hidden rounded-xl brightness-75 filter"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Reference in a new issue