A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
feat: better library folder card
aminnausin15ee175afc43
diff --git a/app/Http/Controllers/Api/V1/FolderController.php b/app/Http/Controllers/Api/V1/FolderController.phpindex 3c015846..0d91387a 100755--- a/app/Http/Controllers/Api/V1/FolderController.php+++ b/app/Http/Controllers/Api/V1/FolderController.php@@ -34,7 +34,7 @@ class FolderController extends Controller {FolderResource::collection(Folder::query()->select('folders.*')->join('series', 'series.folder_id', '=', 'folders.id')- ->with(['series.folderTags.tag', 'series.primaryPoster', 'series.images.user'])+ ->with(['series.folderTags.tag', 'series.primaryPoster', 'series.primaryBanner', 'series.images.user'])->where('category_id', $validated['category_id'])->orderByRaw('COALESCE(series.title, folders.name) ASC')->get() // do not eager load videos... because in this instance, the request is not asking for videos, simply a list of foldersdiff --git a/resources/css/theme.css b/resources/css/theme.cssindex 98edeaaa..28b6081f 100644--- a/resources/css/theme.css+++ b/resources/css/theme.css@@ -272,6 +272,13 @@@apply bg-surface-2 hover:bg-surface-3 dark:hover:bg-primary-dark-600 dark:bg-surface-2/70;}+ .data-card.library-card {+ @apply @container relative flex w-full flex-col rounded-lg shadow-sm;+ @apply ring-1 ring-gray-900/5 [contain-intrinsic-size:auto_260px];+ @apply ease-out hover:ring-2;+ @apply hover:ring-primary-muted hover:dark:ring-primary focus-within:ring-primary-muted dark:focus-within:ring-primary;+ }+.content-auto {content-visibility: auto;contain-intrinsic-size: auto 64px;diff --git a/resources/js/components/cards/data/LibraryCard.vue b/resources/js/components/cards/data/LibraryCard.vueindex bef07d61..293b1d26 100644--- a/resources/js/components/cards/data/LibraryCard.vue+++ b/resources/js/components/cards/data/LibraryCard.vue@@ -134,43 +134,12 @@ watch(aria-label="View Folders"><BlurhashImage- class="peer mb-auto h-full w-full rounded-t-lg object-cover shadow-xs ring-1 ring-gray-900/5 ring-inset hover:ring-4"+ class="peer mb-auto h-full w-full rounded-t-lg object-cover"alt="Folder Cover Art":src="defaultFolder?.series?.poster_image?.path ?? handleStorageURL(defaultFolder?.series?.thumbnail_url) ?? '/storage/thumbnails/default.webp'":blurhash="defaultFolder?.series?.poster_image?.blur_hash"/>- <span class="absolute inset-0 flex h-full w-full flex-col items-end gap-2 rounded-t-lg p-2.5" hidden>- <HoverCard :content-title="'Private Library'" :content="'Only you have access to this library.'" v-if="data?.is_private">- <template #trigger>- <div class="bg-surface-2 text-primary dark:text-foreground-0 ring-r-button size-7 shrink-0 cursor-default rounded-full p-1 ring-1">- <ProiconsLock class="size-5" />- </div>- </template>- </HoverCard>- <HoverCard- :content-title="'Downloadable Library'"- :content="`${data?.downloads_require_auth ? 'Only authenticated users' : 'Any user'} can download from this library.`"- v-if="data?.downloads_enabled"- >- <template #trigger>- <div class="bg-surface-2 text-primary dark:text-foreground-0 ring-r-button size-7 shrink-0 cursor-default rounded-full p-1 pt-0.5 ring-1">- <TablerDownload class="size-5" />- </div>- </template>- </HoverCard>- <HoverCard- :content-title="'Auto Generates Storyboards'"- :content="'Storyboards are auto generated for every video in this library.'"- v-if="data?.storyboard_enabled"- >- <template #trigger>- <div class="bg-surface-2 text-primary dark:text-foreground-0 ring-r-button size-7 shrink-0 cursor-default rounded-full p-1 ring-1">- <ProIconsPhoto class="size-5" />- </div>- </template>- </HoverCard>- </span>- <div v-if="activeFeatureCount" :class="cn('absolute inset-x-0 bottom-2 px-2.5 transition-[padding] duration-200', { 'px-2': activeFeatureCount > 1 })">+ <div v-if="activeFeatureCount" :class="cn('absolute inset-x-0 bottom-2 z-1 px-2.5 transition-[padding] duration-200', { 'px-2': activeFeatureCount > 1 })"><PlayerOSDBase:class="cn('ml-auto flex w-fit items-center justify-start gap-2 p-1 text-white backdrop-blur-sm transition-[padding] duration-200', {diff --git a/resources/js/components/cards/data/LibraryFolderCard.vue b/resources/js/components/cards/data/LibraryFolderCard.vueindex 8557b0d8..e3231802 100644--- a/resources/js/components/cards/data/LibraryFolderCard.vue+++ b/resources/js/components/cards/data/LibraryFolderCard.vue@@ -1,7 +1,7 @@<script setup lang="ts">import type { FolderResource } from '@/types/resources';-import { formatFileSize, handleStorageURL, toFormattedDate } from '@/service/util';+import { formatFileSize, handleStorageURL, toFormattedDate, toPlural, toTimeSpan } from '@/service/util';import { computed, ref, useTemplateRef } from 'vue';import { setSeriesDownloadSettings } from '@/service/siteAPI';import { useDashboardStore } from '@/stores/DashboardStore';@@ -13,11 +13,15 @@ import { HoverCard } from '@/components/cedar-ui/hover-card';import { cn, toast } from '@aminnausin/cedar-ui';import LibraryFolderCardMenu from '@/components/menus/LibraryFolderCardMenu.vue';-import LazyImage from '@/components/lazy/LazyImage.vue';+import PlayerOSDBase from '@/components/video/OSD/PlayerOSDBase.vue';+import BlurhashImage from '@/components/lazy/BlurhashImage.vue';import ProiconsMoreVertical from '~icons/proicons/more-vertical';import TablerDownload from '@/components/icons/TablerDownload.vue';+import ProiconsStar from '~icons/proicons/star';import IconShare from '@/components/icons/IconShare.vue';+import IconMusic from '@/components/icons/IconMusic.vue';+import IconPlay from '@/components/icons/IconPlay.vue';const { stateLibraryId, stateLibraries } = storeToRefs(useDashboardStore());@@ -27,12 +31,14 @@ const popover = useTemplateRef('popover');const queryClient = useQueryClient();const processing = ref(false);-const stateLibrary = computed(() => {- return stateLibraries.value.find((lib) => lib.id === stateLibraryId.value);-});+const stateLibrary = computed(() => stateLibraries.value.find((lib) => lib.id === stateLibraryId.value));+const formattedDate = computed(() => ({+ short: props.data.created_at ? toFormattedDate(props.data.created_at, false, { year: 'numeric', month: '2-digit', day: '2-digit' }) : 'N/A',+ long: props.data.created_at ? toFormattedDate(props.data.created_at) : 'N/A',+}));const handleToggleDownloads = async (id: number, currentValue: boolean) => {- if (processing.value || !props.data?.id || currentValue !== props.data.series?.downloads_enabled) return;+ if (processing.value || !props.data.id || currentValue !== props.data.series?.downloads_enabled) return;try {processing.value = true;@@ -51,49 +57,64 @@ const handleToggleDownloads = async (id: number, currentValue: boolean) => {</script><template>- <div- :class="- cn(- 'data-card group relative flex w-full flex-col rounded-lg shadow-sm ring-1 ring-gray-900/5 [contain-intrinsic-size:auto_260px]',- 'transition-input hover:ring-primary-muted hover:dark:ring-primary ring-1 ease-in-out hover:ring-2',- 'focus-within:ring-primary-muted dark:focus-within:ring-primary',- )- "- >- <RouterLink :to="`/${encodeURI(data.path)}`" class="content-auto h-40 w-full rounded-t-lg [contain-intrinsic-size:auto_160px] focus:-outline-offset-2">- <LazyImage- class="mb-auto h-full w-full object-cover shadow-xs ring-1 ring-gray-900/5"- :src="data?.series?.poster_image?.path ?? handleStorageURL(data?.series?.thumbnail_url) ?? '/storage/thumbnails/default.webp'"+ <div :class="cn('data-card group transition-input library-card')">+ <RouterLink :to="`/${encodeURI(data.path)}/details`" class="content-auto h-40 w-full rounded-t-lg [contain-intrinsic-size:auto_160px] focus:-outline-offset-2">+ <BlurhashImage+ class="mb-auto size-full object-cover"alt="Folder Cover Art"+ :src="data.series?.poster_image?.path ?? data.series?.banner_image?.path ?? handleStorageURL(data.series?.thumbnail_url) ?? '/storage/thumbnails/default.webp'"+ :blurhash="data.series?.poster_image?.blur_hash ?? data.series?.banner_image?.blur_hash"/>- <span class="absolute inset-0 flex h-full w-full flex-col items-end gap-2 p-2.5">- <HoverCard- :content-title="'Downloadable Folder'"- :content="`${stateLibrary?.downloads_require_auth ? 'Only authenticated users' : 'Any user'} can download from this folder.`"- v-show="data.series?.downloads_enabled && stateLibrary?.downloads_enabled"- >- <template #trigger>- <div class="bg-surface-2 text-primary dark:text-foreground-0 ring-r-button size-7 shrink-0 rounded-full p-1 pt-0.5 ring-1">- <TablerDownload class="size-5" />- </div>- </template>- </HoverCard>- </span>+ <div v-if="stateLibrary?.default_folder_id === data.id" class="absolute inset-x-0 top-2 z-1 flex items-start px-1">+ <PlayerOSDBase class="flex w-fit items-center justify-start gap-2 px-2 py-0.5 text-white backdrop-blur-sm">+ <HoverCard+ :content-title="'Downloadable Folder'"+ :content="`${stateLibrary?.downloads_require_auth ? 'Only authenticated users' : 'Any user'} can download from this folder.`"+ :disabled="true"+ >+ <template #trigger>+ <p class="text-xs">Default</p>+ </template>+ </HoverCard>+ </PlayerOSDBase>+ </div>++ <div v-if="data.series?.downloads_enabled && stateLibrary?.downloads_enabled" class="absolute inset-x-0 bottom-2 z-1 flex items-end px-2.5">+ <PlayerOSDBase class="ml-auto flex w-fit items-center justify-start gap-2 p-1 text-white backdrop-blur-sm">+ <HoverCard+ :content-title="'Downloadable Folder'"+ :content="`${stateLibrary?.downloads_require_auth ? 'Only authenticated users' : 'Any user'} can download from this folder.`"+ v-show="data.series?.downloads_enabled && stateLibrary?.downloads_enabled"+ >+ <template #trigger>+ <TablerDownload class="peer size-4.5 shrink-0" :title="'Downloads enabled'" />+ </template>+ </HoverCard>+ </PlayerOSDBase>+ </div>++ <div+ class="playback-progress-bar duration-input absolute inset-x-0 bottom-0 z-1 flex h-1 bg-neutral-300 opacity-80 transition-opacity dark:bg-neutral-700 dark:opacity-60"+ :title="`Completed: ? out of ${data.file_count} ${data.is_majority_audio ? 'track' : 'video'}s`"+ >+ <div+ class="bg-foreground-3 duration-input playback-progress-fill size-full transition-[background-color]"+ :style="{ width: `${(data.completion_count / data.file_count) * 100}%` }"+ ></div>+ </div></RouterLink>- <section class="flex h-full flex-1 flex-col gap-2 p-3" v-if="data">- <div class="xs:flex-nowrap flex flex-wrap items-start justify-between gap-1">- <RouterLink :to="`/${encodeURI(data.path)}`">- <h3 class="group-hover:text-primary dark:group-hover:text-primary-muted capitalize">{{ data?.title ?? data?.name }}</h3>+ <section class="xxs:gap-2 flex h-full flex-1 flex-col gap-4 p-3">+ <div class="xxs:flex-row flex flex-col items-start gap-1.5">+ <RouterLink :to="`/${encodeURI(data.path)}`" class="group-hover:text-primary dark:group-hover:text-primary-muted min-w-0 flex-1" title="Play">+ <h3 class="capitalize">{{ data.title ?? data.name }}</h3></RouterLink>- <span class="flex gap-2 text-sm *:h-6">+ <div class="flex shrink-0 gap-1.5"><ButtonIcon :title="'Open Folder In New Tab'" :to="`/${encodeURI(data.path)}`" :target="'_blank'" class="size-6 p-0"><template #icon><IconShare class="size-4" /></template></ButtonIcon>- <BasePopover popoverClass="max-w-48 lg:max-w-56 rounded-lg" :buttonClass="'p-1'" ref="popover">- <template #buttonIcon>- <ProiconsMoreVertical class="size-4" />- </template>+ <BasePopover popoverClass="max-w-48 lg:max-w-56 rounded-lg" :buttonClass="'size-6 p-0'" ref="popover">+ <template #buttonIcon><ProiconsMoreVertical class="size-4" /></template><template #content><LibraryFolderCardMenu:data="data"@@ -101,26 +122,53 @@ const handleToggleDownloads = async (id: number, currentValue: boolean) => {:library-downloads-enabled="stateLibrary?.downloads_enabled || false":handle-close-popover="popover?.handleClose":handle-toggle-downloads="handleToggleDownloads"- @clickAction="$emit('clickAction', data?.id)"+ @clickAction="$emit('clickAction', data.id)"/></template></BasePopover>- </span>+ </div></div>- <span class="text-foreground-1 mt-auto flex h-full w-full flex-col gap-1 text-sm">- <span class="mt-auto flex flex-wrap items-start justify-between">- <p class="">{{ 'Files' }}: {{ data?.file_count ?? '?' }}</p>- </span>-- <span class="flex items-center justify-between gap-x-2">- <p class="truncate" :title="`Date Added ${toFormattedDate(data?.created_at)}`">- {{ toFormattedDate(data?.created_at) }}- </p>+ <div class="text-foreground-1 font-commit-mono mt-1 flex size-full flex-col gap-2 text-xs">+ <div class="mt-auto flex flex-wrap items-center justify-between gap-3 gap-y-1">+ <div class="flex items-center gap-2">+ <span class="flex items-center gap-1" :title="`${data.file_count} ${data.is_majority_audio ? 'Track' : 'Video'}${toPlural(data.file_count)}`">+ <template v-if="data.is_majority_audio">+ <IconMusic class="size-3.5" />+ {{ data.file_count }}+ </template>+ <template v-else>+ <IconPlay class="size-3.5" />+ {{ data.file_count }}+ </template>+ </span>+ <span+ v-if="data.series?.rating !== null && data.series?.rating !== undefined"+ :title="`Rated ${data.series.rating} out of 100`"+ class="flex items-center gap-1"+ >+ <ProiconsStar class="size-3.75" />+ <div>+ <span class="text-primary dark:text-primary-muted font-bold">{{ data.series.rating }}</span>+ <span class="self-baseline text-[10px]">/100</span>+ </div>+ </span>+ </div>+ <span class="shrink-0" :title="`Total Size ${formatFileSize(data.total_size)}`">{{ formatFileSize(data.total_size) }}</span>+ </div>++ <div class="bg-hr dark:bg-hr/30 -mx-3 mt-1 h-px shrink-0"></div>++ <div class="flex items-center justify-between gap-x-2"><p class="whitespace-nowrap" :title="`Total Size ${formatFileSize(data.total_size)}`">- {{ formatFileSize(data.total_size) }}+ Updated+ <span class="@3xs:hidden">{{ data.updated_at ? toTimeSpan(data.updated_at, '', true) : 'Never' }} ago</span>+ <span class="hidden @3xs:inline-block">{{ data.updated_at ? toTimeSpan(data.updated_at, '') : 'Never' }}</span></p>- </span>- </span>+ <p class="ml-auto truncate" :title="`Date Added ${formattedDate.long}`">+ {{ formattedDate.short }}+ </p>+ </div>+ </div></section></div></template>@@ -134,4 +182,18 @@ img {/* Safari seems to support, but seems deprecated and does the same thing as the others. */image-rendering: -webkit-optimize-contrast;}++.data-card {+ &:hover .playback-progress-bar {+ opacity: 1;+ }++ &:hover .playback-progress-fill {+ background-color: var(--color-primary-muted);+ }+}++.dark .data-card:hover .playback-progress-fill {+ background-color: var(--color-primary-active);+}</style>diff --git a/resources/js/components/menus/LibraryFolderCardMenu.vue b/resources/js/components/menus/LibraryFolderCardMenu.vueindex cf967d79..32a1e70e 100644--- a/resources/js/components/menus/LibraryFolderCardMenu.vue+++ b/resources/js/components/menus/LibraryFolderCardMenu.vue@@ -9,10 +9,10 @@ import { FLAGS } from '@/config/featureFlags';import TablerDownloadOff from '@/components/icons/TablerDownloadOff.vue';import TablerDownload from '@/components/icons/TablerDownload.vue';-import ProiconsInfoSquare from '~icons/proicons/info-square';import ProiconsDelete from '~icons/proicons/delete';import ProiconsPhoto from '~icons/proicons/photo';import IconEdit from '@/components/icons/IconEdit.vue';+import IconPlay from '@/components/icons/IconPlay.vue';const props = withDefaults(defineProps<{@@ -36,9 +36,9 @@ const { isAdmin, isAuthenticated } = useAuth();</div><div class="flex flex-col gap-2 dark:*:bg-neutral-900">- <ButtonText title="Details" :to="`/${data.category_id}/${data.title}/details`">- <p class="flex-1 text-start">Details</p>- <template #icon> <ProiconsInfoSquare class="size-4" /></template>+ <ButtonText title="Play" :to="`/${data.category_id}/${data.title}`">+ <p class="flex-1 text-start">Play</p>+ <template #icon> <IconPlay class="size-4" /></template></ButtonText><template v-if="isAuthenticated"><ButtonText