mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-03 18:17:56 -05:00
refac
This commit is contained in:
1 parent
b52bcff605
commit
e6a8dd052d
17 files changed
+3003
-3064
No files matched your search
@@ -37,6 +37,7 @@
|
||||
import { getModelsConfig, setModelsConfig } from '$lib/apis/configs';
|
||||
import Search from '$lib/components/icons/Search.svelte';
|
||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||
import FilterMenu from '$lib/components/workspace/common/FilterMenu.svelte';
|
||||
import Switch from '$lib/components/common/Switch.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import XMark from '$lib/components/icons/XMark.svelte';
|
||||
@@ -51,7 +52,6 @@
|
||||
import EllipsisHorizontal from '$lib/components/icons/EllipsisHorizontal.svelte';
|
||||
import EyeSlash from '$lib/components/icons/EyeSlash.svelte';
|
||||
import Eye from '$lib/components/icons/Eye.svelte';
|
||||
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
|
||||
import Check from '$lib/components/icons/Check.svelte';
|
||||
import CheckCircle from '$lib/components/icons/CheckCircle.svelte';
|
||||
import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
|
||||
@@ -69,8 +69,6 @@
|
||||
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
||||
import AdminViewSelector from './Models/AdminViewSelector.svelte';
|
||||
import TagSelector from '$lib/components/workspace/common/TagSelector.svelte';
|
||||
import { isMachine } from '$lib/utils/machines';
|
||||
|
||||
type ModelListItem = { id: string; name?: string; owned_by?: string };
|
||||
@@ -82,7 +80,6 @@
|
||||
let modelsImportInProgress = false;
|
||||
let importFiles;
|
||||
let modelsImportInputElement: HTMLInputElement;
|
||||
let tagsContainerElement: HTMLDivElement;
|
||||
let modelListElement: HTMLDivElement;
|
||||
let sortable = null;
|
||||
|
||||
@@ -852,42 +849,52 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex max-w-[60%] shrink-0 items-center gap-1 overflow-x-auto scrollbar-none"
|
||||
bind:this={tagsContainerElement}
|
||||
on:wheel={(e) => {
|
||||
if (e.deltaY !== 0) {
|
||||
e.preventDefault();
|
||||
e.currentTarget.scrollLeft += e.deltaY;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="flex w-fit gap-0.5 text-center text-sm rounded-full bg-transparent whitespace-nowrap"
|
||||
>
|
||||
<AdminViewSelector bind:value={viewOption} align="end" />
|
||||
|
||||
{#if (tags ?? []).length > 0}
|
||||
<TagSelector
|
||||
bind:value={selectedTag}
|
||||
align="end"
|
||||
items={tags.map((tag) => {
|
||||
return { value: tag, label: tag };
|
||||
})}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<FilterMenu
|
||||
sections={[
|
||||
{
|
||||
label: $i18n.t('View'),
|
||||
value: viewOption,
|
||||
items: [
|
||||
{ value: 'available', label: $i18n.t('Available') },
|
||||
{ value: 'unavailable', label: $i18n.t('Unavailable') },
|
||||
{ value: 'base', label: $i18n.t('Base Models') },
|
||||
{ value: 'workspace', label: $i18n.t('Workspace Models') },
|
||||
{ value: 'router', label: $i18n.t('settings.admin.models.routerModels.label') },
|
||||
{ value: 'enabled', label: $i18n.t('Enabled') },
|
||||
{ value: 'disabled', label: $i18n.t('Disabled') },
|
||||
{ value: 'visible', label: $i18n.t('Visible') },
|
||||
{ value: 'hidden', label: $i18n.t('Hidden') },
|
||||
{ value: 'public', label: $i18n.t('Public') },
|
||||
{ value: 'private', label: $i18n.t('Private') },
|
||||
{ value: 'selected', label: $i18n.t('Selected') },
|
||||
{ value: 'pinned', label: $i18n.t('Pinned') }
|
||||
],
|
||||
onChange: (value) => (viewOption = value)
|
||||
},
|
||||
...((tags ?? []).length > 0
|
||||
? [
|
||||
{
|
||||
label: $i18n.t('Tags'),
|
||||
value: selectedTag,
|
||||
items: tags.map((tag) => ({ value: tag, label: tag })),
|
||||
onChange: (value: string) => {
|
||||
selectedTag = value;
|
||||
}
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]}
|
||||
/>
|
||||
<Dropdown closeOnSelect align="end">
|
||||
<Tooltip content={$i18n.t('Actions')}>
|
||||
<button
|
||||
class="flex h-8 items-center gap-1.5 rounded-xl bg-transparent px-1.5 text-[0.8125rem] font-normal text-base-700 transition hover:text-base-900 dark:text-base-200 dark:hover:text-base-100"
|
||||
type="button"
|
||||
>
|
||||
<span>{$i18n.t('Actions')}</span>
|
||||
<ChevronDown className="size-3" strokeWidth="2.5" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
<button
|
||||
type="button"
|
||||
class="relative flex size-6.5 shrink-0 items-center justify-center rounded-full border border-base-100 bg-base-50/60 text-base-500 transition-colors hover:bg-base-100 hover:text-base-900 aria-expanded:bg-base-100 aria-expanded:text-base-900 dark:border-base-850 dark:bg-base-850/50 dark:text-base-400 dark:hover:bg-base-850 dark:hover:text-base-0 dark:aria-expanded:bg-base-850 dark:aria-expanded:text-base-0"
|
||||
aria-label={$i18n.t('Actions')}
|
||||
title={$i18n.t('Actions')}
|
||||
>
|
||||
<EllipsisHorizontal className="size-3.5" />
|
||||
</button>
|
||||
|
||||
<div slot="content">
|
||||
<DropdownMenu className="min-w-[10.625rem] shadow-sm">
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
|
||||
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
|
||||
import Check from '$lib/components/icons/Check.svelte';
|
||||
import Select from '$lib/components/common/Select.svelte';
|
||||
|
||||
const i18n = getContext<typeof import('$lib/i18n').default>('i18n');
|
||||
|
||||
export let value = '';
|
||||
export let placeholder: string | undefined = undefined;
|
||||
export let align = 'start';
|
||||
export let onChange: (value: string) => void = () => {};
|
||||
|
||||
$: items = [
|
||||
{ value: '', label: $i18n.t('All') },
|
||||
{ value: 'available', label: $i18n.t('Available') },
|
||||
{ value: 'unavailable', label: $i18n.t('Unavailable') },
|
||||
{ value: 'base', label: $i18n.t('Base Models') },
|
||||
{ value: 'workspace', label: $i18n.t('Workspace Models') },
|
||||
{ value: 'router', label: $i18n.t('settings.admin.models.routerModels.label') },
|
||||
{ value: 'enabled', label: $i18n.t('Enabled') },
|
||||
{ value: 'disabled', label: $i18n.t('Disabled') },
|
||||
{ value: 'visible', label: $i18n.t('Visible') },
|
||||
{ value: 'hidden', label: $i18n.t('Hidden') },
|
||||
{ value: 'public', label: $i18n.t('Public') },
|
||||
{ value: 'private', label: $i18n.t('Private') },
|
||||
{ value: 'selected', label: $i18n.t('Selected') },
|
||||
{ value: 'pinned', label: $i18n.t('Pinned') }
|
||||
];
|
||||
</script>
|
||||
|
||||
<Select
|
||||
bind:value
|
||||
{items}
|
||||
placeholder={placeholder ?? $i18n.t('Select view')}
|
||||
{align}
|
||||
triggerClass="relative h-8 w-full flex items-center gap-0.5 px-1.5 py-1.5 bg-transparent rounded-xl text-[0.8125rem] font-normal text-base-700 transition hover:text-base-900 dark:text-base-200 dark:hover:text-base-100"
|
||||
labelClass="inline-flex h-input w-full outline-hidden bg-transparent truncate placeholder-base-400 focus:outline-hidden"
|
||||
onChange={() => onChange(value)}
|
||||
>
|
||||
<svelte:fragment slot="trigger" let:selectedLabel>
|
||||
<span
|
||||
class="inline-flex h-input w-full outline-hidden bg-transparent truncate placeholder-base-400 focus:outline-hidden"
|
||||
>
|
||||
{selectedLabel}
|
||||
</span>
|
||||
<ChevronDown className="size-3.5" strokeWidth="2.5" />
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="item" let:item let:selected>
|
||||
{item.label}
|
||||
<div class="ml-auto {selected ? '' : 'invisible'}">
|
||||
<Check />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Select>
|
||||
Reference in new issue
Block a user