Skip to content

A self-hosted media server and file management system

feat: add drawer nav for settings and dashboard

aminnausina57f704b3113
diff --git a/resources/js/components/drawers/DashboardSidebarDrawer.vue b/resources/js/components/drawers/DashboardSidebarDrawer.vue
new file mode 100644
index 00000000..d4c05a3f
--- /dev/null
+++ b/resources/js/components/drawers/DashboardSidebarDrawer.vue
@@ -0,0 +1,22 @@
+<script setup lang="ts">
+import { BaseDrawer } from '@/components/cedar-ui/drawer';
+import { useDrawer } from '@aminnausin/cedar-ui';
+import { useRoute } from 'vue-router';
+import { watch } from 'vue';
+
+import DashboardSidebar from '@/components/panels/DashboardSidebar.vue';
+
+const drawer = useDrawer();
+const route = useRoute();
+
+watch(
+ () => route.fullPath,
+ () => drawer.close('programmatic'),
+);
+</script>
+
+<template>
+ <BaseDrawer>
+ <DashboardSidebar />
+ </BaseDrawer>
+</template>
diff --git a/resources/js/components/drawers/SettingsSidebarDrawer.vue b/resources/js/components/drawers/SettingsSidebarDrawer.vue
new file mode 100644
index 00000000..d4cf0132
--- /dev/null
+++ b/resources/js/components/drawers/SettingsSidebarDrawer.vue
@@ -0,0 +1,22 @@
+<script setup lang="ts">
+import { BaseDrawer } from '@/components/cedar-ui/drawer';
+import { useDrawer } from '@aminnausin/cedar-ui';
+import { useRoute } from 'vue-router';
+import { watch } from 'vue';
+
+import SettingsSidebar from '@/components/panels/SettingsSidebar.vue';
+
+const drawer = useDrawer();
+const route = useRoute();
+
+watch(
+ () => route.fullPath,
+ () => drawer.close('programmatic'),
+);
+</script>
+
+<template>
+ <BaseDrawer>
+ <SettingsSidebar />
+ </BaseDrawer>
+</template>
diff --git a/resources/js/components/panels/DashboardSidebar.vue b/resources/js/components/panels/DashboardSidebar.vue
new file mode 100644
index 00000000..c6126b74
--- /dev/null
+++ b/resources/js/components/panels/DashboardSidebar.vue
@@ -0,0 +1,51 @@
+<script setup lang="ts">
+import { useDashboardTabs } from './DashboardTabs';
+import { cn } from '@aminnausin/cedar-ui';
+
+import DashboardSidebarCard from '@/components/cards/sidebar/DashboardSidebarCard.vue';
+import AppManifestCard from '@/components/cards/data/AppManifestCard.vue';
+import SidebarHeader from '@/components/headers/SidebarHeader.vue';
+
+import ProiconsSettings from '~icons/proicons/settings';
+
+const { dashboardTabs, activeDashboardTab } = useDashboardTabs();
+</script>
+
+<template>
+ <SidebarHeader />
+
+ <div class="flex flex-1 flex-col gap-2">
+ <DashboardSidebarCard
+ v-for="(tab, index) in dashboardTabs.filter((tab) => !tab.disabled)"
+ :key="index"
+ :to="tab.disabled ? '' : `/dashboard/${tab.name}`"
+ :class="cn({ 'hover:ring-primary/90 ring-2': activeDashboardTab?.name === tab.name })"
+ @click="activeDashboardTab = tab"
+ :aria-disabled="tab.disabled"
+ >
+ <template #header>
+ <h3 class="line-clamp-1 w-full flex-1" :title="tab.title ?? tab.name">{{ tab.title ?? tab.name }}</h3>
+ <component v-if="tab.icon" :is="tab.icon" class="ml-auto size-6" />
+ </template>
+ <template #body>
+ <h4 v-if="tab.description" title="Description" class="w-full flex-1 truncate text-wrap sm:text-nowrap">
+ {{ tab.description }}
+ </h4>
+ <h4 v-if="tab.info" title="Information" class="w-fit truncate text-nowrap sm:text-right">
+ {{ tab.info.value }}
+ </h4>
+ </template>
+ </DashboardSidebarCard>
+
+ <DashboardSidebarCard :to="`/settings`" :aria-disabled="false">
+ <template #header>
+ <h3 :title="'Settings'">Settings</h3>
+ <ProiconsSettings class="ml-auto size-6" />
+ </template>
+ <template #body>
+ <h4 title="Description" class="w-full flex-1 truncate text-wrap sm:text-nowrap">Configurable Options</h4>
+ </template>
+ </DashboardSidebarCard>
+ <AppManifestCard />
+ </div>
+</template>
diff --git a/resources/js/components/panels/DashboardTabs.ts b/resources/js/components/panels/DashboardTabs.ts
new file mode 100644
index 00000000..bbb1f6d3
--- /dev/null
+++ b/resources/js/components/panels/DashboardTabs.ts
@@ -0,0 +1,84 @@
+import type { SidebarTabItem } from '@/types/types';
+
+import { computed, ref, watch } from 'vue';
+import { useDashboardStore } from '@/stores/DashboardStore';
+import { useAuthStore } from '@/stores/AuthStore';
+import { storeToRefs } from 'pinia';
+import { useAppStore } from '@/stores/AppStore';
+import { useRoute } from 'vue-router';
+
+import ProiconsLibrary from '~icons/proicons/library';
+import ProiconsGraph from '~icons/proicons/graph';
+import CircumServer from '~icons/circum/server';
+import LucideUsers from '~icons/lucide/users';
+
+export function useDashboardTabs() {
+ const { stateTaskStats, stateTotalLibrariesSize, stateLibraryId, stateActiveSessions } = storeToRefs(useDashboardStore());
+
+ const { userData } = storeToRefs(useAuthStore());
+ const { pageTitle } = storeToRefs(useAppStore());
+
+ const route = useRoute();
+
+ const dashboardTab = ref<{ name: string; title?: string; icon?: any }>();
+ const dashboardTabs = computed<SidebarTabItem[]>(() => {
+ return [
+ {
+ name: 'overview',
+ title: 'Analytics',
+ description: 'Website Overview',
+ icon: ProiconsGraph,
+ },
+ {
+ name: 'libraries',
+ title: 'Content Libraries',
+ info: { value: `Total Size: ${stateTotalLibrariesSize?.value ?? '?'}` },
+ icon: ProiconsLibrary,
+ },
+ // {
+ // name: 'activity',
+ // description: '',
+ // info: { value: 'Logged Events: 686' },
+ // icon: ProiconsHistory,
+ // },
+ {
+ name: 'users',
+ title: 'User Management',
+ info: { value: `Logged In: ${stateActiveSessions?.value ?? '?'}` },
+ icon: LucideUsers,
+ },
+ {
+ name: 'tasks',
+ title: 'Task Management',
+ info: { value: `Currently Running: ${stateTaskStats.value?.count_running ?? '?'}` },
+ icon: CircumServer,
+ disabled: userData.value?.id !== 1,
+ },
+ ];
+ });
+
+ watch(
+ () => route?.params?.tab,
+ (URL_TAB) => {
+ if (!URL_TAB) return;
+ const defaultTab = dashboardTabs.value.find((tab) => tab.title === URL_TAB || tab.name === URL_TAB) ?? dashboardTabs.value[0];
+
+ pageTitle.value = defaultTab.title ?? defaultTab.name;
+ dashboardTab.value = defaultTab;
+ },
+ { immediate: true },
+ );
+
+ watch(
+ () => dashboardTab.value,
+ () => {
+ stateLibraryId.value = -1;
+ if (!dashboardTab.value) return;
+ pageTitle.value = dashboardTab.value.title ?? dashboardTab.value.name;
+ },
+ );
+ return {
+ dashboardTabs,
+ activeDashboardTab: dashboardTab,
+ };
+}
diff --git a/resources/js/components/panels/NavBar.vue b/resources/js/components/panels/NavBar.vue
index 33177fc5..b1d8952b 100755
--- a/resources/js/components/panels/NavBar.vue
+++ b/resources/js/components/panels/NavBar.vue
@@ -9,6 +9,8 @@ import { storeToRefs } from 'pinia';
import { drawer } from '@aminnausin/cedar-ui';
import { ref } from 'vue';
+import DashboardSidebarDrawer from '@/components/drawers/DashboardSidebarDrawer.vue';
+import SettingsSidebarDrawer from '@/components/drawers/SettingsSidebarDrawer.vue';
import VideoSidebarDrawer from '@/components/drawers/VideoSidebarDrawer.vue';
import ToggleLightMode from '@/components/inputs/ToggleLightMode.vue';
@@ -44,6 +46,25 @@ const toggleVideoSidebar = (sidebar: 'folders' | 'history') => {
});
}
};
+
+// Hardcoded could be much better elsewhere
+const toggleLeftSidebar = (sidebar: 'dashboard' | 'settings') => {
+ cycleSideBar(sidebar, 'left-card', false);
+
+ if (selectedSideBar.value !== sidebar) return;
+
+ const screenSize = getScreenSize();
+ const SidebarComponent = sidebar === 'dashboard' ? DashboardSidebarDrawer : SettingsSidebarDrawer;
+ if (screenSize === 'default' || screenSize === 'sm') {
+ drawer.open(SidebarComponent, {
+ showHeader: false,
+ showFooter: false,
+ onClose: () => {
+ cycleSideBar(sidebar, 'left-card');
+ },
+ });
+ }
+};
</script>
<template>
@@ -106,7 +127,7 @@ const toggleVideoSidebar = (sidebar: 'folders' | 'history') => {
</NavButton>
<NavButton
v-if="$route.name === 'dashboard'"
- @click="cycleSideBar('dashboard', 'left-card')"
+ @click="toggleLeftSidebar('dashboard')"
:label="'dashboard'"
:active="selectedSideBar === 'dashboard'"
title="Toggle Dashboard Menu"
@@ -116,7 +137,7 @@ const toggleVideoSidebar = (sidebar: 'folders' | 'history') => {
</NavButton>
<NavButton
v-if="$route.name === 'settings' || $route.name === 'preferences'"
- @click="cycleSideBar('settings', 'left-card')"
+ @click="toggleLeftSidebar('settings')"
:label="'settings'"
:active="selectedSideBar === 'settings'"
title="Toggle Settings Menu"
diff --git a/resources/js/components/panels/SettingsSidebar.vue b/resources/js/components/panels/SettingsSidebar.vue
new file mode 100644
index 00000000..d39ce6cf
--- /dev/null
+++ b/resources/js/components/panels/SettingsSidebar.vue
@@ -0,0 +1,48 @@
+<script setup lang="ts">
+import { useSettingsTabs } from '@/components/panels/SettingsTabs';
+
+import DashboardSidebarCard from '@/components/cards/sidebar/DashboardSidebarCard.vue';
+import AppManifestCard from '@/components/cards/data/AppManifestCard.vue';
+import SidebarHeader from '@/components/headers/SidebarHeader.vue';
+
+import CircumGrid31 from '~icons/circum/grid-3-1';
+
+const { settingsTabs, activeSettingsTab } = useSettingsTabs();
+</script>
+
+<template>
+ <SidebarHeader />
+ <div class="flex flex-1 flex-col gap-2">
+ <DashboardSidebarCard
+ v-for="(tab, index) in settingsTabs.filter((tab) => !tab.disabled)"
+ :key="index"
+ :to="tab.disabled ? '' : `/settings/${tab.name}`"
+ :class="[{ 'ring-2': activeSettingsTab?.name == tab.name }]"
+ @click="activeSettingsTab = tab"
+ :disabled="tab.disabled"
+ >
+ <template #header>
+ <h3 class="line-clamp-1 w-full flex-1" :title="tab.title ?? tab.name">{{ tab.title ?? tab.name }}</h3>
+ <component v-if="tab.icon" :is="tab.icon" class="ml-auto size-6" />
+ </template>
+ <template #body>
+ <h4 v-if="tab.description" title="Description" class="w-full flex-1 truncate text-wrap sm:text-nowrap">
+ {{ tab.description }}
+ </h4>
+ <h4 v-if="tab.info" title="Information" class="w-fit truncate text-nowrap sm:text-right">
+ {{ tab.info.value }}
+ </h4>
+ </template>
+ </DashboardSidebarCard>
+ <DashboardSidebarCard :to="`/dashboard`">
+ <template #header>
+ <h3 :title="'Dashboard'">Dashboard</h3>
+ <CircumGrid31 class="ml-auto size-6" />
+ </template>
+ <template #body>
+ <h4 title="App Dashboard" class="w-full flex-1 truncate text-wrap sm:text-nowrap">Server Analytics</h4>
+ </template>
+ </DashboardSidebarCard>
+ <AppManifestCard />
+ </div>
+</template>
diff --git a/resources/js/components/panels/SettingsTabs.ts b/resources/js/components/panels/SettingsTabs.ts
new file mode 100644
index 00000000..ac1c7783
--- /dev/null
+++ b/resources/js/components/panels/SettingsTabs.ts
@@ -0,0 +1,73 @@
+import type { SidebarTabItem } from '@/types/types';
+
+import { computed, ref, watch } from 'vue';
+import { useAuthStore } from '@/stores/AuthStore';
+import { useAppStore } from '@/stores/AppStore';
+import { storeToRefs } from 'pinia';
+import { useRoute } from 'vue-router';
+
+import ProiconsSettings from '~icons/proicons/settings';
+import LucideUser from '~icons/lucide/user';
+
+export function useSettingsTabs() {
+ const { userData } = storeToRefs(useAuthStore());
+ const { pageTitle } = storeToRefs(useAppStore());
+
+ const route = useRoute();
+ const dev = true;
+
+ const settingsTab = ref<{ name: string; title?: string; icon?: any }>();
+ const settingsTabs = computed<SidebarTabItem[]>(() => {
+ return [
+ {
+ name: 'preferences',
+ title: 'Preferences',
+ description: 'Website Preferences', // Remember Volume, Ambient Mode, Playback Heatmap, Opt out of things?
+ icon: ProiconsSettings,
+ },
+ {
+ name: 'account',
+ title: 'Account',
+ description: 'Account Settings', // Email Password Sessions
+ disabled: !userData.value,
+ icon: LucideUser,
+ },
+ {
+ name: 'profile',
+ title: 'Profile',
+ description: 'Profile Settings', // Visibility, Avatar, Banner
+ disabled: dev || !userData.value,
+ },
+ {
+ name: 'server',
+ title: 'Server',
+ description: 'Server Settings', // Disable features
+ disabled: dev || !userData.value || userData.value?.id !== 1,
+ },
+ ];
+ });
+
+ watch(
+ () => route?.params?.tab,
+ (URL_TAB) => {
+ if (!URL_TAB) return;
+ const defaultTab = settingsTabs.value.find((tab) => tab.title === URL_TAB || tab.name === URL_TAB) ?? settingsTabs.value[0];
+
+ pageTitle.value = defaultTab.title ?? defaultTab.name;
+ settingsTab.value = defaultTab;
+ },
+ { immediate: true },
+ );
+
+ watch(
+ () => settingsTab.value,
+ () => {
+ if (!settingsTab.value) return;
+ pageTitle.value = settingsTab.value.title ?? settingsTab.value.name;
+ },
+ );
+ return {
+ settingsTabs,
+ activeSettingsTab: settingsTab,
+ };
+}
diff --git a/resources/js/layouts/LayoutBase.vue b/resources/js/layouts/LayoutBase.vue
index 9a17aae5..64998fe8 100755
--- a/resources/js/layouts/LayoutBase.vue
+++ b/resources/js/layouts/LayoutBase.vue
@@ -14,10 +14,9 @@ const { selectedSideBar, sideBarTarget } = storeToRefs(useAppStore());
id="left-card"
:class="
cn(
- 'card',
- `order-2 col-span-1 sm:scroll-mt-6 lg:order-1 lg:col-span-2 2xl:col-span-1`,
- selectedSideBar && sideBarTarget === 'left-card' ? 'flex sm:ring-1' : 'hidden lg:invisible lg:block',
- 'flex-col gap-3 sm:p-3',
+ 'card order-2 col-span-1 sm:scroll-mt-6 lg:order-1 lg:col-span-2 2xl:col-span-1',
+ 'hidden flex-col gap-3 sm:p-3',
+ selectedSideBar && sideBarTarget === 'left-card' ? 'visible hidden sm:ring-1 md:flex' : 'lg:invisible lg:block',
)
"
>
@@ -30,7 +29,7 @@ const { selectedSideBar, sideBarTarget } = storeToRefs(useAppStore());
<section
id="list-card"
:class="
- cn(`card order-3 col-span-1 sm:scroll-mt-6 lg:col-span-2 2xl:col-span-1`, 'hidden flex-col gap-3 sm:p-3', {
+ cn('card order-3 col-span-1 sm:scroll-mt-6 lg:col-span-2 2xl:col-span-1', 'hidden flex-col gap-3 sm:p-3', {
'hidden md:flex': selectedSideBar && sideBarTarget === 'list-card',
})
"
diff --git a/resources/js/views/DashboardView.vue b/resources/js/views/DashboardView.vue
index 6811491f..89c91f23 100644
--- a/resources/js/views/DashboardView.vue
+++ b/resources/js/views/DashboardView.vue
@@ -1,155 +1,42 @@
<script setup lang="ts">
-import type { SidebarTabItem, TaskStatsResponse } from '@/types/types';
-import type { Ref } from 'vue';
-
-import { computed, onMounted, ref, watch } from 'vue';
-import { useDashboardStore } from '@/stores/DashboardStore';
-import { useAuthStore } from '@/stores/AuthStore';
+import { useDashboardTabs } from '@/components/panels/DashboardTabs';
+import { getScreenSize } from '@/service/util';
import { useAppStore } from '@/stores/AppStore';
-import { storeToRefs } from 'pinia';
-import { useRoute } from 'vue-router';
-import { cn } from '@aminnausin/cedar-ui';
+import { onMounted } from 'vue';
-import DashboardSidebarCard from '@/components/cards/sidebar/DashboardSidebarCard.vue';
import DashboardAnalytics from '@/components/dashboard/DashboardAnalytics.vue';
import DashboardLibraries from '@/components/dashboard/DashboardLibraries.vue';
import DashboardActivity from '@/components/dashboard/DashboardActivity.vue';
-import AppManifestCard from '@/components/cards/data/AppManifestCard.vue';
+import DashboardSidebar from '@/components/panels/DashboardSidebar.vue';
import DashboardUsers from '@/components/dashboard/DashboardUsers.vue';
import DashboardTasks from '@/components/dashboard/DashboardTasks.vue';
-import SidebarHeader from '@/components/headers/SidebarHeader.vue';
import LayoutBase from '@/layouts/LayoutBase.vue';
-import ProiconsSettings from '~icons/proicons/settings';
-import ProiconsLibrary from '~icons/proicons/library';
-import ProiconsGraph from '~icons/proicons/graph';
-import CircumServer from '~icons/circum/server';
-import LucideUsers from '~icons/lucide/users';
-
-const { stateTaskStats, stateTotalLibrariesSize, stateLibraryId, stateActiveSessions } = storeToRefs(useDashboardStore()) as {
- stateTaskStats: Ref<TaskStatsResponse>;
- stateTotalLibrariesSize: Ref<string>;
- stateLibraryId: Ref<number>;
- stateActiveSessions: Ref<number>;
-};
+const { activeDashboardTab } = useDashboardTabs();
const { cycleSideBar } = useAppStore();
-const { pageTitle } = storeToRefs(useAppStore());
-const { userData } = storeToRefs(useAuthStore());
-
-const dashboardTab = ref<{ name: string; title?: string; icon?: any }>();
-const dashboardTabs = computed<SidebarTabItem[]>(() => {
- return [
- {
- name: 'overview',
- title: 'Analytics',
- description: 'Website Overview',
- icon: ProiconsGraph,
- },
- {
- name: 'libraries',
- title: 'Content Libraries',
- info: { value: `Total Size: ${stateTotalLibrariesSize?.value ?? '?'}` },
- icon: ProiconsLibrary,
- },
- // {
- // name: 'activity',
- // description: '',
- // info: { value: 'Logged Events: 686' },
- // icon: ProiconsHistory,
- // },
- {
- name: 'users',
- title: 'User Management',
- info: { value: `Logged In: ${stateActiveSessions?.value ?? '?'}` },
- icon: LucideUsers,
- },
- {
- name: 'tasks',
- title: 'Task Management',
- info: { value: `Currently Running: ${stateTaskStats.value?.count_running ?? '?'}` },
- icon: CircumServer,
- disabled: userData.value?.id !== 1,
- },
- ];
-});
+onMounted(async () => {
+ const screenSize = getScreenSize();
-const route = useRoute();
+ if (screenSize === 'default' || screenSize === 'sm') return;
-onMounted(async () => {
cycleSideBar('dashboard', 'left-card', false);
});
-
-watch(
- () => route?.params?.tab,
- (URL_TAB) => {
- if (!URL_TAB) return;
- const defaultTab = dashboardTabs.value.find((tab) => tab.title === URL_TAB || tab.name === URL_TAB) ?? dashboardTabs.value[0];
-
- pageTitle.value = defaultTab.title ?? defaultTab.name;
- dashboardTab.value = defaultTab;
- },
- { immediate: true },
-);
-
-watch(
- () => dashboardTab.value,
- () => {
- stateLibraryId.value = -1;
- if (!dashboardTab.value) return;
- pageTitle.value = dashboardTab.value.title ?? dashboardTab.value.name;
- },
-);
</script>
<template>
<LayoutBase>
<template v-slot:content>
<section id="content-dashboard" class="3xl:min-h-[60vh] flex flex-col gap-4 text-sm lg:min-h-[80vh]">
- <DashboardAnalytics v-if="dashboardTab?.name == 'overview'" />
- <DashboardLibraries v-if="dashboardTab?.name == 'libraries'" />
- <DashboardActivity v-if="dashboardTab?.name == 'activity'" />
- <DashboardUsers v-if="dashboardTab?.name == 'users'" />
- <DashboardTasks v-if="dashboardTab?.name == 'tasks'" />
+ <DashboardAnalytics v-if="activeDashboardTab?.name == 'overview'" />
+ <DashboardLibraries v-if="activeDashboardTab?.name == 'libraries'" />
+ <DashboardActivity v-if="activeDashboardTab?.name == 'activity'" />
+ <DashboardUsers v-if="activeDashboardTab?.name == 'users'" />
+ <DashboardTasks v-if="activeDashboardTab?.name == 'tasks'" />
</section>
</template>
<template v-slot:leftSidebar>
- <SidebarHeader />
-
- <section class="flex flex-1 flex-col gap-2">
- <DashboardSidebarCard
- v-for="(tab, index) in dashboardTabs.filter((tab) => !tab.disabled)"
- :key="index"
- :to="tab.disabled ? '' : `/dashboard/${tab.name}`"
- :class="cn({ 'hover:ring-primary/90 ring-2': dashboardTab?.name === tab.name })"
- @click="dashboardTab = tab"
- :aria-disabled="tab.disabled"
- >
- <template #header>
- <h3 class="line-clamp-1 w-full flex-1" :title="tab.title ?? tab.name">{{ tab.title ?? tab.name }}</h3>
- <component v-if="tab.icon" :is="tab.icon" class="ml-auto size-6" />
- </template>
- <template #body>
- <h4 v-if="tab.description" title="Description" class="w-full flex-1 truncate text-wrap sm:text-nowrap">
- {{ tab.description }}
- </h4>
- <h4 v-if="tab.info" title="Information" class="w-fit truncate text-nowrap sm:text-right">
- {{ tab.info.value }}
- </h4>
- </template>
- </DashboardSidebarCard>
-
- <DashboardSidebarCard :to="`/settings`" :aria-disabled="false">
- <template #header>
- <h3 :title="'Settings'">Settings</h3>
- <ProiconsSettings class="ml-auto size-6" />
- </template>
- <template #body>
- <h4 title="Description" class="w-full flex-1 truncate text-wrap sm:text-nowrap">Configurable Options</h4>
- </template>
- </DashboardSidebarCard>
- <AppManifestCard />
- </section>
+ <DashboardSidebar />
</template>
</LayoutBase>
</template>
diff --git a/resources/js/views/SettingsView.vue b/resources/js/views/SettingsView.vue
index cccf931d..818f3a23 100755
--- a/resources/js/views/SettingsView.vue
+++ b/resources/js/views/SettingsView.vue
@@ -1,131 +1,36 @@
<script setup lang="ts">
-import type { SidebarTabItem } from '@/types/types';
-
-import { computed, onMounted, ref, watch } from 'vue';
-import { useAuthStore } from '@/stores/AuthStore';
+import { useSettingsTabs } from '@/components/panels/SettingsTabs';
+import { getScreenSize } from '@/service/util';
import { useAppStore } from '@/stores/AppStore';
-import { storeToRefs } from 'pinia';
-import { useRoute } from 'vue-router';
+import { onMounted } from 'vue';
-import DashboardSidebarCard from '@/components/cards/sidebar/DashboardSidebarCard.vue';
import SettingsPreferences from '@/components/settings/SettingsPreferences.vue';
import SettingsAccount from '@/components/settings/SettingsAccount.vue';
-import AppManifestCard from '@/components/cards/data/AppManifestCard.vue';
-import SidebarHeader from '@/components/headers/SidebarHeader.vue';
+import SettingsSidebar from '@/components/panels/SettingsSidebar.vue';
import LayoutBase from '@/layouts/LayoutBase.vue';
-import ProiconsSettings from '~icons/proicons/settings';
-import CircumGrid31 from '~icons/circum/grid-3-1';
-import LucideUser from '~icons/lucide/user';
-
-const { pageTitle, selectedSideBar } = storeToRefs(useAppStore());
+const { activeSettingsTab } = useSettingsTabs();
const { cycleSideBar } = useAppStore();
-const { userData } = storeToRefs(useAuthStore());
-
-const dev = true;
-const settingsTab = ref<{ name: string; title?: string; icon?: any }>();
-
-const settingsTabs = computed<SidebarTabItem[]>(() => {
- return [
- {
- name: 'preferences',
- title: 'Preferences',
- description: 'Website Preferences', // Remember Volume, Ambient Mode, Playback Heatmap, Opt out of things?
- icon: ProiconsSettings,
- },
- {
- name: 'account',
- title: 'Account',
- description: 'Account Settings', // Email Password Sessions
- disabled: !userData.value,
- icon: LucideUser,
- },
- {
- name: 'profile',
- title: 'Profile',
- description: 'Profile Settings', // Visibility, Avatar, Banner
- disabled: dev || !userData.value,
- },
- {
- name: 'server',
- title: 'Server',
- description: 'Server Settings', // Disable features
- disabled: dev || !userData.value || userData.value?.id !== 1,
- },
- ];
-});
+onMounted(async () => {
+ const screenSize = getScreenSize();
-const route = useRoute();
+ if (screenSize === 'default' || screenSize === 'sm') return;
-onMounted(async () => {
cycleSideBar('settings', 'left-card', false);
});
-
-watch(
- () => route?.params?.tab,
- (URL_TAB) => {
- if (!URL_TAB) return;
- const defaultTab = settingsTabs.value.find((tab) => tab.title === URL_TAB || tab.name === URL_TAB) ?? settingsTabs.value[0];
-
- pageTitle.value = defaultTab.title ?? defaultTab.name;
- settingsTab.value = defaultTab;
- },
- { immediate: true },
-);
-
-watch(
- () => settingsTab.value,
- () => {
- if (!settingsTab.value) return;
- pageTitle.value = settingsTab.value.title ?? settingsTab.value.name;
- },
-);
</script>
<template>
<LayoutBase>
<template v-slot:content>
<section id="content-settings" class="3xl:min-h-[60vh] flex flex-col gap-4 text-sm lg:min-h-[80vh]">
- <SettingsPreferences v-if="settingsTab?.name == 'preferences'" />
- <SettingsAccount v-if="settingsTab?.name == 'account'" />
+ <SettingsPreferences v-if="activeSettingsTab?.name == 'preferences'" />
+ <SettingsAccount v-if="activeSettingsTab?.name == 'account'" />
</section>
</template>
<template v-slot:leftSidebar>
- <SidebarHeader />
- <section class="flex flex-1 flex-col gap-2">
- <DashboardSidebarCard
- v-for="(tab, index) in settingsTabs.filter((tab) => !tab.disabled)"
- :key="index"
- :to="tab.disabled ? '' : `/settings/${tab.name}`"
- :class="[{ 'ring-2': settingsTab?.name == tab.name }]"
- @click="settingsTab = tab"
- :disabled="tab.disabled"
- >
- <template #header>
- <h3 class="line-clamp-1 w-full flex-1" :title="tab.title ?? tab.name">{{ tab.title ?? tab.name }}</h3>
- <component v-if="tab.icon" :is="tab.icon" class="ml-auto size-6" />
- </template>
- <template #body>
- <h4 v-if="tab.description" title="Description" class="w-full flex-1 truncate text-wrap sm:text-nowrap">
- {{ tab.description }}
- </h4>
- <h4 v-if="tab.info" title="Information" class="w-fit truncate text-nowrap sm:text-right">
- {{ tab.info.value }}
- </h4>
- </template>
- </DashboardSidebarCard>
- <DashboardSidebarCard :to="`/dashboard`">
- <template #header>
- <h3 :title="'Dashboard'">Dashboard</h3>
- <CircumGrid31 class="ml-auto size-6" />
- </template>
- <template #body>
- <h4 title="App Dashboard" class="w-full flex-1 truncate text-wrap sm:text-nowrap">Server Analytics</h4>
- </template>
- </DashboardSidebarCard>
- <AppManifestCard />
- </section>
+ <SettingsSidebar />
</template>
</LayoutBase>
</template>