A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
add folder thumbnail on hover for sidebar and dont reset table when editing entries
aminnausina69df3d9ae4f
diff --git a/resources/js/components/cards/FolderCard.vue b/resources/js/components/cards/FolderCard.vueindex cfb83536..75c7fafb 100755--- a/resources/js/components/cards/FolderCard.vue+++ b/resources/js/components/cards/FolderCard.vue@@ -1,9 +1,11 @@<script setup lang="ts">import type { FolderResource } from '@/types/resources';+import { formatFileSize } from '@/service/util';import { RouterLink } from 'vue-router';import { ref } from 'vue';+import RelativeHoverCard from '@/components/cards/RelativeHoverCard.vue';import ButtonCorner from '@/components/inputs/ButtonCorner.vue';import CircumFolderOn from '~icons/circum/folder-on';@@ -19,45 +21,61 @@ const folderLink = ref(`/${props.categoryName}/${props.folder.name}`);</script><template>- <RouterLink- :to="folderLink"- class="text-left relative flex flex-col gap-4 lg:gap-2 sm:flex-row flex-wrap rounded-lg dark:bg-primary-dark-800/70 bg-primary-800 dark:hover:bg-primary-dark-600 hover:bg-gray-200 dark:text-white shadow p-3 w-full group cursor-pointer divide-gray-300 dark:divide-gray-400"- >- <section class="flex justify-between gap-4 w-full items-center">- <h2 class="w-full truncate" :title="props.folder.name">{{ props.folder.name }}</h2>- <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 Folder'"- @click.stop.prevent="$emit('clickAction', folderLink)"- >- <template #icon>- <CircumShare1 width="20" height="20" />- </template>- </ButtonCorner>- <ButtonCorner- :positionClasses="'w-7 h-7'"- :textClasses="`${props.folder.name === props.stateFolderName ? '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>- </section>- <section class="flex flex-col sm:flex-row sm:justify-between w-full flex-wrap gap-2 text-sm">- <h3 class="text-neutral-500 w-full text-wrap truncate sm:text-nowrap flex-1" :title="`${props.folder.file_count} Episode${props.folder.file_count !== 1 ? 's' : ''}`">- {{ props.folder.file_count }} Episode{{ props.folder.file_count !== 1 ? 's' : '' }}- </h3>- <h3 class="truncate text-nowrap sm:text-right text-neutral-500 w-fit lg:hidden xl:block">- <!-- some other folder statistic or data like number of seasons or if its popular or something -->- {{ props.folder.total_size ? formatFileSize(props.folder.total_size) : '' }}- </h3>- </section>- </RouterLink>+ <RelativeHoverCard class="w-full" positionClasses="!p-0 !border-none z-50 -top-5 lg:-left-24" iconHidden :hoverCardDelay="50" :hoverCardLeaveDelay="50">+ <template #content>+ <img+ :src="+ folder.series?.thumbnail_url ?? 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'+ "+ alt="Folder Thumbnail"+ class="hidden lg:block h-32 aspect-2/3 object-cover shadow-md"+ />+ </template>+ <template #trigger>+ <RouterLink+ :to="folderLink"+ class="text-left relative flex flex-col gap-4 lg:gap-2 sm:flex-row flex-wrap rounded-lg dark:bg-primary-dark-800/70 bg-primary-800 dark:hover:bg-primary-dark-600 hover:bg-gray-200 dark:text-white shadow p-3 w-full group cursor-pointer divide-gray-300 dark:divide-gray-400"+ >+ <section class="flex justify-between gap-4 w-full items-center">+ <h2 class="w-full truncate" :title="props.folder.name">{{ props.folder.name }}</h2>+ <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 Folder'"+ @click.stop.prevent="$emit('clickAction', folderLink)"+ >+ <template #icon>+ <CircumShare1 width="20" height="20" />+ </template>+ </ButtonCorner>+ <ButtonCorner+ :positionClasses="'w-7 h-7'"+ :textClasses="`${props.folder.name === props.stateFolderName ? '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>+ </section>+ <section class="flex flex-col sm:flex-row sm:justify-between w-full flex-wrap gap-2 text-sm">+ <h3+ class="text-neutral-500 w-full text-wrap truncate sm:text-nowrap flex-1"+ :title="`${props.folder.file_count} Episode${props.folder.file_count !== 1 ? 's' : ''}`"+ >+ {{ props.folder.file_count }} Episode{{ props.folder.file_count !== 1 ? 's' : '' }}+ </h3>+ <h3 class="truncate text-nowrap sm:text-right text-neutral-500 w-fit lg:hidden xl:block">+ <!-- some other folder statistic or data like number of seasons or if its popular or something -->+ {{ props.folder.total_size ? formatFileSize(props.folder.total_size) : '' }}+ </h3>+ </section>+ </RouterLink>+ </template>+ </RelativeHoverCard></template>diff --git a/resources/js/components/cards/HoverCard.vue b/resources/js/components/cards/HoverCard.vueindex 638517f4..48104662 100644--- a/resources/js/components/cards/HoverCard.vue+++ b/resources/js/components/cards/HoverCard.vue@@ -9,11 +9,14 @@ const props = withDefaults(hoverCardDelay?: number;hoverCardLeaveDelay?: number;margin?: number;+ iconHidden?: boolean;+ paddingLeft?: number;}>(),{hoverCardDelay: 600,hoverCardLeaveDelay: 500,margin: 0,+ paddingLeft: 0,},);@@ -55,7 +58,7 @@ const hoverCardLeave = () => {const updateTooltipPosition = (event: MouseEvent) => {const rect = (event.target as HTMLElement).getBoundingClientRect();- tooltipStyles.value = { left: `${rect.left + window.scrollX}px`, top: `${rect.bottom + props.margin + window.scrollY}px` };+ tooltipStyles.value = { left: `${rect.left + window.scrollX + props.paddingLeft}px`, top: `${rect.bottom + props.margin + window.scrollY}px` };};//relative</script>@@ -76,7 +79,7 @@ const updateTooltipPosition = (event: MouseEvent) => {:style="tooltipStyles"><slot name="icon">- <ProiconsCommentExclamation class="h-5 w-5 mb-auto shrink-0" />+ <ProiconsCommentExclamation v-if="!iconHidden" class="h-5 w-5 mb-auto shrink-0" /></slot><slot name="content"><p class="text-pretty h-fit w-full break-words whitespace-pre-wrap">diff --git a/resources/js/components/cards/RelativeHoverCard.vue b/resources/js/components/cards/RelativeHoverCard.vuenew file mode 100644index 00000000..a4874e31--- /dev/null+++ b/resources/js/components/cards/RelativeHoverCard.vue@@ -0,0 +1,81 @@+<script setup lang="ts">+import { ref } from 'vue';+import ProiconsCommentExclamation from '~icons/proicons/comment-exclamation';++const props = withDefaults(+ defineProps<{+ content?: string;+ positionClasses?: string;+ hoverCardDelay?: number;+ hoverCardLeaveDelay?: number;+ iconHidden?: boolean;+ }>(),+ {+ hoverCardDelay: 600,+ hoverCardLeaveDelay: 500,+ },+);++const hoverCardHovered = ref<boolean>(false);+const hoverCardTimout = ref<number | null>(null);+const hoverCardLeaveTimeout = ref<number | null>(null);+const tooltipStyles = ref<Record<string, string>>({});++const init = ref(false);++const hoverCardEnter = () => {+ if (props.content === '') return;++ if (hoverCardLeaveTimeout.value) clearTimeout(hoverCardLeaveTimeout.value);++ if (hoverCardHovered.value) return;++ if (hoverCardTimout.value) clearTimeout(hoverCardTimout.value);++ if (!init.value) init.value = true; // Loads into Dom after hover for the first time++ hoverCardTimout.value = setTimeout(() => {+ hoverCardHovered.value = true;+ }, props.hoverCardDelay);+};++const hoverCardLeave = () => {+ if (props.content === '') return;+ if (hoverCardTimout.value) clearTimeout(hoverCardTimout.value);++ if (!hoverCardHovered.value) return;+ if (hoverCardLeaveTimeout.value) clearTimeout(hoverCardLeaveTimeout.value);++ hoverCardLeaveTimeout.value = setTimeout(() => {+ hoverCardHovered.value = false;+ }, props.hoverCardLeaveDelay);+};+</script>++<template>+ <div class="relative" @mouseover="hoverCardEnter" @mouseleave="hoverCardLeave">+ <slot name="trigger">+ <a href="#_" class="hover:underline">@thedevdojo</a>+ </slot>+ <Transition enter-from-class="opacity-0" enter-to-class="opacity-100" leave-from-class="opacity-100" leave-to-class="opacity-0">+ <div+ @mouseover="hoverCardEnter"+ @mouseleave="hoverCardLeave"+ v-show="hoverCardHovered"+ v-cloak+ :class="`${positionClasses ?? ''} flex absolute overflow-auto transition-opacity ease-in-out duration-200 md:max-w-xl xl:max-w-3xl text-sm p-3 h-fit bg-white dark:odd:bg-primary-dark-600/70 dark:bg-neutral-800/70 backdrop-blur-lg border dark:border-none rounded-md shadow-md border-neutral-200/70 gap-2 items-center`"+ :style="tooltipStyles"+ v-if="init"+ >+ <slot name="icon">+ <ProiconsCommentExclamation v-if="!iconHidden" class="h-5 w-5 mb-auto shrink-0" />+ </slot>+ <slot name="content">+ <p class="text-pretty h-fit w-full break-words whitespace-pre-wrap">+ {{ content }}+ </p>+ </slot>+ </div>+ </Transition>+ </div>+</template>diff --git a/resources/js/components/cards/VideoCard.vue b/resources/js/components/cards/VideoCard.vueindex 63c7feaa..22ecf8e3 100755--- a/resources/js/components/cards/VideoCard.vue+++ b/resources/js/components/cards/VideoCard.vue@@ -1,14 +1,14 @@<script setup lang="ts">import type { ContextMenuItem } from '@/types/types';+import type { VideoResource } from '@/types/resources';import { useContentStore } from '@/stores/ContentStore';-import { toFormattedDate } from '@/service/util';+import { formatFileSize, toFormattedDate } from '@/service/util';import { computed, watch } from 'vue';import { storeToRefs } from 'pinia';import { useAppStore } from '@/stores/AppStore';import { RouterLink } from 'vue-router';-import ContextMenu from '@/components/pinesUI/ContextMenu.vue';import useMetaData from '@/composables/useMetaData';import HoverCard from '@/components/cards/HoverCard.vue';import ChipTag from '@/components/labels/ChipTag.vue';@@ -18,7 +18,7 @@ import CircumShare1 from '~icons/circum/share-1';import CircumEdit from '~icons/circum/edit';const emit = defineEmits(['clickAction', 'otherAction']);-const props = defineProps(['data', 'index', 'currentID']);+const props = defineProps<{ data: VideoResource; index: number; currentID: any }>();const metaData = useMetaData({ ...props.data, id: props.data.id, skipBaseURL: true });const { stateFolder, stateDirectory } = storeToRefs(useContentStore());const { setContextMenu } = useAppStore();@@ -95,13 +95,20 @@ watch(props, handlePropsUpdate, { immediate: true, deep: true });{{ metaData?.fields?.duration }}</h4></section>- <section class="flex justify-between gap-4 w-full items-start text-sm sm:w-auto text-neutral-500 dark:text-neutral-400 group">+ <section class="flex flex-wrap justify-between gap-x-4 gap-y-2 w-full items-start text-sm sm:w-auto text-neutral-500 dark:text-neutral-400 group"><span class="flex gap-2 items-center w-full flex-1">- <h4 class="text-nowrap text-start truncate" title="View Count">- {{ metaData?.fields?.views }}- </h4>+ <span class="flex gap-1 truncate">+ <h4 class="text-nowrap text-start truncate" :title="`File Size: ${data.file_size ? formatFileSize(data.file_size) : ''}`">+ {{ data.file_size ? formatFileSize(data.file_size) : '' }}+ </h4>- <span class="hidden sm:flex flex-wrap gap-1 max-h-5 h-full sm:max-h-[24px] px-2 flex-1 overflow-y-auto scrollbar-minimal scrollbar-hover" title="Tags">+ <h4>|</h4>+ <h4 class="text-nowrap text-start truncate" :title="`View Count: ${metaData?.fields?.views}`">+ {{ metaData?.fields?.views }}+ </h4>+ </span>++ <span class="hidden sm:flex flex-wrap gap-1 max-h-[22px] px-2 flex-1 overflow-y-auto scrollbar-minimal scrollbar-hover" title="Tags"><ChipTagv-for="(tag, index) in props.data?.video_tags"v-bind:key="index"@@ -114,6 +121,15 @@ watch(props, handlePropsUpdate, { immediate: true, deep: true });<h4 class="text-end truncate" title="Date Uploaded">{{ toFormattedDate(new Date(props.data?.date + ' GMT')) }}</h4>++ <span class="sm:hidden w-full flex flex-wrap gap-1 scrollbar-minimal scrollbar-hover" title="Tags">+ <ChipTag+ v-for="(tag, index) in props.data?.video_tags"+ v-bind:key="index"+ :label="tag.name"+ :colour="'bg-neutral-200 leading-none text-neutral-500 shadow dark:bg-neutral-900 hover:bg-violet-600 hover:text-neutral-50 hover:dark:bg-violet-600/90'"+ />+ </span></section></RouterLink></template>diff --git a/resources/js/components/table/TableBase.vue b/resources/js/components/table/TableBase.vueindex 0eb81a89..408c911b 100755--- a/resources/js/components/table/TableBase.vue+++ b/resources/js/components/table/TableBase.vue@@ -57,8 +57,6 @@ const handleSortChange = (sortKey?: { title?: string; value?: string; disabled?:props.sortAction(lastSortKey.value, sortAscending.value ? 1 : -1);};-watch(() => props.data, tableData.handlePageReset, { immediate: true });-onMounted(() => {if (props.useToolbar && props.sortAction) props.sortAction(lastSortKey.value, props.startAscending ? 1 : -1);});diff --git a/resources/js/composables/useTable.ts b/resources/js/composables/useTable.tsindex dfa53900..7a124805 100644--- a/resources/js/composables/useTable.ts+++ b/resources/js/composables/useTable.ts@@ -22,7 +22,13 @@ export default function useTable(props: any) {},});- watch(() => props.data, table.handlePageReset, { immediate: true });+ watch(+ () => props.data,+ (newData, old) => {+ if (newData?.length !== old?.length || (newData[0] && old[0] && newData[0]?.id === old[0]?.id)) table.handlePageReset();+ },+ { immediate: true },+ );return table;}diff --git a/resources/js/views/VideoView.vue b/resources/js/views/VideoView.vueindex 7a6d3c9b..1192ee1c 100755--- a/resources/js/views/VideoView.vue+++ b/resources/js/views/VideoView.vue@@ -186,6 +186,91 @@ watch(() => selectedSideBar.value, cycleSideBar, { immediate: false });</template><template v-slot:sidebar><VideoSidebar />+ <table class="medialist table">+ <div class="entry row">+ <div class="cover">+ <div class="edit"></div>+ <div class="image" style="background-image: url('https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx128547-TWRVIu5zRTYx.jpg')"></div>+ </div>+ <div class="title"></div>+ <div score="9.4" label="Score" class="score">+ 9.4+ <!---->+ </div>+ <div label="Progress" class="progress">+ 13+ <!---->+ </div>+ <!---->+ <div label="Status" class="status">Completed</div>+ <div label="Format" class="format">TV</div>+ <span class="release-status FINISHED"></span>+ </div>+ </table></template></LayoutBase></template>+<style lang="css" scoped>+.medialist.table .entry:hover {+ background: rgb(50, 50, 50);+ color: rgb(255, 244, 233);+}+.medialist.table .row {+ display: flex;+ justify-content: space-between;+ align-items: center;+}++.medialist.table .entry {+ position: relative;+ transition: 0.15s;+}++.medialist.table .entry .cover {+ align-items: center;+ display: flex;+ flex: 1;+ justify-content: flex-end;+ max-width: 60px;+ min-width: 60px;+ padding: 0;+}++.medialist.table .entry .title {+ flex: 5;+ padding-left: 15px;+ text-align: left;+ display: flex;+ justify-content: flex-end;+ align-items: center;+ word-break: break-word;+}++.medialist.table .entry > div {+ flex: 1;+ padding: 18px 20px;+ text-align: center;+}++.medialist.table .entry .cover .image {+ background-position: 50%;+ background-repeat: no-repeat;+ background-size: cover;+ border-radius: 3px;+ height: 40px;+ width: 40px;+}++.medialist.table .entry:hover .cover .image {+ border-radius: 3px;+ box-shadow: 0 2px 20px rgba(49, 54, 68, 0.3);+ display: block;+ height: 200px;+ left: -160px;+ padding: 0;+ position: absolute;+ top: -60px;+ width: 140px;+ z-index: 1;+}+</style>