2022-12-09 15:51:42 -05:00
|
|
|
<script lang="ts">
|
2023-03-05 15:03:51 +01:00
|
|
|
// DO NOT include `import { page } from '$app/stores'` here, because this can
|
|
|
|
|
// lead to pages not being unmounted, which then causes weird page nesting
|
|
|
|
|
// and routing issues.
|
|
|
|
|
//
|
|
|
|
|
// This is an issue in SvelteKit caused by using the page store in layouts and
|
|
|
|
|
// using transitions on pages: https://github.com/sveltejs/kit/issues/7405
|
|
|
|
|
|
2022-12-09 15:51:42 -05:00
|
|
|
import SideBarButton from '$lib/components/shared-components/side-bar/side-bar-button.svelte';
|
|
|
|
|
import AccountMultipleOutline from 'svelte-material-icons/AccountMultipleOutline.svelte';
|
|
|
|
|
import Sync from 'svelte-material-icons/Sync.svelte';
|
|
|
|
|
import Cog from 'svelte-material-icons/Cog.svelte';
|
|
|
|
|
import Server from 'svelte-material-icons/Server.svelte';
|
|
|
|
|
import StatusBox from '$lib/components/shared-components/status-box.svelte';
|
|
|
|
|
import { goto } from '$app/navigation';
|
|
|
|
|
import { AppRoute } from '../../lib/constants';
|
2023-03-05 15:03:51 +01:00
|
|
|
import type { LayoutData } from './$types';
|
2023-04-15 03:41:52 +02:00
|
|
|
import SideBarSection from '$lib/components/shared-components/side-bar/side-bar-section.svelte';
|
2023-05-23 20:02:12 -04:00
|
|
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
2023-03-05 15:03:51 +01:00
|
|
|
|
|
|
|
|
export let data: LayoutData;
|
2022-12-09 15:51:42 -05:00
|
|
|
|
2023-03-05 15:03:51 +01:00
|
|
|
// Circumvents the need to import the page store. Should be replaced by
|
|
|
|
|
// `$page.data.meta.title` once issue #7405 of SvelteKit is resolved.
|
2022-12-09 15:51:42 -05:00
|
|
|
const getPageTitle = (routeId: string | null) => {
|
|
|
|
|
switch (routeId) {
|
|
|
|
|
case AppRoute.ADMIN_USER_MANAGEMENT:
|
|
|
|
|
return 'User Management';
|
|
|
|
|
case AppRoute.ADMIN_SETTINGS:
|
2022-12-17 16:08:18 -06:00
|
|
|
return 'System Settings';
|
2022-12-09 15:51:42 -05:00
|
|
|
case AppRoute.ADMIN_JOBS:
|
|
|
|
|
return 'Jobs';
|
|
|
|
|
case AppRoute.ADMIN_STATS:
|
|
|
|
|
return 'Server Stats';
|
|
|
|
|
default:
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
2023-05-23 20:02:12 -04:00
|
|
|
<UserPageLayout user={data.user} showUploadButton={false} title={getPageTitle(data.routeId)}>
|
|
|
|
|
<SideBarSection slot="sidebar">
|
|
|
|
|
<SideBarButton
|
|
|
|
|
title="Users"
|
|
|
|
|
logo={AccountMultipleOutline}
|
|
|
|
|
isSelected={data.routeId === AppRoute.ADMIN_USER_MANAGEMENT}
|
|
|
|
|
on:selected={() => goto(AppRoute.ADMIN_USER_MANAGEMENT)}
|
|
|
|
|
/>
|
|
|
|
|
<SideBarButton
|
|
|
|
|
title="Jobs"
|
|
|
|
|
logo={Sync}
|
|
|
|
|
isSelected={data.routeId === AppRoute.ADMIN_JOBS}
|
|
|
|
|
on:selected={() => goto(AppRoute.ADMIN_JOBS)}
|
|
|
|
|
/>
|
|
|
|
|
<SideBarButton
|
|
|
|
|
title="Settings"
|
|
|
|
|
logo={Cog}
|
|
|
|
|
isSelected={data.routeId === AppRoute.ADMIN_SETTINGS}
|
|
|
|
|
on:selected={() => goto(AppRoute.ADMIN_SETTINGS)}
|
|
|
|
|
/>
|
|
|
|
|
<SideBarButton
|
|
|
|
|
title="Server Stats"
|
|
|
|
|
logo={Server}
|
|
|
|
|
isSelected={data.routeId === AppRoute.ADMIN_STATS}
|
|
|
|
|
on:selected={() => goto(AppRoute.ADMIN_STATS)}
|
|
|
|
|
/>
|
|
|
|
|
<div class="mb-6 mt-auto">
|
|
|
|
|
<StatusBox />
|
|
|
|
|
</div>
|
|
|
|
|
</SideBarSection>
|
2022-12-09 15:51:42 -05:00
|
|
|
|
2023-05-23 20:02:12 -04:00
|
|
|
<section id="setting-content" class="flex place-content-center mx-4">
|
|
|
|
|
<section class="w-full sm:w-5/6 md:w-[800px] pt-5 pb-28">
|
|
|
|
|
<slot />
|
2022-12-09 15:51:42 -05:00
|
|
|
</section>
|
|
|
|
|
</section>
|
2023-05-23 20:02:12 -04:00
|
|
|
</UserPageLayout>
|