Skip to content

A self-hosted media server and file management system

UI for when no data exists yet

aminnausin860406ef0f59
diff --git a/resources/js/components/video/VideoInfoPanel.vue b/resources/js/components/video/VideoInfoPanel.vue
index b0dea849..9ea957aa 100755
--- a/resources/js/components/video/VideoInfoPanel.vue
+++ b/resources/js/components/video/VideoInfoPanel.vue
@@ -77,7 +77,7 @@ watch(() => stateVideo.value, handlePropsUpdate, { immediate: true, deep: true }
<div class="flex flex-col sm:flex-row gap-2 sm:gap-4 p-3 w-full rounded-xl shadow-lg dark:bg-primary-dark-800/70 bg-primary-800 z-[11]">
<div id="mp4-header-mobile" class="flex items-center justify-between w-full sm:hidden gap-2 flex-wrap">
<h2 class="text-xl font-medium line-clamp-1 capitalize">
- {{ metaData?.fields.title ?? '[Video Name]' }}
+ {{ metaData?.fields.title ?? '[File Not Found]' }}
</h2>
<span class="flex gap-1 flex-row flex-wrap h-[22px] overflow-hidden">
<ChipTag v-for="(tag, index) in stateVideo?.video_tags" v-bind:key="index" :label="tag.name" />
@@ -113,7 +113,7 @@ watch(() => stateVideo.value, handlePropsUpdate, { immediate: true, deep: true }
</div>
<div class="flex flex-col gap-2 w-full group">
<h2 id="mp4-title" class="text-xl font-medium line-clamp-1 capitalize hidden sm:block h-8">
- {{ metaData?.fields.title ?? '[Video Name]' }}
+ {{ metaData?.fields.title ?? '[File Not Found]' }}
</h2>
<HoverCard :content="metaData?.fields?.description ?? defaultDescription" :hover-card-delay="800" :margin="10">
<template #trigger>
diff --git a/resources/js/composables/useMetaData.js b/resources/js/composables/useMetaData.js
index 66738d79..f95b7676 100755
--- a/resources/js/composables/useMetaData.js
+++ b/resources/js/composables/useMetaData.js
@@ -13,7 +13,7 @@ export default function useMetaData(data) {
duration: toFormattedDuration(data?.duration) ?? 'N/A',
views: data?.view_count ? `${data?.view_count} View${data?.view_count !== 1 ? 's' : ''}` : '0 Views',
description: data.description ?? '',
- url: encodeURI((data?.skipBaseURL ? '' : document.location.origin) + route.path + `?video=${data.id}`),
+ url: encodeURI(data?.skipBaseURL ? '' : document.location.origin + route.path + (data.id ? `?video=${data.id}` : '')),
file_size: data.file_size ? formatFileSize(data.file_size) : '',
},
updateData(props) {
@@ -21,7 +21,7 @@ export default function useMetaData(data) {
this.fields.duration = toFormattedDuration(props?.duration) ?? 'N/A';
this.fields.views = props?.view_count ? `${props?.view_count} View${props?.view_count !== 1 ? 's' : ''}` : '0 Views';
this.fields.description = props?.description ?? '';
- this.fields.url = encodeURI((props?.skipBaseURL ? '' : document.location.origin) + route.path + `?video=${props.id}`);
+ this.fields.url = encodeURI((props?.skipBaseURL ? '' : document.location.origin) + route.path + (data.id ? `?video=${data.id}` : ''));
this.file_size = data.file_size ? formatFileSize(data.file_size) : '';
},
});
diff --git a/resources/js/stores/ContentStore.js b/resources/js/stores/ContentStore.js
index 48110135..4218765d 100755
--- a/resources/js/stores/ContentStore.js
+++ b/resources/js/stores/ContentStore.js
@@ -138,35 +138,41 @@ export const useContentStore = defineStore('Content', () => {
}
async function getCategory(URL_CATEGORY, URL_FOLDER) {
- const { data: response, error } = await mediaAPI.getCategory(`${URL_CATEGORY}${URL_FOLDER ? '/' + URL_FOLDER : ''}`); // => {dir: {id,name,folderCount}, folder: {id,name,videos[],series}}
+ try {
+ const { data: response } = await mediaAPI.getCategory(`${URL_CATEGORY}${URL_FOLDER ? '/' + URL_FOLDER : ''}`); // => {dir: {id,name,folderCount}, folder: {id,name,videos[],series}}
- // statedir (list of folders) = dir => /api/categories/1
- // statefolder (list of videos) = folder => /api/folders/8?videos=true
+ // statedir (list of folders) = dir => /api/categories/1
+ // statefolder (list of videos) = folder => /api/folders/8?videos=true
- if (error || !response?.success) {
- toast.add('Error', { type: 'danger', description: response?.message ?? 'Unable to load data.' });
- pageTitle.value = 'Folder not Found';
- console.log(error ?? response?.message);
- return false;
- }
+ if (!response?.success) {
+ toast.add('Error', { type: 'danger', description: response?.message ?? 'Unable to load data.' });
+ pageTitle.value = 'Folder not Found';
+ console.log(error ?? response?.message);
+ return false;
+ }
- stateDirectory.value = response.data.dir;
- stateFolder.value = response.data.folder;
- // folders.value = data.data.dir.folders;
+ stateDirectory.value = response.data.dir;
+ stateFolder.value = response.data.folder;
+ // folders.value = data.data.dir.folders;
- pageTitle.value = stateFolder.value.name;
+ pageTitle.value = stateFolder.value.name;
- if (!stateFolder.value.id) {
- toast.add('Invalid folder', { type: 'danger', description: `The folder '${stateFolder.value.name}' does not exist.` });
- return false;
- }
+ if (!stateFolder.value.id) {
+ toast.add('Invalid folder', { type: 'danger', description: `The folder '${stateFolder.value.name}' does not exist.` });
+ return false;
+ }
- searchQuery.value = '';
+ searchQuery.value = '';
- playlistFind(route.query?.video);
+ playlistFind(route.query?.video);
- // InitPlaylist();
- return true;
+ // InitPlaylist();
+ return true;
+ } catch (error) {
+ pageTitle.value = 'Folder not Found';
+ console.log(error);
+ return false;
+ }
}
async function getFolder(nextFolderName) {
diff --git a/resources/js/views/VideoView.vue b/resources/js/views/VideoView.vue
index d020bac4..3c550c5a 100755
--- a/resources/js/views/VideoView.vue
+++ b/resources/js/views/VideoView.vue
@@ -30,7 +30,7 @@ const cachedVideoUrl = computed(() => {
if (!cachedVideo.value) return null;
return encodeURI(document.location.origin + route.path + `?video=${cachedVideo.value.id}`);
});
-const { selectedSideBar } = storeToRefs(useAppStore());
+const { selectedSideBar, pageTitle } = storeToRefs(useAppStore());
const { getFolder, getCategory, getRecords, playlistFind, playlistSort, updateVideoData } = useContentStore();
const { searchQuery, stateFilteredPlaylist, stateDirectory, stateVideo, stateFolder } = storeToRefs(useContentStore()) as unknown as {
searchQuery: Ref<string>;
@@ -55,15 +55,20 @@ async function cycleSideBar(state: string) {
async function reload() {
if (loading.value) return;
- const URL_CATEGORY = route.params.category;
- const URL_FOLDER = route.params.folder;
+ try {
+ const URL_CATEGORY = route.params.category;
+ const URL_FOLDER = route.params.folder;
- loading.value = true;
+ loading.value = true;
- if (stateDirectory.value?.name && stateDirectory.value.name === URL_CATEGORY && URL_FOLDER) {
- await getFolder(URL_FOLDER);
- } else {
- await getCategory(URL_CATEGORY, URL_FOLDER);
+ if (stateDirectory.value?.name && stateDirectory.value.name === URL_CATEGORY && URL_FOLDER) {
+ await getFolder(URL_FOLDER);
+ } else {
+ await getCategory(URL_CATEGORY, URL_FOLDER);
+ }
+ } catch (error) {
+ console.log(error);
+ pageTitle.value = 'Folder not Found';
}
loading.value = false;
}