open-webui/src/routes/(app)/admin/+layout.svelte

86 lines
2.2 KiB
Svelte
Raw Normal View History

2024-05-26 09:43:52 +00:00
<script lang="ts">
import { onMount, getContext } from 'svelte';
import { goto } from '$app/navigation';
2024-05-26 09:43:52 +00:00
import { WEBUI_NAME, showSidebar, user } from '$lib/stores';
2024-05-26 09:43:52 +00:00
import MenuLines from '$lib/components/icons/MenuLines.svelte';
import { page } from '$app/stores';
const i18n = getContext('i18n');
let loaded = false;
onMount(async () => {
if ($user?.role !== 'admin') {
await goto('/');
}
loaded = true;
});
2024-05-26 09:43:52 +00:00
</script>
<svelte:head>
<title>
{$i18n.t('Admin Panel')} | {$WEBUI_NAME}
</title>
</svelte:head>
{#if loaded}
<div
class=" flex flex-col w-full min-h-screen max-h-screen {$showSidebar
? 'md:max-w-[calc(100%-260px)]'
: ''}"
>
2024-11-07 05:13:37 +00:00
<div class=" px-3.5 pt-1.5">
<div class=" flex items-center gap-1">
2024-11-07 05:13:37 +00:00
<div class="{$showSidebar ? 'md:hidden' : ''} flex flex-none items-center">
<button
id="sidebar-toggle-button"
2024-10-14 19:46:05 +00:00
class="cursor-pointer p-1.5 flex rounded-xl hover:bg-gray-100 dark:hover:bg-gray-850 transition"
on:click={() => {
showSidebar.set(!$showSidebar);
}}
aria-label="Toggle Sidebar"
>
<div class=" m-auto self-center">
<MenuLines />
</div>
</button>
</div>
2024-05-26 09:43:52 +00:00
2024-10-14 19:46:05 +00:00
<div class=" flex w-full">
<div
2024-11-07 05:45:48 +00:00
class="flex gap-1 scrollbar-none overflow-x-auto w-fit text-center text-sm font-medium rounded-full bg-transparent py-1"
2024-10-14 19:46:05 +00:00
>
<a
2024-11-07 05:13:37 +00:00
class="min-w-fit rounded-full p-1.5 {['/admin', '/admin/'].includes(
2024-10-14 19:46:05 +00:00
$page.url.pathname
)
2024-11-07 05:13:37 +00:00
? ''
: 'text-gray-300 dark:text-gray-600'} transition"
2024-10-14 19:46:05 +00:00
href="/admin">{$i18n.t('Dashboard')}</a
>
2024-05-26 09:43:52 +00:00
2024-10-22 10:16:48 +00:00
<a
2024-11-07 05:13:37 +00:00
class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/admin/evaluations')
? ''
: 'text-gray-300 dark:text-gray-600'} transition"
2024-10-22 10:16:48 +00:00
href="/admin/evaluations">{$i18n.t('Evaluations')}</a
>
2024-10-14 19:46:05 +00:00
<a
2024-11-07 05:13:37 +00:00
class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/admin/settings')
? ''
: 'text-gray-300 dark:text-gray-600'} transition"
2024-10-14 19:46:05 +00:00
href="/admin/settings">{$i18n.t('Settings')}</a
>
</div>
</div>
</div>
2024-05-26 09:43:52 +00:00
</div>
2024-10-21 01:54:08 +00:00
<div class=" pb-1 px-[18px] flex-1 max-h-full overflow-y-auto">
<slot />
</div>
2024-05-26 09:43:52 +00:00
</div>
{/if}