2022-08-28 13:12:38 -05:00
|
|
|
<template>
|
|
|
|
|
<modals-modal v-model="show" name="queue-items" :width="800" :height="'unset'">
|
|
|
|
|
<template #outer>
|
|
|
|
|
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
2023-02-11 15:02:56 -06:00
|
|
|
<p class="text-3xl text-white truncate">{{ $strings.HeaderPlayerQueue }}</p>
|
2022-08-28 13:12:38 -05:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<div ref="container" class="w-full rounded-lg bg-bg box-shadow-md overflow-y-auto overflow-x-hidden py-4" style="max-height: 80vh">
|
|
|
|
|
<div v-if="show" class="w-full h-full">
|
2022-08-28 14:21:28 -05:00
|
|
|
<div class="pb-4 px-4 flex items-center">
|
2022-11-12 16:48:35 -06:00
|
|
|
<p class="text-base text-gray-200">{{ $strings.HeaderPlayerQueue }}</p>
|
2022-08-28 14:21:28 -05:00
|
|
|
<p class="text-base text-gray-400 px-4">{{ playerQueueItems.length }} Items</p>
|
2025-03-16 16:41:37 +02:00
|
|
|
<div class="grow" />
|
2022-08-28 14:21:28 -05:00
|
|
|
<ui-checkbox v-model="playerQueueAutoPlay" label="Auto Play" medium checkbox-bg="primary" border-color="gray-600" label-class="pl-2 mb-px" />
|
|
|
|
|
</div>
|
2026-04-01 22:14:32 +09:00
|
|
|
<draggable v-model="queueItemsCopy" v-bind="dragOptions" handle=".drag-handle" draggable=".queue-item" tag="div" @start="drag = true" @end="drag = false" @update="draggableUpdate">
|
|
|
|
|
<transition-group type="transition" :name="!drag ? 'queue-item' : null">
|
|
|
|
|
<modals-player-queue-item-row v-for="(item, index) in queueItemsCopy" :key="item.libraryItemId + '-' + (item.episodeId || index)" :is-dragging="drag" :item="item" :index="index" class="queue-item" @play="playItem(index)" @remove="removeItem" />
|
|
|
|
|
</transition-group>
|
|
|
|
|
</draggable>
|
2022-08-28 13:12:38 -05:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</modals-modal>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2026-04-01 22:14:32 +09:00
|
|
|
import draggable from 'vuedraggable'
|
|
|
|
|
|
2022-08-28 13:12:38 -05:00
|
|
|
export default {
|
2026-04-01 22:14:32 +09:00
|
|
|
components: {
|
|
|
|
|
draggable
|
|
|
|
|
},
|
2022-08-28 13:12:38 -05:00
|
|
|
props: {
|
2024-08-17 13:32:00 -05:00
|
|
|
value: Boolean
|
2022-08-28 13:12:38 -05:00
|
|
|
},
|
|
|
|
|
data() {
|
2026-04-01 22:14:32 +09:00
|
|
|
return {
|
|
|
|
|
drag: false,
|
|
|
|
|
dragOptions: {
|
|
|
|
|
animation: 200,
|
|
|
|
|
ghostClass: 'ghost',
|
|
|
|
|
chosenClass: 'chosen'
|
|
|
|
|
},
|
|
|
|
|
queueItemsCopy: []
|
|
|
|
|
}
|
2022-08-28 13:12:38 -05:00
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
show: {
|
|
|
|
|
get() {
|
|
|
|
|
return this.value
|
|
|
|
|
},
|
|
|
|
|
set(val) {
|
|
|
|
|
this.$emit('input', val)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-08-28 14:21:28 -05:00
|
|
|
playerQueueAutoPlay: {
|
|
|
|
|
get() {
|
|
|
|
|
return this.$store.state.playerQueueAutoPlay
|
|
|
|
|
},
|
|
|
|
|
set(val) {
|
|
|
|
|
this.$store.commit('setPlayerQueueAutoPlay', val)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-08-28 13:12:38 -05:00
|
|
|
playerQueueItems() {
|
|
|
|
|
return this.$store.state.playerQueueItems || []
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-04-01 22:14:32 +09:00
|
|
|
watch: {
|
|
|
|
|
playerQueueItems: {
|
|
|
|
|
handler() {
|
|
|
|
|
this.initCopy()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
show(newVal) {
|
|
|
|
|
if (newVal) this.initCopy()
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-08-28 13:12:38 -05:00
|
|
|
methods: {
|
2026-04-01 22:14:32 +09:00
|
|
|
initCopy() {
|
|
|
|
|
this.queueItemsCopy = this.playerQueueItems.map((i) => ({ ...i }))
|
|
|
|
|
},
|
|
|
|
|
draggableUpdate() {
|
|
|
|
|
this.$store.commit('setPlayerQueueItems', this.queueItemsCopy)
|
|
|
|
|
},
|
2024-08-17 13:32:00 -05:00
|
|
|
playItem(index) {
|
|
|
|
|
this.$eventBus.$emit('play-queue-item', {
|
|
|
|
|
index
|
2022-08-28 13:12:38 -05:00
|
|
|
})
|
|
|
|
|
this.show = false
|
|
|
|
|
},
|
|
|
|
|
removeItem(item) {
|
2022-11-12 15:41:41 -06:00
|
|
|
this.$store.commit('removeItemFromQueue', item)
|
2022-08-28 13:12:38 -05:00
|
|
|
}
|
2026-04-01 22:14:32 +09:00
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.initCopy()
|
2022-08-28 13:12:38 -05:00
|
|
|
}
|
|
|
|
|
}
|
2024-08-17 13:32:00 -05:00
|
|
|
</script>
|
2026-04-01 22:14:32 +09:00
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.queue-item {
|
|
|
|
|
transition: transform 0.2s ease;
|
|
|
|
|
}
|
|
|
|
|
.ghost {
|
|
|
|
|
opacity: 0.3;
|
|
|
|
|
border-top: 2px solid #4ade80;
|
|
|
|
|
}
|
|
|
|
|
.chosen {
|
|
|
|
|
background: rgba(74, 222, 128, 0.1) !important;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|