diff --git a/web/src/lib/components/shared-components/search-bar/search-filter-box.svelte b/web/src/lib/components/shared-components/search-bar/search-filter-box.svelte index 4fd85fa9bd..45e9393ed4 100644 --- a/web/src/lib/components/shared-components/search-bar/search-filter-box.svelte +++ b/web/src/lib/components/shared-components/search-bar/search-filter-box.svelte @@ -10,8 +10,8 @@ } export type SearchFilter = { - context?: string; - filename?: string; + query: string; + queryType: 'smart' | 'metadata'; personIds: Set; location: SearchLocationFilter; camera: SearchCameraFilter; @@ -48,8 +48,8 @@ } let filter: SearchFilter = { - context: 'query' in searchQuery ? searchQuery.query : '', - filename: 'originalFileName' in searchQuery ? searchQuery.originalFileName : undefined, + query: 'query' in searchQuery ? searchQuery.query : searchQuery.originalFileName || '', + queryType: 'query' in searchQuery ? 'smart' : 'metadata', personIds: new Set('personIds' in searchQuery ? searchQuery.personIds : []), location: { country: withNullAsUndefined(searchQuery.country), @@ -79,6 +79,8 @@ const resetForm = () => { filter = { + query: '', + queryType: 'smart', personIds: new Set(), location: {}, camera: {}, @@ -96,9 +98,11 @@ type = AssetTypeEnum.Video; } + const query = filter.query || undefined; + let payload: SmartSearchDto | MetadataSearchDto = { - query: filter.context || undefined, - originalFileName: filter.filename, + query: filter.queryType === 'smart' ? query : undefined, + originalFileName: filter.queryType === 'metadata' ? query : undefined, country: filter.location.country, state: filter.location.state, city: filter.location.city, @@ -132,7 +136,7 @@ - + diff --git a/web/src/lib/components/shared-components/search-bar/search-text-section.svelte b/web/src/lib/components/shared-components/search-bar/search-text-section.svelte index e2b74b8388..c3145b2f0c 100644 --- a/web/src/lib/components/shared-components/search-bar/search-text-section.svelte +++ b/web/src/lib/components/shared-components/search-bar/search-text-section.svelte @@ -2,46 +2,25 @@ import RadioButton from '$lib/components/elements/radio-button.svelte'; import { t } from 'svelte-i18n'; - export let filename: string | undefined; - export let context: string | undefined; - - enum TextSearchOptions { - Context = 'context', - Filename = 'filename', - } - - let selectedOption = filename ? TextSearchOptions.Filename : TextSearchOptions.Context; - - $: { - if (selectedOption === TextSearchOptions.Context) { - filename = undefined; - } else { - context = undefined; - } - } + export let query: string | undefined; + export let queryType: 'smart' | 'metadata' = 'smart';
{$t('search_type')}
- +
-{#if selectedOption === TextSearchOptions.Context} +{#if queryType === 'smart'} {:else} @@ -59,7 +38,7 @@ id="file-name-input" name="file-name" placeholder={$t('search_by_filename_example')} - bind:value={filename} + bind:value={query} aria-labelledby="file-name-label" /> {/if}