2023-05-21 08:26:06 +02:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
|
|
|
|
|
import type { MapSettings } from '$lib/stores/preferences.store';
|
|
|
|
|
import { Duration } from 'luxon';
|
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
|
import { fly } from 'svelte/transition';
|
|
|
|
|
import Button from '../elements/buttons/button.svelte';
|
|
|
|
|
import LinkButton from '../elements/buttons/link-button.svelte';
|
2024-02-22 15:36:14 +01:00
|
|
|
import SettingSelect from '$lib/components/shared-components/settings/setting-select.svelte';
|
|
|
|
|
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
|
2024-02-27 04:07:49 +01:00
|
|
|
import DateInput from '../elements/date-input.svelte';
|
2023-05-21 08:26:06 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
export let settings: MapSettings;
|
|
|
|
|
let customDateRange = !!settings.dateAfter || !!settings.dateBefore;
|
2023-05-21 08:26:06 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const dispatch = createEventDispatcher<{
|
|
|
|
|
close: void;
|
|
|
|
|
save: MapSettings;
|
|
|
|
|
}>();
|
2023-09-26 04:53:26 +02:00
|
|
|
|
|
|
|
|
const handleClose = () => dispatch('close');
|
2023-05-21 08:26:06 +02:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-07 04:18:53 +01:00
|
|
|
<FullScreenModal onClose={handleClose}>
|
2023-07-01 00:50:47 -04:00
|
|
|
<div
|
2023-07-18 13:19:39 -05:00
|
|
|
class="flex w-96 max-w-lg flex-col gap-8 rounded-3xl border bg-white p-8 shadow-sm dark:border-immich-dark-gray dark:bg-immich-dark-gray"
|
2023-07-01 00:50:47 -04:00
|
|
|
>
|
2023-07-18 13:19:39 -05:00
|
|
|
<h1 class="self-center text-2xl font-medium text-immich-primary dark:text-immich-dark-primary">Map Settings</h1>
|
2023-05-21 08:26:06 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
<form
|
|
|
|
|
on:submit|preventDefault={() => dispatch('save', settings)}
|
|
|
|
|
class="flex flex-col gap-4 text-immich-primary dark:text-immich-dark-primary"
|
|
|
|
|
>
|
2024-04-06 14:18:49 +00:00
|
|
|
<SettingSwitch id="allow-dark-mode" title="Allow dark mode" bind:checked={settings.allowDarkMode} />
|
|
|
|
|
<SettingSwitch id="only-favorites" title="Only favorites" bind:checked={settings.onlyFavorites} />
|
|
|
|
|
<SettingSwitch id="include-archived" title="Include archived" bind:checked={settings.includeArchived} />
|
|
|
|
|
<SettingSwitch id="include-shared-with-me" title="Include shared with me" bind:checked={settings.withPartners} />
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if customDateRange}
|
|
|
|
|
<div in:fly={{ y: 10, duration: 200 }} class="flex flex-col gap-4">
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="flex items-center justify-between gap-8">
|
|
|
|
|
<label class="immich-form-label shrink-0 text-sm" for="date-after">Date after</label>
|
2024-02-27 04:07:49 +01:00
|
|
|
<DateInput
|
2023-07-01 00:50:47 -04:00
|
|
|
class="immich-form-input w-40"
|
|
|
|
|
type="date"
|
|
|
|
|
id="date-after"
|
|
|
|
|
max={settings.dateBefore}
|
|
|
|
|
bind:value={settings.dateAfter}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="flex items-center justify-between gap-8">
|
|
|
|
|
<label class="immich-form-label shrink-0 text-sm" for="date-before">Date before</label>
|
2024-02-27 04:07:49 +01:00
|
|
|
<DateInput class="immich-form-input w-40" type="date" id="date-before" bind:value={settings.dateBefore} />
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
|
|
|
|
<div class="flex justify-center text-xs">
|
|
|
|
|
<LinkButton
|
|
|
|
|
on:click={() => {
|
|
|
|
|
customDateRange = false;
|
|
|
|
|
settings.dateAfter = '';
|
|
|
|
|
settings.dateBefore = '';
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Remove custom date range
|
|
|
|
|
</LinkButton>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{:else}
|
|
|
|
|
<div in:fly={{ y: -10, duration: 200 }} class="flex flex-col gap-1">
|
|
|
|
|
<SettingSelect
|
|
|
|
|
label="Date range"
|
|
|
|
|
name="date-range"
|
|
|
|
|
bind:value={settings.relativeDate}
|
|
|
|
|
options={[
|
|
|
|
|
{
|
|
|
|
|
value: '',
|
|
|
|
|
text: 'All',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: Duration.fromObject({ hours: 24 }).toISO() || '',
|
|
|
|
|
text: 'Past 24 hours',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: Duration.fromObject({ days: 7 }).toISO() || '',
|
|
|
|
|
text: 'Past 7 days',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: Duration.fromObject({ days: 30 }).toISO() || '',
|
|
|
|
|
text: 'Past 30 days',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: Duration.fromObject({ years: 1 }).toISO() || '',
|
|
|
|
|
text: 'Past year',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: Duration.fromObject({ years: 3 }).toISO() || '',
|
|
|
|
|
text: 'Past 3 years',
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
<div class="text-xs">
|
|
|
|
|
<LinkButton
|
|
|
|
|
on:click={() => {
|
|
|
|
|
customDateRange = true;
|
|
|
|
|
settings.relativeDate = '';
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Use custom date range instead
|
|
|
|
|
</LinkButton>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2023-05-21 08:26:06 +02:00
|
|
|
|
2023-07-18 13:19:39 -05:00
|
|
|
<div class="mt-4 flex w-full gap-4">
|
2023-09-26 04:53:26 +02:00
|
|
|
<Button color="gray" size="sm" fullwidth on:click={handleClose}>Cancel</Button>
|
2023-07-01 00:50:47 -04:00
|
|
|
<Button type="submit" size="sm" fullwidth>Save</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
2023-05-21 08:26:06 +02:00
|
|
|
</FullScreenModal>
|