Skip to content

A self-hosted media server and file management system

Add video links to share, update history ui and add modals from pinesui

aminnausinff1f8911bc0c
diff --git a/resources/js/components/cards/RecordCardDetails.vue b/resources/js/components/cards/RecordCardDetails.vue
index 2bb64c7a..9ceafe9a 100644
--- a/resources/js/components/cards/RecordCardDetails.vue
+++ b/resources/js/components/cards/RecordCardDetails.vue
@@ -1,32 +1,70 @@
<script setup>
- import { toTimeSpan } from '../../service/util';
+import ButtonCorner from '../inputs/ButtonCorner.vue';
+
+import CircumLogin from '~icons/circum/login';
+import CircumMaximize1 from '~icons/circum/maximize-1';
+import CircumPlay1 from '~icons/circum/play-1';
+
+import { toTimeSpan } from '../../service/util';
+import { computed } from 'vue';
+
+const { record } = defineProps(['record']);
+
+const rawDate = new Date(record.attributes.created_at.replace(' ', 'T'));
+const timeSpan = toTimeSpan(rawDate);
+
+const videoLink = computed(() => {
+ return (`/${encodeURIComponent(record.relationships.category_name)}/${encodeURIComponent(record.relationships.folder_name)}?video=${record.relationships.video_id}`);
+})
- const { record } = defineProps(['record']);
- const rawDate = new Date(record.attributes.created_at.replace(' ', 'T'));
- const timeSpan = toTimeSpan(rawDate);
</script>
<template>
<div class="flex gap-12 group cursor-default">
- <div class="flex rounded-xl items-center justify-center dark:bg-primary-dark-800 bg-primary-800 dark:hover:bg-neutral-700 hover:bg-slate-200 dark:text-white shadow p-3 w-full group flex-grow cursor-pointer">
+ <div
+ class="hidden flex rounded-xl items-center justify-center dark:bg-primary-dark-800 bg-primary-800 dark:hover:bg-neutral-700 hover:bg-neutral-200 dark:text-white shadow p-3 w-full group flex-grow cursor-pointer">
<div class="w-full flex-wrap divide-y divide-gray-300">
<section class="flex justify-between items-baseline w-full">
<h2 class="text-xl text-left truncate">{{ record.relationships.video_name }}</h2>
- <h2 class="text-xl text-right truncate">{{ `${rawDate.toLocaleDateString('en-ca', {year: "numeric", month: '2-digit', day: '2-digit', hour: '2-digit', hour12:false, minute:'2-digit'})}` }}</h2>
+ <h2 class="text-xl text-right truncate">{{ `${rawDate.toLocaleDateString('en-ca', {
+ year: "numeric",
+ month: '2-digit', day: '2-digit', hour: '2-digit', hour12: false, minute:'2-digit'})}` }}</h2>
</section>
<aside class="flex justify-between items-center w-full pt-1">
<h3 class="text-lg text-left text-neutral-500 truncate">{{ record.relationships.folder_name }}</h3>
- <h3 class="text-lg text-right text-neutral-500 text-nowrap line-clamp-1 truncate">{{ timeSpan }}</h3>
+ <h3 class="text-lg text-right text-neutral-500 text-nowrap line-clamp-1 truncate">{{ timeSpan }}
+ </h3>
<span class="hidden space-x-1">
- <button class="hover:bg-orange-500 hover:stroke-none border-orange-500 border-2 rounded shadow px-2">Watch</button>
+ <button
+ class="hover:bg-orange-500 hover:stroke-none border-orange-500 border-2 rounded shadow px-2">Watch</button>
</span>
</aside>
</div>
</div>
- <div class="aspect-square rounded-full items-center justify-center group-hover:visible invisible flex">
- <button class="record-delete w-full p-3 items-center justify-center rounded-xl bg-red-700 hover:bg-red-600" :data-id={record} @click="$emit('deleteRecord')">
+ <div class="hidden aspect-square rounded-full items-center justify-center group-hover:visible invisible flex">
+ <button class="record-delete w-full p-3 items-center justify-center rounded-xl bg-red-700 hover:bg-red-600"
+ :data-id="record" @click="$emit('deleteRecord')">
Delete
</button>
</div>
+ <div class="relative flex flex-col gap-2 sm:flex-row flex-wrap rounded-xl dark:bg-primary-dark-800 bg-primary-800 dark:hover:bg-neutral-700 hover:bg-slate-200 dark:text-white shadow p-3 w-full group cursor-pointer sm:divide-y divide-gray-300 dark:divide-gray-400">
+ <section class="flex justify-between gap-4 w-full">
+ <h2 class="text-xl w-full truncate">{{ record.relationships.video_name }}</h2>
+ <div class="flex justify-end gap-1">
+ <ButtonCorner :positionClasses="'w-7 h-7'" :textClasses="'hover:text-indigo-600 dark:hover:text-indigo-300'" :colourClasses="'dark:hover:bg-neutral-800 hover:bg-slate-300'" :to="videoLink">
+ <template #icon>
+ <CircumPlay1 width="20" height="20" fill="none" viewBox="0 0 24 24"/>
+ </template>
+ </ButtonCorner>
+ <ButtonCorner :positionClasses="'w-7 h-7'" :textClasses="'text-rose-700'" :colourClasses="'dark:hover:bg-neutral-800 hover:bg-slate-300'" @click="$emit('deleteRecord')"/>
+ </div>
+ </section>
+ <section class="flex flex-col sm:flex-row sm:justify-between w-full pt-2">
+ <h3 class="text-lg text-neutral-500 w-full text-wrap truncate">{{ record.relationships.folder_name }} · {{ timeSpan }}</h3>
+ <h3 class="text-lg truncate sm:text-right text-neutral-500 w-full line-clamp-2">{{ `${rawDate.toLocaleDateString('en-ca', {
+ year: "numeric",
+ month: '2-digit', day: '2-digit', hour: '2-digit', hour12: false, minute:'2-digit'})}` }}</h3>
+ </section>
+ </div>
</div>
</template>
\ No newline at end of file
diff --git a/resources/js/components/icons/IconDelete.vue b/resources/js/components/icons/IconDelete.vue
new file mode 100644
index 00000000..c03c686e
--- /dev/null
+++ b/resources/js/components/icons/IconDelete.vue
@@ -0,0 +1,6 @@
+<template>
+ <svg class="w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
+ stroke="currentColor">
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
+ </svg>
+</template>
\ No newline at end of file
diff --git a/resources/js/components/inputs/ButtonCorner.vue b/resources/js/components/inputs/ButtonCorner.vue
new file mode 100644
index 00000000..184ff880
--- /dev/null
+++ b/resources/js/components/inputs/ButtonCorner.vue
@@ -0,0 +1,21 @@
+<script setup>
+import IconDelete from '../icons/IconDelete.vue';
+const props = defineProps(['positionClasses', 'colourClasses', 'textClasses', 'to', 'label']);
+</script>
+
+<template>
+ <router-link v-if="props?.to" :aria-label="props?.label ?? 'Link'" :to="props?.to ?? '/'"
+ class="flex items-center justify-center rounded-full"
+ :class="`${props?.positionClasses ?? 'absolute top-0 right-0 w-8 h-8 mt-5 mr-5'} ${props?.colourClasses ?? 'hover:bg-gray-50 hover:dark:bg-gray-700'} ${ props?.textClasses ?? 'text-gray-600 dark:text-gray-400 hover:text-gray-800 hover:dark:text-gray-200'}`">
+ <slot name="icon">
+ <IconDelete/>
+ </slot>
+ </router-link>
+ <button v-else :aria-label="props?.label ?? 'Close Modal'"
+ class="flex items-center justify-center rounded-full"
+ :class="`${props?.positionClasses ?? 'absolute top-0 right-0 w-8 h-8 mt-5 mr-5'} ${props?.colourClasses ?? 'hover:bg-gray-50 hover:dark:bg-gray-700'} ${ props?.textClasses ?? 'text-gray-600 dark:text-gray-400 hover:text-gray-800 hover:dark:text-gray-200'}`">
+ <slot name="icon">
+ <IconDelete/>
+ </slot>
+ </button>
+</template>
\ No newline at end of file
diff --git a/resources/js/components/pinesUI/ModalBase.vue b/resources/js/components/pinesUI/ModalBase.vue
new file mode 100644
index 00000000..dd020e61
--- /dev/null
+++ b/resources/js/components/pinesUI/ModalBase.vue
@@ -0,0 +1,54 @@
+<script setup>
+import ButtonCorner from '../inputs/ButtonCorner.vue';
+
+const props = defineProps(['modalData', 'action'])
+const toggleModal = props.modalData.toggleModal;
+
+const submitModal = async () => {
+ await props.action();
+ toggleModal(false);
+}
+</script>
+<template>
+ <div @keydown.escape="toggleModal(false)" :class="{ 'z-40': modalData.modalOpen }" class="relative w-auto h-auto">
+ <Teleport to="body">
+ <div v-if="modalData.modalOpen"
+ class="fixed top-0 left-0 z-[99] flex items-center justify-center w-screen h-screen text-neutral-900 dark:text-neutral-200"
+ v-cloak>
+ <Transition enter-active-class="ease-out duration-300" enter-from-class="opacity-0" enter-to-class="opacity-100" leave-active-class="ease-in duration-300" leave-from-class="opacity-100" leave-to-class="opacity-0">
+ <div v-if="modalData.modalOpen" @click="toggleModal(false)" class="absolute inset-0 w-full h-full backdrop-blur-sm bg-opacity-70"></div>
+ </Transition>
+ <Transition enter-active-class="ease-out duration-300" enter-from-class="opacity-0 -translate-y-2 sm:scale-95" enter-to-class="opacity-100 translate-y-0 sm:scale-100" leave-active-class="ease-in duration-200" leave-from-class="opacity-100 translate-y-0 sm:scale-100" leave-to-class="opacity-0 -translate-y-2 sm:scale-95">
+ <div v-if="modalData.modalOpen" x-trap.inert.noscroll="modalOpen" class="relative w-full m-6 p-6 bg-white dark:bg-neutral-800 border shadow-lg border-neutral-200 dark:border-neutral-700 sm:max-w-lg rounded-md sm:rounded-lg">
+ <div class="flex items-center justify-between pb-3">
+ <h3 class="text-lg font-semibold">{{ modalData?.props.title ?? 'Modal Title' }}</h3>
+ <ButtonCorner @click="toggleModal(false)"/>
+ <!-- <button @click="toggleModal(false)"
+ class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 text-gray-600 dark:text-gray-400 rounded-full hover:text-gray-800 hover:dark:text-gray-200 hover:bg-gray-50 hover:dark:bg-gray-700">
+ <svg class="w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
+ stroke-width="1.5" stroke="currentColor">
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
+ </svg>
+ </button> -->
+ </div>
+ <slot name="content">
+ <div class="relative w-auto pb-8">
+ <p>This is placeholder text. Replace it with your own content.</p>
+ </div>
+ </slot>
+ <slot name="controls">
+ <div class="relative flex flex-col-reverse sm:flex-row sm:justify-end gap-2">
+ <button @click="toggleModal(false)" 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="submitModal" 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 '">{{ modalData.props.submitText }}</button>
+ </div>
+ </slot>
+ </div>
+ </Transition>
+ </div>
+ </Teleport>
+ </div>
+</template>
\ No newline at end of file
diff --git a/resources/js/components/video/VideoInfoPanel.vue b/resources/js/components/video/VideoInfoPanel.vue
index d7681582..608e8126 100644
--- a/resources/js/components/video/VideoInfoPanel.vue
+++ b/resources/js/components/video/VideoInfoPanel.vue
@@ -6,6 +6,8 @@ import CircumShare1 from '~icons/circum/share-1';
import { watch } from 'vue';
import { storeToRefs } from 'pinia';
import { useContentStore } from '../../stores/ContentStore';
+import ModalBase from '../pinesUI/ModalBase.vue';
+import useModal from '../../composables/useModal';
const defaultDescription = `After defeating the
@@ -28,11 +30,13 @@ const defaultDescription = `After defeating the
const ContentStore = useContentStore();
const { stateVideo } = storeToRefs(ContentStore);
-const metaData = useMetaData(stateVideo.value.attributes);
+const editModal = useModal({title: 'Edit Video Details', submitText: 'Submit Details'});
+const shareModal = useModal({title: 'Share Video'});
+const metaData = useMetaData({...stateVideo.value.attributes, id: stateVideo.value.id});
const handlePropsUpdate = () => {
- metaData.updateData(stateVideo.value.attributes);
+ metaData.updateData({...stateVideo.value.attributes, id: stateVideo.value.id});
}
watch(() => stateVideo.value, handlePropsUpdate, {immediate: true});
@@ -61,21 +65,38 @@ watch(() => stateVideo.value, handlePropsUpdate, {immediate: true});
</div>
</div>
<div id="mp4-details"
- class="container flex sm:w-auto sm:flex-col justify-between lg:min-w-32 items-center sm:items-end gap-3 flex-wrap"
+ 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">
- <button aria-label="edit details"
+ <button aria-label="edit details" @click="editModal.toggleModal()"
class="p-2 bg-button-100 dark:bg-button-900 rounded-lg ring-violet-500 hover:ring-violet-700 hover:bg-violet-400/50 ring-[0.125rem] ring-inset shadow">Edit
Details</button>
- <button aria-label="share"
+ <button aria-label="share" @click="shareModal.toggleModal()"
class="p-2 bg-button-100 dark:bg-button-900 rounded-lg ring-neutral-700 hover:ring-violet-700 hover:bg-violet-400/50 dark:ring-[0.125rem] hover:ring-[0.125rem] ring-inset shadow">
<CircumShare1 height="24" width="24" />
</button>
</section>
- <section class="flex gap flex-col items-end text-sm dark:text-slate-400 text-slate-500 justify-between">
+ <section class="flex gap flex-col items-end text-sm dark:text-slate-400 text-slate-500 justify-between max-w-full">
<p>{{ metaData?.fields.views }}</p>
<p class="line-clamp-1 truncate">{{ stateVideo?.tags ?? '#atmospheroc #sad #rocky' }}</p>
</section>
</div>
</div>
+ <ModalBase :modalData="editModal" :action="() => { console.log('submit'); }">
+ <template #content>
+ <div class="py-6">
+ !! FORM !!
+ </div>
+ </template>
+ </ModalBase>
+ <ModalBase :modalData="shareModal" :action="() => { console.log('submit'); }">
+ <template #content>
+ <div class="py-3">
+ Copy link to clipboard to share it.
+ </div>
+ </template>
+ <template #controls>
+ <p>{{ metaData.fields.url }}</p>
+ </template>
+ </ModalBase>
</template>
\ No newline at end of file
diff --git a/resources/js/composables/useMetaData.js b/resources/js/composables/useMetaData.js
index d9f36c77..f66546fa 100644
--- a/resources/js/composables/useMetaData.js
+++ b/resources/js/composables/useMetaData.js
@@ -1,12 +1,15 @@
import { reactive, ref } from "vue";
import { toFormattedDuration } from "@/service/util";
+import { useRoute } from "vue-router";
// This so does not work lol
export default function useMetaData(data) {
+ const route = useRoute();
const fields = ref({
title: data?.title ?? data?.name,
duration: toFormattedDuration(data?.duration) ?? 'N/A',
views: data?.view_count ? `${data?.view_count} View${data?.view_count !== 1 ? 's' : ''}` : '0 Views',
+ url: document.location.origin + route.path + `?video=${data.id}`
})
const updateData = (props) => {
@@ -14,6 +17,7 @@ export default function useMetaData(data) {
title: props?.title ?? props?.name,
duration: toFormattedDuration(props?.duration) ?? 'N/A',
views: props?.view_count ? `${props?.view_count} View${props?.view_count !== 1 ? 's' : ''}` : '0 Views',
+ url: document.location.origin + route.path + `?video=${data.id}`
}
}
diff --git a/resources/js/composables/useModal.js b/resources/js/composables/useModal.js
new file mode 100644
index 00000000..f55c4427
--- /dev/null
+++ b/resources/js/composables/useModal.js
@@ -0,0 +1,16 @@
+import { reactive, ref } from "vue";
+
+export default function useModal(props){
+ const modalOpen = ref(false);
+
+ const toggleModal = (state = null) => {
+ if (state != null) modalOpen.value = state;
+ else modalOpen.value = !modalOpen.value;
+ }
+
+ return reactive({
+ props,
+ modalOpen,
+ toggleModal
+ });
+}
\ No newline at end of file
diff --git a/resources/js/stores/ContentStore.js b/resources/js/stores/ContentStore.js
index 53979842..50b6fad6 100644
--- a/resources/js/stores/ContentStore.js
+++ b/resources/js/stores/ContentStore.js
@@ -155,7 +155,7 @@ export const useContentStore = defineStore('Content', () => {
// eslint-disable-next-line no-undef
if(!result) toastr.error('Selected video cannot be found...');
stateVideo.value = result;
- console.log(document.location.origin + route.path + `?video=${stateVideo.value.id}`);
+ // console.log(document.location.origin + route.path + `?video=${stateVideo.value.id}`);
}
// InitPlaylist (set up playlist with indexes and current video)
diff --git a/resources/js/views/HistoryView.vue b/resources/js/views/HistoryView.vue
index 175f8025..945a0a03 100644
--- a/resources/js/views/HistoryView.vue
+++ b/resources/js/views/HistoryView.vue
@@ -1,11 +1,13 @@
<script setup>
import RecordCardDetails from '../components/cards/RecordCardDetails.vue';
import LayoutBase from '../components/layout/LayoutBase.vue';
+ import ModalBase from '../components/pinesUI/ModalBase.vue';
+ import useModal from '../composables/useModal';
import { storeToRefs } from 'pinia';
import { useAppStore } from '../stores/AppStore';
import { useContentStore } from '../stores/ContentStore';
- import { onMounted } from 'vue';
+ import { onMounted, ref } from 'vue';
const appStore = useAppStore();
@@ -14,6 +16,18 @@
const { records } = storeToRefs(ContentStore);
const { getRecords, deleteRecord } = ContentStore;
+ const cachedID = ref(null);
+ const confirmModal = useModal({title: 'Delete Record?', submitText: 'Confim'});
+
+ const handleDelete = (id) => {
+ cachedID.value = id;
+ confirmModal.toggleModal(true);
+ console.log(confirmModal.modalOpen);
+ }
+
+ const submitDelete = async () => {
+ if(cachedID.value) await deleteRecord(cachedID.value)
+ }
onMounted(() => {
getRecords();
@@ -25,8 +39,15 @@
<LayoutBase>
<template v-slot:content>
<section id="content-history" class=" space-y-2 cursor-pointer min-h-[80vh] pt-8">
- <RecordCardDetails v-for="record in records" :record="record" :key="record.recordID" @deleteRecord="deleteRecord(record.id)"/>
+ <RecordCardDetails v-for="record in records" :record="record" :key="record.recordID" @deleteRecord="handleDelete(record.id)"/>
</section>
+ <ModalBase :modalData="confirmModal" :action="submitDelete">
+ <template #content>
+ <div class="relative w-auto pb-8">
+ <p>Are you sure you want to delete this record?</p>
+ </div>
+ </template>
+ </ModalBase>
</template>
<template v-slot:sidebar>
<!-- <HistorySidebar /> -->