Skip to content

Commit

Permalink
simplify option for text search
Browse files Browse the repository at this point in the history
  • Loading branch information
alextran1502 committed Mar 4, 2024
1 parent 5d4dce5 commit cf37250
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 63 deletions.
12 changes: 1 addition & 11 deletions server/src/infra/infra.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,9 @@ export function searchAssetBuilder(
builder.andWhere(`${builder.alias}.ownerId IN (:...userIds)`, { userIds: options.userIds });
}

const path = _.pick(options, ['encodedVideoPath', 'originalPath', 'resizePath', 'webpPath']);
const path = _.pick(options, ['encodedVideoPath', 'originalPath', 'originalFileName', 'resizePath', 'webpPath']);
builder.andWhere(_.omitBy(path, _.isUndefined));

if (options.originalFileName) {
builder.andWhere(`${builder.alias}.originalFileName ILIKE :originalFileName`, {
originalFileName: `%${options.originalFileName}%`,
});

builder.orWhere(`${builder.alias}.originalPath ILIKE :originalFileName`, {
originalFileName: `%${options.originalFileName}%`,
});
}

const status = _.pick(options, ['isExternal', 'isFavorite', 'isOffline', 'isReadOnly', 'isVisible', 'type']);
const {
isArchived,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
let filter: SearchFilter = {
context: 'query' in searchQuery ? searchQuery.query : '',
fileName: 'originalFileName' in searchQuery ? searchQuery.originalFileName : undefined,
personIds: new Set('personIds' in searchQuery ? searchQuery.personIds : []),
location: {
country: searchQuery.country,
Expand Down Expand Up @@ -94,7 +93,6 @@
let payload: SmartSearchDto | MetadataSearchDto = {
query: filter.context || undefined,
originalFileName: filter.fileName,
country: filter.location.country,
state: filter.location.state,
city: filter.location.city,
Expand Down Expand Up @@ -129,7 +127,7 @@
<SearchPeopleSection width={filterBoxWidth} bind:selectedPeople={filter.personIds} />

<!-- TEXT -->
<SearchTextSection bind:fileName={filter.fileName} bind:context={filter.context} />
<SearchTextSection bind:context={filter.context} />

<!-- LOCATION -->
<SearchLocationSection bind:filters={filter.location} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,18 @@
<script lang="ts">
export let fileName: string | undefined;
export let context: string | undefined;
enum TextSearchOptions {
Context = 'context',
FileName = 'file-name',
}
let selectedOption = context ? TextSearchOptions.Context : TextSearchOptions.FileName;
$: {
if (selectedOption === TextSearchOptions.Context) {
fileName = undefined;
} else {
context = undefined;
}
}
</script>

<div class="flex gap-5">
<label class="immich-form-label" for="context">
<input type="radio" name="context" id="context" bind:group={selectedOption} value={TextSearchOptions.Context} />
<span>CONTEXT</span>
</label>

<label class="immich-form-label" for="file-name">
<input
type="radio"
name="file-name"
id="file-name"
bind:group={selectedOption}
value={TextSearchOptions.FileName}
/>
<span>FILE NAME</span>
<label class="immich-form-label" for="text">
<span>TEXT</span>
</label>
</div>

{#if selectedOption === TextSearchOptions.Context}
<input
class="immich-form-input hover:cursor-text w-full !mt-1"
type="text"
id="context"
name="context"
placeholder="Sunrise on the beach"
bind:value={context}
/>
{:else}
<input
class="immich-form-input hover:cursor-text w-full !mt-1"
type="text"
id="file-name"
name="file-name"
placeholder="IMG_1234.jpg"
bind:value={fileName}
/>
{/if}
<input
class="immich-form-input hover:cursor-text w-full !mt-1"
type="text"
id="text"
name="text"
placeholder={'Photo\'s context such as "Baby with yellow teddy bear", or file name, or file extension'}
bind:value={context}
/>

0 comments on commit cf37250

Please sign in to comment.