mirror of
https://github.com/open-webui/open-webui
synced 2025-04-05 05:10:46 +00:00
Merge dd84f54871
into e0ec2cdeb0
This commit is contained in:
commit
ab3c1dfe53
@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
|
import Sortable from 'sortablejs';
|
||||||
|
|
||||||
import { getBackendConfig, getTaskConfig, updateTaskConfig } from '$lib/apis';
|
import { getBackendConfig, getTaskConfig, updateTaskConfig } from '$lib/apis';
|
||||||
import { setDefaultPromptSuggestions } from '$lib/apis/configs';
|
import { setDefaultPromptSuggestions } from '$lib/apis/configs';
|
||||||
@ -38,6 +39,25 @@
|
|||||||
|
|
||||||
let promptSuggestions = [];
|
let promptSuggestions = [];
|
||||||
let banners: Banner[] = [];
|
let banners: Banner[] = [];
|
||||||
|
let bannersSortable;
|
||||||
|
|
||||||
|
const updateBanners = async () => {
|
||||||
|
const sortedBanners = Array.from(document.querySelector('.banners-sortable').children).map((element, index) => {
|
||||||
|
const idInput = element.querySelector('input[name="id"]');
|
||||||
|
if (idInput) {
|
||||||
|
const banner = banners.find(b => b.id === idInput.value);
|
||||||
|
if (banner) {
|
||||||
|
banner.position = index;
|
||||||
|
}
|
||||||
|
return banner;
|
||||||
|
} else {
|
||||||
|
console.error('No id input found for banner');
|
||||||
|
}
|
||||||
|
}).filter(banner => banner !== undefined);
|
||||||
|
|
||||||
|
await setBanners(localStorage.token, sortedBanners);
|
||||||
|
_banners.set(sortedBanners);
|
||||||
|
};
|
||||||
|
|
||||||
const updateInterfaceHandler = async () => {
|
const updateInterfaceHandler = async () => {
|
||||||
taskConfig = await updateTaskConfig(localStorage.token, taskConfig);
|
taskConfig = await updateTaskConfig(localStorage.token, taskConfig);
|
||||||
@ -49,15 +69,21 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
taskConfig = await getTaskConfig(localStorage.token);
|
taskConfig = await getTaskConfig(localStorage.token);
|
||||||
|
promptSuggestions = $config?.default_prompt_suggestions ?? [];
|
||||||
|
|
||||||
promptSuggestions = $config?.default_prompt_suggestions ?? [];
|
while (!document.querySelector('.banners-sortable')) {
|
||||||
banners = await getBanners(localStorage.token);
|
await new Promise(resolve => globalThis.setTimeout(resolve, 100));
|
||||||
});
|
}
|
||||||
|
|
||||||
const updateBanners = async () => {
|
banners = await getBanners(localStorage.token);
|
||||||
_banners.set(await setBanners(localStorage.token, banners));
|
_banners.set(banners);
|
||||||
};
|
|
||||||
|
bannersSortable = new Sortable(document.querySelector('.banners-sortable'), {
|
||||||
|
handle: ".flex-1",
|
||||||
|
animation: 300,
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if taskConfig}
|
{#if taskConfig}
|
||||||
@ -321,12 +347,13 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class=" flex flex-col space-y-1">
|
<div class="banners-sortable">
|
||||||
{#each banners as banner, bannerIdx}
|
{#each banners as banner, bannerIdx}
|
||||||
<div class=" flex justify-between">
|
<div class=" flex justify-between">
|
||||||
<div
|
<div
|
||||||
class="flex flex-row flex-1 border rounded-xl border-gray-100 dark:border-gray-850"
|
class="flex flex-row flex-1 border rounded-xl border-gray-100 dark:border-gray-850"
|
||||||
>
|
>
|
||||||
|
<input type="hidden" name="id" value={banner.id} />
|
||||||
<select
|
<select
|
||||||
class="w-fit capitalize rounded-xl py-2 px-4 text-xs bg-transparent outline-hidden"
|
class="w-fit capitalize rounded-xl py-2 px-4 text-xs bg-transparent outline-hidden"
|
||||||
bind:value={banner.type}
|
bind:value={banner.type}
|
||||||
|
Loading…
Reference in New Issue
Block a user