2024-05-26 09:43:52 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { onMount, getContext } from 'svelte';
|
2024-08-02 16:08:23 +00:00
|
|
|
import { goto } from '$app/navigation';
|
2024-05-26 09:43:52 +00:00
|
|
|
|
2025-08-07 23:53:09 +00:00
|
|
|
import { WEBUI_NAME, mobile, showSidebar, user } from '$lib/stores';
|
2024-05-26 09:43:52 +00:00
|
|
|
import { page } from '$app/stores';
|
2025-08-06 23:35:12 +00:00
|
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
2025-08-08 10:04:44 +00:00
|
|
|
|
2025-08-06 23:35:12 +00:00
|
|
|
import Sidebar from '$lib/components/icons/Sidebar.svelte';
|
2024-05-26 09:43:52 +00:00
|
|
|
|
|
|
|
|
const i18n = getContext('i18n');
|
2024-08-02 16:08:23 +00:00
|
|
|
|
|
|
|
|
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>
|
2025-05-01 12:39:36 +00:00
|
|
|
{$i18n.t('Admin Panel')} • {$WEBUI_NAME}
|
2024-05-26 09:43:52 +00:00
|
|
|
</title>
|
|
|
|
|
</svelte:head>
|
|
|
|
|
|
2024-08-02 16:08:23 +00:00
|
|
|
{#if loaded}
|
|
|
|
|
<div
|
2025-08-08 08:07:15 +00:00
|
|
|
class=" flex flex-col h-screen max-h-[100dvh] flex-1 transition-width duration-200 ease-in-out {$showSidebar
|
2024-08-02 16:08:23 +00:00
|
|
|
? 'md:max-w-[calc(100%-260px)]'
|
2025-08-08 08:07:15 +00:00
|
|
|
: ' md:max-w-[calc(100%-49px)]'} w-full max-w-full"
|
2024-08-02 16:08:23 +00:00
|
|
|
>
|
2025-08-06 23:35:12 +00:00
|
|
|
<nav class=" px-2.5 pt-1.5 backdrop-blur-xl drag-region">
|
2024-08-02 16:08:23 +00:00
|
|
|
<div class=" flex items-center gap-1">
|
2025-08-07 23:53:09 +00:00
|
|
|
{#if $mobile}
|
|
|
|
|
<div class="{$showSidebar ? 'md:hidden' : ''} flex flex-none items-center self-end">
|
2025-08-08 10:04:44 +00:00
|
|
|
<Tooltip
|
|
|
|
|
content={$showSidebar ? $i18n.t('Close Sidebar') : $i18n.t('Open Sidebar')}
|
|
|
|
|
interactive={true}
|
|
|
|
|
>
|
2025-08-07 23:53:09 +00:00
|
|
|
<button
|
|
|
|
|
id="sidebar-toggle-button"
|
|
|
|
|
class=" cursor-pointer flex rounded-lg hover:bg-gray-100 dark:hover:bg-gray-850 transition cursor-"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
showSidebar.set(!$showSidebar);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class=" self-center p-1.5">
|
|
|
|
|
<Sidebar />
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
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
|
2025-07-03 14:13:23 +00:00
|
|
|
class="min-w-fit p-1.5 {$page.url.pathname.includes('/admin/users')
|
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
|
|
|
|
2025-08-05 18:28:16 +00:00
|
|
|
<!-- <a
|
|
|
|
|
class="min-w-fit p-1.5 {$page.url.pathname.includes('/admin/analytics')
|
|
|
|
|
? ''
|
|
|
|
|
: 'text-gray-300 dark:text-gray-600 hover:text-gray-700 dark:hover:text-white'} transition"
|
|
|
|
|
href="/admin/analytics">{$i18n.t('Analytics')}</a
|
|
|
|
|
> -->
|
|
|
|
|
|
2024-10-22 10:16:48 +00:00
|
|
|
<a
|
2025-07-03 14:13:23 +00:00
|
|
|
class="min-w-fit p-1.5 {$page.url.pathname.includes('/admin/evaluations')
|
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-10-22 10:16:48 +00:00
|
|
|
href="/admin/evaluations">{$i18n.t('Evaluations')}</a
|
|
|
|
|
>
|
|
|
|
|
|
2024-11-15 02:32:23 +00:00
|
|
|
<a
|
2025-07-03 14:13:23 +00:00
|
|
|
class="min-w-fit p-1.5 {$page.url.pathname.includes('/admin/functions')
|
2024-11-15 02:32:23 +00:00
|
|
|
? ''
|
|
|
|
|
: '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
|
2025-07-03 14:13:23 +00:00
|
|
|
class="min-w-fit p-1.5 {$page.url.pathname.includes('/admin/settings')
|
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-10-14 19:46:05 +00:00
|
|
|
href="/admin/settings">{$i18n.t('Settings')}</a
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-08-02 16:08:23 +00:00
|
|
|
</div>
|
2025-01-14 02:19:46 +00:00
|
|
|
</nav>
|
2024-05-26 09:43:52 +00:00
|
|
|
|
2025-09-16 20:47:43 +00:00
|
|
|
<div class=" pb-1 flex-1 max-h-full overflow-y-auto">
|
2024-08-02 16:08:23 +00:00
|
|
|
<slot />
|
|
|
|
|
</div>
|
2024-05-26 09:43:52 +00:00
|
|
|
</div>
|
2024-08-02 16:08:23 +00:00
|
|
|
{/if}
|