mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
* First test * Added translation using Weblate (French) * Translated using Weblate (German) Currently translated at 100.0% (4 of 4 strings) Translation: immich/web Translate-URL: http://familie-mach.net/projects/immich/web/de/ * Translated using Weblate (French) Currently translated at 100.0% (4 of 4 strings) Translation: immich/web Translate-URL: http://familie-mach.net/projects/immich/web/fr/ * Further testing * Further testing * Translated using Weblate (German) Currently translated at 100.0% (18 of 18 strings) Translation: immich/web Translate-URL: http://familie-mach.net/projects/immich/web/de/ * Further work * Update string file. * More strings * Automatically changed strings * Add automatically translated german file for testing purposes * Fix merge-face-selector component * Make server stats strings uppercase * Fix uppercase string * Fix some strings in jobs-panel * Fix lower and uppercase strings. Add a few additional string. Fix a few unnecessary replacements * Update german test translations * Fix typo in locales file * Change string keys * Extract more strings * Extract and replace some more strings * Update testtranslationfile * Change translation keys * Fix rebase errors * Fix one more rebase error * Remove german translation file * Co-authored-by: Daniel Dietzler <danieldietzler@users.noreply.github.com> * chore: clean up translations * chore: add new line * fix formatting * chore: fixes * fix: loading and tests --------- Co-authored-by: root <root@Blacki> Co-authored-by: admin <admin@example.com> Co-authored-by: Jason Rasmussen <jrasm91@gmail.com> Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
185 lines
5.4 KiB
Svelte
185 lines
5.4 KiB
Svelte
<script lang="ts">
|
|
import { type LibraryResponseDto } from '@immich/sdk';
|
|
import { mdiPencilOutline } from '@mdi/js';
|
|
import { createEventDispatcher, onMount } from 'svelte';
|
|
import { handleError } from '../../utils/handle-error';
|
|
import Button from '../elements/buttons/button.svelte';
|
|
import LibraryExclusionPatternForm from './library-exclusion-pattern-form.svelte';
|
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
|
import { t } from 'svelte-i18n';
|
|
|
|
export let library: Partial<LibraryResponseDto>;
|
|
|
|
let addExclusionPattern = false;
|
|
let editExclusionPattern: number | null = null;
|
|
|
|
let exclusionPatternToAdd: string;
|
|
let editedExclusionPattern: string;
|
|
|
|
let exclusionPatterns: string[] = [];
|
|
|
|
onMount(() => {
|
|
if (library.exclusionPatterns) {
|
|
exclusionPatterns = library.exclusionPatterns;
|
|
} else {
|
|
library.exclusionPatterns = [];
|
|
}
|
|
});
|
|
|
|
const dispatch = createEventDispatcher<{
|
|
cancel: void;
|
|
submit: Partial<LibraryResponseDto>;
|
|
}>();
|
|
const handleCancel = () => {
|
|
dispatch('cancel');
|
|
};
|
|
|
|
const handleSubmit = () => {
|
|
dispatch('submit', library);
|
|
};
|
|
|
|
const handleAddExclusionPattern = () => {
|
|
if (!addExclusionPattern) {
|
|
return;
|
|
}
|
|
|
|
if (!library.exclusionPatterns) {
|
|
library.exclusionPatterns = [];
|
|
}
|
|
|
|
try {
|
|
// Check so that exclusion pattern isn't duplicated
|
|
if (!library.exclusionPatterns.includes(exclusionPatternToAdd)) {
|
|
library.exclusionPatterns.push(exclusionPatternToAdd);
|
|
exclusionPatterns = library.exclusionPatterns;
|
|
}
|
|
} catch (error) {
|
|
handleError(error, 'Unable to add exclusion pattern');
|
|
} finally {
|
|
exclusionPatternToAdd = '';
|
|
addExclusionPattern = false;
|
|
}
|
|
};
|
|
|
|
const handleEditExclusionPattern = () => {
|
|
if (editExclusionPattern === null) {
|
|
return;
|
|
}
|
|
|
|
if (!library.exclusionPatterns) {
|
|
library.exclusionPatterns = [];
|
|
}
|
|
|
|
try {
|
|
library.exclusionPatterns[editExclusionPattern] = editedExclusionPattern;
|
|
exclusionPatterns = library.exclusionPatterns;
|
|
} catch (error) {
|
|
handleError(error, 'Unable to edit exclude pattern');
|
|
} finally {
|
|
editExclusionPattern = null;
|
|
}
|
|
};
|
|
|
|
const handleDeleteExclusionPattern = () => {
|
|
if (editExclusionPattern === null) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
if (!library.exclusionPatterns) {
|
|
library.exclusionPatterns = [];
|
|
}
|
|
|
|
const pathToDelete = library.exclusionPatterns[editExclusionPattern];
|
|
library.exclusionPatterns = library.exclusionPatterns.filter((path) => path != pathToDelete);
|
|
exclusionPatterns = library.exclusionPatterns;
|
|
} catch (error) {
|
|
handleError(error, 'Unable to delete exclude pattern');
|
|
} finally {
|
|
editExclusionPattern = null;
|
|
}
|
|
};
|
|
</script>
|
|
|
|
{#if addExclusionPattern}
|
|
<LibraryExclusionPatternForm
|
|
submitText={$t('add')}
|
|
bind:exclusionPattern={exclusionPatternToAdd}
|
|
{exclusionPatterns}
|
|
on:submit={handleAddExclusionPattern}
|
|
on:cancel={() => {
|
|
addExclusionPattern = false;
|
|
}}
|
|
/>
|
|
{/if}
|
|
|
|
{#if editExclusionPattern != undefined}
|
|
<LibraryExclusionPatternForm
|
|
submitText={$t('save')}
|
|
isEditing={true}
|
|
bind:exclusionPattern={editedExclusionPattern}
|
|
{exclusionPatterns}
|
|
on:submit={handleEditExclusionPattern}
|
|
on:delete={handleDeleteExclusionPattern}
|
|
on:cancel={() => {
|
|
editExclusionPattern = null;
|
|
}}
|
|
/>
|
|
{/if}
|
|
|
|
<form on:submit|preventDefault={() => handleSubmit()} autocomplete="off" class="m-4 flex flex-col gap-4">
|
|
<table class="w-full text-left">
|
|
<tbody class="block w-full overflow-y-auto rounded-md border dark:border-immich-dark-gray">
|
|
{#each exclusionPatterns as exclusionPattern, listIndex}
|
|
<tr
|
|
class={`flex h-[80px] w-full place-items-center text-center dark:text-immich-dark-fg ${
|
|
listIndex % 2 == 0
|
|
? 'bg-immich-gray dark:bg-immich-dark-gray/75'
|
|
: 'bg-immich-bg dark:bg-immich-dark-gray/50'
|
|
}`}
|
|
>
|
|
<td class="w-3/4 text-ellipsis px-4 text-sm">{exclusionPattern}</td>
|
|
<td class="w-1/4 text-ellipsis flex justify-center">
|
|
<CircleIconButton
|
|
color="primary"
|
|
icon={mdiPencilOutline}
|
|
title={$t('edit_exclusion_pattern')}
|
|
size="16"
|
|
on:click={() => {
|
|
editExclusionPattern = listIndex;
|
|
editedExclusionPattern = exclusionPattern;
|
|
}}
|
|
/>
|
|
</td>
|
|
</tr>
|
|
{/each}
|
|
<tr
|
|
class={`flex h-[80px] w-full place-items-center text-center dark:text-immich-dark-fg ${
|
|
exclusionPatterns.length % 2 == 0
|
|
? 'bg-immich-gray dark:bg-immich-dark-gray/75'
|
|
: 'bg-immich-bg dark:bg-immich-dark-gray/50'
|
|
}`}
|
|
>
|
|
<td class="w-3/4 text-ellipsis px-4 text-sm">
|
|
{#if exclusionPatterns.length === 0}
|
|
No pattern added
|
|
{/if}
|
|
</td>
|
|
<td class="w-1/4 text-ellipsis px-4 text-sm"
|
|
><Button
|
|
size="sm"
|
|
on:click={() => {
|
|
addExclusionPattern = true;
|
|
}}>{$t('add_exclusion_pattern')}</Button
|
|
></td
|
|
></tr
|
|
>
|
|
</tbody>
|
|
</table>
|
|
|
|
<div class="flex w-full justify-end gap-4">
|
|
<Button size="sm" color="gray" on:click={() => handleCancel()}>{$t('cancel')}</Button>
|
|
<Button size="sm" type="submit">{$t('save')}</Button>
|
|
</div>
|
|
</form>
|