2023-09-20 13:16:33 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
|
import Button from '../elements/buttons/button.svelte';
|
|
|
|
|
import FullScreenModal from '../shared-components/full-screen-modal.svelte';
|
2023-10-25 09:48:25 -04:00
|
|
|
import { mdiFolderRemove } from '@mdi/js';
|
2024-02-09 01:09:09 +01:00
|
|
|
import { onMount } from 'svelte';
|
2023-09-20 13:16:33 +02:00
|
|
|
|
|
|
|
|
export let exclusionPattern: string;
|
2024-02-09 01:09:09 +01:00
|
|
|
export let exclusionPatterns: string[] = [];
|
|
|
|
|
export let isEditing = false;
|
2023-09-20 13:16:33 +02:00
|
|
|
export let submitText = 'Submit';
|
|
|
|
|
|
2024-02-09 01:09:09 +01:00
|
|
|
onMount(() => {
|
|
|
|
|
if (isEditing) {
|
|
|
|
|
exclusionPatterns = exclusionPatterns.filter((pattern) => pattern !== exclusionPattern);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$: isDuplicate = exclusionPattern !== null && exclusionPatterns.includes(exclusionPattern);
|
2024-04-14 13:57:45 +00:00
|
|
|
$: canSubmit = exclusionPattern && !exclusionPatterns.includes(exclusionPattern);
|
2024-02-09 01:09:09 +01:00
|
|
|
|
2023-12-15 03:54:21 +01:00
|
|
|
const dispatch = createEventDispatcher<{
|
|
|
|
|
cancel: void;
|
|
|
|
|
submit: { excludePattern: string };
|
|
|
|
|
delete: void;
|
|
|
|
|
}>();
|
2023-09-20 13:16:33 +02:00
|
|
|
const handleCancel = () => dispatch('cancel');
|
|
|
|
|
const handleSubmit = () => dispatch('submit', { excludePattern: exclusionPattern });
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-04-08 21:02:09 +00:00
|
|
|
<FullScreenModal
|
|
|
|
|
id="add-exclusion-pattern-modal"
|
|
|
|
|
title="Add exclusion pattern"
|
|
|
|
|
icon={mdiFolderRemove}
|
|
|
|
|
onClose={handleCancel}
|
|
|
|
|
>
|
|
|
|
|
<form on:submit|preventDefault={() => handleSubmit()} autocomplete="off">
|
|
|
|
|
<p class="py-5 text-sm">
|
|
|
|
|
Exclusion patterns lets you ignore files and folders when scanning your library. This is useful if you have
|
|
|
|
|
folders that contain files you don't want to import, such as RAW files.
|
|
|
|
|
<br /><br />
|
|
|
|
|
Add exclusion patterns. Globbing using *, **, and ? is supported. To ignore all files in any directory named "Raw",
|
|
|
|
|
use "**/Raw/**". To ignore all files ending in ".tif", use "**/*.tif". To ignore an absolute path, use "/path/to/ignore".
|
|
|
|
|
</p>
|
|
|
|
|
<div class="my-4 flex flex-col gap-2">
|
|
|
|
|
<label class="immich-form-label" for="exclusionPattern">Pattern</label>
|
|
|
|
|
<input
|
|
|
|
|
class="immich-form-input"
|
|
|
|
|
id="exclusionPattern"
|
|
|
|
|
name="exclusionPattern"
|
|
|
|
|
type="text"
|
|
|
|
|
bind:value={exclusionPattern}
|
|
|
|
|
/>
|
2023-09-20 13:16:33 +02:00
|
|
|
</div>
|
2024-04-08 21:02:09 +00:00
|
|
|
<div class="mt-8 flex w-full gap-4">
|
|
|
|
|
<Button color="gray" fullwidth on:click={() => handleCancel()}>Cancel</Button>
|
|
|
|
|
{#if isEditing}
|
|
|
|
|
<Button color="red" fullwidth on:click={() => dispatch('delete')}>Delete</Button>
|
|
|
|
|
{/if}
|
2023-09-20 13:16:33 +02:00
|
|
|
|
2024-04-08 21:02:09 +00:00
|
|
|
<Button type="submit" disabled={!canSubmit} fullwidth>{submitText}</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-8 flex w-full gap-4">
|
|
|
|
|
{#if isDuplicate}
|
|
|
|
|
<p class="text-red-500 text-sm">This exclusion pattern already exists.</p>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2023-09-20 13:16:33 +02:00
|
|
|
</FullScreenModal>
|