2025-12-04 22:43:01 +01:00
|
|
|
<script setup lang="ts">
|
2026-01-09 17:32:40 +01:00
|
|
|
import { computed, ref, watch, nextTick, toRef } from "vue";
|
|
|
|
|
import { useRenderer } from "@/composables/useRenderers";
|
|
|
|
|
import QueueItem from "./QueueItem.vue";
|
2026-01-31 11:44:23 +01:00
|
|
|
import { Link, Radio } from "lucide-vue-next";
|
2026-01-09 17:32:40 +01:00
|
|
|
import type { QueueItem as QueueItemType } from "@/services/pmocontrol/types";
|
2025-12-04 22:43:01 +01:00
|
|
|
|
|
|
|
|
const props = defineProps<{
|
2026-01-09 17:32:40 +01:00
|
|
|
rendererId: string;
|
|
|
|
|
}>();
|
2025-12-04 22:43:01 +01:00
|
|
|
|
2025-12-27 14:56:45 +01:00
|
|
|
const emit = defineEmits<{
|
2026-01-09 17:32:40 +01:00
|
|
|
clickItem: [item: QueueItemType];
|
|
|
|
|
}>();
|
2025-12-27 14:56:45 +01:00
|
|
|
|
2026-01-31 11:44:23 +01:00
|
|
|
const { queue, binding, isStream } = useRenderer(toRef(props, "rendererId"));
|
2025-12-04 22:43:01 +01:00
|
|
|
|
2026-01-09 17:32:40 +01:00
|
|
|
const isAttached = computed(() => !!binding.value);
|
2025-12-04 22:43:01 +01:00
|
|
|
|
2026-01-09 17:32:40 +01:00
|
|
|
const queueContainer = ref<HTMLElement | null>(null);
|
2025-12-04 22:43:01 +01:00
|
|
|
|
2025-12-27 14:56:45 +01:00
|
|
|
function handleItemClick(item: QueueItemType) {
|
2026-01-09 17:32:40 +01:00
|
|
|
emit("clickItem", item);
|
2025-12-27 14:56:45 +01:00
|
|
|
}
|
|
|
|
|
|
2025-12-04 22:43:01 +01:00
|
|
|
// Auto-scroll vers la piste courante lors de l'ouverture
|
2026-01-09 17:32:40 +01:00
|
|
|
watch(
|
|
|
|
|
() => queue.value?.current_index,
|
|
|
|
|
async (currentIndex) => {
|
|
|
|
|
if (
|
|
|
|
|
currentIndex !== null &&
|
|
|
|
|
currentIndex !== undefined &&
|
|
|
|
|
queueContainer.value
|
|
|
|
|
) {
|
|
|
|
|
await nextTick();
|
|
|
|
|
const currentItem = queueContainer.value.querySelector(
|
|
|
|
|
".queue-item.current",
|
|
|
|
|
);
|
|
|
|
|
if (currentItem) {
|
|
|
|
|
currentItem.scrollIntoView({
|
|
|
|
|
behavior: "smooth",
|
|
|
|
|
block: "nearest",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true },
|
|
|
|
|
);
|
2025-12-04 22:43:01 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-01-09 17:32:40 +01:00
|
|
|
<div class="queue-viewer">
|
|
|
|
|
<!-- Header avec indication de binding -->
|
|
|
|
|
<div class="queue-header">
|
|
|
|
|
<h3 class="queue-title">
|
|
|
|
|
File d'attente
|
|
|
|
|
<span class="queue-count" v-if="queue?.items.length">
|
|
|
|
|
({{ queue.items.length }})
|
|
|
|
|
</span>
|
|
|
|
|
</h3>
|
|
|
|
|
|
2026-01-31 11:44:23 +01:00
|
|
|
<!-- Indicateurs de status -->
|
|
|
|
|
<div class="status-indicators">
|
|
|
|
|
<!-- Indicateur playlist attachée -->
|
|
|
|
|
<div v-if="isAttached" class="binding-indicator">
|
|
|
|
|
<Link :size="16" />
|
|
|
|
|
<span class="binding-text"> Attachée à une playlist </span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Indicateur web radio -->
|
|
|
|
|
<div v-if="isStream" class="stream-indicator">
|
|
|
|
|
<Radio :size="16" />
|
|
|
|
|
<span class="stream-text"> Web Radio </span>
|
|
|
|
|
</div>
|
2026-01-09 17:32:40 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Liste des items -->
|
|
|
|
|
<div v-if="queue?.items.length" class="queue-list" ref="queueContainer">
|
|
|
|
|
<QueueItem
|
|
|
|
|
v-for="item in queue.items"
|
|
|
|
|
:key="item.index"
|
|
|
|
|
:item="item"
|
|
|
|
|
:is-current="item.index === queue.current_index"
|
|
|
|
|
@click="handleItemClick"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- État vide -->
|
|
|
|
|
<div v-else class="queue-empty">
|
|
|
|
|
<p>Aucun élément dans la file d'attente</p>
|
|
|
|
|
</div>
|
2025-12-04 22:43:01 +01:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.queue-viewer {
|
2026-01-09 17:32:40 +01:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: var(--spacing-md);
|
|
|
|
|
height: 100%;
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.queue-header {
|
2026-01-09 17:32:40 +01:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: var(--spacing-sm);
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.queue-title {
|
2026-01-09 17:32:40 +01:00
|
|
|
font-size: var(--text-lg);
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
color: var(--color-text);
|
|
|
|
|
margin: 0;
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.queue-count {
|
2026-01-09 17:32:40 +01:00
|
|
|
font-size: var(--text-sm);
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
color: var(--color-text-secondary);
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-31 11:44:23 +01:00
|
|
|
.status-indicators {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
gap: var(--spacing-sm);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-04 22:43:01 +01:00
|
|
|
.binding-indicator {
|
2026-01-09 17:32:40 +01:00
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: var(--spacing-xs);
|
|
|
|
|
padding: var(--spacing-xs) var(--spacing-sm);
|
|
|
|
|
background-color: var(--status-playing-bg);
|
|
|
|
|
color: var(--status-playing);
|
|
|
|
|
border-radius: var(--radius-md);
|
|
|
|
|
font-size: var(--text-sm);
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
border: 1px solid var(--status-playing);
|
|
|
|
|
width: fit-content;
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.binding-text {
|
2026-01-09 17:32:40 +01:00
|
|
|
font-size: var(--text-xs);
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-31 11:44:23 +01:00
|
|
|
.stream-indicator {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: var(--spacing-xs);
|
|
|
|
|
padding: var(--spacing-xs) var(--spacing-sm);
|
|
|
|
|
background-color: rgba(147, 51, 234, 0.1);
|
|
|
|
|
color: #9333ea;
|
|
|
|
|
border-radius: var(--radius-md);
|
|
|
|
|
font-size: var(--text-sm);
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
border: 1px solid #9333ea;
|
|
|
|
|
width: fit-content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stream-text {
|
|
|
|
|
font-size: var(--text-xs);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-04 22:43:01 +01:00
|
|
|
.queue-list {
|
2026-01-09 17:32:40 +01:00
|
|
|
flex: 1;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: var(--spacing-xs);
|
|
|
|
|
padding-right: var(--spacing-xs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ajoute un espace de scroll en bas pour ne pas cacher les derniers items sous la barre */
|
|
|
|
|
.queue-list::after {
|
|
|
|
|
content: "";
|
|
|
|
|
display: block;
|
|
|
|
|
height: 80px; /* Espace pour la barre fixe en bas */
|
|
|
|
|
flex-shrink: 0;
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Scrollbar styling */
|
|
|
|
|
.queue-list::-webkit-scrollbar {
|
2026-01-09 17:32:40 +01:00
|
|
|
width: 6px;
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.queue-list::-webkit-scrollbar-track {
|
2026-01-09 17:32:40 +01:00
|
|
|
background: var(--color-bg-secondary);
|
|
|
|
|
border-radius: var(--radius-full);
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.queue-list::-webkit-scrollbar-thumb {
|
2026-01-09 17:32:40 +01:00
|
|
|
background: var(--color-border);
|
|
|
|
|
border-radius: var(--radius-full);
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.queue-list::-webkit-scrollbar-thumb:hover {
|
2026-01-09 17:32:40 +01:00
|
|
|
background: var(--color-text-tertiary);
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.queue-empty {
|
2026-01-09 17:32:40 +01:00
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
color: var(--color-text-tertiary);
|
|
|
|
|
font-size: var(--text-base);
|
|
|
|
|
text-align: center;
|
|
|
|
|
padding: var(--spacing-xl);
|
2025-12-04 22:43:01 +01:00
|
|
|
}
|
|
|
|
|
</style>
|