2024-04-16 02:57:45 -04:00
|
|
|
<template>
|
2024-04-27 16:44:52 -04:00
|
|
|
<div
|
|
|
|
id="playlist-container"
|
|
|
|
ref="playlistContainer"
|
|
|
|
class="relative w-full h-full !bg-base-300 rounded-e overflow-auto"
|
|
|
|
>
|
2024-04-16 02:57:45 -04:00
|
|
|
<div v-if="playlistStore.isLoading" class="w-full h-full absolute z-10 flex justify-center bg-base-100/70">
|
|
|
|
<span class="loading loading-spinner loading-lg" />
|
|
|
|
</div>
|
|
|
|
<table class="table table-zebra table-fixed">
|
|
|
|
<thead class="top-0 sticky z-10">
|
|
|
|
<tr class="bg-base-100 rounded-tr-lg">
|
2024-05-15 02:53:25 -04:00
|
|
|
<th v-if="!configStore.playout.playlist.infinit" class="w-[85px] p-0 text-left">
|
2024-04-16 02:57:45 -04:00
|
|
|
<div class="border-b border-my-gray px-4 py-3 -mb-[2px]">
|
2024-08-27 05:16:58 -04:00
|
|
|
{{ t('player.start') }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
2024-04-19 04:59:17 -04:00
|
|
|
<th class="w-full p-0 text-left">
|
2024-04-16 02:57:45 -04:00
|
|
|
<div class="border-b border-my-gray px-4 py-3 -mb-[2px]">
|
2024-08-27 05:16:58 -04:00
|
|
|
{{ t('player.file') }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
2024-05-05 14:47:43 -04:00
|
|
|
<th class="w-[85px] p-0 text-center">
|
2024-04-16 02:57:45 -04:00
|
|
|
<div class="border-b border-my-gray px-4 py-3 -mb-[2px]">
|
2024-08-27 05:16:58 -04:00
|
|
|
{{ t('player.play') }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
2024-09-25 01:48:31 -04:00
|
|
|
<th class="w-[85px] p-0 text-center hidden 2xs:table-cell">
|
2024-04-16 02:57:45 -04:00
|
|
|
<div class="border-b border-my-gray px-4 py-3 -mb-[2px]">
|
2024-08-27 05:16:58 -04:00
|
|
|
{{ t('player.duration') }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
<th class="w-[85px] p-0 text-center hidden xl:table-cell">
|
|
|
|
<div class="border-b border-my-gray px-4 py-3 -mb-[2px]">
|
2024-08-27 05:16:58 -04:00
|
|
|
{{ t('player.in') }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
<th class="w-[85px] p-0 text-center hidden xl:table-cell">
|
|
|
|
<div class="border-b border-my-gray px-4 py-3 -mb-[2px]">
|
2024-08-27 05:16:58 -04:00
|
|
|
{{ t('player.out') }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
<th class="w-[85px] p-0 text-center hidden xl:table-cell justify-center">
|
|
|
|
<div class="border-b border-my-gray px-4 py-3 -mb-[2px]">
|
2024-08-27 05:16:58 -04:00
|
|
|
{{ t('player.ad') }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
2024-05-05 14:47:43 -04:00
|
|
|
<th class="w-[85px] p-0 text-center">
|
2024-04-16 02:57:45 -04:00
|
|
|
<div class="border-b border-my-gray px-4 py-3 -mb-[2px]">
|
2024-08-27 05:16:58 -04:00
|
|
|
{{ t('player.edit') }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
2024-09-25 01:48:31 -04:00
|
|
|
<th class="w-[85px] p-0 text-center hidden 2xs:table-cell justify-center">
|
2024-04-16 02:57:45 -04:00
|
|
|
<div class="border-b border-my-gray px-4 py-3 -mb-[2px]">
|
2024-08-27 05:16:58 -04:00
|
|
|
{{ t('player.delete') }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2024-04-19 04:59:17 -04:00
|
|
|
|
2024-04-16 02:57:45 -04:00
|
|
|
<Sortable
|
2024-04-19 04:59:17 -04:00
|
|
|
id="sort-container"
|
|
|
|
ref="sortContainer"
|
2024-04-16 02:57:45 -04:00
|
|
|
:list="playlistStore.playlist"
|
|
|
|
item-key="uid"
|
|
|
|
tag="tbody"
|
|
|
|
:options="playlistSortOptions"
|
|
|
|
@add="addClip"
|
|
|
|
@start="addBG"
|
|
|
|
@end="moveItemInArray"
|
|
|
|
>
|
|
|
|
<template #item="{ element, index }">
|
|
|
|
<tr
|
|
|
|
:id="`clip-${index}`"
|
2024-04-16 12:13:28 -04:00
|
|
|
:key="element.uid"
|
2024-04-16 02:57:45 -04:00
|
|
|
class="draggable border-t border-b border-base-content/20 duration-1000 transition-all"
|
|
|
|
:class="{
|
|
|
|
'!bg-lime-500/30':
|
2024-09-11 03:51:16 -04:00
|
|
|
playlistStore.playoutIsRunning && listDate === todayDate && index === currentIndex,
|
2024-04-17 03:55:57 -04:00
|
|
|
'!bg-amber-600/40': element.overtime,
|
2024-09-27 05:34:52 -04:00
|
|
|
'text-blue-300': element.category === 'advertisement',
|
2024-04-16 02:57:45 -04:00
|
|
|
}"
|
|
|
|
>
|
2024-05-15 02:53:25 -04:00
|
|
|
<td v-if="!configStore.playout.playlist.infinit" class="ps-4 py-2 text-left">
|
|
|
|
{{ secondsToTime(element.begin) }}
|
|
|
|
</td>
|
2024-04-16 02:57:45 -04:00
|
|
|
<td class="py-2 text-left truncate" :class="{ 'grabbing cursor-grab': width > 768 }">
|
2024-04-30 10:48:01 -04:00
|
|
|
{{ element.title || filename(element.source) }}
|
2024-04-16 02:57:45 -04:00
|
|
|
</td>
|
|
|
|
<td class="py-2 text-center hover:text-base-content/70">
|
|
|
|
<button @click="preview(element.source)">
|
|
|
|
<i class="bi-play-fill" />
|
|
|
|
</button>
|
|
|
|
</td>
|
2024-09-25 01:48:31 -04:00
|
|
|
<td class="py-2 text-center hidden 2xs:table-cell">{{ secToHMS(element.duration) }}</td>
|
2024-04-16 02:57:45 -04:00
|
|
|
<td class="py-2 text-center hidden xl:table-cell">
|
|
|
|
{{ secToHMS(element.in) }}
|
|
|
|
</td>
|
|
|
|
<td class="py-2 text-center hidden xl:table-cell">
|
|
|
|
{{ secToHMS(element.out) }}
|
|
|
|
</td>
|
|
|
|
<td class="py-2 text-center hidden xl:table-cell leading-3">
|
|
|
|
<input
|
|
|
|
class="checkbox checkbox-xs rounded"
|
|
|
|
type="checkbox"
|
|
|
|
:checked="element.category && element.category === 'advertisement' ? true : false"
|
|
|
|
@change="setCategory($event, element)"
|
2024-04-17 03:55:57 -04:00
|
|
|
/>
|
2024-04-16 02:57:45 -04:00
|
|
|
</td>
|
|
|
|
<td class="py-2 text-center hover:text-base-content/70">
|
|
|
|
<button @click="editItem(index)">
|
|
|
|
<i class="bi-pencil-square" />
|
|
|
|
</button>
|
|
|
|
</td>
|
2024-09-25 01:48:31 -04:00
|
|
|
<td class="py-2 text-center hidden 2xs:table-cell justify-center hover:text-base-content/70">
|
2024-04-16 02:57:45 -04:00
|
|
|
<button @click="deletePlaylistItem(index)">
|
|
|
|
<i class="bi-x-circle-fill" />
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
</Sortable>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
|
|
2024-08-27 05:16:58 -04:00
|
|
|
const { t } = useI18n()
|
2024-04-16 02:57:45 -04:00
|
|
|
const { $dayjs } = useNuxtApp()
|
|
|
|
const { width } = useWindowSize({ initialWidth: 800 })
|
|
|
|
|
|
|
|
const configStore = useConfig()
|
|
|
|
const mediaStore = useMedia()
|
|
|
|
const playlistStore = usePlaylist()
|
|
|
|
const { secToHMS, filename, secondsToTime } = stringFormatter()
|
|
|
|
const { processPlaylist, genUID } = playlistOperations()
|
|
|
|
|
2024-04-27 16:44:52 -04:00
|
|
|
const playlistContainer = ref()
|
2024-04-19 04:59:17 -04:00
|
|
|
const sortContainer = ref()
|
2024-04-16 02:57:45 -04:00
|
|
|
const todayDate = ref($dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD'))
|
2024-08-22 04:59:11 -04:00
|
|
|
const { id } = storeToRefs(useConfig())
|
2024-09-13 01:31:32 -04:00
|
|
|
const { currentIndex, listDate, playoutIsRunning } = storeToRefs(usePlaylist())
|
2024-04-16 02:57:45 -04:00
|
|
|
|
|
|
|
const playlistSortOptions = {
|
|
|
|
group: 'playlist',
|
|
|
|
animation: 100,
|
|
|
|
handle: '.grabbing',
|
|
|
|
}
|
|
|
|
|
2024-04-30 03:11:26 -04:00
|
|
|
defineProps({
|
2024-04-16 02:57:45 -04:00
|
|
|
editItem: {
|
|
|
|
type: Function,
|
|
|
|
default() {
|
|
|
|
return ''
|
|
|
|
},
|
|
|
|
},
|
|
|
|
preview: {
|
|
|
|
type: Function,
|
|
|
|
default() {
|
|
|
|
return ''
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
onMounted(() => {
|
2024-07-22 04:32:21 -04:00
|
|
|
setTimeout(() => {
|
|
|
|
getPlaylist()
|
|
|
|
}, 150)
|
2024-04-16 02:57:45 -04:00
|
|
|
})
|
|
|
|
|
2024-08-22 04:59:11 -04:00
|
|
|
watch([listDate, id], () => {
|
2024-06-24 01:51:50 -04:00
|
|
|
setTimeout(() => {
|
|
|
|
getPlaylist()
|
|
|
|
}, 800)
|
2024-04-16 02:57:45 -04:00
|
|
|
})
|
|
|
|
|
2024-09-13 01:31:32 -04:00
|
|
|
watch([playoutIsRunning], () => {
|
|
|
|
setTimeout(() => {
|
|
|
|
scrollTo(currentIndex.value)
|
|
|
|
}, 400)
|
|
|
|
})
|
|
|
|
|
2024-04-19 04:59:17 -04:00
|
|
|
defineExpose({
|
|
|
|
classSwitcher,
|
2024-04-30 03:11:26 -04:00
|
|
|
getPlaylist,
|
2024-04-19 04:59:17 -04:00
|
|
|
})
|
|
|
|
|
2024-04-30 03:11:26 -04:00
|
|
|
function scrollTo(index: number) {
|
|
|
|
const child = document.getElementById(`clip-${index}`)
|
|
|
|
const parent = document.getElementById('playlist-container')
|
|
|
|
|
|
|
|
if (child && parent) {
|
|
|
|
const topPos = child.offsetTop
|
|
|
|
parent.scrollTop = topPos - 50
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-19 04:59:17 -04:00
|
|
|
function classSwitcher() {
|
2024-04-27 16:44:52 -04:00
|
|
|
if (playlistStore.playlist.length === 0) {
|
2024-05-05 14:47:43 -04:00
|
|
|
sortContainer.value?.sortable.el.classList.add('is-empty')
|
2024-04-19 04:59:17 -04:00
|
|
|
} else {
|
2024-04-27 16:44:52 -04:00
|
|
|
const lastItem = playlistStore.playlist[playlistStore.playlist.length - 1]
|
|
|
|
|
|
|
|
if (
|
|
|
|
configStore.playout.playlist.startInSec + configStore.playout.playlist.lengthInSec >
|
2024-05-15 02:53:25 -04:00
|
|
|
lastItem.begin + lastItem.out - lastItem.in ||
|
|
|
|
configStore.playout.playlist.infinit
|
2024-04-27 16:44:52 -04:00
|
|
|
) {
|
2024-05-05 14:47:43 -04:00
|
|
|
sortContainer.value?.sortable.el.classList.add('add-space')
|
2024-04-27 16:44:52 -04:00
|
|
|
} else {
|
2024-05-05 14:47:43 -04:00
|
|
|
sortContainer.value?.sortable.el.classList.remove('add-space')
|
2024-04-27 16:44:52 -04:00
|
|
|
}
|
2024-05-05 14:47:43 -04:00
|
|
|
sortContainer.value?.sortable.el.classList.remove('is-empty')
|
2024-04-19 04:59:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-30 03:11:26 -04:00
|
|
|
async function getPlaylist() {
|
|
|
|
playlistStore.isLoading = true
|
|
|
|
await playlistStore.getPlaylist(listDate.value)
|
|
|
|
playlistStore.isLoading = false
|
|
|
|
|
2024-04-30 03:29:37 -04:00
|
|
|
if (listDate.value === todayDate.value) {
|
2024-09-11 03:51:16 -04:00
|
|
|
await until(currentIndex).toMatch((v) => v > 0, { timeout: 1500 })
|
|
|
|
scrollTo(currentIndex.value)
|
2024-04-30 03:29:37 -04:00
|
|
|
} else {
|
|
|
|
scrollTo(0)
|
|
|
|
}
|
2024-04-30 03:11:26 -04:00
|
|
|
|
2024-04-30 03:29:37 -04:00
|
|
|
classSwitcher()
|
2024-04-30 03:11:26 -04:00
|
|
|
}
|
|
|
|
|
2024-04-16 02:57:45 -04:00
|
|
|
function setCategory(event: any, item: PlaylistItem) {
|
|
|
|
if (event.target.checked) {
|
|
|
|
item.category = 'advertisement'
|
|
|
|
} else {
|
|
|
|
item.category = ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function addBG(obj: any) {
|
|
|
|
if (obj.item) {
|
|
|
|
obj.item.classList.add('!bg-fuchsia-900/30')
|
|
|
|
} else {
|
2024-05-12 15:00:26 -04:00
|
|
|
obj?.classList?.add('!bg-fuchsia-900/30')
|
2024-04-16 02:57:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeBG(item: any) {
|
|
|
|
setTimeout(() => {
|
2024-05-12 15:00:26 -04:00
|
|
|
item?.classList?.remove('!bg-fuchsia-900/30')
|
2024-04-16 02:57:45 -04:00
|
|
|
}, 100)
|
|
|
|
}
|
|
|
|
|
|
|
|
function addClip(event: any) {
|
|
|
|
const o = event.oldIndex
|
|
|
|
const n = event.newIndex
|
|
|
|
const uid = genUID()
|
|
|
|
|
2024-05-12 15:00:26 -04:00
|
|
|
event.item?.remove()
|
2024-04-16 02:57:45 -04:00
|
|
|
|
2024-09-12 14:49:25 -04:00
|
|
|
const storagePath = configStore.channels[configStore.id].storage_path
|
2024-04-16 02:57:45 -04:00
|
|
|
const sourcePath = `${storagePath}/${mediaStore.folderTree.source}/${mediaStore.folderTree.files[o].name}`.replace(
|
|
|
|
/\/[/]+/g,
|
|
|
|
'/'
|
|
|
|
)
|
|
|
|
|
|
|
|
playlistStore.playlist.splice(n, 0, {
|
|
|
|
uid,
|
|
|
|
begin: 0,
|
|
|
|
source: sourcePath,
|
|
|
|
in: 0,
|
|
|
|
out: mediaStore.folderTree.files[o].duration,
|
|
|
|
duration: mediaStore.folderTree.files[o].duration,
|
|
|
|
})
|
|
|
|
|
2024-04-19 04:59:17 -04:00
|
|
|
processPlaylist(listDate.value, playlistStore.playlist, false)
|
2024-04-27 16:44:52 -04:00
|
|
|
classSwitcher()
|
2024-04-16 02:57:45 -04:00
|
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
const newNode = document.getElementById(`clip-${n}`)
|
|
|
|
addBG(newNode)
|
|
|
|
removeBG(newNode)
|
2024-04-27 16:44:52 -04:00
|
|
|
|
2024-05-21 13:02:40 -04:00
|
|
|
if (n > playlistStore.playlist.length - 3) {
|
|
|
|
playlistContainer.value.scroll({ top: playlistContainer.value.scrollHeight, behavior: 'smooth' })
|
|
|
|
}
|
2024-04-16 02:57:45 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function moveItemInArray(event: any) {
|
|
|
|
playlistStore.playlist.splice(event.newIndex, 0, playlistStore.playlist.splice(event.oldIndex, 1)[0])
|
|
|
|
|
2024-04-19 04:59:17 -04:00
|
|
|
processPlaylist(listDate.value, playlistStore.playlist, false)
|
2024-04-16 02:57:45 -04:00
|
|
|
|
|
|
|
removeBG(event.item)
|
|
|
|
}
|
|
|
|
|
|
|
|
function deletePlaylistItem(index: number) {
|
|
|
|
playlistStore.playlist.splice(index, 1)
|
2024-05-12 15:00:26 -04:00
|
|
|
|
|
|
|
processPlaylist(listDate.value, playlistStore.playlist, false)
|
2024-04-19 04:59:17 -04:00
|
|
|
classSwitcher()
|
2024-04-16 02:57:45 -04:00
|
|
|
}
|
|
|
|
</script>
|
2024-04-18 05:49:39 -04:00
|
|
|
<style>
|
2024-04-19 04:59:17 -04:00
|
|
|
#sort-container.is-empty:not(:has(.sortable-ghost)):after {
|
|
|
|
content: '\f1bc';
|
|
|
|
font-family: 'bootstrap-icons';
|
|
|
|
opacity: 0.3;
|
|
|
|
font-size: 50px;
|
|
|
|
width: 100%;
|
|
|
|
height: 210px;
|
|
|
|
display: flex;
|
|
|
|
position: absolute;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
2024-04-27 16:44:52 -04:00
|
|
|
#sort-container.add-space:after {
|
|
|
|
content: ' ';
|
|
|
|
width: 100%;
|
|
|
|
height: 37px;
|
|
|
|
display: flex;
|
|
|
|
position: absolute;
|
|
|
|
}
|
|
|
|
|
2024-05-15 02:53:25 -04:00
|
|
|
#sort-container .timeHidden {
|
|
|
|
display: none !important;
|
|
|
|
}
|
|
|
|
|
2024-04-18 05:49:39 -04:00
|
|
|
/*
|
|
|
|
format dragging element
|
|
|
|
*/
|
|
|
|
#playlist-container .sortable-ghost {
|
|
|
|
background-color: #701a754b !important;
|
|
|
|
min-height: 37px !important;
|
|
|
|
height: 37px !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
#playlist-container .sortable-ghost td {
|
|
|
|
padding-left: 1rem;
|
|
|
|
padding-right: 1rem;
|
|
|
|
padding-top: 0.5rem;
|
|
|
|
padding-bottom: 0.5rem;
|
|
|
|
}
|
|
|
|
|
2024-09-25 01:48:31 -04:00
|
|
|
#playlist-container .sortable-ghost td:nth-last-child(3),
|
|
|
|
#playlist-container .sortable-ghost td:nth-last-child(-n + 1) {
|
2024-04-18 05:49:39 -04:00
|
|
|
display: table-cell !important;
|
|
|
|
}
|
2024-05-05 14:47:43 -04:00
|
|
|
|
|
|
|
@media (min-width: 1280px) {
|
|
|
|
#playlist-container .sortable-ghost td:nth-last-child(5),
|
|
|
|
#playlist-container .sortable-ghost td:nth-last-child(4),
|
|
|
|
#playlist-container .sortable-ghost td:nth-last-child(-n + 2) {
|
|
|
|
display: table-cell !important;
|
|
|
|
}
|
|
|
|
}
|
2024-04-18 05:49:39 -04:00
|
|
|
</style>
|