mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-10 12:52:22 +01:00
Merge main
This commit is contained in:
@ -38,16 +38,29 @@
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav navbar-right hidden-xs">
|
||||
<li class="nav-item me-3">
|
||||
<p class="navbar-text mb-0 start-queue hidden-sm hidden-xs"></p>
|
||||
</li>
|
||||
<li class="nav-item me-3">
|
||||
<p class="navbar-text mb-0 end-queue"></p>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<p class="navbar-text mb-0 duration-queue"></p>
|
||||
</li>
|
||||
|
||||
<ul id="personal-queue-container" class="navbar-nav navbar-right hidden-xs">
|
||||
<template v-if="infobar !== null && 'start_personal_queue' in infobar && infobar.start_personal_queue !== null">
|
||||
<li v-if="infobar.start_personal_queue !== 0" class="nav-item me-3">
|
||||
<p v-if="infobar.plays_in" class="navbar-text mb-0 start-queue hidden-sm hidden-xs">
|
||||
First song starts in ${infobar.start_personal_queue.secondsToMMSS() }$
|
||||
</p>
|
||||
<p v-else class="navbar-text mb-0 start-queue hidden-sm hidden-xs">
|
||||
First song starts at ${(infobar.now_in_seconds + infobar.start_personal_queue).timestampToHHMMSS() }$
|
||||
</p>
|
||||
</li>
|
||||
<li class="nav-item me-3">
|
||||
<p v-if="infobar.plays_in" class="navbar-text mb-0 start-queue hidden-sm hidden-xs">
|
||||
Last song ends in ${infobar.end_personal_queue.secondsToMMSS() }$
|
||||
</p>
|
||||
<p v-else class="navbar-text mb-0 start-queue hidden-sm hidden-xs">
|
||||
Last song ends at ${(infobar.now_in_seconds + infobar.end_personal_queue).timestampToHHMMSS() }$
|
||||
</p>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<p class="navbar-text mb-0 duration-queue" v-bind:class="{danger: infobar.length_personal_queue > infobar.max_length * 60}">(${infobar.length_personal_queue.secondsToMMSS() }$)</p>
|
||||
</li>
|
||||
</template>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
@ -214,6 +227,14 @@
|
||||
const CAN_MOVE = {{ perms.queues.can_move|yesno:"1,0" }};
|
||||
</script>
|
||||
<script>
|
||||
const personal_queue_vue = createApp({
|
||||
delimiters: ['${', '}$'],
|
||||
data() {
|
||||
return {
|
||||
infobar: null,
|
||||
}
|
||||
},
|
||||
}).mount('#personal-queue-container');
|
||||
const queue_vue = createApp({
|
||||
delimiters: ['${', '}$'],
|
||||
data() {
|
||||
@ -228,6 +249,13 @@
|
||||
playsIn: true,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
playsIn: {
|
||||
handler(val, oldVal) {
|
||||
this.update_infobar();
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.clockInterval = setInterval(this.update_song_times, 1000);
|
||||
},
|
||||
@ -253,27 +281,6 @@
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
infoBar() {
|
||||
let infoBar = {
|
||||
start_personal_queue: 0,
|
||||
length_personal_queue: 0,
|
||||
length_total_queue: 0,
|
||||
end_personal_queue: 0,
|
||||
max_length: 45,
|
||||
}
|
||||
for (let i = 0; i < this.queue.length; i++) {
|
||||
const current_song = this.queue[i];
|
||||
infoBar['length_total_queue'] = infoBar['length_total_queue'] + current_song.song.duration;
|
||||
if (current_song.user !== null && current_song.user.id === this.user_data.id) {
|
||||
infoBar['length_personal_queue'] = infoBar['length_personal_queue'] + current_song.song.duration;
|
||||
infoBar['end_personal_queue'] = infoBar['length_total_queue'];
|
||||
if (infoBar['start_personal_queue'] === 0) {
|
||||
infoBar['start_personal_queue'] = infoBar['length_total_queue'] - current_song.song.duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
return infoBar;
|
||||
},
|
||||
play_next_song_at() {
|
||||
if (this.started_at !== null && this.current_song !== null) {
|
||||
return this.started_at + this.current_song.song.duration;
|
||||
@ -301,6 +308,40 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
this.update_infobar();
|
||||
},
|
||||
update_infobar() {
|
||||
let infoBar = {
|
||||
start_personal_queue: null,
|
||||
length_personal_queue: 0,
|
||||
length_total_queue: 0,
|
||||
end_personal_queue: 0,
|
||||
max_length: 45,
|
||||
plays_in: this.playsIn,
|
||||
now_in_seconds: 0,
|
||||
}
|
||||
infoBar.now_in_seconds = Math.round((new Date()).getTime() / 1000);
|
||||
// If the current song is the current user's, their queue has started.
|
||||
if (this.queue[0].user.id === this.user_data.id) {
|
||||
infoBar.start_personal_queue = 0;
|
||||
}
|
||||
for (let i = 0; i < this.queue.length; i++) {
|
||||
const current_song = this.queue[i];
|
||||
if (i === 0) {
|
||||
const current_song_remaining_seconds = current_song.song.duration - this.queue[1].time_until_song_seconds;
|
||||
infoBar['length_personal_queue'] -= current_song_remaining_seconds;
|
||||
infoBar['length_total_queue'] -= current_song_remaining_seconds;
|
||||
}
|
||||
infoBar['length_total_queue'] += current_song.song.duration;
|
||||
if (current_song.user !== null && current_song.user.id === this.user_data.id) {
|
||||
infoBar['length_personal_queue'] += current_song.song.duration;
|
||||
infoBar['end_personal_queue'] = infoBar['length_total_queue'];
|
||||
if (infoBar['start_personal_queue'] === null) {
|
||||
infoBar['start_personal_queue'] = infoBar['length_total_queue'] - current_song.song.duration - this.queue[1].time_until_song_seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
personal_queue_vue.infobar = infoBar;
|
||||
},
|
||||
refresh() {
|
||||
if (!this.refreshing) {
|
||||
@ -384,9 +425,9 @@
|
||||
}).finally(() => {
|
||||
this.refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}).mount('#queue-container');
|
||||
}).mount("#queue-container");
|
||||
</script>
|
||||
<script>
|
||||
const request_vue = createApp({
|
||||
|
||||
Reference in New Issue
Block a user