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
@@ -26,6 +26,7 @@
|
||||
} from '$lib/apis/functions';
|
||||
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import FilterMenu from '$lib/components/workspace/common/FilterMenu.svelte';
|
||||
import ProfilePreview from '$lib/components/channel/Messages/Message/ProfilePreview.svelte';
|
||||
import ProfileImage from '$lib/components/chat/Messages/ProfileImage.svelte';
|
||||
import ConfirmDialog from '../common/ConfirmDialog.svelte';
|
||||
@@ -41,8 +42,6 @@
|
||||
import Search from '../icons/Search.svelte';
|
||||
import XMark from '../icons/XMark.svelte';
|
||||
import ImportModal from '../ImportModal.svelte';
|
||||
import ViewSelector from '../workspace/common/ViewSelector.svelte';
|
||||
import TagSelector from '../workspace/common/TagSelector.svelte';
|
||||
import CommunityDiscover from '../workspace/common/CommunityDiscover.svelte';
|
||||
import { capitalizeFirstLetter } from '$lib/utils';
|
||||
import Spinner from '../common/Spinner.svelte';
|
||||
@@ -58,7 +57,6 @@
|
||||
let functionsImportInputElement: HTMLInputElement;
|
||||
let importFiles;
|
||||
|
||||
let tagsContainerElement: HTMLDivElement;
|
||||
let viewOption = '';
|
||||
let sortKey = 'updated_at';
|
||||
let sortDirection = 'desc';
|
||||
@@ -255,6 +253,33 @@
|
||||
}
|
||||
};
|
||||
|
||||
$: createActions = [
|
||||
{
|
||||
id: 'functions-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/admin/functions/create'
|
||||
},
|
||||
{
|
||||
id: 'functions-import-link',
|
||||
label: $i18n.t('Import from URL'),
|
||||
onClick: () => {
|
||||
showImportModal = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'functions-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => functionsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin'
|
||||
},
|
||||
{
|
||||
id: 'functions-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: downloadFunctions,
|
||||
visible: $user?.role === 'admin' && (functions ?? []).length > 0
|
||||
}
|
||||
];
|
||||
|
||||
onMount(async () => {
|
||||
viewOption = localStorage?.workspaceViewOption || '';
|
||||
functions = await getFunctionList(localStorage.token).catch((error) => {
|
||||
@@ -346,37 +371,6 @@
|
||||
{filteredItems.length}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex w-full justify-end">
|
||||
<SplitCreateButton
|
||||
actions={[
|
||||
{
|
||||
id: 'functions-new',
|
||||
label: $i18n.t('Create'),
|
||||
href: '/admin/functions/create'
|
||||
},
|
||||
{
|
||||
id: 'functions-import-link',
|
||||
label: $i18n.t('Import from URL'),
|
||||
onClick: () => {
|
||||
showImportModal = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'functions-import',
|
||||
label: $i18n.t('Import JSON'),
|
||||
onClick: () => functionsImportInputElement?.click(),
|
||||
visible: $user?.role === 'admin'
|
||||
},
|
||||
{
|
||||
id: 'functions-export',
|
||||
label: $i18n.t('Export JSON'),
|
||||
onClick: downloadFunctions,
|
||||
visible: $user?.role === 'admin' && functions.length > 0
|
||||
}
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -412,40 +406,35 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex max-w-[55%] shrink-0 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"
|
||||
>
|
||||
<ViewSelector
|
||||
bind:value={viewOption}
|
||||
align="end"
|
||||
onChange={async (value) => {
|
||||
localStorage.workspaceViewOption = value;
|
||||
|
||||
await tick();
|
||||
}}
|
||||
/>
|
||||
|
||||
<TagSelector
|
||||
bind:value={selectedType}
|
||||
align="end"
|
||||
items={[
|
||||
{ value: 'pipe', label: $i18n.t('Pipe') },
|
||||
{ value: 'filter', label: $i18n.t('Filter') },
|
||||
{ value: 'action', label: $i18n.t('Action') },
|
||||
{ value: 'event', label: $i18n.t('Event') }
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<FilterMenu
|
||||
sections={[
|
||||
{
|
||||
label: $i18n.t('Owner'),
|
||||
value: viewOption,
|
||||
items: [
|
||||
{ value: 'created', label: $i18n.t('Created by you') },
|
||||
{ value: 'shared', label: $i18n.t('Shared with you') }
|
||||
],
|
||||
onChange: (value) => {
|
||||
viewOption = value;
|
||||
localStorage.workspaceViewOption = value;
|
||||
}
|
||||
},
|
||||
{
|
||||
label: $i18n.t('Type'),
|
||||
value: selectedType,
|
||||
items: [
|
||||
{ value: 'pipe', label: $i18n.t('Pipe') },
|
||||
{ value: 'filter', label: $i18n.t('Filter') },
|
||||
{ value: 'action', label: $i18n.t('Action') },
|
||||
{ value: 'event', label: $i18n.t('Event') }
|
||||
],
|
||||
onChange: (value) => (selectedType = value)
|
||||
}
|
||||
]}
|
||||
/>
|
||||
<SplitCreateButton actions={createActions} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -14,10 +14,12 @@
|
||||
import EditGroupModal from './Groups/EditGroupModal.svelte';
|
||||
import GroupItem from './Groups/GroupItem.svelte';
|
||||
import XMark from '$lib/components/icons/XMark.svelte';
|
||||
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
|
||||
import Check from '$lib/components/icons/Check.svelte';
|
||||
import ChevronRight from '$lib/components/icons/ChevronRight.svelte';
|
||||
import Select from '$lib/components/common/Select.svelte';
|
||||
import Dropdown from '$lib/components/common/Dropdown.svelte';
|
||||
import DropdownMenu from '$lib/components/common/DropdownMenu.svelte';
|
||||
import AdjustmentsHorizontal from '$lib/components/icons/AdjustmentsHorizontal.svelte';
|
||||
import Plus from '$lib/components/icons/Plus.svelte';
|
||||
import { createNewGroup, getGroups, updateGroupById } from '$lib/apis/groups';
|
||||
import { getUserDefaultPermissions, updateUserDefaultPermissions } from '$lib/apis/users';
|
||||
|
||||
@@ -242,39 +244,47 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<Select
|
||||
bind:value={sortBy}
|
||||
items={sortItems}
|
||||
placeholder={$i18n.t('Sort')}
|
||||
triggerClass="relative h-8 shrink-0 flex items-center gap-1 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 outline-hidden bg-transparent truncate placeholder-base-400 focus:outline-hidden"
|
||||
align="end"
|
||||
>
|
||||
<svelte:fragment slot="trigger" let:selectedLabel>
|
||||
<span
|
||||
class="inline-flex h-input outline-hidden bg-transparent truncate placeholder-base-400 focus:outline-hidden"
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<Dropdown align="end">
|
||||
<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('Sort by')}
|
||||
title={$i18n.t('Sort by')}
|
||||
>
|
||||
{selectedLabel}
|
||||
</span>
|
||||
<ChevronDown className="size-3.5" strokeWidth="2.5" />
|
||||
</svelte:fragment>
|
||||
<AdjustmentsHorizontal className="size-3.75" />
|
||||
</button>
|
||||
|
||||
<svelte:fragment slot="item" let:item let:selected>
|
||||
{item.label}
|
||||
<div class="ml-auto {selected ? '' : 'invisible'}">
|
||||
<Check />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Select>
|
||||
<DropdownMenu slot="content" className="w-44">
|
||||
<div class="px-2 pt-1.5 pb-0.5 text-xs text-base-400 dark:text-base-500">
|
||||
{$i18n.t('Sort by')}
|
||||
</div>
|
||||
{#each sortItems as item (item.value)}
|
||||
<button
|
||||
type="button"
|
||||
role="menuitemradio"
|
||||
aria-checked={sortBy === item.value}
|
||||
on:click={() => (sortBy = item.value)}
|
||||
>
|
||||
<span class="flex-1 text-left">{item.label}</span>
|
||||
{#if sortBy === item.value}<Check className="size-3! shrink-0" />{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
|
||||
<button
|
||||
class="ml-1 shrink-0 rounded-lg bg-base-50 px-2.5 py-1 text-xs text-base-900 transition ring-1 ring-base-200 hover:bg-base-100 dark:bg-base-850 dark:text-base-100 dark:ring-base-800 dark:hover:bg-base-800"
|
||||
on:click={() => {
|
||||
showAddGroupModal = !showAddGroupModal;
|
||||
}}
|
||||
>
|
||||
{$i18n.t('New Group')}
|
||||
</button>
|
||||
<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('New Group')}
|
||||
title={$i18n.t('New Group')}
|
||||
on:click={() => {
|
||||
showAddGroupModal = !showAddGroupModal;
|
||||
}}
|
||||
>
|
||||
<Plus className="size-3.5" strokeWidth="2" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
import Search from '$lib/components/icons/Search.svelte';
|
||||
import XMark from '$lib/components/icons/XMark.svelte';
|
||||
import Plus from '$lib/components/icons/Plus.svelte';
|
||||
import ChevronUp from '$lib/components/icons/ChevronUp.svelte';
|
||||
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
|
||||
import Banner from '$lib/components/common/Banner.svelte';
|
||||
@@ -220,12 +221,15 @@
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="ml-1 shrink-0 rounded-lg bg-base-50 px-2.5 py-1 text-xs text-base-900 transition ring-1 ring-base-200 hover:bg-base-100 dark:bg-base-850 dark:text-base-100 dark:ring-base-800 dark:hover:bg-base-800"
|
||||
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('Add User')}
|
||||
title={$i18n.t('Add User')}
|
||||
on:click={() => {
|
||||
showAddUserModal = !showAddUserModal;
|
||||
}}
|
||||
>
|
||||
{$i18n.t('Add User')}
|
||||
<Plus className="size-3.5" strokeWidth="2" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user