Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
323b9adc
"src/git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "df2cb1608652fb8d4c4fb41d405e39eaa2f51d35"
Commit
323b9adc
authored
Apr 16, 2024
by
Timothy J. Baek
Browse files
feat: chat menu tag
parent
3488b7f0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
1 deletion
+67
-1
src/lib/components/chat/Tags.svelte
src/lib/components/chat/Tags.svelte
+52
-0
src/lib/components/common/Dropdown.svelte
src/lib/components/common/Dropdown.svelte
+2
-0
src/lib/components/layout/Sidebar.svelte
src/lib/components/layout/Sidebar.svelte
+1
-0
src/lib/components/layout/Sidebar/ChatMenu.svelte
src/lib/components/layout/Sidebar/ChatMenu.svelte
+12
-1
No files found.
src/lib/components/chat/Tags.svelte
0 → 100644
View file @
323b9adc
<script>
import {
addTagById,
deleteTagById,
getAllChatTags,
getTagsById,
updateChatById
} from '$lib/apis/chats';
import { tags as _tags } from '$lib/stores';
import { onMount } from 'svelte';
import Tags from '../common/Tags.svelte';
export let chatId = '';
let tags = [];
const getTags = async () => {
return await getTagsById(localStorage.token, chatId).catch(async (error) => {
return [];
});
};
const addTag = async (tagName) => {
const res = await addTagById(localStorage.token, chatId, tagName);
tags = await getTags();
await updateChatById(localStorage.token, chatId, {
tags: tags
});
_tags.set(await getAllChatTags(localStorage.token));
};
const deleteTag = async (tagName) => {
const res = await deleteTagById(localStorage.token, chatId, tagName);
tags = await getTags();
await updateChatById(localStorage.token, chatId, {
tags: tags
});
_tags.set(await getAllChatTags(localStorage.token));
};
onMount(async () => {
if (chatId) {
tags = await getTags();
}
});
</script>
<Tags {tags} {deleteTag} {addTag} />
src/lib/components/common/Dropdown.svelte
View file @
323b9adc
...
@@ -4,10 +4,12 @@
...
@@ -4,10 +4,12 @@
import { flyAndScale } from '$lib/utils/transitions';
import { flyAndScale } from '$lib/utils/transitions';
export let show = false;
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher();
</script>
</script>
<DropdownMenu.Root
<DropdownMenu.Root
bind:open={show}
onOpenChange={(state) => {
onOpenChange={(state) => {
dispatch('change', state);
dispatch('change', state);
}}
}}
...
...
src/lib/components/layout/Sidebar.svelte
View file @
323b9adc
...
@@ -538,6 +538,7 @@
...
@@ -538,6 +538,7 @@
{:else}
{:else}
<div class="flex self-center space-x-1.5 z-10">
<div class="flex self-center space-x-1.5 z-10">
<ChatMenu
<ChatMenu
chatId={chat.id}
renameHandler={() => {
renameHandler={() => {
chatTitle = chat.title;
chatTitle = chat.title;
chatTitleEditId = chat.id;
chatTitleEditId = chat.id;
...
...
src/lib/components/layout/Sidebar/ChatMenu.svelte
View file @
323b9adc
...
@@ -6,14 +6,19 @@
...
@@ -6,14 +6,19 @@
import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
import Pencil from '$lib/components/icons/Pencil.svelte';
import Pencil from '$lib/components/icons/Pencil.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Tags from '$lib/components/chat/Tags.svelte';
export let renameHandler: Function;
export let renameHandler: Function;
export let deleteHandler: Function;
export let deleteHandler: Function;
export let onClose: Function;
export let onClose: Function;
export let chatId = '';
let show = false;
</script>
</script>
<Dropdown
<Dropdown
bind:show
on:change={(e) => {
on:change={(e) => {
if (e.detail === false) {
if (e.detail === false) {
onClose();
onClose();
...
@@ -51,6 +56,12 @@
...
@@ -51,6 +56,12 @@
<GarbageBin strokeWidth="2" />
<GarbageBin strokeWidth="2" />
<div class="flex items-center">Delete</div>
<div class="flex items-center">Delete</div>
</DropdownMenu.Item>
</DropdownMenu.Item>
<hr class="border-gray-100 dark:border-gray-800 mt-2.5 mb-1.5" />
<div class="flex p-1">
<Tags {chatId} />
</div>
</DropdownMenu.Content>
</DropdownMenu.Content>
</div>
</div>
</Dropdown>
</Dropdown>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment