A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
Remove video table and replace it with the standard table element
aminnausinc3a0336c6175
diff --git a/resources/js/components/cards/VideoCard.vue b/resources/js/components/cards/VideoCard.vueindex baad4c04..0a5a07cd 100644--- a/resources/js/components/cards/VideoCard.vue+++ b/resources/js/components/cards/VideoCard.vue@@ -1,28 +1,26 @@<script setup>import useMetaData from '../../composables/useMetaData';-import { toFormattedDate } from '@/service/util';import { watch } from 'vue';--const props = defineProps(['video', 'index', 'currentID']);-const metaData = useMetaData(props.video?.attributes);-const emit = defineEmits(['playByID']);+const props = defineProps(['data', 'index', 'currentID']);+const metaData = useMetaData(props.data?.attributes);+const emit = defineEmits(['clickAction']);const handlePlay = () => {- emit('playByID', props.video?.id);+ emit('clickAction', props.data?.id);}const handlePropsUpdate = () => {- metaData.updateData(props.video?.attributes);+ metaData.updateData(props.data?.attributes);}watch(props, handlePropsUpdate, {immediate: true});</script><template>- <div :class="{ 'ring-violet-600/70 ring-[0.125rem]': (props.currentID === props.video?.id) }"+ <div :class="{ 'ring-violet-600/70 ring-[0.125rem]': (props?.currentID === props.data?.id) }"class="flex flex-wrap flex-col sm:flex-row sm:flex-nowrap gap-x-8 gap-y-4 p-3 w-full shadow rounded-md ring-inset dark:bg-primary-dark-800/70 dark:hover:bg-violet-700/70 bg-gray-100 hover:bg-violet-400/30 odd:bg-violet-100 dark:odd:bg-primary-dark-600"- :data-id="props.video?.id" :data-path="`../${props.video?.attributes.path}`" @click="handlePlay">+ :data-id="props.data?.id" :data-path="`../${props.data?.attributes.path}`" @click="handlePlay"><section class="flex justify-between gap-4 w-full items-start sm:items-center"><h3 class="w-full line-clamp-2 sm:line-clamp-1">{{ metaData?.fields?.title }}@@ -36,7 +34,7 @@ watch(props, handlePropsUpdate, {immediate: true});{{ metaData?.fields?.duration }}</h3><h3 class="line-clamp-1 sm:min-w-40">- {{ toFormattedDate(new Date(props.video?.attributes.date + ' GMT')) }}+ {{ props.data?.attributes.date }}</h3></section></div>diff --git a/resources/js/components/table/TableBase.vue b/resources/js/components/table/TableBase.vueindex 939fe174..2971daac 100644--- a/resources/js/components/table/TableBase.vue+++ b/resources/js/components/table/TableBase.vue@@ -12,7 +12,7 @@ import PhSortDescendingLight from '~icons/ph/sort-descending-light';import { ref, watch } from 'vue';-const props = defineProps(['useToolbar','data', 'row', 'clickAction', 'loading', 'sortAction', 'sortingOptions']);+const props = defineProps(['useToolbar','data', 'row', 'clickAction', 'loading', 'sortAction', 'sortingOptions', 'itemsPerPage','searchQuery', 'selectedID']);const tableData = useTable(props);const sortAscending = ref(true);const lastSortKey = ref('');@@ -49,7 +49,7 @@ watch(props.data, tableData.handlePageReset, {immediate: true});</section><tbody class="flex w-full flex-wrap gap-2"><div v-if="tableData.filteredPage.length === 0 && !props.loading" class="text-center text-lg text-gray-500 dark:text-gray-400 uppercase tracking-wider w-full">No Results</div>- <component v-else :is="props.row" v-for="(row, index) in tableData.filteredPage" :key="row?.id ?? index" :data="row" @clickAction="props.clickAction(row?.id)"></component>+ <component v-else :is="props.row" v-for="(row, index) in tableData.filteredPage" :key="row?.id ?? index" :data="row" :index="index" :currentID="props.selectedID ?? null" @clickAction="props.clickAction(row?.id)"></component></tbody><TablePagination :listLength="props.data?.length ?? 0" :itemsPerPage="tableData.fields.itemsPerPage" :currentPage="tableData.fields.currentPage" @setPage="tableData.handlePageChange"/></table>diff --git a/resources/js/components/table/TablePagination.vue b/resources/js/components/table/TablePagination.vueindex 3506bcf8..257f73c4 100644--- a/resources/js/components/table/TablePagination.vue+++ b/resources/js/components/table/TablePagination.vue@@ -24,12 +24,12 @@ const pageRange = computed(() => {const handleSetPage = async (page) => {emit('setPage', page);await nextTick();- $element.value?.scrollIntoView({behavior: "smooth"});+ $element.value?.scrollIntoView({behavior: "smooth", block: "end"});}</script><template>- <div class="flex items-center flex-col sm:flex-row sm:justify-between flex-wrap gap-2" ref="$element">+ <div class="flex items-center flex-col sm:flex-row sm:justify-between flex-wrap gap-2 scroll-mb-12" ref="$element"><p class="text-gray-700 dark:text-neutral-300 line-clamp-1">Showing<span class="font-medium dark:text-neutral-100">{{ props.listLength ? props.itemsPerPage * (currentPage - 1) + 1 : 0 }}</span>diff --git a/resources/js/components/video/VideoTable.vue b/resources/js/components/video/VideoTable.vuedeleted file mode 100644index 5727cb32..00000000--- a/resources/js/components/video/VideoTable.vue+++ /dev/null@@ -1,117 +0,0 @@-<script setup>-import LabelledTextInput from '../inputs/LabelledTextInput.vue';-import FormInputLabel from '../labels/FormInputLabel.vue';-import TablePagination from '../table/TablePagination.vue';-import InputSelect from '../pinesUI/InputSelect.vue';-import VideoCard from '../cards/VideoCard.vue';--import PhSortAscendingLight from '~icons/ph/sort-ascending-light';-import PhSortDescendingLight from '~icons/ph/sort-descending-light';--import { useContentStore } from '../../stores/ContentStore';-import { storeToRefs } from 'pinia';-import { computed, ref, watch } from 'vue';-import ButtonIcon from '../inputs/ButtonIcon.vue';---const ContentStore = useContentStore();-const { searchQuery, stateFilteredPlaylist, stateVideo, stateFolder } = storeToRefs(ContentStore);-const { playlistFind, playlistSort } = ContentStore;--const currentPage = ref(1);-const itemsPerPage = ref(10);-const filteredPage = computed(() => {- const minIndex = itemsPerPage.value * (currentPage.value - 1);- const maxIndex = Math.min(itemsPerPage.value * (currentPage.value), stateFilteredPlaylist.value.length);-- return stateFilteredPlaylist.value.slice(minIndex, maxIndex);-});-const sortAscending = ref(true);-const lastSortKey = ref('');--const handlePageChange = (page) => {- currentPage.value = page;-}--const handlePageReset = () => {- currentPage.value = 1-};--const handleSortChange = (sortKey) => {- if (sortKey?.value) lastSortKey.value = sortKey?.value;-- if (!lastSortKey.value) return;- playlistSort(lastSortKey.value, sortAscending.value ? 1 : -1)-}--const sortingOptions = ref([- {- title: 'Title',- value: 'title',- disabled: false- },- {- title: 'Duration',- value: 'duration',- disabled: false- },- {- title: 'Views',- value: 'view_count',- disabled: false- },- {- title: 'Date Uploaded',- value: 'date',- disabled: false- },- {- title: 'Date released',- value: 'date_released',- disabled: true- },- {- title: 'Episode',- value: 'episode',- disabled: true- },- {- title: 'Season',- value: 'season',- disabled: true- },-]);--watch(stateFolder, handlePageReset, { immediate: true })-</script>--<template>- <table class="w-full flex flex-col gap-2">- <section class="flex justify-center sm:justify-between py-2 flex-col sm:flex-row gap-2">- <!-- <h2 class="text-2xl py-4">Episodes</h2> -->- <LabelledTextInput v-model="searchQuery" :text="'Search:'" :placeholder="'Enter Search Query...'"- :id="'table-search'" class="w-full sm:w-80" title="Search Results"/>- <span class="flex items-end gap-2">- <div class="flex gap-2 flex-col w-full sm:w-40">- <FormInputLabel :field="{ name: 'sort', text: 'Sort by:' }" />- <InputSelect :placeholder="'None'" :options="sortingOptions" class="w-full" title="Select Sort"- @selectItem="handleSortChange" :defaultItem="0" />- </div>- <ButtonIcon @click="sortAscending = !sortAscending; handleSortChange()">- <template #icon>- <PhSortAscendingLight v-if="sortAscending" width="24" height="24" />- <PhSortDescendingLight v-else width="24" height="24" />- </template>- </ButtonIcon>- </span>- </section>- <hr>- <tbody class="flex w-full flex-wrap gap-2">- <VideoCard v-for="(video, index) in filteredPage" :key="index" :video="video" :index="index"- :currentID="stateVideo?.id" @playByID="playlistFind" />- </tbody>- <hr>- <TablePagination :listLength="stateFilteredPlaylist?.length ?? 0" :itemsPerPage="itemsPerPage"- :currentPage="currentPage" @setPage="handlePageChange" />- </table>-</template>\ No newline at end of filediff --git a/resources/js/composables/useTable.js b/resources/js/composables/useTable.jsindex a595a248..9cd02340 100644--- a/resources/js/composables/useTable.js+++ b/resources/js/composables/useTable.js@@ -2,8 +2,8 @@ import { computed, reactive, ref, watch } from 'vue';export default function useTable(props){const currentPage = ref(1);- const itemsPerPage = ref(10);- const searchQuery = ref('')+ const itemsPerPage = ref(props.itemsPerPage ?? 10);+ const searchQuery = ref(props.searchQuery ?? '')const handlePageChange = (page) => {currentPage.value = page;diff --git a/resources/js/stores/ContentStore.js b/resources/js/stores/ContentStore.jsindex aa8809bf..9fe12475 100644--- a/resources/js/stores/ContentStore.js+++ b/resources/js/stores/ContentStore.js@@ -1,5 +1,6 @@-import recordsAPI from "../service/recordsAPI";-import mediaAPI from "../service/mediaAPI";+import recordsAPI from "@/service/recordsAPI";+import mediaAPI from "@/service/mediaAPI";+import { toFormattedDate } from '@/service/util';import { ref, watch } from "vue";import { defineStore, storeToRefs } from "pinia";@@ -15,7 +16,6 @@ export const useContentStore = defineStore('Content', () => {const route = useRoute();const folders = ref([]);- const videos = ref([]);const records = ref([]);const stateDirectory = ref({id:7, name:'anime', folders: []})@@ -186,7 +186,10 @@ export const useContentStore = defineStore('Content', () => {return;}- statePlaylist.value = stateFolder.value.videos.map((video, index) => { return {index, ...video}; } );+ statePlaylist.value = stateFolder.value.videos.map((video, index) => {+ video.attributes.date = toFormattedDate(new Date(video.attributes.date + ' GMT'));+ return {index, ...video};+ } );playlistSort();searchQuery.value = '';playlistFind(route.query?.video);@@ -208,9 +211,13 @@ export const useContentStore = defineStore('Content', () => {}const playlistFilter = (query) => {+ console.log(query);+let tempList = query ? statePlaylist.value.filter((video) => {{try {let strRepresentation = [video.attributes.name, video.attributes.date].join(' ').toLowerCase();+ console.log(strRepresentation);+return strRepresentation.includes(query.toLowerCase())} catch (error) {console.log(error);@@ -231,7 +238,7 @@ export const useContentStore = defineStore('Content', () => {watch(searchQuery, playlistFilter, {immediate: false});return {- folders, videos, records,+ folders, records,stateDirectory, stateFolder, stateVideo,searchQuery, filterQuery, stateFilteredPlaylist,getRecords, createRecord, deleteRecord, recordsSort,diff --git a/resources/js/views/VideoView.vue b/resources/js/views/VideoView.vueindex bb0b8ef8..4bd1c5b4 100644--- a/resources/js/views/VideoView.vue+++ b/resources/js/views/VideoView.vue@@ -2,21 +2,24 @@import VideoSidebar from '../components/panels/VideoSidebar.vue';import LayoutBase from '../components/layout/LayoutBase.vue';import VideoPlayer from '../components/video/VideoPlayer.vue';-import VideoTable from '../components/video/VideoTable.vue';import VideoInfoPanel from '../components/video/VideoInfoPanel.vue';+import VideoCard from '../components/cards/VideoCard.vue';-import { nextTick, onMounted, watch } from 'vue';+import { nextTick, onMounted, ref, watch } from 'vue';import { useContentStore } from '../stores/ContentStore';import { useAppStore } from '../stores/AppStore';import { storeToRefs } from 'pinia';import { useRoute } from 'vue-router'+import TableBase from '../components/table/TableBase.vue';const route = useRoute();+const loading = ref(true);const appStore = useAppStore();const ContentStore = useContentStore();const { selectedSideBar } = storeToRefs(appStore);-const { getFolder, getCategory, getRecords } = ContentStore;+const { searchQuery, stateFilteredPlaylist, stateVideo} = storeToRefs(ContentStore);+const { getFolder, getCategory, getRecords, playlistFind, playlistSort } = ContentStore;async function cycleSideBar(state) {if (state === "history") {@@ -29,14 +32,65 @@ async function cycleSideBar(state) {}async function reload(nextFolderName) {+ loading.value = true;await getFolder(nextFolderName);+ loading.value = false;+}++// Table++const sortingOptions = ref([+ {+ title: 'Title',+ value: 'title',+ disabled: false+ },+ {+ title: 'Duration',+ value: 'duration',+ disabled: false+ },+ {+ title: 'Views',+ value: 'view_count',+ disabled: false+ },+ {+ title: 'Date Uploaded',+ value: 'date',+ disabled: false+ },+ {+ title: 'Date released',+ value: 'date_released',+ disabled: true+ },+ {+ title: 'Episode',+ value: 'episode',+ disabled: true+ },+ {+ title: 'Season',+ value: 'season',+ disabled: true+ },+]);++const handleSort = (column = 'date', dir = 1) =>{+ playlistSort(column, dir);+}++const handleSearch = (query) => {+ searchQuery.value = query;}onMounted(async () => {const URL_CATEGORY = route.params.category;const URL_FOLDER = route.params.folder;- getCategory(URL_CATEGORY, URL_FOLDER);+ await getCategory(URL_CATEGORY, URL_FOLDER);+ loading.value = false;})watch(() => route.params.folder, reload, { immediate: false });@@ -57,7 +111,7 @@ watch(() => selectedSideBar.value, cycleSideBar, { immediate: false });<!-- <hr id='preData'> -->- <VideoTable />+ <TableBase :data="stateFilteredPlaylist" :row="VideoCard" :clickAction="playlistFind" :loading="loading" :useToolbar="true" :sortAction="handleSort" :sortingOptions="sortingOptions" :selectedID="stateVideo?.id" @search="handleSearch"/></section></template><template v-slot:sidebar>