mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-28 16:11:43 -05:00
refac
This commit is contained in:
1 parent
4dc3bdc466
commit
950da84bdb
5 files changed
+203
-356
No files matched your search
@@ -121,113 +121,115 @@
|
||||
{/each}
|
||||
{/snippet}
|
||||
|
||||
<Dropdown
|
||||
align="end"
|
||||
visualViewportAware
|
||||
maxHeight="min(21rem, calc(100dvh - 2rem))"
|
||||
contentClass="overscroll-contain scrollbar-thin"
|
||||
onOpenChange={(open) => {
|
||||
active = null;
|
||||
controlsOpen = open && available.length === 0;
|
||||
}}
|
||||
>
|
||||
<Tooltip content={$i18n.t('Model controls')} placement="top">
|
||||
<button
|
||||
type="button"
|
||||
aria-label={$i18n.t('Model controls')}
|
||||
class="mr-2 flex shrink-0 items-center justify-center text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
|
||||
>
|
||||
<Knobs className="size-4" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
<div slot="content">
|
||||
<DropdownMenu
|
||||
className="w-70 max-w-[calc(100vw-2rem)] max-h-[min(21rem,calc(100dvh-2rem))] overflow-y-auto overscroll-contain scrollbar-thin"
|
||||
>
|
||||
{#if $mobile && active}
|
||||
<button type="button" aria-label={$i18n.t('Back')} on:click={back}>
|
||||
<ChevronLeft className="size-3.5" />
|
||||
<span>{active.control.label}</span>
|
||||
</button>
|
||||
{@render choices(active.model, active.key, active.control)}
|
||||
{:else}
|
||||
{#each available as model (model.id)}
|
||||
{#if selectedModels.length > 1}
|
||||
<div class="truncate px-2 pt-1.5 pb-0.5 text-xs text-gray-400 dark:text-gray-500">
|
||||
{resolveLocalizedModelName(model, $i18n.language)}
|
||||
</div>
|
||||
{/if}
|
||||
{#each Object.entries(localizeModelControls(model, $i18n.language)) as [key, control] (key)}
|
||||
{#if control.display === 'slider'}
|
||||
<ModelControlSlider
|
||||
{control}
|
||||
value={modelControls[model.id]?.[key] ?? ''}
|
||||
disabled={saving}
|
||||
on:change={(event) => select(model.id, key, event.detail)}
|
||||
/>
|
||||
{:else if $mobile}
|
||||
<button
|
||||
type="button"
|
||||
aria-label={control.label}
|
||||
id={`model-control-${model.id}-${key}`}
|
||||
class={rowClass}
|
||||
on:click={(event) =>
|
||||
(active = { model, key, control, trigger: event.currentTarget })}
|
||||
>
|
||||
{@render summary(model, key, control)}
|
||||
</button>
|
||||
{:else}
|
||||
<DropdownSub
|
||||
maxWidth={240}
|
||||
contentClass="w-60 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin"
|
||||
>
|
||||
{#if controlsAllowed || available.length > 0}
|
||||
<Dropdown
|
||||
align="end"
|
||||
visualViewportAware
|
||||
maxHeight="min(21rem, calc(100dvh - 2rem))"
|
||||
contentClass="overscroll-contain scrollbar-thin"
|
||||
onOpenChange={(open) => {
|
||||
active = null;
|
||||
controlsOpen = open && available.length === 0;
|
||||
}}
|
||||
>
|
||||
<Tooltip content={$i18n.t('Model controls')} placement="top">
|
||||
<button
|
||||
type="button"
|
||||
aria-label={$i18n.t('Model controls')}
|
||||
class="mr-2 flex shrink-0 items-center justify-center text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
|
||||
>
|
||||
<Knobs className="size-4" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
<div slot="content">
|
||||
<DropdownMenu
|
||||
className="w-70 max-w-[calc(100vw-2rem)] max-h-[min(21rem,calc(100dvh-2rem))] overflow-y-auto overscroll-contain scrollbar-thin"
|
||||
>
|
||||
{#if $mobile && active}
|
||||
<button type="button" aria-label={$i18n.t('Back')} on:click={back}>
|
||||
<ChevronLeft className="size-3.5" />
|
||||
<span>{active.control.label}</span>
|
||||
</button>
|
||||
{@render choices(active.model, active.key, active.control)}
|
||||
{:else}
|
||||
{#each available as model (model.id)}
|
||||
{#if selectedModels.length > 1}
|
||||
<div class="truncate px-2 pt-1.5 pb-0.5 text-xs text-gray-400 dark:text-gray-500">
|
||||
{resolveLocalizedModelName(model, $i18n.language)}
|
||||
</div>
|
||||
{/if}
|
||||
{#each Object.entries(localizeModelControls(model, $i18n.language)) as [key, control] (key)}
|
||||
{#if control.display === 'slider'}
|
||||
<ModelControlSlider
|
||||
{control}
|
||||
value={modelControls[model.id]?.[key] ?? ''}
|
||||
disabled={saving}
|
||||
on:change={(event) => select(model.id, key, event.detail)}
|
||||
/>
|
||||
{:else if $mobile}
|
||||
<button
|
||||
slot="trigger"
|
||||
type="button"
|
||||
aria-label={control.label}
|
||||
aria-haspopup="menu"
|
||||
id={`model-control-${model.id}-${key}`}
|
||||
class={rowClass}
|
||||
on:click={(event) =>
|
||||
(active = { model, key, control, trigger: event.currentTarget })}
|
||||
>
|
||||
{@render summary(model, key, control)}
|
||||
</button>
|
||||
{@render choices(model, key, control)}
|
||||
</DropdownSub>
|
||||
{/if}
|
||||
{:else}
|
||||
<DropdownSub
|
||||
maxWidth={240}
|
||||
contentClass="w-60 max-h-[calc(100dvh-2rem)] overflow-y-auto scrollbar-thin"
|
||||
>
|
||||
<button
|
||||
slot="trigger"
|
||||
type="button"
|
||||
aria-label={control.label}
|
||||
aria-haspopup="menu"
|
||||
class={rowClass}
|
||||
>
|
||||
{@render summary(model, key, control)}
|
||||
</button>
|
||||
{@render choices(model, key, control)}
|
||||
</DropdownSub>
|
||||
{/if}
|
||||
{/each}
|
||||
{/each}
|
||||
{/each}
|
||||
{#if controlsAllowed}
|
||||
{#if available.length}<hr class="border-gray-200/30 dark:border-gray-700/25" />{/if}
|
||||
<button
|
||||
type="button"
|
||||
class={`${rowClass} text-xs!`}
|
||||
aria-expanded={controlsOpen}
|
||||
on:click={() => (controlsOpen = !controlsOpen)}
|
||||
>
|
||||
<Tooltip
|
||||
as="span"
|
||||
content={$i18n.t(
|
||||
'Configure chat files, valves, system prompt, and advanced parameters.'
|
||||
)}
|
||||
allowHTML={false}
|
||||
{#if controlsAllowed}
|
||||
{#if available.length}<hr class="border-gray-200/30 dark:border-gray-700/25" />{/if}
|
||||
<button
|
||||
type="button"
|
||||
class={`${rowClass} text-xs!`}
|
||||
aria-expanded={controlsOpen}
|
||||
on:click={() => (controlsOpen = !controlsOpen)}
|
||||
>
|
||||
<span
|
||||
class="cursor-help underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
||||
<Tooltip
|
||||
as="span"
|
||||
content={$i18n.t(
|
||||
'Configure chat files, valves, system prompt, and advanced parameters.'
|
||||
)}
|
||||
allowHTML={false}
|
||||
>
|
||||
{$i18n.t('Controls')}
|
||||
</span>
|
||||
</Tooltip>
|
||||
<ChevronDown
|
||||
className={`ml-auto size-3.5 text-gray-400 ${controlsOpen ? 'rotate-180' : ''}`}
|
||||
strokeWidth="1.5"
|
||||
/>
|
||||
</button>
|
||||
{#if controlsOpen}
|
||||
<div class="px-1.5 pb-1">
|
||||
<Controls embed={true} bind:chatFiles bind:params {onParamChange} />
|
||||
</div>
|
||||
<span
|
||||
class="cursor-help underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
||||
>
|
||||
{$i18n.t('Controls')}
|
||||
</span>
|
||||
</Tooltip>
|
||||
<ChevronDown
|
||||
className={`ml-auto size-3.5 text-gray-400 ${controlsOpen ? 'rotate-180' : ''}`}
|
||||
strokeWidth="1.5"
|
||||
/>
|
||||
</button>
|
||||
{#if controlsOpen}
|
||||
<div class="px-1.5 pb-1">
|
||||
<Controls embed={true} bind:chatFiles bind:params {onParamChange} />
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</Dropdown>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</Dropdown>
|
||||
{/if}
|
||||
Reference in new issue
Block a user