2025-03-27 08:38:35 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { getContext, tick } from 'svelte';
|
|
|
|
|
const i18n = getContext('i18n');
|
|
|
|
|
|
|
|
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
|
|
|
import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
|
|
|
|
|
import Cog6 from '$lib/components/icons/Cog6.svelte';
|
|
|
|
|
import ConfirmDialog from '$lib/components/common/ConfirmDialog.svelte';
|
|
|
|
|
import AddServerModal from '$lib/components/AddServerModal.svelte';
|
|
|
|
|
|
|
|
|
|
export let onDelete = () => {};
|
|
|
|
|
export let onSubmit = () => {};
|
|
|
|
|
|
2025-04-03 03:42:23 +00:00
|
|
|
export let connection = null;
|
2025-04-05 10:05:52 +00:00
|
|
|
export let direct = false;
|
2025-03-27 08:38:35 +00:00
|
|
|
|
|
|
|
|
let showConfigModal = false;
|
|
|
|
|
let showDeleteConfirmDialog = false;
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<AddServerModal
|
|
|
|
|
edit
|
|
|
|
|
direct
|
|
|
|
|
bind:show={showConfigModal}
|
2025-04-03 03:42:23 +00:00
|
|
|
{connection}
|
2025-03-27 08:38:35 +00:00
|
|
|
onDelete={() => {
|
|
|
|
|
showDeleteConfirmDialog = true;
|
|
|
|
|
}}
|
2025-04-03 03:42:23 +00:00
|
|
|
onSubmit={(c) => {
|
|
|
|
|
connection = c;
|
|
|
|
|
onSubmit(c);
|
2025-03-27 08:38:35 +00:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<ConfirmDialog
|
|
|
|
|
bind:show={showDeleteConfirmDialog}
|
|
|
|
|
on:confirm={() => {
|
|
|
|
|
onDelete();
|
|
|
|
|
showConfigModal = false;
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div class="flex w-full gap-2 items-center">
|
|
|
|
|
<Tooltip
|
|
|
|
|
className="w-full relative"
|
2025-04-05 10:05:52 +00:00
|
|
|
content={$i18n.t(`WebUI will make requests to "{{url}}"`, {
|
|
|
|
|
url: `${connection?.url}/${connection?.path ?? 'openapi.json'}`
|
2025-03-27 08:38:35 +00:00
|
|
|
})}
|
|
|
|
|
placement="top-start"
|
|
|
|
|
>
|
2025-04-03 03:42:23 +00:00
|
|
|
{#if !(connection?.config?.enable ?? true)}
|
2025-03-27 08:38:35 +00:00
|
|
|
<div
|
|
|
|
|
class="absolute top-0 bottom-0 left-0 right-0 opacity-60 bg-white dark:bg-gray-900 z-10"
|
|
|
|
|
></div>
|
|
|
|
|
{/if}
|
|
|
|
|
<div class="flex w-full">
|
|
|
|
|
<div class="flex-1 relative">
|
|
|
|
|
<input
|
2025-04-03 03:42:23 +00:00
|
|
|
class=" outline-hidden w-full bg-transparent"
|
2025-03-27 08:38:35 +00:00
|
|
|
placeholder={$i18n.t('API Base URL')}
|
2025-04-03 03:42:23 +00:00
|
|
|
bind:value={connection.url}
|
2025-03-27 08:38:35 +00:00
|
|
|
autocomplete="off"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-04-03 03:42:23 +00:00
|
|
|
{#if (connection?.auth_type ?? 'bearer') === 'bearer'}
|
|
|
|
|
<SensitiveInput
|
|
|
|
|
inputClassName=" outline-hidden bg-transparent w-full"
|
|
|
|
|
placeholder={$i18n.t('API Key')}
|
|
|
|
|
bind:value={connection.key}
|
|
|
|
|
required={false}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
2025-03-27 08:38:35 +00:00
|
|
|
</div>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
|
|
<div class="flex gap-1">
|
|
|
|
|
<Tooltip content={$i18n.t('Configure')} className="self-start">
|
|
|
|
|
<button
|
|
|
|
|
class="self-center p-1 bg-transparent hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-850 rounded-lg transition"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
showConfigModal = true;
|
|
|
|
|
}}
|
|
|
|
|
type="button"
|
|
|
|
|
>
|
|
|
|
|
<Cog6 />
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|