feat: add search bar to admin settings sidebar (#20434)
This commit is contained in:
1 file changed
+244
-186
@@ -18,12 +18,15 @@
|
||||
import Documents from './Settings/Documents.svelte';
|
||||
import WebSearch from './Settings/WebSearch.svelte';
|
||||
|
||||
import ChartBar from '../icons/ChartBar.svelte';
|
||||
import DocumentChartBar from '../icons/DocumentChartBar.svelte';
|
||||
import Evaluations from './Settings/Evaluations.svelte';
|
||||
import CodeExecution from './Settings/CodeExecution.svelte';
|
||||
import Tools from './Settings/Tools.svelte';
|
||||
|
||||
import ChartBar from '../icons/ChartBar.svelte';
|
||||
import DocumentChartBar from '../icons/DocumentChartBar.svelte';
|
||||
import Search from '../icons/Search.svelte';
|
||||
import XMark from '../icons/XMark.svelte';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
let selectedTab = 'general';
|
||||
@@ -63,6 +66,207 @@
|
||||
}
|
||||
};
|
||||
|
||||
let search = '';
|
||||
let searchDebounceTimeout;
|
||||
let filteredSettings = [];
|
||||
|
||||
const allSettings = [
|
||||
{
|
||||
id: 'general',
|
||||
title: 'General',
|
||||
route: '/admin/settings/general',
|
||||
keywords: [
|
||||
'general',
|
||||
'admin',
|
||||
'settings',
|
||||
'version',
|
||||
'update',
|
||||
'language',
|
||||
'theme',
|
||||
'data',
|
||||
'users',
|
||||
'roles',
|
||||
'ldap',
|
||||
'authentication',
|
||||
'reverse proxy',
|
||||
'webhook',
|
||||
'community',
|
||||
'channels'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'connections',
|
||||
title: 'Connections',
|
||||
route: '/admin/settings/connections',
|
||||
keywords: [
|
||||
'connections',
|
||||
'ollama',
|
||||
'openai',
|
||||
'api',
|
||||
'base url',
|
||||
'direct connections',
|
||||
'proxy',
|
||||
'key'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'models',
|
||||
title: 'Models',
|
||||
route: '/admin/settings/models',
|
||||
keywords: [
|
||||
'models',
|
||||
'pull',
|
||||
'delete',
|
||||
'create',
|
||||
'edit',
|
||||
'modelfile',
|
||||
'gguf',
|
||||
'import',
|
||||
'export'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'evaluations',
|
||||
title: 'Evaluations',
|
||||
route: '/admin/settings/evaluations',
|
||||
keywords: ['evaluations', 'feedback', 'rating', 'arena', 'leaderboard', 'preference']
|
||||
},
|
||||
{
|
||||
id: 'tools',
|
||||
title: 'External Tools',
|
||||
route: '/admin/settings/tools',
|
||||
keywords: ['tools', 'plugins', 'extensions', 'functions', 'openapi', 'server']
|
||||
},
|
||||
{
|
||||
id: 'documents',
|
||||
title: 'Documents',
|
||||
route: '/admin/settings/documents',
|
||||
keywords: [
|
||||
'documents',
|
||||
'files',
|
||||
'rag',
|
||||
'knowledge',
|
||||
'upload',
|
||||
'embedding',
|
||||
'vector db',
|
||||
'chunk',
|
||||
'overlap',
|
||||
'splitter',
|
||||
'pdf',
|
||||
'ocr',
|
||||
'tika',
|
||||
'docling',
|
||||
'unstructured'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'web',
|
||||
title: 'Web Search',
|
||||
route: '/admin/settings/web',
|
||||
keywords: [
|
||||
'web search',
|
||||
'google',
|
||||
'bing',
|
||||
'duckduckgo',
|
||||
'serp',
|
||||
'searxng',
|
||||
'moojeh',
|
||||
'yacy',
|
||||
'serper',
|
||||
'serply',
|
||||
'tavily',
|
||||
'exa',
|
||||
'perplexity',
|
||||
'firecrawl'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'code-execution',
|
||||
title: 'Code Execution',
|
||||
route: '/admin/settings/code-execution',
|
||||
keywords: ['code execution', 'python', 'sandbox', 'compiler', 'jupyter', 'interpreter']
|
||||
},
|
||||
{
|
||||
id: 'interface',
|
||||
title: 'Interface',
|
||||
route: '/admin/settings/interface',
|
||||
keywords: [
|
||||
'interface',
|
||||
'ui',
|
||||
'appearance',
|
||||
'banners',
|
||||
'tasks',
|
||||
'prompt suggestions',
|
||||
'title generation',
|
||||
'tags'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'audio',
|
||||
title: 'Audio',
|
||||
route: '/admin/settings/audio',
|
||||
keywords: [
|
||||
'audio',
|
||||
'voice',
|
||||
'speech',
|
||||
'tts',
|
||||
'stt',
|
||||
'whisper',
|
||||
'deepgram',
|
||||
'azure',
|
||||
'openai',
|
||||
'elevenlabs'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'images',
|
||||
title: 'Images',
|
||||
route: '/admin/settings/images',
|
||||
keywords: [
|
||||
'images',
|
||||
'generation',
|
||||
'dalle',
|
||||
'stable diffusion',
|
||||
'comfyui',
|
||||
'automatic1111',
|
||||
'gemini'
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'pipelines',
|
||||
title: 'Pipelines',
|
||||
route: '/admin/settings/pipelines',
|
||||
keywords: ['pipelines', 'workflows', 'filters', 'valves', 'middleware']
|
||||
},
|
||||
{
|
||||
id: 'db',
|
||||
title: 'Database',
|
||||
route: '/admin/settings/db',
|
||||
keywords: ['database', 'export', 'import', 'backup', 'chats', 'users']
|
||||
}
|
||||
];
|
||||
|
||||
const setFilteredSettings = () => {
|
||||
filteredSettings = allSettings.filter((tab) => {
|
||||
const searchTerm = search.toLowerCase().trim();
|
||||
return (
|
||||
search === '' ||
|
||||
tab.title.toLowerCase().includes(searchTerm) ||
|
||||
tab.keywords.some((keyword) => keyword.includes(searchTerm))
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const searchDebounceHandler = () => {
|
||||
if (searchDebounceTimeout) {
|
||||
clearTimeout(searchDebounceTimeout);
|
||||
}
|
||||
|
||||
searchDebounceTimeout = setTimeout(() => {
|
||||
setFilteredSettings();
|
||||
}, 100);
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
const containerElement = document.getElementById('admin-settings-tabs-container');
|
||||
|
||||
@@ -75,6 +279,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
setFilteredSettings();
|
||||
// Scroll to the selected tab on mount
|
||||
scrollToTab(selectedTab);
|
||||
});
|
||||
@@ -85,17 +290,36 @@
|
||||
id="admin-settings-tabs-container"
|
||||
class="tabs mx-[16px] lg:mx-0 lg:px-[16px] flex flex-row overflow-x-auto gap-2.5 max-w-full lg:gap-1 lg:flex-col lg:flex-none lg:w-50 dark:text-gray-200 text-sm font-medium text-left scrollbar-none"
|
||||
>
|
||||
<div
|
||||
class="hidden md:flex w-full rounded-full px-2.5 gap-2 bg-gray-100/80 dark:bg-gray-850/80 backdrop-blur-2xl my-1 mb-1.5"
|
||||
id="settings-search"
|
||||
>
|
||||
<div class="self-center rounded-l-xl bg-transparent">
|
||||
<Search className="size-3.5" strokeWidth="1.5" />
|
||||
</div>
|
||||
<label class="sr-only" for="search-input-settings-modal">{$i18n.t('Search')}</label>
|
||||
<input
|
||||
class="w-full py-1 text-sm bg-transparent dark:text-gray-300 outline-hidden"
|
||||
bind:value={search}
|
||||
id="search-input-settings-modal"
|
||||
on:input={searchDebounceHandler}
|
||||
placeholder={$i18n.t('Search')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{#each filteredSettings as tab (tab.id)}
|
||||
<button
|
||||
id="general"
|
||||
id={tab.id}
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 lg:flex-none flex text-right transition {selectedTab ===
|
||||
'general'
|
||||
tab.id
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/general');
|
||||
goto(tab.route);
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{#if tab.id === 'general'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
@@ -108,21 +332,7 @@
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('General')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="connections"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'connections'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/connections');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'connections'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
@@ -133,21 +343,7 @@
|
||||
d="M1 9.5A3.5 3.5 0 0 0 4.5 13H12a3 3 0 0 0 .917-5.857 2.503 2.503 0 0 0-3.198-3.019 3.5 3.5 0 0 0-6.628 2.171A3.5 3.5 0 0 0 1 9.5Z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Connections')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="models"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'models'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/models');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'models'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20"
|
||||
@@ -160,37 +356,9 @@
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Models')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="evaluations"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'evaluations'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/evaluations');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'evaluations'}
|
||||
<DocumentChartBar />
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Evaluations')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="tools"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'tools'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/tools');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'tools'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
@@ -203,21 +371,7 @@
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('External Tools')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="documents"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'documents'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/documents');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'documents'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
@@ -234,21 +388,7 @@
|
||||
d="M14.25 5.25a5.23 5.23 0 0 0-1.279-3.434 9.768 9.768 0 0 1 6.963 6.963A5.23 5.23 0 0 0 16.5 7.5h-1.875a.375.375 0 0 1-.375-.375V5.25Z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Documents')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="web"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'web'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/web');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'web'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
@@ -259,21 +399,7 @@
|
||||
d="M21.721 12.752a9.711 9.711 0 0 0-.945-5.003 12.754 12.754 0 0 1-4.339 2.708 18.991 18.991 0 0 1-.214 4.772 17.165 17.165 0 0 0 5.498-2.477ZM14.634 15.55a17.324 17.324 0 0 0 .332-4.647c-.952.227-1.945.347-2.966.347-1.021 0-2.014-.12-2.966-.347a17.515 17.515 0 0 0 .332 4.647 17.385 17.385 0 0 0 5.268 0ZM9.772 17.119a18.963 18.963 0 0 0 4.456 0A17.182 17.182 0 0 1 12 21.724a17.18 17.18 0 0 1-2.228-4.605ZM7.777 15.23a18.87 18.87 0 0 1-.214-4.774 12.753 12.753 0 0 1-4.34-2.708 9.711 9.711 0 0 0-.944 5.004 17.165 17.165 0 0 0 5.498 2.477ZM21.356 14.752a9.765 9.765 0 0 1-7.478 6.817 18.64 18.64 0 0 0 1.988-4.718 18.627 18.627 0 0 0 5.49-2.098ZM2.644 14.752c1.682.971 3.53 1.688 5.49 2.099a18.64 18.64 0 0 0 1.988 4.718 9.765 9.765 0 0 1-7.478-6.816ZM13.878 2.43a9.755 9.755 0 0 1 6.116 3.986 11.267 11.267 0 0 1-3.746 2.504 18.63 18.63 0 0 0-2.37-6.49ZM12 2.276a17.152 17.152 0 0 1 2.805 7.121c-.897.23-1.837.353-2.805.353-.968 0-1.908-.122-2.805-.353A17.151 17.151 0 0 1 12 2.276ZM10.122 2.43a18.629 18.629 0 0 0-2.37 6.49 11.266 11.266 0 0 1-3.746-2.504 9.754 9.754 0 0 1 6.116-3.985Z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Web Search')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="code-execution"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'code-execution'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/code-execution');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'code-execution'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
@@ -286,21 +412,7 @@
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Code Execution')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="interface"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'interface'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/interface');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'interface'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
@@ -313,21 +425,7 @@
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Interface')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="audio"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'audio'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/audio');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'audio'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
@@ -341,21 +439,7 @@
|
||||
d="M10.828 5.172a.75.75 0 1 0-1.06 1.06 2.5 2.5 0 0 1 0 3.536.75.75 0 1 0 1.06 1.06 4 4 0 0 0 0-5.656Z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Audio')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="images"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'images'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/images');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'images'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
@@ -368,21 +452,7 @@
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Images')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="pipelines"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'pipelines'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/pipelines');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'pipelines'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
@@ -399,21 +469,7 @@
|
||||
d="m10.933 19.231-7.668-4.13-1.37.739a.75.75 0 0 0 0 1.32l9.75 5.25c.221.12.489.12.71 0l9.75-5.25a.75.75 0 0 0 0-1.32l-1.37-.738-7.668 4.13a2.25 2.25 0 0 1-2.134-.001Z"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Pipelines')}</div>
|
||||
</button>
|
||||
|
||||
<button
|
||||
id="db"
|
||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||
'db'
|
||||
? ''
|
||||
: ' text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'}"
|
||||
on:click={() => {
|
||||
goto('/admin/settings/db');
|
||||
}}
|
||||
>
|
||||
<div class=" self-center mr-2">
|
||||
{:else if tab.id === 'db'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
@@ -428,9 +484,11 @@
|
||||
d="M8 12.5c1.84 0 3.579-.37 4.914-1.037.366-.183.74-.41 1.086-.684V12c0 1.657-2.686 3-6 3s-6-1.343-6-3v-1.22c.346.273.72.5 1.087.683C4.42 12.131 6.16 12.5 8 12.5Z"
|
||||
/>
|
||||
</svg>
|
||||
{/if}
|
||||
</div>
|
||||
<div class=" self-center">{$i18n.t('Database')}</div>
|
||||
<div class=" self-center">{$i18n.t(tab.title)}</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
||||
Reference in new issue
Block a user