mirror of
https://github.com/immich-app/immich.git
synced 2025-06-03 05:34:32 -04:00
* no-misused-promises * no-floating-promises * format * revert for now * remove load function * require-await * revert a few no-floating-promises changes that would cause no-misused-promises failures * format * fix a few more * fix most remaining errors * executor-queue * executor-queue.spec * remove duplicate comments by grouping rules * upgrade sveltekit and enforce rules * oops. move await * try this * just ignore for now since it's only a test * run in parallel * Update web/src/routes/admin/jobs-status/+page.svelte Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> * remove Promise.resolve call * rename function * remove unnecessary warning silencing * make handleError sync * fix new errors from recently merged PR to main * extract method * use handlePromiseError --------- Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
98 lines
3.0 KiB
Svelte
98 lines
3.0 KiB
Svelte
<script lang="ts" context="module">
|
|
export interface SearchLocationFilter {
|
|
country?: string;
|
|
state?: string;
|
|
city?: string;
|
|
}
|
|
</script>
|
|
|
|
<script lang="ts">
|
|
import { getSearchSuggestions, SearchSuggestionType } from '@immich/sdk';
|
|
import Combobox, { toComboBoxOptions } from '../combobox.svelte';
|
|
import { handlePromiseError } from '$lib/utils';
|
|
|
|
export let filters: SearchLocationFilter;
|
|
|
|
let countries: string[] = [];
|
|
let states: string[] = [];
|
|
let cities: string[] = [];
|
|
|
|
$: countryFilter = filters.country;
|
|
$: stateFilter = filters.state;
|
|
$: handlePromiseError(updateCountries());
|
|
$: handlePromiseError(updateStates(countryFilter));
|
|
$: handlePromiseError(updateCities(countryFilter, stateFilter));
|
|
|
|
async function updateCountries() {
|
|
countries = await getSearchSuggestions({
|
|
$type: SearchSuggestionType.Country,
|
|
});
|
|
|
|
if (filters.country && !countries.includes(filters.country)) {
|
|
filters.country = undefined;
|
|
}
|
|
}
|
|
|
|
async function updateStates(country?: string) {
|
|
states = await getSearchSuggestions({
|
|
$type: SearchSuggestionType.State,
|
|
country,
|
|
});
|
|
|
|
if (filters.state && !states.includes(filters.state)) {
|
|
filters.state = undefined;
|
|
}
|
|
}
|
|
|
|
async function updateCities(country?: string, state?: string) {
|
|
cities = await getSearchSuggestions({
|
|
$type: SearchSuggestionType.City,
|
|
country,
|
|
state,
|
|
});
|
|
|
|
if (filters.city && !cities.includes(filters.city)) {
|
|
filters.city = undefined;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<div id="location-selection">
|
|
<p class="immich-form-label">PLACE</p>
|
|
|
|
<div class="grid grid-cols-[repeat(auto-fit,minmax(10rem,1fr))] gap-5 mt-1">
|
|
<div class="w-full">
|
|
<label class="text-sm text-black dark:text-white" for="search-place-country">Country</label>
|
|
<Combobox
|
|
id="search-place-country"
|
|
options={toComboBoxOptions(countries)}
|
|
selectedOption={filters.country ? { label: filters.country, value: filters.country } : undefined}
|
|
on:select={({ detail }) => (filters.country = detail?.value)}
|
|
placeholder="Search country..."
|
|
/>
|
|
</div>
|
|
|
|
<div class="w-full">
|
|
<label class="text-sm text-black dark:text-white" for="search-place-state">State</label>
|
|
<Combobox
|
|
id="search-place-state"
|
|
options={toComboBoxOptions(states)}
|
|
selectedOption={filters.state ? { label: filters.state, value: filters.state } : undefined}
|
|
on:select={({ detail }) => (filters.state = detail?.value)}
|
|
placeholder="Search state..."
|
|
/>
|
|
</div>
|
|
|
|
<div class="w-full">
|
|
<label class="text-sm text-black dark:text-white" for="search-place-city">City</label>
|
|
<Combobox
|
|
id="search-place-city"
|
|
options={toComboBoxOptions(cities)}
|
|
selectedOption={filters.city ? { label: filters.city, value: filters.city } : undefined}
|
|
on:select={({ detail }) => (filters.city = detail?.value)}
|
|
placeholder="Search city..."
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|