A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
feat: folder tabs and metadata page
aminnausinc9a7b589aff0
diff --git a/resources/js/components/folders/FolderDescription.vue b/resources/js/components/folders/FolderDescription.vuenew file mode 100644index 00000000..dfcc617b--- /dev/null+++ b/resources/js/components/folders/FolderDescription.vue@@ -0,0 +1,139 @@+<script setup lang="ts">+import type { FolderResource } from '@/contracts/media';+import type { Ref } from 'vue';++import { computed, inject, nextTick, onMounted, ref, useTemplateRef, watch } from 'vue';+import { toFormattedDuration } from '@/service/util';+import { ButtonBase } from '@/components/cedar-ui/button';+import { cn } from '@aminnausin/cedar-ui';++import FolderTab from '@/components/folders/FolderTab.vue';+import MediaTag from '@/components/labels/MediaTag.vue';++const data = inject<Ref<FolderResource>>('data');+const isAudio = inject<Ref<boolean>>('isAudio');++const avgDuration = computed(() => (data?.value.file_count ? data.value.videos.reduce((acc, vid) => (acc += vid.duration ?? 0), 0) / data.value.file_count : undefined));+const startingSeason = computed(() => (data?.value.series?.started_at ? getMediaReleaseSeason(data.value.series.started_at) : undefined));+const endingSeason = computed(() => (data?.value.series?.ended_at ? getMediaReleaseSeason(data.value.series.ended_at) : data?.value.series?.started_at ? 'Ongoing' : undefined));++const stats = computed(+ () =>+ [+ { label: isAudio ? 'Discs' : 'Seasons', value: data?.value.series?.seasons },+ { label: isAudio ? 'Tracks' : 'Episodes', value: data?.value.series?.episodes },+ !isAudio && { label: 'Films', value: data?.value.series?.films },+ { label: 'Avg Duration', value: avgDuration.value ? toFormattedDuration(avgDuration.value, false) : '—' },+ ].filter(Boolean) as { label: string; value: any }[],+);++const descriptionRef = useTemplateRef('folder-description');++const isOverflowing = ref(false);+const isExpanded = ref(false);++function getMediaReleaseSeason(dateString?: string): string | null {+ if (!dateString) {+ return null;+ }++ const date = new Date(dateString);+ const month = date.getMonth();+ const year = date.getFullYear();+ switch (month) {+ case 1:+ case 2:+ case 3:+ return `Winter ${year}`;+ case 4:+ case 5:+ case 6:+ return `Spring ${year}`;+ case 7:+ case 8:+ case 9:+ return `Summer ${year}`;+ default:+ return `Fall ${year}`;+ }+}++function checkOverflow() {+ if (!descriptionRef.value) return;++ isOverflowing.value = descriptionRef.value.scrollHeight > descriptionRef.value.clientHeight;+}++watch([() => data?.value.series?.description, () => isExpanded.value], (values, oldValues) => {+ nextTick(() => checkOverflow());+});++onMounted(() => {+ checkOverflow();+});+</script>++<template>+ <FolderTab v-if="data && data.series" class="text-xs">+ <div class="flex flex-col gap-1 overflow-clip">+ <div class="flex flex-wrap justify-between gap-x-2 gap-y-1">+ <div class="flex flex-1 flex-col gap-1">+ <h3 class="text-xl font-semibold capitalize">{{ data.series?.title ?? data.title }}</h3>+ <p class="text-foreground-1 text-sm" v-if="data.series?.studio">{{ data.series.studio }} · {{ data.path?.split('/')?.[0] }}</p>+ </div>++ <div class="flex flex-col items-end gap-1 tabular-nums" v-if="data.series">+ <span class="text-primary dark:text-primary-muted text-xl font-bold">+ {{ data.series.rating }}<span class="text-foreground-2 text-sm font-normal">{{ data.series.rating !== null ? '/100' : 'No Rating' }}</span>+ </span>+ <p class="text-foreground-2 h-4" v-if="data.series.started_at">+ <span>{{ startingSeason }}</span>+ <span v-if="endingSeason && endingSeason !== startingSeason"> – {{ endingSeason }}</span>+ <!-- {{ toFormattedDate(data.series.started_at, false, { year: 'numeric', month: '2-digit', day: '2-digit' }) }} – -->+ <!-- {{ data.series.ended_at ? toFormattedDate(data.series.ended_at, false, { year: 'numeric', month: '2-digit', day: '2-digit' }) : 'Ongoing' }} -->+ </p>+ </div>+ </div>++ <div class="flex w-full flex-1 flex-wrap gap-1" v-if="data.series?.folder_tags?.length">+ <MediaTag+ v-for="tag in data.series.folder_tags.slice(0, Math.min(5, data.series.folder_tags.length))"+ :key="tag.id"+ class="bg-surface-3! text-foreground-0 py-0.5 text-xs capitalize"+ >+ {{ tag.name }}+ </MediaTag>+ </div>+ </div>++ <article :class="['text-foreground-1 flex w-full flex-1 flex-col justify-between gap-1 text-sm leading-relaxed text-balance', { 'max-h-32': !isExpanded }]">+ <div+ :class="[+ 'flex-1 overflow-hidden whitespace-pre-wrap',+ { 'h-20': !isExpanded && isOverflowing }, // h-16 and 2.5rem on big screens if show more button exists and not expanded+ ]"+ ref="folder-description"+ id="folder-description"+ >+ {{ data.series?.description ?? 'No Description' }}+ </div>+ <ButtonBase+ v-if="isOverflowing || isExpanded"+ @click="isExpanded = !isExpanded"+ :class="['hocus:text-foreground-0 block h-auto w-fit p-0 transition-colors', { 'leading-none': !isExpanded }]"+ :title="isExpanded ? 'Hide expanded description' : 'Show expanded description'"+ :aria-expanded="isExpanded"+ aria-controls="folder-description"+ >+ {{ isExpanded ? 'Show less' : '...more' }}+ </ButtonBase>+ </article>++ <div :class="cn('grid grid-cols-1 gap-2', { '@3xs:grid-cols-3': stats.length >= 3 }, { '@3xs:grid-cols-2 @sm:grid-cols-4': stats.length >= 4 })" v-if="data.series">+ <div class="bg-surface-3 flex flex-col items-center justify-center gap-0.5 rounded-lg p-3 text-center" v-for="stat in stats" :key="stat.label">+ <span class="text-base font-semibold">{{ stat.value ?? '—' }}</span>+ <span class="text-foreground-2">{{ stat.label }}</span>+ </div>+ </div>+ </FolderTab>+</template>diff --git a/resources/js/components/folders/FolderHeader.vue b/resources/js/components/folders/FolderHeader.vuenew file mode 100644index 00000000..cc3436c3--- /dev/null+++ b/resources/js/components/folders/FolderHeader.vue@@ -0,0 +1,36 @@+<script setup lang="ts">+import type { FolderResource } from '@/contracts/media';++import { handleStorageURL, toTimeSpan } from '@/service/util';+import { inject } from 'vue';++import FolderTab from '@/components/folders/FolderTab.vue';+import LazyImage from '@/components/lazy/LazyImage.vue';++const data = inject<FolderResource>('data');+</script>++<template>+ <FolderTab class="h-fit w-full gap-0 p-0">+ <div+ class="ring-r-default/5 flex h-52 items-end overflow-clip rounded-t-xl bg-cover text-white ring-1 lg:h-64"+ :style="{+ 'background-image': `url(${data?.series?.banner_image?.path ?? 'https://s4.anilist.co/file/anilistcdn/user/banner/b6792701-mBLPRvzr3xPL.jpg'})`,+ }"+ >+ <div class="flex w-full flex-wrap items-end gap-4 bg-linear-to-b from-transparent to-neutral-950/40 p-3 text-center">+ <LazyImage+ :wrapper-class="'relative h-fit w-fit'"+ class="aspect-2-3 mx-auto w-24 min-w-24 rounded-md object-cover"+ :src="data?.series?.poster_image?.path ?? handleStorageURL(data?.series?.thumbnail_url) ?? '/storage/thumbnails/default.webp'"+ alt="profile"+ />+ <div class="text-centre flex flex-1 flex-wrap items-end justify-center gap-1 sm:pb-2">+ <h2 class="w-full text-2xl text-balance capitalize sm:flex-1 sm:text-left">{{ data?.title }}</h2>+ <p class="text-sm">Created: {{ toTimeSpan(data?.created_at || '', '') }}</p>+ </div>+ </div>+ </div>+ <slot> </slot>+ </FolderTab>+</template>diff --git a/resources/js/components/folders/FolderImages.vue b/resources/js/components/folders/FolderImages.vueindex 678c1dda..9e7ded05 100644--- a/resources/js/components/folders/FolderImages.vue+++ b/resources/js/components/folders/FolderImages.vue@@ -1,70 +1,73 @@<script setup lang="ts" generic="T extends ImageType">import type { ImageType, SeriesResource } from '@/contracts/media';+import type { ComputedRef } from 'vue';-import { computed, ref } from 'vue';+import { computed, inject, ref } from 'vue';import { ButtonText } from '@/components/cedar-ui/button';import { toPlural } from '@/service/util.ts';import { cn } from '@aminnausin/cedar-ui';import ProIconsPhotoOff from '@/components/icons/ProIconsPhotoOff.vue';import ImageCard from '@/components/cards/data/ImageCard.vue';+import FolderTab from '@/components/folders/FolderTab.vue';-const props = defineProps<{- data: SeriesResource;- isAudio?: boolean;- primaryIds?: Partial<Record<T, number>>;-}>();+const primaryIds = inject<ComputedRef<Record<T, number>>>('primaryImageIds');+const isAudio = inject<ComputedRef<boolean>>('isAudio');+const data = inject<ComputedRef<SeriesResource>>('series');const activeFilters = computed<ImageType[]>(() => ['poster', 'banner', 'preview']);-const filteredImages = computed(() => props.data.images.filter((i) => i.type === filteredType.value && !i.replaced_at));-const replacedImages = computed(() => props.data.images.filter((i) => i.type === filteredType.value && i.replaced_at));+const filteredImages = computed(() => (data?.value.images ?? []).filter((i) => i.type === filteredType.value && !i.replaced_at));+const replacedImages = computed(() => (data?.value.images ?? []).filter((i) => i.type === filteredType.value && i.replaced_at));const filteredType = ref<ImageType>(activeFilters.value[0]);+const filteredPrimaryId = computed(() => primaryIds?.value?.[filteredType.value as T]);const isShowingReplaced = ref(false);</script><template>- <div class="flex flex-wrap gap-2">- <ButtonText- v-for="filter in activeFilters"- :key="filter"- :class="cn('hocus:ring-1 h-8 rounded-lg px-3 py-0.5 text-sm capitalize dark:bg-white/5', { 'bg-surface-i! text-foreground-i!': filter === filteredType })"- @click="filteredType = filter"- >- {{ filter }}- </ButtonText>- </div>- <div class="xms:text-sm flex flex-1 flex-col gap-4 text-xs">- <div- v-if="filteredImages.length > 0"- :class="['grid w-full grid-cols-1 gap-2', { 'xms:grid-cols-3': filteredImages.length > 2, 'xms:grid-cols-2': filteredImages.length === 2 }]"- >- <ImageCard v-for="image in filteredImages" :data="image" :key="image.id" :is-read-only="true" :is-primary="image.id == primaryIds?.[filteredType as T]" />+ <FolderTab class="flex-1">+ <div class="flex flex-wrap gap-2">+ <ButtonText+ v-for="filter in activeFilters"+ :key="filter"+ :class="cn('hocus:ring-1 h-8 rounded-lg px-3 py-0.5 text-sm capitalize dark:bg-white/5', { 'bg-surface-i! text-foreground-i!': filter === filteredType })"+ @click="filteredType = filter"+ >+ {{ filter }}+ </ButtonText></div>- <div v-else class="text-foreground-1 my-auto flex w-full items-center justify-center gap-1 py-8 tracking-widest">- <ProIconsPhotoOff class="size-6" />- <span> No images yet </span>- </div>-- <template v-if="replacedImages.length > 0">- <div class="text-foreground-2 flex w-full items-center justify-between gap-2 text-xs">- <ButtonText- :variant="'ghost'"- type="button"- class="hover:text-foreground-0 duration-input h-fit gap-1 bg-transparent! p-0 uppercase transition-colors"- @click="isShowingReplaced = !isShowingReplaced"- >- <svg xmlns="http://www.w3.org/2000/svg" class="size-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" :class="'size-3 shrink-0'">- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>- </svg>- {{ isShowingReplaced ? 'Hide' : 'Show' }} deleted- </ButtonText>- <p>{{ replacedImages.length }} image{{ toPlural(replacedImages.length) }}</p>+ <div class="xms:text-sm flex flex-1 flex-col gap-4 text-xs">+ <div+ v-if="filteredImages.length > 0"+ :class="['grid w-full grid-cols-1 gap-2', { 'xms:grid-cols-3': filteredImages.length > 2, 'xms:grid-cols-2': filteredImages.length === 2 }]"+ >+ <ImageCard v-for="image in filteredImages" :data="image" :key="image.id" :is-read-only="true" :is-primary="image.id == filteredPrimaryId" /></div>-- <div :class="cn('xms:grid-cols-3 grid max-h-0 w-full gap-2 overflow-hidden', { 'max-h-none': isShowingReplaced })" v-if="isShowingReplaced">- <ImageCard v-for="image in replacedImages" :key="image.id" :data="image" :is-audio="isAudio" :is-read-only="true" />+ <div v-else class="text-foreground-1 my-auto flex w-full items-center justify-center gap-1 py-8 tracking-widest">+ <ProIconsPhotoOff class="size-6" />+ <span> No images yet </span></div>- </template>- </div>++ <template v-if="replacedImages.length > 0">+ <div class="text-foreground-2 flex w-full items-center justify-between gap-2 text-xs">+ <ButtonText+ :variant="'ghost'"+ type="button"+ class="hover:text-foreground-0 duration-input h-fit gap-1 bg-transparent! p-0 uppercase transition-colors"+ @click="isShowingReplaced = !isShowingReplaced"+ >+ <svg xmlns="http://www.w3.org/2000/svg" class="size-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" :class="'size-3 shrink-0'">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>+ </svg>+ {{ isShowingReplaced ? 'Hide' : 'Show' }} deleted+ </ButtonText>+ <p>{{ replacedImages.length }} image{{ toPlural(replacedImages.length) }}</p>+ </div>++ <div :class="cn('xms:grid-cols-3 grid max-h-0 w-full gap-2 overflow-hidden', { 'max-h-none': isShowingReplaced })" v-if="isShowingReplaced">+ <ImageCard v-for="image in replacedImages" :key="image.id" :data="image" :is-audio="isAudio" :is-read-only="true" />+ </div>+ </template>+ </div>+ </FolderTab></template>diff --git a/resources/js/components/folders/FolderInfoRow.vue b/resources/js/components/folders/FolderInfoRow.vueindex 3a86b708..67f4ee56 100644--- a/resources/js/components/folders/FolderInfoRow.vue+++ b/resources/js/components/folders/FolderInfoRow.vue@@ -1,13 +1,23 @@<script setup lang="ts">-defineProps<{ title: string; value?: any }>();+import { RouterLink } from 'vue-router';+import { cn } from '@aminnausin/cedar-ui';++import CircumShare1 from '~icons/circum/share-1';++defineProps<{ title: string; value?: any; to?: string; valueClass?: string; iconClass?: string }>();</script><template><div class="space-y-0.5"><div class="text-nowrap">{{ title }}</div><slot>- <div class="text-foreground-1 text-xs text-nowrap" v-if="value">- {{ value }}- </div>+ <component+ :class="cn('text-foreground-1 flex items-center gap-1 text-xs text-nowrap', { 'hover:text-primary dark:hover:text-primary-muted': to }, valueClass)"+ :is="to ? RouterLink : 'div'"+ :to="to"+ >+ {{ value ?? '—' }}+ <CircumShare1 v-if="to" :class="cn('size-4', iconClass)" />+ </component></slot></div></template>diff --git a/resources/js/components/folders/FolderMedia.vue b/resources/js/components/folders/FolderMedia.vuenew file mode 100644index 00000000..4daacdfc--- /dev/null+++ b/resources/js/components/folders/FolderMedia.vue@@ -0,0 +1,86 @@+<script setup lang="ts">+import type { GenericSortOption } from '@/types/types';+import type { VideoResource } from '@/contracts/media';+import type { ComputedRef } from 'vue';+import type { SortDir } from '@aminnausin/cedar-ui';++import { mediaSortingOptions } from '@/constants/sortingOptions';+import { useContentStore } from '@/stores/ContentStore';+import { useModalStore } from '@/stores/ModalStore';+import { storeToRefs } from 'pinia';+import { MediaType } from '@/types/types';+import { cn, toast } from '@aminnausin/cedar-ui';+import { computed } from 'vue';++import EditMediaModal from '@/components/modals/EditMediaModal.vue';+import ShareModal from '@/components/modals/ShareModal.vue';+import TableBase from '@/components/cedar-ui/table/TableBase.vue';+import VideoCard from '@/components/cards/data/VideoCard.vue';+import FolderTab from '@/components/folders/FolderTab.vue';++const { searchQuery, stateFilteredPlaylist, stateDirectory, stateVideo, stateFolder, currentMediaIndex, isLoadingContent } = storeToRefs(useContentStore());+const { playlistSort } = useContentStore();++const props = defineProps<{ useBackground?: boolean }>();+const modal = useModalStore();++const sortingOptions = computed(() => mediaSortingOptions(stateFolder.value)) satisfies ComputedRef<GenericSortOption<VideoResource>[]>; // Idk what the point of using satisfies is++const mediaTypeDescription = computed(() => {+ return stateVideo.value?.metadata?.media_type === MediaType.AUDIO || stateFolder.value?.is_majority_audio ? 'Track' : 'Video';+});++const handleSort = (column: keyof VideoResource = 'file_modified_at', dir: SortDir = 1) => {+ playlistSort({ column, dir });+};++const handleVideoAction = (e: Event, id: number, action: 'edit' | 'share' | 'download') => {+ if (!stateFolder.value?.videos) return;++ const mediaResource = stateFolder.value.videos.find((video: VideoResource) => video.id === id);++ if (!mediaResource) {+ toast.error('File not found');+ return;+ }++ switch (action) {+ case 'edit': {+ const metadataInfo = mediaResource.metadata ? { titleTooltip: `UUID: ${mediaResource.metadata.uuid}` } : {};++ modal.open(EditMediaModal, { title: `Edit ${mediaTypeDescription.value} Metadata`, mediaResource: mediaResource, ...metadataInfo });+ break;+ }+ case 'share':+ modal.open(ShareModal, {+ title: `Share ${mediaTypeDescription.value}`,+ shareLink: encodeURI(`${document.location.origin}/${stateDirectory.value.name}/${stateFolder.value.title}?video=${mediaResource.id}`),+ defaultTimestamp: 0,+ });+ break;+ default:+ toast.error('Option Unavailable', { description: `You cannot ${action} this file.` });+ break;+ }+};+</script>++<template>+ <FolderTab :class="cn('flex-1', { 'bg-transparent p-0 shadow-none ring-0': !useBackground })">+ <TableBase+ ref="mediaTable"+ :class="'h-full flex-1'"+ :data="stateFilteredPlaylist"+ :row="VideoCard"+ :otherAction="handleVideoAction"+ :loading="isLoadingContent"+ :useToolbar="true"+ :sortAction="handleSort"+ :sortingOptions="sortingOptions.filter((s) => !s.hidden)"+ :selectedID="stateVideo?.id"+ :startAscending="true"+ :currentIndex="currentMediaIndex"+ v-model="searchQuery"+ />+ </FolderTab>+</template>diff --git a/resources/js/components/folders/FolderMetadata.vue b/resources/js/components/folders/FolderMetadata.vuenew file mode 100644index 00000000..f62bce4a--- /dev/null+++ b/resources/js/components/folders/FolderMetadata.vue@@ -0,0 +1,139 @@+<script setup lang="ts">+import type { FolderResource } from '@/contracts/media';+import type { ComputedRef, Ref } from 'vue';++import { formatFileSize, toFormattedDate, toFormattedDuration } from '@/service/util';+import { computed, inject } from 'vue';++import FolderInfoRow from '@/components/folders/FolderInfoRow.vue';+import FolderTab from '@/components/folders/FolderTab.vue';+import MediaTag from '@/components/labels/MediaTag.vue';++import ProiconsChevronRight from '~icons/proicons/chevron-right';++const isAudio = inject<ComputedRef<boolean>>('isAudio');+const data = inject<Ref<FolderResource>>('data');++const metadataItems = computed<{ label: string; items: { label: string; value: any; to?: string }[] }[]>(() => {+ if (!data?.value.series) return [];+ return [+ {+ label: 'Series',+ items: [+ { label: 'Title', value: data.value.series.title },+ { label: 'Studio', value: data.value.series.studio },+ { label: 'Score', value: data.value.series.rating ? data.value.series.rating + '%' : undefined },+ ...(isAudio?.value+ ? [+ { label: 'Discs', value: data.value.series.seasons },+ { label: 'Tracks', value: data.value.series.episodes },+ ]+ : [+ { label: 'Seasons', value: data.value.series.seasons },+ { label: 'Episodes', value: data.value.series.episodes },+ { label: 'Films', value: data.value.series.films },+ ]),+ { label: 'Avg Intro', value: toFormattedDuration(data.value.series.avg_intro_duration) },+ { label: 'Started', value: data.value.series.started_at },+ { label: 'Ended', value: data.value.series.ended_at ?? (data.value.series.started_at ? 'Ongoing' : undefined) },+ ],+ },+ {+ label: 'Library',+ items: [+ { label: 'Files', value: data.value.file_count },+ data.value.file_count !== data.value.episodes && { label: 'In Series', value: data.value.episodes },+ { label: 'Total Size', value: formatFileSize(data.value.total_size ?? 0) },+ { label: 'Type', value: data.value.is_majority_audio ? 'Audio' : 'Video' },+ { label: 'Path', value: data.value.path, to: `/${data.value.category_id}/${data.value.title}` },+ { label: 'ID', value: data.value.id },+ { label: 'UUID', value: data.value.series.uuid },+ { label: 'Library ID', value: data.value.category_id, to: `/dashboard/libraries/${data.value.category_id}` },+ ].filter(Boolean) as { label: string; value: any; to?: string }[],+ },+ {+ label: 'Attachments',+ items: [+ { label: 'Images', value: data.value.series.images.length },+ { label: 'Media Images', value: data.value.videos.reduce((acc, vid) => (acc += vid.metadata?.images?.length ?? 0), 0) },+ { label: 'Attachments', value: 0 },+ !isAudio?.value && { label: 'Subtitles', value: data.value.videos.reduce((acc, vid) => (acc += vid.subtitles.length ?? 0), 0) },+ ].filter(Boolean) as { label: string; value: any; to?: string }[],+ },+ {+ label: 'Timestamps',+ items: [+ { label: 'Created', value: toFormattedDate(data.value.created_at) },+ { label: 'Last Updated', value: toFormattedDate(data.value.updated_at) },+ { label: 'Last Edited', value: toFormattedDate(data.value.edited_at) },+ ],+ },+ ];+});+</script>++<template>+ <FolderTab v-if="data" class="text-xs">+ <template v-for="(group, index) in metadataItems" :key="index">+ <div class="flex flex-col gap-0.5">+ <p class="text-foreground-1 font-semibold uppercase">{{ group.label }}</p>+ <div class="flex flex-wrap gap-x-6 gap-y-3">+ <FolderInfoRow+ v-for="item in group.items"+ class="text-foreground-1"+ :key="item.label"+ :title="item.label"+ :value="item.value"+ :value-class="'text-sm text-foreground-0'"+ :to="item.to"+ />++ <FolderInfoRow v-if="group.label === 'Series' && data.series?.folder_tags?.length" title="Tags" class="text-foreground-1">+ <div class="flex flex-wrap gap-1 pt-0.5" v-if="data.series.folder_tags?.length">+ <MediaTag v-for="tag in data.series.folder_tags" :key="tag.id" class="bg-surface-3! text-foreground-0 py-0.5 text-xs capitalize">+ {{ tag.name }}+ </MediaTag>+ </div>+ </FolderInfoRow>++ <details v-if="group.label === 'Series' && data.series?.description" class="group text-foreground-1 flex w-full flex-col open:gap-2">+ <summary class="hover:text-foreground-0 text-foreground-1 flex w-fit cursor-pointer items-center gap-1.5 font-semibold uppercase transition-colors">+ <ProiconsChevronRight class="-ms-1 size-3 transition-transform duration-200 group-open:rotate-90" />++ Description+ </summary>++ <p class="scrollbar-minimal bg-surface-3 dark:bg-surface-2 overflow-x-auto rounded-lg p-3 leading-relaxed whitespace-pre-line">+ {{ data.series.description }}+ </p>+ </details>+ </div>+ </div>++ <div v-if="index !== metadataItems.length - 1" class="border-foreground-0/10 border-t" />+ </template>++ <details class="group text-foreground-1 flex flex-col open:gap-2">+ <summary class="hover:text-foreground-0 flex w-fit cursor-pointer items-center gap-1.5 transition-colors">+ <ProiconsChevronRight class="-ms-1 size-3 transition-transform duration-200 group-open:rotate-90" />++ Raw Data+ </summary>++ <pre class="scrollbar-minimal bg-surface-3 dark:bg-surface-2 overflow-x-auto rounded-lg p-3 leading-relaxed whitespace-pre-wrap">{{+ JSON.stringify(+ {+ ...data,+ videos: undefined,+ series: {+ ...data.series,+ images: undefined,+ },+ },+ null,+ 2,+ )+ }}</pre>+ </details>+ </FolderTab>+</template>diff --git a/resources/js/components/folders/FolderOverview.vue b/resources/js/components/folders/FolderOverview.vuenew file mode 100644index 00000000..4d4cf0d5--- /dev/null+++ b/resources/js/components/folders/FolderOverview.vue@@ -0,0 +1,13 @@+<script setup lang="ts">+import FolderOverviewSidebar from '@/components/folders/FolderOverviewSidebar.vue';+import FolderDescription from '@/components/folders/FolderDescription.vue';+import FolderMedia from '@/components/folders/FolderMedia.vue';+</script>++<template>+ <FolderDescription />+ <div class="flex flex-1 flex-col gap-3 @[40rem]:flex-row">+ <FolderOverviewSidebar />+ <FolderMedia :useBackground="true" />+ </div>+</template>diff --git a/resources/js/components/folders/FolderOverviewSidebar.vue b/resources/js/components/folders/FolderOverviewSidebar.vuenew file mode 100644index 00000000..ebc0d031--- /dev/null+++ b/resources/js/components/folders/FolderOverviewSidebar.vue@@ -0,0 +1,38 @@+<script setup lang="ts">+import type { FolderResource } from '@/contracts/media';++import { formatFileSize, toFormattedDuration } from '@/service/util';+import { inject, useTemplateRef } from 'vue';+import { useScrollbarDetection } from '@/composables/design/useScrollbarDetection';+import { cn } from '@aminnausin/cedar-ui';++import FolderInfoRow from '@/components/folders/FolderInfoRow.vue';+import FolderTab from '@/components/folders/FolderTab.vue';++const folderInfoScrollContainer = useTemplateRef('folder-info');+const data = inject<FolderResource>('data');++const { hasScrollbar: folderInfoHasScrollbar } = useScrollbarDetection(folderInfoScrollContainer, 0, 'x');+</script>++<template>+ <FolderTab class="w-full @[40rem]:max-w-40">+ <div v-if="data" :class="cn('scrollbar-minimal flex gap-x-4 gap-y-2 overflow-x-auto @[40rem]:flex-col', { 'pb-2': folderInfoHasScrollbar })" ref="folder-info">+ <FolderInfoRow v-if="data.total_size" title="Total Size" :value="formatFileSize(data.total_size)" />+ <FolderInfoRow title="Total Views" :value="data.videos.reduce((acc, vid) => (acc += vid.view_count ?? 0), 0)" />+ <FolderInfoRow v-if="data.series?.episodes" title="Episodes" :value="data.series.episodes" />+ <FolderInfoRow v-if="data.series?.seasons" title="Seasons" :value="data.series?.seasons" />+ <FolderInfoRow title="Avg Duration" :value="toFormattedDuration(data.videos.reduce((acc, vid) => (acc += vid.duration ?? 0), 0) / (data.episodes || 1))" />+ <FolderInfoRow title="Intro Duration" :value="`${data.series?.avg_intro_duration}s`" />+ <FolderInfoRow v-if="data.series?.started_at" title="Start Date" :value="data.series?.started_at" />+ <FolderInfoRow v-if="data.series?.ended_at" title="End Date" :value="data.series?.ended_at" />+ <FolderInfoRow v-if="data.series?.rating" title="Average Score" :value="`${data.series?.rating}%`" />+ <FolderInfoRow v-if="data.series?.studio" title="Studio" :value="data.series?.studio" />+ <FolderInfoRow v-if="data.series?.folder_tags?.length" title="Tags">+ <div class="flex gap-0.5 *:w-fit *:max-w-full *:truncate @[40rem]:flex-col">+ <div class="text-foreground-1 text-xs" :title="tag.name" v-for="tag in data.series?.folder_tags" :key="tag.id">{{ tag.name }}</div>+ </div>+ </FolderInfoRow>+ </div>+ </FolderTab>+</template>diff --git a/resources/js/components/folders/FolderStats.vue b/resources/js/components/folders/FolderStats.vuenew file mode 100644index 00000000..7ed0f102--- /dev/null+++ b/resources/js/components/folders/FolderStats.vue@@ -0,0 +1,7 @@+<script setup lang="ts">+import FolderTab from '@/components/folders/FolderTab.vue';+</script>++<template>+ <FolderTab> </FolderTab>+</template>diff --git a/resources/js/router/index.ts b/resources/js/router/index.tsindex d62da756..9bace06e 100644--- a/resources/js/router/index.ts+++ b/resources/js/router/index.ts@@ -145,7 +145,7 @@ export const router = createRouter({redirect: '/dashboard/analytics',},{- path: '/:category/:folder/info',+ path: '/:category/:folder/info/:tab?',name: 'folder',component: () => import('@/views/FolderView.vue'),},diff --git a/resources/js/views/FolderView.vue b/resources/js/views/FolderView.vueindex 322ae32d..4894180c 100644--- a/resources/js/views/FolderView.vue+++ b/resources/js/views/FolderView.vue@@ -1,106 +1,75 @@<script setup lang="ts">-import type { GenericSortOption } from '@/types/types';-import type { VideoResource } from '@/contracts/media';-import type { ComputedRef } from 'vue';-import type { SortDir } from '@aminnausin/cedar-ui';+import type { SidebarTabItem } from '@/types/types';-import { formatFileSize, getScreenSizeRank, handleStorageURL, toFormattedDuration, toTimeSpan } from '@/service/util';-import { onMounted, nextTick, computed, watch, ref, useTemplateRef } from 'vue';+import { onMounted, nextTick, computed, watch, provide, defineAsyncComponent } from 'vue';+import { ButtonBase, ButtonIcon, ButtonText } from '@/components/cedar-ui/button';import { handleEditFolderImages } from '@/service/folder/folderActions';-import { ButtonBase, ButtonIcon } from '@/components/cedar-ui/button';-import { useScrollbarDetection } from '@/composables/design/useScrollbarDetection';-import { mediaSortingOptions } from '@/constants/sortingOptions';+import { getScreenSizeRank } from '@/service/util';import { useContentStore } from '@/stores/ContentStore';+import { createTabStore } from '@/stores/TabStore';import { useModalStore } from '@/stores/ModalStore';import { useAppStore } from '@/stores/AppStore';import { storeToRefs } from 'pinia';-import { MediaType } from '@/types/types';-import { cn, toast } from '@aminnausin/cedar-ui';import { useRoute } from 'vue-router';import { useAuth } from '@/composables/auth/useAuth';+import { cn } from '@aminnausin/cedar-ui';import EditFolderModal from '@/components/modals/EditFolderModal.vue';-import EditMediaModal from '@/components/modals/EditMediaModal.vue';-import FolderInfoRow from '@/components/folders/FolderInfoRow.vue';-import VideoSidebar from '@/components/panels/VideoSidebar.vue';-import FolderImages from '@/components/folders/FolderImages.vue';import ShareModal from '@/components/modals/ShareModal.vue';+import VideoSidebar from '@/components/panels/VideoSidebar.vue';import LayoutBase from '@/layouts/LayoutBase.vue';-import TableBase from '@/components/cedar-ui/table/TableBase.vue';-import VideoCard from '@/components/cards/data/VideoCard.vue';-import FolderTab from '@/components/folders/FolderTab.vue';-import LazyImage from '@/components/lazy/LazyImage.vue';import ProiconsPhoto from '~icons/proicons/photo';import CircumMonitor from '~icons/circum/monitor';import CircumShare1 from '~icons/circum/share-1';import CircumEdit from '~icons/circum/edit';-type FolderTab = 'overview' | 'files' | 'images' | 'metadata' | 'stats';--const folderTabs: FolderTab[] = ['overview', 'files', 'images', 'metadata', 'stats'];--const activeTab = ref<FolderTab>('overview');+const VALID_TABS = new Set(['overview', 'files', 'images', 'metadata', 'stats']);-const { searchQuery, stateFilteredPlaylist, stateDirectory, stateVideo, stateFolder, currentMediaIndex, isLoadingContent } = storeToRefs(useContentStore());+const { stateDirectory, stateFolder, isLoadingContent } = storeToRefs(useContentStore());const { pageTitle, selectedSideBar } = storeToRefs(useAppStore());const { isAuthenticated } = useAuth();-const { getCategory, playlistSort } = useContentStore();+const { getCategory } = useContentStore();-const folderInfoScrollContainer = useTemplateRef('folder-info');+const baseUrl = computed(() => (stateDirectory.value.name && stateFolder.value.name ? `/${stateDirectory.value.name}/${stateFolder.value.title}` : false));+const currentUrl = computed(() => window.location.origin + baseUrl.value);-const { hasScrollbar: folderInfoHasScrollbar } = useScrollbarDetection(folderInfoScrollContainer, 0, 'x');--const route = useRoute();const modal = useModalStore();--const sortingOptions = computed(() => mediaSortingOptions(stateFolder.value)) satisfies ComputedRef<GenericSortOption<VideoResource>[]>; // Idk what the point of using satisfies is--const handleSort = (column: keyof VideoResource = 'file_modified_at', dir: SortDir = 1) => {- playlistSort({ column, dir });-};--const mediaTypeDescription = computed(() => {- return stateVideo.value?.metadata?.media_type === MediaType.AUDIO || stateFolder.value?.is_majority_audio ? 'Track' : 'Video';-});--const handleVideoAction = (e: Event, id: number, action: 'edit' | 'share' | 'download') => {- if (!stateFolder.value?.videos) return;-- const mediaResource = stateFolder.value.videos.find((video: VideoResource) => video.id === id);-- if (!mediaResource) {- toast.error('File not found');- return;- }-- switch (action) {- case 'edit': {- const metadataInfo = mediaResource.metadata ? { titleTooltip: `UUID: ${mediaResource.metadata.uuid}` } : {};-- modal.open(EditMediaModal, { title: `Edit ${mediaTypeDescription.value} Metadata`, mediaResource: mediaResource, ...metadataInfo });- break;- }- case 'share':- modal.open(ShareModal, {- title: `Share ${mediaTypeDescription.value}`,- shareLink: encodeURI(document.location.origin + route.path + `?video=${mediaResource.id}`),- defaultTimestamp: 0,- });- break;+const tabsStore = createTabStore(+ `folder-info`,+ () => [{ name: 'overview' }, { name: 'files' }, { name: 'images' }, { name: 'metadata' }, { name: 'stats' }],+ (tab: SidebarTabItem) => `${stateFolder.value.title} ${tab.name}`,+)();++const { activeTab: activeFolderTab, tabs } = storeToRefs(tabsStore);++const FolderOverview = defineAsyncComponent(() => import('@/components/folders/FolderOverview.vue'));+const FolderMetadata = defineAsyncComponent(() => import('@/components/folders/FolderMetadata.vue'));+const FolderImages = defineAsyncComponent(() => import('@/components/folders/FolderImages.vue'));+const FolderHeader = defineAsyncComponent(() => import('@/components/folders/FolderHeader.vue'));+const FolderStats = defineAsyncComponent(() => import('@/components/folders/FolderStats.vue'));+const FolderMedia = defineAsyncComponent(() => import('@/components/folders/FolderMedia.vue'));++const activeComponent = computed(() => {+ switch (activeFolderTab.value?.name) {+ case 'overview':+ return FolderOverview;+ case 'files':+ return FolderMedia;+ case 'images':+ return FolderImages;+ case 'metadata':+ return FolderMetadata;+ case 'stats':+ return FolderStats;default:- toast.error('Option Unavailable', { description: `You cannot ${action} this file.` });- break;+ return null;}-};--onMounted(async () => {- await reload();- await nextTick();- if (getScreenSizeRank() >= 3 && selectedSideBar.value !== 'folders') useAppStore().cycleSideBar('folders', 'list-card');});+const route = useRoute();+async function reload() {if (isLoadingContent.value) return;@@ -118,147 +87,114 @@ async function reload() {setFolderAsPageTitle();} catch (error) {console.log(error);+ } finally {+ isLoadingContent.value = false;}- isLoadingContent.value = false;}const setFolderAsPageTitle = () => {- const title = stateFolder.value?.series?.title ?? stateFolder?.value?.name;- if (!title) {- pageTitle.value = 'Folder not Found';- document.title = 'Folder not Found';- return;- }- pageTitle.value = title;- document.title = title;+ const title = `${stateFolder.value?.series?.title ?? stateFolder?.value?.name}`;++ pageTitle.value = title || 'Folder not Found';+ document.title = title || 'Folder not Found';};watch(() => `${route.params.category}/${route.params.folder}`, reload, { immediate: false });++watch(+ () => route.params.tab,+ (tab) => {+ let parsedTab = tab as string;++ if (!VALID_TABS.has(parsedTab)) {+ parsedTab = 'overview';+ }++ tabsStore.setTab(parsedTab);+ setFolderAsPageTitle();+ },+ { immediate: true },+);++onMounted(async () => {+ await reload();+ await nextTick();+ if (getScreenSizeRank() >= 3 && selectedSideBar.value !== 'folders') useAppStore().cycleSideBar('folders', 'list-card');+});++provide('data', stateFolder);+provide(+ 'series',+ computed(() => stateFolder.value.series),+);+provide(+ 'isAudio',+ computed(() => stateFolder.value.is_majority_audio),+);+provide(+ 'primaryImageIds',+ computed(() => ({ poster: stateFolder.value.series?.poster_image?.id, banner: stateFolder.value.series?.primary_banner_id })),+);</script><template><LayoutBase><template #content><div id="content-folder" class="page-height @container flex flex-col gap-3 text-sm">- <FolderTab class="h-fit w-full gap-0 p-0">- <div- class="ring-r-default/5 flex h-52 items-end overflow-clip rounded-t-xl bg-cover text-white ring-1 lg:h-64"- :style="{- 'background-image': `url(${stateFolder?.series?.banner_image?.path ?? 'https://s4.anilist.co/file/anilistcdn/user/banner/b6792701-mBLPRvzr3xPL.jpg'})`,- }"- >- <div class="flex w-full flex-wrap items-end gap-4 bg-linear-to-b from-transparent to-neutral-950/40 p-3 text-center">- <LazyImage- :wrapper-class="'relative h-fit w-fit'"- class="aspect-2-3 mx-auto w-24 min-w-24 rounded-md object-cover"- :src="stateFolder?.series?.poster_image?.path ?? handleStorageURL(stateFolder?.series?.thumbnail_url) ?? '/storage/thumbnails/default.webp'"- alt="profile"- />- <div class="text-centre flex flex-1 flex-wrap items-end justify-center gap-1 sm:pb-2">- <h2 class="w-full text-2xl text-balance capitalize sm:flex-1 sm:text-left">{{ stateFolder?.title }}</h2>- <p class="text-sm">Created: {{ toTimeSpan(stateFolder?.created_at || '', '') }}</p>- </div>- </div>- </div>+ <FolderHeader><div class="z-3 flex w-full flex-col justify-between gap-4 p-3">- <div class="flex flex-wrap items-start gap-2">- <div class="flex flex-1">+ <div class="flex flex-wrap items-center gap-2" v-if="baseUrl && !isLoadingContent">+ <div class="scrollbar-minimal flex w-full flex-1 overflow-x-auto"><ButtonBase- v-for="tab in folderTabs"- :key="tab"- :class="cn('hover:text-primary dark:hover:text-primary-muted capitalize', { 'text-primary-active dark:text-primary-muted': activeTab === tab })"- @click="activeTab = tab"+ v-for="tab in tabs"+ :key="tab.name"+ :class="+ cn('hover:text-primary dark:hover:text-primary-muted capitalize', {+ 'text-primary-active dark:text-primary-muted': activeFolderTab?.name === tab.name,+ })+ "+ :to="`${baseUrl}/info/${tab.name}`">- {{ tab }}+ {{ tab.name }}</ButtonBase></div>- <div v-if="isAuthenticated && stateFolder.title && !isLoadingContent" class="flex flex-wrap gap-2">- <ButtonIcon class="size-7 p-0 shadow-md" title="Edit Folder Images" @click="handleEditFolderImages(stateFolder)">+ <div class="flex flex-wrap gap-2">+ <ButtonText class="h-7 min-w-7 gap-1 px-0 py-0 sm:px-2" title="Watch" :to="baseUrl">+ <CircumMonitor class="size-4" />+ <span class="hidden leading-none sm:block">Watch</span>+ </ButtonText>+ <ButtonIcon+ v-if="activeFolderTab?.name === 'images' && isAuthenticated"+ class="size-7 p-0 shadow-md"+ title="Edit Folder Images"+ @click="handleEditFolderImages(stateFolder)"+ ><template #icon><ProiconsPhoto class="size-4" /></template></ButtonIcon>- <ButtonIcon class="size-7 p-0 shadow-md" title="Edit Folder Metadata" @click="modal.open(EditFolderModal, { cachedFolder: stateFolder })">- <template #icon>- <CircumEdit class="size-4" />- </template>- </ButtonIcon><ButtonIcon+ v-if="activeFolderTab?.name === 'metadata' && isAuthenticated"class="size-7 p-0 shadow-md"- title="Share Folder"- @click="modal.open(ShareModal, { title: 'Share Folder', shareLink: `/${stateDirectory.name}/${stateFolder.title}/info` })"+ title="Edit Folder Metadata"+ @click="modal.open(EditFolderModal, { cachedFolder: stateFolder })"><template #icon>- <CircumShare1 class="size-4" />- </template>- </ButtonIcon>- <ButtonIcon class="size-7 p-0 shadow-md" title="Watch" :to="`/${stateDirectory.name}/${stateFolder.title}`">- <template #icon>- <CircumMonitor class="size-4" />+ <CircumEdit class="size-4" /></template></ButtonIcon>+ <ButtonText+ class="size-7 p-0"+ title="Share Folder"+ @click="modal.open(ShareModal, { title: 'Share Folder', shareLink: `${encodeURI(currentUrl)}` })"+ >+ <CircumShare1 class="size-4" />+ </ButtonText></div></div></div>- </FolderTab>-- <div class="text-foreground-1 space-y-1" v-if="activeTab === 'overview'">- <p>Description</p>- <FolderTab class="text-balance">- {{ stateFolder?.series?.description ?? 'No Description' }}- </FolderTab>- </div>-- <div class="flex flex-1 flex-col gap-3 @[40rem]:flex-row" v-if="activeTab === 'overview' || activeTab === 'files'">- <FolderTab class="w-full @[40rem]:max-w-40" v-if="activeTab === 'overview'">- <div :class="cn('scrollbar-minimal flex gap-x-4 gap-y-2 overflow-x-auto @[40rem]:flex-col', { 'pb-2': folderInfoHasScrollbar })" ref="folder-info">- <FolderInfoRow v-if="stateFolder.total_size" title="Total Size" :value="formatFileSize(stateFolder.total_size)" />- <FolderInfoRow title="Total Views" :value="stateFolder.videos.reduce((acc, vid) => (acc += vid.view_count ?? 0), 0)" />- <FolderInfoRow v-if="stateFolder.series?.episodes" title="Episodes" :value="stateFolder.series.episodes" />- <FolderInfoRow v-if="stateFolder.series?.seasons" title="Seasons" :value="stateFolder.series?.seasons" />- <FolderInfoRow- title="Avg Duration"- :value="`${toFormattedDuration(stateFolder.videos.reduce((acc, vid) => (acc += vid.duration ?? 0), 0) / (stateFolder.episodes || 1))}`"- />- <FolderInfoRow title="Intro Duration" :value="`${stateFolder.series?.avg_intro_duration}s`" />- <FolderInfoRow v-if="stateFolder.series?.started_at" title="Start Date" :value="stateFolder.series?.started_at" />- <FolderInfoRow v-if="stateFolder.series?.ended_at" title="End Date" :value="stateFolder.series?.ended_at" />- <FolderInfoRow v-if="stateFolder.series?.rating" title="Average Score" :value="`${stateFolder.series?.rating}%`" />- <FolderInfoRow v-if="stateFolder.series?.studio" title="Studio" :value="stateFolder.series?.studio" />- <FolderInfoRow v-if="stateFolder.series?.folder_tags?.length" title="Tags">- <div class="flex gap-0.5 *:w-fit *:max-w-full *:truncate @[40rem]:flex-col">- <div class="text-foreground-1 text-xs" :title="tag.name" v-for="tag in stateFolder.series?.folder_tags" :key="tag.id">{{ tag.name }}</div>- </div>- </FolderInfoRow>- </div>- </FolderTab>- <FolderTab :class="cn('flex-1', { 'bg-transparent p-0 shadow-none ring-0': activeTab === 'files' })">- <TableBase- ref="mediaTable"- :class="'h-full flex-1'"- :data="stateFilteredPlaylist"- :row="VideoCard"- :otherAction="handleVideoAction"- :loading="isLoadingContent"- :useToolbar="true"- :sortAction="handleSort"- :sortingOptions="sortingOptions.filter((s) => !s.hidden)"- :selectedID="stateVideo?.id"- :startAscending="true"- :currentIndex="currentMediaIndex"- v-model="searchQuery"- />- </FolderTab>- </div>-- <FolderTab v-if="activeTab === 'images'" class="flex-1">- <FolderImages- v-if="stateFolder.series"- :data="stateFolder.series"- :is-audio="stateFolder.is_majority_audio"- :primary-ids="{ poster: stateFolder.series.poster_image?.id, banner: stateFolder.series.primary_banner_id }"- />- </FolderTab>+ </FolderHeader>+ <component :is="activeComponent" /></div></template><template v-slot:sidebar>