A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
refactor: use theme in most of dashboard / settings sidebar
aminnausin8b785f4688bc
diff --git a/resources/js/components/cards/AppManifestCard.vue b/resources/js/components/cards/AppManifestCard.vuedeleted file mode 100644index 359ed380..00000000--- a/resources/js/components/cards/AppManifestCard.vue+++ /dev/null@@ -1,33 +0,0 @@-<script setup lang="ts">-import { useAppStore } from '@/stores/AppStore';-import { storeToRefs } from 'pinia';--import SidebarCard from '@/components/cards/SidebarCard.vue';--import ProiconsGithub from '~icons/proicons/github';--const { appManifest } = storeToRefs(useAppStore());-</script>--<template>- <SidebarCard- :to="`${appManifest?.commit ? `https://github.com/aminnausin/mediaServer/commit/${appManifest?.commit}` : ''}`"- target="_blank"- :class="[- 'items-center justify-between',- 'hover:bg-primary-800 overflow-hidden bg-white capitalize',- 'ring-purple-600 ring-inset hover:ring-2 hover:ring-purple-600/50',- 'aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-disabled:hover:ring-neutral-200 dark:aria-disabled:hover:ring-neutral-700',- ]"- :aria-disabled="false"- >- <template #header>- <h3 class="text-gray-900 dark:text-white" :title="'Source Code'">MediaServer</h3>- <ProiconsGithub class="ml-auto h-6 w-6" />- </template>- <template #body>- <h4 title="App Version" class="w-full flex-1 truncate text-wrap sm:text-nowrap">V{{ appManifest.version ?? '0.1.15b' }}</h4>- <h4 v-if="appManifest.commit" title="Latest Commit" class="w-fit truncate text-nowrap sm:text-right">#{{ appManifest.commit }}</h4>- </template>- </SidebarCard>-</template>diff --git a/resources/js/components/cards/SidebarCard.vue b/resources/js/components/cards/SidebarCard.vuedeleted file mode 100644index 45df0efb..00000000--- a/resources/js/components/cards/SidebarCard.vue+++ /dev/null@@ -1,123 +0,0 @@-<script setup lang="ts">-import { computed, useSlots } from 'vue';-import { RouterLink } from 'vue-router';--import ButtonCorner from '@/components/inputs/ButtonCorner.vue';--import CircumFolderOn from '~icons/circum/folder-on';-import CircumShare1 from '~icons/circum/share-1';--const props = defineProps<{- link?: string;- to?: string;- title?: string;-}>();--const slots = useSlots();-const isCompleteElement = computed(() => !!slots.header && !!slots.body);-</script>--<template>- <a- v-if="to"- :href="to"- :class="[- 'flex flex-col sm:flex-row flex-wrap relative',- 'w-full group cursor-pointer rounded-lg shadow-sm p-3',- 'text-left text-neutral-600 dark:text-neutral-400',- 'dark:bg-primary-dark-800/70 bg-primary-800',- 'dark:hover:bg-primary-dark-600 hover:bg-gray-200',- { 'gap-4 lg:gap-2 ': isCompleteElement },- ]"- >- <section class="flex justify-between gap-4 w-full items-center">- <slot name="header">- <h3 class="w-full truncate dark:text-white" :title="title">{{ title }}</h3>- <div class="flex justify-end gap-1">- <ButtonCorner- :positionClasses="'w-7 h-7'"- :textClasses="'hover:text-violet-600 dark:hover:text-violet-500'"- :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-300'"- :label="'Share'"- @click.stop.prevent="$emit('clickAction', link)"- >- <template #icon>- <CircumShare1 width="20" height="20" />- </template>- </ButtonCorner>- <ButtonCorner- :positionClasses="'w-7 h-7'"- :textClasses="`${true ? 'text-violet-600' : 'hover:text-violet-600'} dark:hover:text-violet-500`"- :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-300'"- :to="''"- :label="'Open Folder'"- >- <template #icon>- <CircumFolderOn width="20" height="20" />- </template>- </ButtonCorner>- </div>- </slot>- </section>- <section class="flex flex-col sm:flex-row sm:justify-between w-full flex-wrap gap-2 text-sm">- <slot name="body">- <h4 class="w-full text-wrap truncate sm:text-nowrap flex-1" v-if="false">Episodes: 2</h4>- <h4 class="truncate text-nowrap sm:text-right w-fit hidden" v-if="false">- <!-- some other folder statistic or data like number of seasons or if its popular or something -->- {{ '20gb' }}- </h4>- </slot>- </section>- </a>- <RouterLink- v-else-if="link"- :to="link"- :class="[- 'flex flex-col sm:flex-row flex-wrap relative',- 'w-full group cursor-pointer rounded-lg shadow-sm p-3',- 'text-left text-neutral-600 dark:text-neutral-400',- 'dark:bg-primary-dark-800/70 bg-primary-800',- 'dark:hover:bg-primary-dark-600 hover:bg-gray-200',- { 'gap-4 lg:gap-2 ': isCompleteElement },- ]"- >- <section class="flex justify-between gap-4 w-full items-center">- <slot name="header">- <h3 class="w-full truncate dark:text-white" :title="title">{{ title }}</h3>- <div class="flex justify-end gap-1">- <ButtonCorner- :positionClasses="'w-7 h-7'"- :textClasses="'hover:text-violet-600 dark:hover:text-violet-500'"- :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-300'"- :label="'Share'"- @click.stop.prevent="$emit('clickAction', link)"- >- <template #icon>- <CircumShare1 width="20" height="20" />- </template>- </ButtonCorner>- <ButtonCorner- :positionClasses="'w-7 h-7'"- :textClasses="`${true ? 'text-violet-600' : 'hover:text-violet-600'} dark:hover:text-violet-500`"- :colourClasses="'dark:hover:bg-neutral-800 hover:bg-gray-300'"- :to="''"- :label="'Open Folder'"- >- <template #icon>- <CircumFolderOn width="20" height="20" />- </template>- </ButtonCorner>- </div>- </slot>- </section>- <section class="flex flex-col sm:flex-row sm:justify-between w-full flex-wrap gap-2 text-sm">- <slot name="body">- <h4 class="w-full text-wrap truncate sm:text-nowrap flex-1" v-if="false">Episodes: 2</h4>- <h4 class="truncate text-nowrap sm:text-right w-fit hidden" v-if="false">- <!-- some other folder statistic or data like number of seasons or if its popular or something -->- {{ '20gb' }}- </h4>- </slot>- </section>- </RouterLink>-</template>diff --git a/resources/js/components/cards/sidebar/AppManifestCard.vue b/resources/js/components/cards/sidebar/AppManifestCard.vuenew file mode 100644index 00000000..d703609a--- /dev/null+++ b/resources/js/components/cards/sidebar/AppManifestCard.vue@@ -0,0 +1,23 @@+<script setup lang="ts">+import { useAppStore } from '@/stores/AppStore';+import { storeToRefs } from 'pinia';++import DashboardSidebarCard from '@/components/cards/sidebar/DashboardSidebarCard.vue';++import ProiconsGithub from '~icons/proicons/github';++const { appManifest } = storeToRefs(useAppStore());+</script>++<template>+ <DashboardSidebarCard target="_blank" :to="`${appManifest?.commit ? `https://github.com/aminnausin/mediaServer/commit/${appManifest.commit}` : ''}`" :disabled="false">+ <template #header>+ <h3 :title="'Source Code'">MediaServer</h3>+ <ProiconsGithub class="ml-auto h-6 w-6" />+ </template>+ <template #body>+ <h4 title="App Version" class="w-full flex-1 truncate text-wrap sm:text-nowrap">V{{ appManifest.version ?? '0.1.15b' }}</h4>+ <h4 v-if="appManifest.commit" title="Latest Commit" class="w-fit truncate text-nowrap sm:text-right">#{{ appManifest.commit }}</h4>+ </template>+ </DashboardSidebarCard>+</template>diff --git a/resources/js/components/cards/sidebar/DashboardSidebarCard.vue b/resources/js/components/cards/sidebar/DashboardSidebarCard.vuenew file mode 100644index 00000000..1b7a3ff9--- /dev/null+++ b/resources/js/components/cards/sidebar/DashboardSidebarCard.vue@@ -0,0 +1,22 @@+<script setup lang="ts">+import { cn } from '@aminnausin/cedar-ui';++import SidebarCard from './SidebarCard.vue';+</script>++<template>+ <SidebarCard+ :class="+ cn(+ 'gap-2',+ 'items-center justify-between',+ 'hover:bg-primary-800 overflow-hidden bg-white capitalize',+ 'ring-primary hover:ring-primary/50 ring-inset hover:ring-2',+ 'aria-disabled:button-disabled',+ )+ "+ >+ <template #header><slot name="header" /></template>+ <template #body><slot name="body" /></template>+ </SidebarCard>+</template>diff --git a/resources/js/components/cards/sidebar/SidebarCard.vue b/resources/js/components/cards/sidebar/SidebarCard.vuenew file mode 100644index 00000000..6ab96e3e--- /dev/null+++ b/resources/js/components/cards/sidebar/SidebarCard.vue@@ -0,0 +1,49 @@+<script setup lang="ts">+import { computed, useSlots } from 'vue';+import { RouterLink } from 'vue-router';+import { cn } from '@aminnausin/cedar-ui';++const props = defineProps<{+ to?: string;+ href?: string;+ class?: string;+ target?: string;+ disabled?: boolean;+}>();++const wrapper = computed(() => (props.to ? RouterLink : 'a')); // Component is set here but props are set 1 level above++const slots = useSlots();+const isCompleteElement = computed(() => !!slots.header && !!slots.body);+</script>++<template>+ <component+ ref="el"+ :is="wrapper"+ :class="+ cn(+ 'relative flex flex-col flex-wrap sm:flex-row',+ 'group w-full cursor-pointer rounded-lg p-3 shadow-sm',+ 'text-left',+ 'dark:bg-primary-dark-800/70 bg-primary-800',+ 'dark:hover:bg-primary-dark-600 hover:bg-gray-200',+ { 'gap-4 lg:gap-2': isCompleteElement },+ props.class,+ )+ "+ :target="target"+ :aria-disabled="disabled ?? false"+ :href="href"+ :to="to"+ >+ <slot>+ <section class="flex w-full items-center justify-between gap-4">+ <slot name="header"> </slot>+ </section>+ <section class="text-foreground-1 flex w-full flex-col flex-wrap gap-2 text-sm sm:flex-row sm:justify-between">+ <slot name="body"> </slot>+ </section>+ </slot>+ </component>+</template>diff --git a/resources/js/views/DashboardView.vue b/resources/js/views/DashboardView.vueindex c308d49f..6709151f 100644--- a/resources/js/views/DashboardView.vue+++ b/resources/js/views/DashboardView.vue@@ -8,15 +8,16 @@ import { useAuthStore } from '@/stores/AuthStore';import { useAppStore } from '@/stores/AppStore';import { storeToRefs } from 'pinia';import { useRoute } from 'vue-router';+import { cn } from '@aminnausin/cedar-ui';+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/AppManifestCard.vue';+import AppManifestCard from '@/components/cards/sidebar/AppManifestCard.vue';import DashboardUsers from '@/components/dashboard/DashboardUsers.vue';import DashboardTasks from '@/components/dashboard/DashboardTasks.vue';import SidebarHeader from '@/components/headers/SidebarHeader.vue';-import SidebarCard from '@/components/cards/SidebarCard.vue';import LayoutBase from '@/layouts/LayoutBase.vue';import ProiconsSettings from '~icons/proicons/settings';@@ -31,8 +32,8 @@ const { stateTaskStats, stateTotalLibrariesSize, stateLibraryId, stateActiveSessstateLibraryId: Ref<number>;stateActiveSessions: Ref<number>;};-const { pageTitle, selectedSideBar } = storeToRefs(useAppStore());const { cycleSideBar } = useAppStore();+const { pageTitle } = storeToRefs(useAppStore());const { userData } = storeToRefs(useAuthStore());const dashboardTab = ref<{ name: string; title?: string; icon?: any }>();@@ -116,27 +117,17 @@ watch(<SidebarHeader /><section class="flex flex-1 flex-col gap-2">- <SidebarCard+ <DashboardSidebarCardv-for="(tab, index) in dashboardTabs.filter((tab) => !tab.disabled)":key="index":link="tab.disabled ? '' : `/dashboard/${tab.name}`"- :class="[- 'items-center justify-between gap-2!',- 'hover:bg-primary-800 overflow-hidden bg-white capitalize',- `ring-purple-600 ring-inset hover:ring-2 hover:ring-purple-600/50 ${dashboardTab?.name == tab.name && 'ring-2'}`,- 'aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-disabled:hover:ring-neutral-200 dark:aria-disabled:hover:ring-neutral-700',- ]"- @click="- () => {- if (tab.disabled) return;- dashboardTab = tab;- }- "+ :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 text-gray-900 dark:text-white" :title="tab.title ?? tab.name">{{ tab.title ?? tab.name }}</h3>- <component v-if="tab.icon" :is="tab.icon" class="ml-auto h-6 w-6" />+ <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">@@ -146,26 +137,17 @@ watch({{ tab.info.value }}</h4></template>- </SidebarCard>+ </DashboardSidebarCard>- <SidebarCard- :link="`/settings`"- :class="[- 'items-center justify-between',- 'hover:bg-primary-800 overflow-hidden bg-white capitalize',- 'ring-purple-600 ring-inset hover:ring-2 hover:ring-purple-600/50',- 'aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-disabled:hover:ring-neutral-200 dark:aria-disabled:hover:ring-neutral-700',- ]"- :aria-disabled="false"- >+ <DashboardSidebarCard :to="`/settings`" :aria-disabled="false"><template #header>- <h3 class="text-gray-900 dark:text-white" :title="'Settings'">Settings</h3>- <ProiconsSettings class="ml-auto h-6 w-6" />+ <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>- </SidebarCard>+ </DashboardSidebarCard><AppManifestCard /></section></template>diff --git a/resources/js/views/SettingsView.vue b/resources/js/views/SettingsView.vueindex c55b93d7..65517e8d 100755--- a/resources/js/views/SettingsView.vue+++ b/resources/js/views/SettingsView.vue@@ -7,11 +7,11 @@ import { useAppStore } from '@/stores/AppStore';import { storeToRefs } from 'pinia';import { useRoute } from 'vue-router';+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/AppManifestCard.vue';+import AppManifestCard from '@/components/cards/sidebar/AppManifestCard.vue';import SidebarHeader from '@/components/headers/SidebarHeader.vue';-import SidebarCard from '@/components/cards/SidebarCard.vue';import LayoutBase from '@/layouts/LayoutBase.vue';import ProiconsSettings from '~icons/proicons/settings';@@ -94,22 +94,17 @@ watch(<template v-slot:leftSidebar><SidebarHeader /><section class="flex flex-1 flex-col gap-2">- <SidebarCard+ <DashboardSidebarCardv-for="(tab, index) in settingsTabs.filter((tab) => !tab.disabled)":key="index"- :link="tab.disabled ? '' : `/settings/${tab.name}`"- :class="[- 'items-center justify-between gap-2!',- 'hover:bg-primary-800 overflow-hidden bg-white capitalize',- `ring-purple-600 ring-inset hover:ring-2 hover:ring-purple-600/50 ${settingsTab?.name == tab.name && 'ring-2'}`,- 'aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-disabled:hover:ring-neutral-200 dark:aria-disabled:hover:ring-neutral-700',- ]"+ :to="tab.disabled ? '' : `/settings/${tab.name}`"+ :class="[{ 'ring-2': settingsTab?.name == tab.name }]"@click="settingsTab = tab"- :aria-disabled="tab.disabled"+ :disabled="tab.disabled"><template #header>- <h3 class="line-clamp-1 w-full flex-1 text-gray-900 dark:text-white" :title="tab.title ?? tab.name">{{ tab.title ?? tab.name }}</h3>- <component v-if="tab.icon" :is="tab.icon" class="ml-auto h-6 w-6" />+ <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">@@ -119,25 +114,16 @@ watch({{ tab.info.value }}</h4></template>- </SidebarCard>- <SidebarCard- :link="`/dashboard`"- :class="[- 'items-center justify-between',- 'hover:bg-primary-800 overflow-hidden bg-white capitalize',- 'ring-purple-600 ring-inset hover:ring-2 hover:ring-purple-600/50',- 'aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-disabled:hover:ring-neutral-200 dark:aria-disabled:hover:ring-neutral-700',- ]"- :aria-disabled="false"- >+ </DashboardSidebarCard>+ <DashboardSidebarCard :to="`/dashboard`"><template #header>- <h3 class="text-gray-900 dark:text-white" :title="'Dashboard'">Dashboard</h3>- <CircumGrid31 class="ml-auto h-6 w-6" />+ <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>- </SidebarCard>+ </DashboardSidebarCard><AppManifestCard /></section></template>