You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-06-26 05:01:05 +02:00
feat(ml): support multiple urls (#14347)
* support multiple url * update api * styling unnecessary `?.` * update docs, make new url field go first add load balancing section * update tests doc formatting wording wording linting * small styling * `url` -> `urls` * fix tests * update docs * make docusaurus happy --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@ -12,6 +12,9 @@
|
||||
import { t } from 'svelte-i18n';
|
||||
import FormatMessage from '$lib/components/i18n/format-message.svelte';
|
||||
import { SettingInputFieldType } from '$lib/constants';
|
||||
import Button from '$lib/components/elements/buttons/button.svelte';
|
||||
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||
import { mdiMinusCircle } from '@mdi/js';
|
||||
|
||||
interface Props {
|
||||
savedConfig: SystemConfigDto;
|
||||
@ -42,15 +45,42 @@
|
||||
|
||||
<hr />
|
||||
|
||||
<SettingInputField
|
||||
inputType={SettingInputFieldType.TEXT}
|
||||
label={$t('url')}
|
||||
description={$t('admin.machine_learning_url_description')}
|
||||
bind:value={config.machineLearning.url}
|
||||
required={true}
|
||||
disabled={disabled || !config.machineLearning.enabled}
|
||||
isEdited={config.machineLearning.url !== savedConfig.machineLearning.url}
|
||||
/>
|
||||
<div>
|
||||
{#each config.machineLearning.urls as _, i}
|
||||
{#snippet removeButton()}
|
||||
{#if config.machineLearning.urls.length > 1}
|
||||
<CircleIconButton
|
||||
size="24"
|
||||
class="ml-2"
|
||||
padding="2"
|
||||
color="red"
|
||||
title=""
|
||||
onclick={() => config.machineLearning.urls.splice(i, 1)}
|
||||
icon={mdiMinusCircle}
|
||||
/>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
<SettingInputField
|
||||
inputType={SettingInputFieldType.TEXT}
|
||||
label={i === 0 ? $t('url') : undefined}
|
||||
description={i === 0 ? $t('admin.machine_learning_url_description') : undefined}
|
||||
bind:value={config.machineLearning.urls[i]}
|
||||
required={i === 0}
|
||||
disabled={disabled || !config.machineLearning.enabled}
|
||||
isEdited={i === 0 && !isEqual(config.machineLearning.urls, savedConfig.machineLearning.urls)}
|
||||
trailingSnippet={removeButton}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
class="mb-2"
|
||||
type="button"
|
||||
size="sm"
|
||||
onclick={() => config.machineLearning.urls.splice(0, 0, '')}
|
||||
disabled={disabled || !config.machineLearning.enabled}>{$t('add_url')}</Button
|
||||
>
|
||||
</div>
|
||||
|
||||
<SettingAccordion
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script lang="ts" module>
|
||||
export type Color = 'transparent' | 'light' | 'dark' | 'gray' | 'primary' | 'opaque' | 'alert';
|
||||
export type Color = 'transparent' | 'light' | 'dark' | 'red' | 'gray' | 'primary' | 'opaque' | 'alert';
|
||||
export type Padding = '1' | '2' | '3';
|
||||
</script>
|
||||
|
||||
@ -64,6 +64,7 @@
|
||||
transparent: 'bg-transparent hover:bg-[#d3d3d3] dark:text-immich-dark-fg',
|
||||
opaque: 'bg-transparent hover:bg-immich-bg/30 text-white hover:dark:text-white',
|
||||
light: 'bg-white hover:bg-[#d3d3d3]',
|
||||
red: 'text-red-400 hover:bg-[#d3d3d3]',
|
||||
dark: 'bg-[#202123] hover:bg-[#d3d3d3]',
|
||||
alert: 'text-[#ff0000] hover:text-white',
|
||||
gray: 'bg-[#d3d3d3] hover:bg-[#e2e7e9] text-immich-dark-gray hover:text-black',
|
||||
|
@ -22,6 +22,7 @@
|
||||
autofocus?: boolean;
|
||||
passwordAutocomplete?: AutoFill;
|
||||
descriptionSnippet?: Snippet;
|
||||
trailingSnippet?: Snippet;
|
||||
}
|
||||
|
||||
let {
|
||||
@ -39,6 +40,7 @@
|
||||
autofocus = false,
|
||||
passwordAutocomplete = 'current-password',
|
||||
descriptionSnippet,
|
||||
trailingSnippet,
|
||||
}: Props = $props();
|
||||
|
||||
let input: HTMLInputElement | undefined = $state();
|
||||
@ -68,7 +70,7 @@
|
||||
</script>
|
||||
|
||||
<div class="mb-4 w-full">
|
||||
<div class={`flex h-[26px] place-items-center gap-1`}>
|
||||
<div class={`flex place-items-center gap-1`}>
|
||||
<label class="font-medium text-immich-primary dark:text-immich-dark-primary text-sm" for={label}>{label}</label>
|
||||
{#if required}
|
||||
<div class="text-red-400">*</div>
|
||||
@ -132,6 +134,8 @@
|
||||
{disabled}
|
||||
{title}
|
||||
/>
|
||||
|
||||
{@render trailingSnippet?.()}
|
||||
</div>
|
||||
{:else}
|
||||
<PasswordField
|
||||
|
Reference in New Issue
Block a user