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

91 lines
2.6 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
2025-02-06 09:07:01 +00:00
class=" flex flex-col w-full h-screen max-h-[100dvh] transition-width duration-200 ease-in-out {$showSidebar
? 'md:max-w-[calc(100%-260px)]'
2025-01-14 03:18:32 +00:00
: ''} max-w-full"
>
2025-01-14 02:19:46 +00:00
<nav class=" px-2.5 pt-1 backdrop-blur-xl drag-region">
<div class=" flex items-center gap-1">
2025-01-14 03:18:32 +00:00
<div class="{$showSidebar ? 'md:hidden' : ''} flex flex-none items-center self-end">
<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-18 14:38:29 +00:00
class="flex gap-1 scrollbar-none overflow-x-auto w-fit text-center text-sm font-medium rounded-full bg-transparent pt-1"
2024-10-14 19:46:05 +00:00
>
<a
2024-11-13 05:51:42 +00:00
class="min-w-fit rounded-full p-1.5 {['/admin/users'].includes($page.url.pathname)
2024-11-07 05:13:37 +00:00
? ''
2024-11-11 21:56:33 +00:00
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
2024-11-13 05:51:42 +00:00
href="/admin">{$i18n.t('Users')}</a
2024-10-14 19:46:05 +00:00
>
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')
? ''
2024-11-11 21:56:33 +00:00
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
2024-10-22 10:16:48 +00:00
href="/admin/evaluations">{$i18n.t('Evaluations')}</a
>
<a
class="min-w-fit rounded-full p-1.5 {$page.url.pathname.includes('/admin/functions')
? ''
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
href="/admin/functions">{$i18n.t('Functions')}</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')
? ''
2024-11-11 21:56:33 +00:00
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
2024-10-14 19:46:05 +00:00
href="/admin/settings">{$i18n.t('Settings')}</a
>
</div>
</div>
</div>
2025-01-14 02:19:46 +00:00
</nav>
2024-05-26 09:43:52 +00:00
2024-11-07 06:52:06 +00:00
<div class=" pb-1 px-[16px] flex-1 max-h-full overflow-y-auto">
<slot />
</div>
2024-05-26 09:43:52 +00:00
</div>
{/if}