2023-10-08 15:38:42 -07:00
|
|
|
<script lang="ts">
|
2024-03-03 00:08:51 +03:30
|
|
|
import { getContext } from 'svelte';
|
2024-03-01 10:18:07 +01:00
|
|
|
import { toast } from 'svelte-sonner';
|
2023-12-31 23:13:17 -08:00
|
|
|
|
2024-05-14 14:50:24 -10:00
|
|
|
import {
|
|
|
|
|
WEBUI_NAME,
|
|
|
|
|
chatId,
|
|
|
|
|
mobile,
|
|
|
|
|
settings,
|
2024-05-14 22:22:15 -10:00
|
|
|
showArchivedChats,
|
2024-09-17 22:05:19 +02:00
|
|
|
showControls,
|
2024-05-14 14:50:24 -10:00
|
|
|
showSidebar,
|
|
|
|
|
user
|
|
|
|
|
} from '$lib/stores';
|
2024-03-29 17:20:07 -07:00
|
|
|
|
|
|
|
|
import { slide } from 'svelte/transition';
|
2024-01-17 21:01:30 -08:00
|
|
|
import ShareChatModal from '../chat/ShareChatModal.svelte';
|
2024-03-29 17:20:07 -07:00
|
|
|
import ModelSelector from '../chat/ModelSelector.svelte';
|
|
|
|
|
import Tooltip from '../common/Tooltip.svelte';
|
|
|
|
|
import Menu from './Navbar/Menu.svelte';
|
2024-05-02 01:15:58 -07:00
|
|
|
import { page } from '$app/stores';
|
2024-05-14 14:50:24 -10:00
|
|
|
import UserMenu from './Sidebar/UserMenu.svelte';
|
2024-05-14 20:16:22 -10:00
|
|
|
import MenuLines from '../icons/MenuLines.svelte';
|
2024-07-08 16:55:12 -07:00
|
|
|
import AdjustmentsHorizontal from '../icons/AdjustmentsHorizontal.svelte';
|
2024-09-17 22:05:19 +02:00
|
|
|
import Map from '../icons/Map.svelte';
|
2023-10-18 22:57:55 -07:00
|
|
|
|
2024-03-03 00:08:51 +03:30
|
|
|
const i18n = getContext('i18n');
|
|
|
|
|
|
2023-12-26 03:28:30 -08:00
|
|
|
export let initNewChat: Function;
|
2024-02-23 17:12:19 -08:00
|
|
|
export let title: string = $WEBUI_NAME;
|
2023-12-14 01:05:38 -08:00
|
|
|
export let shareEnabled: boolean = false;
|
2023-12-14 16:50:54 -08:00
|
|
|
|
2024-04-03 19:30:25 -07:00
|
|
|
export let chat;
|
2024-03-29 17:20:07 -07:00
|
|
|
export let selectedModels;
|
2024-03-31 22:03:28 +01:00
|
|
|
export let showModelSelector = true;
|
2024-01-17 22:49:58 -08:00
|
|
|
|
2024-03-29 17:20:07 -07:00
|
|
|
let showShareChatModal = false;
|
2024-04-03 19:30:25 -07:00
|
|
|
let showDownloadChatModal = false;
|
2023-10-08 15:38:42 -07:00
|
|
|
</script>
|
|
|
|
|
|
2024-04-20 14:40:06 -05:00
|
|
|
<ShareChatModal bind:show={showShareChatModal} chatId={$chatId} />
|
2024-06-18 15:11:59 -07:00
|
|
|
<nav id="nav" class=" sticky py-2.5 top-0 flex flex-row justify-center z-10">
|
2024-05-14 12:09:30 -10:00
|
|
|
<div class=" flex max-w-full w-full mx-auto px-5 pt-0.5 md:px-[1rem]">
|
2024-03-29 17:20:07 -07:00
|
|
|
<div class="flex items-center w-full max-w-full">
|
2024-05-14 20:21:22 -10:00
|
|
|
<div
|
|
|
|
|
class="{$showSidebar
|
|
|
|
|
? 'md:hidden'
|
|
|
|
|
: ''} mr-3 self-start flex flex-none items-center text-gray-600 dark:text-gray-400"
|
|
|
|
|
>
|
2024-05-14 12:09:30 -10:00
|
|
|
<button
|
2024-05-14 12:17:56 -10:00
|
|
|
id="sidebar-toggle-button"
|
2024-07-08 20:17:09 -07:00
|
|
|
class="cursor-pointer px-2 py-2 flex rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
2024-05-14 12:09:30 -10:00
|
|
|
on:click={() => {
|
|
|
|
|
showSidebar.set(!$showSidebar);
|
|
|
|
|
}}
|
2024-08-25 23:43:28 +02:00
|
|
|
aria-label="Toggle Sidebar"
|
2024-05-14 12:09:30 -10:00
|
|
|
>
|
|
|
|
|
<div class=" m-auto self-center">
|
2024-05-14 20:16:22 -10:00
|
|
|
<MenuLines />
|
2024-05-14 12:09:30 -10:00
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2024-07-08 16:55:12 -07:00
|
|
|
|
2024-03-31 22:03:28 +01:00
|
|
|
<div class="flex-1 overflow-hidden max-w-full">
|
|
|
|
|
{#if showModelSelector}
|
2024-05-02 01:15:58 -07:00
|
|
|
<ModelSelector bind:selectedModels showSetDefault={!shareEnabled} />
|
2024-03-31 22:03:28 +01:00
|
|
|
{/if}
|
2024-03-29 17:20:07 -07:00
|
|
|
</div>
|
2024-01-17 21:01:30 -08:00
|
|
|
|
2024-05-14 20:21:22 -10:00
|
|
|
<div class="self-start flex flex-none items-center text-gray-600 dark:text-gray-400">
|
2024-05-14 12:09:30 -10:00
|
|
|
<!-- <div class="md:hidden flex self-center w-[1px] h-5 mx-2 bg-gray-300 dark:bg-stone-700" /> -->
|
2024-03-29 17:20:07 -07:00
|
|
|
|
2024-06-04 09:56:51 -07:00
|
|
|
{#if shareEnabled && chat && chat.id}
|
2024-03-29 17:20:07 -07:00
|
|
|
<Menu
|
2024-04-03 19:30:25 -07:00
|
|
|
{chat}
|
2024-03-29 17:20:07 -07:00
|
|
|
{shareEnabled}
|
|
|
|
|
shareHandler={() => {
|
|
|
|
|
showShareChatModal = !showShareChatModal;
|
|
|
|
|
}}
|
2024-04-03 19:30:25 -07:00
|
|
|
downloadHandler={() => {
|
|
|
|
|
showDownloadChatModal = !showDownloadChatModal;
|
|
|
|
|
}}
|
2024-03-29 17:20:07 -07:00
|
|
|
>
|
|
|
|
|
<button
|
2024-09-18 01:30:09 +02:00
|
|
|
class="flex cursor-pointer px-2 py-2 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
2024-05-14 15:14:47 +02:00
|
|
|
id="chat-context-menu-button"
|
2024-05-16 18:21:19 -10:00
|
|
|
>
|
2024-03-29 17:20:07 -07:00
|
|
|
<div class=" m-auto self-center">
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
fill="none"
|
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
stroke-width="1.5"
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
class="size-5"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
stroke-linecap="round"
|
|
|
|
|
stroke-linejoin="round"
|
|
|
|
|
d="M6.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM12.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0ZM18.75 12a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Z"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</Menu>
|
|
|
|
|
{/if}
|
2024-07-08 16:55:12 -07:00
|
|
|
|
2024-09-18 01:30:09 +02:00
|
|
|
{#if !$mobile}
|
|
|
|
|
<Tooltip content={$i18n.t('Controls')}>
|
|
|
|
|
<button
|
|
|
|
|
class=" flex cursor-pointer px-2 py-2 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
2024-09-21 03:33:06 +02:00
|
|
|
on:click={async () => {
|
|
|
|
|
await showControls.set(!$showControls);
|
2024-09-18 01:30:09 +02:00
|
|
|
}}
|
|
|
|
|
aria-label="Controls"
|
|
|
|
|
>
|
|
|
|
|
<div class=" m-auto self-center">
|
|
|
|
|
<AdjustmentsHorizontal className=" size-5" strokeWidth="0.5" />
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
{/if}
|
2024-07-08 16:55:12 -07:00
|
|
|
|
2024-04-28 14:39:06 +02:00
|
|
|
<Tooltip content={$i18n.t('New Chat')}>
|
2024-03-29 17:20:07 -07:00
|
|
|
<button
|
|
|
|
|
id="new-chat-button"
|
2024-05-14 12:11:57 -10:00
|
|
|
class=" flex {$showSidebar
|
|
|
|
|
? 'md:hidden'
|
2024-07-08 20:17:09 -07:00
|
|
|
: ''} cursor-pointer px-2 py-2 rounded-xl text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
2024-03-29 17:20:07 -07:00
|
|
|
on:click={() => {
|
|
|
|
|
initNewChat();
|
2023-12-14 01:05:38 -08:00
|
|
|
}}
|
2024-08-25 23:43:28 +02:00
|
|
|
aria-label="New Chat"
|
2023-10-08 15:38:42 -07:00
|
|
|
>
|
2023-12-14 01:05:38 -08:00
|
|
|
<div class=" m-auto self-center">
|
|
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
2024-03-29 17:20:07 -07:00
|
|
|
viewBox="0 0 20 20"
|
2023-12-14 01:05:38 -08:00
|
|
|
fill="currentColor"
|
2024-03-29 17:20:07 -07:00
|
|
|
class="w-5 h-5"
|
2023-12-14 01:05:38 -08:00
|
|
|
>
|
|
|
|
|
<path
|
2024-03-29 17:20:07 -07:00
|
|
|
d="M5.433 13.917l1.262-3.155A4 4 0 017.58 9.42l6.92-6.918a2.121 2.121 0 013 3l-6.92 6.918c-.383.383-.84.685-1.343.886l-3.154 1.262a.5.5 0 01-.65-.65z"
|
|
|
|
|
/>
|
|
|
|
|
<path
|
|
|
|
|
d="M3.5 5.75c0-.69.56-1.25 1.25-1.25H10A.75.75 0 0010 3H4.75A2.75 2.75 0 002 5.75v9.5A2.75 2.75 0 004.75 18h9.5A2.75 2.75 0 0017 15.25V10a.75.75 0 00-1.5 0v5.25c0 .69-.56 1.25-1.25 1.25h-9.5c-.69 0-1.25-.56-1.25-1.25v-9.5z"
|
2023-12-14 01:05:38 -08:00
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
2024-03-29 17:20:07 -07:00
|
|
|
</Tooltip>
|
2024-05-14 14:50:24 -10:00
|
|
|
|
2024-05-14 23:45:27 -10:00
|
|
|
{#if $user !== undefined}
|
2024-05-14 14:50:24 -10:00
|
|
|
<UserMenu
|
2024-05-14 23:45:27 -10:00
|
|
|
className="max-w-[200px]"
|
2024-05-14 14:50:24 -10:00
|
|
|
role={$user.role}
|
|
|
|
|
on:show={(e) => {
|
|
|
|
|
if (e.detail === 'archived-chat') {
|
2024-05-14 22:22:15 -10:00
|
|
|
showArchivedChats.set(true);
|
2024-05-14 14:50:24 -10:00
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<button
|
2024-07-08 20:17:09 -07:00
|
|
|
class="select-none flex rounded-xl p-1.5 w-full hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
2024-05-15 23:49:26 +08:00
|
|
|
aria-label="User Menu"
|
2024-05-14 14:50:24 -10:00
|
|
|
>
|
|
|
|
|
<div class=" self-center">
|
|
|
|
|
<img
|
|
|
|
|
src={$user.profile_image_url}
|
2024-05-18 14:04:35 -07:00
|
|
|
class="size-6 object-cover rounded-full"
|
2024-05-14 14:50:24 -10:00
|
|
|
alt="User profile"
|
2024-05-18 14:04:35 -07:00
|
|
|
draggable="false"
|
2024-05-14 14:50:24 -10:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</UserMenu>
|
|
|
|
|
{/if}
|
2024-01-17 21:01:30 -08:00
|
|
|
</div>
|
2023-12-14 01:05:38 -08:00
|
|
|
</div>
|
2023-10-08 15:38:42 -07:00
|
|
|
</div>
|
2023-12-14 01:05:38 -08:00
|
|
|
</nav>
|