Skip to content

A self-hosted media server and file management system

update edit video and add exit folder

aminnausina330573dfe81
diff --git a/resources/js/components/forms/EditFolder.vue b/resources/js/components/forms/EditFolder.vue
new file mode 100644
index 00000000..ccf3acf1
--- /dev/null
+++ b/resources/js/components/forms/EditFolder.vue
@@ -0,0 +1,146 @@
+<script setup>
+import useForm from '../../composables/useForm';
+import mediaAPI from '../../service/mediaAPI';
+import FormInput from '../inputs/FormInput.vue';
+import FormTextArea from '../inputs/FormTextArea.vue';
+import FormInputLabel from '../labels/FormInputLabel.vue';
+
+import { reactive } from 'vue';
+import { useToast } from '../../composables/useToast';
+import DatePicker from '../pinesUI/DatePicker.vue';
+import FormInputNumber from '../inputs/FormInputNumber.vue';
+
+const emit = defineEmits(['handleFinish']);
+const props = defineProps(['video']);
+
+const toast = useToast();
+
+
+'title',
+'description',
+'studio',
+'seasons',
+'episodes',
+'films',
+'date_start',
+'date_end',
+'thumbnail_url',
+'editor_id'
+const fields = reactive([
+ {
+ name: 'title',
+ text: 'Title',
+ type: 'text',
+ required: true,
+ value: props.folder?.series?.attributes.title,
+ default: props.folder?.series?.attributes.title,
+ subtext: 'The intended title of the episode',
+ max: 255
+ },
+ {
+ name: 'description',
+ text: 'Description',
+ type: 'textArea',
+ value: props.folder?.series?.attributes.description,
+ default: ''
+ },
+ {
+ name: 'studio',
+ text: 'Studio',
+ type: 'text',
+ value: props.folder?.series?.attributes.studio,
+ subtext: 'The producer',
+ default: ''
+ },
+ {
+ name: 'episodes',
+ text: 'Episodes',
+ type: 'number',
+ value: props.folder?.series?.attributes.episodes ?? 1,
+ subtext: 'The number of episodes in the series',
+ default: 0,
+ min: 0,
+ },
+ {
+ name: 'seasons',
+ text: 'Seasons',
+ type: 'number',
+ value: props.folder?.series?.attributes.seasons ?? 1,
+ subtext: 'The number of seasons in the series',
+ default: 0,
+ min: 0,
+ },
+ {
+ name: 'films',
+ text: 'Films',
+ type: 'number',
+ value: props.folder?.series?.attributes.films ?? 1,
+ subtext: 'The number of films in the series',
+ default: 0,
+ min: 0,
+ },
+ {
+ name: 'date_start',
+ text: 'Start Date',
+ type: 'date',
+ value: props.folder?.series?.attributes.date_start,
+ default: null,
+ },
+ {
+ name: 'date_end',
+ text: 'End Date',
+ type: 'date',
+ value: props.folder?.series?.attributes.date_end,
+ default: null,
+ },
+]);
+
+const form = useForm({
+ title: props.video?.attributes.title ?? props.video?.attributes.name,
+ description: props.video?.attributes.description ?? '',
+ episode: props.video?.attributes.episode ?? null,
+ season: props.video?.attributes.season ?? null,
+});
+
+const handleSubmit = async () => {
+ form.submit(
+ async (fields) => {
+ return mediaAPI.updateVideo(props.video.id, fields);
+ },
+ {
+ onSuccess: (response) => {
+ emit('handleFinish', response?.data);
+ toast.add({ type: 'success', title:'Success', description:'Edit submitted!', life: 3000});
+ },
+ onError: () => {
+ toast.add({ type: 'danger', title:'Error', description:'Unable to update video details.', life: 3000});
+ },
+ }
+ )
+}
+</script>
+
+<template>
+ <form class="flex flex-col sm:flex-row sm:justify-between flex-wrap gap-4" @submit.prevent="handleSubmit">
+ <div v-for="(field, index) in fields" :key="index" class='w-full' :class="field.class">
+
+ <FormInputLabel :field="field"/>
+
+ <FormTextArea v-if="field.type === 'textArea'" v-model="form.fields[field.name]" :field="field" :tabindex="index + 1"/>
+ <DatePicker v-else-if="field.type === 'date'"/>
+ <FormInputNumber v-else-if="field.type === 'number'" v-model="form.fields[field.name]" :field="field" :tabindex="index + 1"/>
+ <FormInput v-else v-model="form.fields[field.name]" :field="field" :tabindex="index + 1"/>
+ <ul class="text-sm text-red-600 dark:text-red-400">
+ <li v-for="(item, index) in form.errors[field.name]" :key="index">{{ item }}</li>
+ </ul>
+ </div>
+ <div class="relative flex flex-col-reverse sm:flex-row sm:justify-end gap-2 pt-1 w-full">
+ <button @click="$emit('handleFinish')" type="button"
+ class="inline-flex items-center justify-center h-10 px-4 py-2 text-sm font-medium transition-colors border dark:border-neutral-600 rounded-md focus:outline-none "
+ :class="'focus:ring-1 focus:ring-neutral-100 dark:focus:ring-neutral-400 focus:ring-offset-1 hover:bg-neutral-100 dark:hover:bg-neutral-900'">Cancel</button>
+ <button @click="handleSubmit" type="button"
+ class="inline-flex items-center justify-center h-10 px-4 py-2 text-sm font-medium text-white transition-colors border border-transparent rounded-md focus:outline-none "
+ :class="'focus:ring-1 focus:ring-violet-900 focus:ring-offset-1 bg-neutral-950 hover:bg-neutral-800 dark:hover:bg-neutral-900 '">Submit Details</button>
+ </div>
+ </form>
+</template>
\ No newline at end of file
diff --git a/resources/js/components/forms/EditVideo.vue b/resources/js/components/forms/EditVideo.vue
index 9032a922..af0d9f63 100755
--- a/resources/js/components/forms/EditVideo.vue
+++ b/resources/js/components/forms/EditVideo.vue
@@ -4,6 +4,8 @@ import mediaAPI from '../../service/mediaAPI';
import FormInput from '../inputs/FormInput.vue';
import FormTextArea from '../inputs/FormTextArea.vue';
import FormInputLabel from '../labels/FormInputLabel.vue';
+import DatePicker from '../pinesUI/DatePicker.vue';
+import FormInputNumber from '../inputs/FormInputNumber.vue';
import { reactive } from 'vue';
import { useToast } from '../../composables/useToast';
@@ -47,6 +49,13 @@ const fields = reactive([
default: 0,
min: 0,
},
+ {
+ name: 'release_date',
+ text: 'Release Date',
+ type: 'date',
+ value: props.video?.attributes?.release_date ?? null,
+ default: null,
+ },
]);
const form = useForm({
@@ -81,8 +90,9 @@ const handleSubmit = async () => {
<FormInputLabel :field="field"/>
<FormTextArea v-if="field.type === 'textArea'" v-model="form.fields[field.name]" :field="field" :tabindex="index + 1"/>
+ <DatePicker v-else-if="field.type === 'date'"/>
+ <FormInputNumber v-else-if="field.type === 'number'" v-model="form.fields[field.name]" :field="field" :tabindex="index + 1"/>
<FormInput v-else v-model="form.fields[field.name]" :field="field" :tabindex="index + 1"/>
-
<ul class="text-sm text-red-600 dark:text-red-400">
<li v-for="(item, index) in form.errors[field.name]" :key="index">{{ item }}</li>
</ul>
diff --git a/resources/js/components/video/VideoInfoPanel.vue b/resources/js/components/video/VideoInfoPanel.vue
index 7ec4b29e..efe81b17 100755
--- a/resources/js/components/video/VideoInfoPanel.vue
+++ b/resources/js/components/video/VideoInfoPanel.vue
@@ -4,18 +4,22 @@ import useMetaData from '../../composables/useMetaData';
import ModalBase from '../pinesUI/ModalBase.vue';
import useModal from '../../composables/useModal';
import EditVideo from '../forms/EditVideo.vue';
+import EditFolder from '../forms/EditFolder.vue';
import CircumShare1 from '~icons/circum/share-1';
import { watch } from 'vue';
import { storeToRefs } from 'pinia';
import { useContentStore } from '../../stores/ContentStore';
+import { useAuthStore } from '../../stores/AuthStore';
import ButtonIcon from '../inputs/ButtonIcon.vue';
import ButtonText from '../inputs/ButtonText.vue';
const ContentStore = useContentStore();
+const AuthStore = useAuthStore();
const { stateVideo } = storeToRefs(ContentStore);
+const { userData } = storeToRefs(AuthStore);
const { updateVideoData } = ContentStore;
@@ -38,8 +42,9 @@ const defaultDescription = `After defeating the
seeing Fern is already remarkably skilled despite her youth.`;
const metaData = useMetaData({ ...stateVideo.value.attributes, id: stateVideo.value.id }, stateVideo.value);
-const editModal = useModal({ title: 'Edit Video Details', submitText: 'Submit Details' });
-const shareModal = useModal({ title: 'Share Video' });
+const editFolderModal = useModal({ title: 'Edit Folder Details', submitText: 'Submit Details' });
+const editVideoModal = useModal({ title: 'Edit Video Details', submitText: 'Submit Details' });
+const shareVideoModal = useModal({ title: 'Share Video' });
const handlePropsUpdate = () => {
metaData.updateData({ ...stateVideo.value.attributes, id: stateVideo.value.id });
@@ -50,7 +55,15 @@ const handleVideoDetailsUpdate = (res) => {
stateVideo.value = { index: stateVideo.value.index, ...res.data }
updateVideoData({ index: stateVideo.value.index, ...res.data }, stateVideo.value.index);
}
- editModal.toggleModal(false);
+ editVideoModal.toggleModal(false);
+}
+
+const handleSeriesUpdate = (res) => {
+ if (res?.data) {
+ stateVideo.value = { index: stateVideo.value.index, ...res.data }
+ updateVideoData({ index: stateVideo.value.index, ...res.data }, stateVideo.value.index);
+ }
+ editVideoModal.toggleModal(false);
}
watch(() => stateVideo.value, handlePropsUpdate, { immediate: true, deep: true });
@@ -62,7 +75,9 @@ watch(() => stateVideo.value, handlePropsUpdate, { immediate: true, deep: true }
<div id="mp4-description" class="flex items-center gap-4 w-full md:w-2/3 ">
<img id="folder-thumbnail" class="h-28 object-contain rounded-md shadow-md"
:src="stateVideo?.attributes?.thumbnail?.url ?? 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'"
- alt="Folder Cover Art">
+ alt="Folder Cover Art"
+ @click="() => {if(userData) editFolderModal.toggleModal()}"
+ title="Edit Folder Details">
<div class="h-full flex flex-col gap-2">
<div id="mp4-title" class="text-xl font-medium line capitalize">
{{ metaData?.fields.title ?? '[Video Name]' }}
@@ -76,14 +91,14 @@ watch(() => stateVideo.value, handlePropsUpdate, { immediate: true, deep: true }
class="container flex sm:w-auto sm:flex-col justify-between lg:min-w-32 items-center sm:items-end gap-3 flex-wrap flex-1 w-full"
role="group">
<section class="flex gap-2 justify-end">
- <ButtonText aria-label="edit details" title="Edit Video Details" @click="editModal.toggleModal()">
+ <ButtonText v-if="userData" aria-label="edit details" title="Edit Video Details" @click="editVideoModal.toggleModal()">
<template #text>
<p class="text-nowrap">
Edit Details
</p>
</template>
</ButtonText>
- <ButtonIcon aria-label="share" title="Share Video" @click="shareModal.toggleModal()">
+ <ButtonIcon aria-label="share" title="Share Video" @click="shareVideoModal.toggleModal()">
<template #icon>
<CircumShare1 height="24" width="24" />
</template>
@@ -100,21 +115,28 @@ watch(() => stateVideo.value, handlePropsUpdate, { immediate: true, deep: true }
</section>
</div>
</div>
- <ModalBase :modalData="editModal" :useControls="false">
+ <ModalBase :modalData="editFolderModal" :useControls="false">
+ <template #content>
+ <div class="pt-3">
+ <EditFolder :video="stateVideo" @handleFinish="handleSeriesUpdate" />
+ </div>
+ </template>
+ </ModalBase>
+ <ModalBase :modalData="editVideoModal" :useControls="false">
<template #content>
<div class="pt-3">
<EditVideo :video="stateVideo" @handleFinish="handleVideoDetailsUpdate" />
</div>
</template>
</ModalBase>
- <ModalBase :modalData="shareModal">
+ <ModalBase :modalData="shareVideoModal">
<template #content>
<div class="py-3">
Copy link to clipboard to share it.
</div>
</template>
<template #controls>
- <ButtonClipboard :text="metaData.fields.url" />
+ <ButtonClipboard :text="metaData.fields.url" tabindex="1"/>
</template>
</ModalBase>
</template>