mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-11 13:32:20 +01:00
Marietje in header and fix load times for upload page
This commit is contained in:
@ -39,26 +39,28 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul v-if="'start_personal_queue' in infobar && infobar.start_personal_queue !== null" id="personal-queue-container" class="navbar-nav navbar-right hidden-xs">
|
||||
<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>
|
||||
<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>
|
||||
@ -87,22 +89,22 @@
|
||||
<tr :class="{ marietjequeue: (song.user === null),
|
||||
underline_cell: (index === queue[-1]),
|
||||
currentsong: (index === 0),}">
|
||||
<td class="artist"><% song.song.artist %></td>
|
||||
<td class="title"><% song.song.title %></td>
|
||||
<td class="artist">${ song.song.artist }$</td>
|
||||
<td class="title">${ song.song.title }$</td>
|
||||
<td class="d-sm-table-cell d-none requested-by">
|
||||
<template v-if="song.user === null">
|
||||
Marietje
|
||||
</template>
|
||||
<template v-else>
|
||||
<% song.user.name %>
|
||||
${ song.user.name }$
|
||||
</template>
|
||||
</td>
|
||||
<td class="d-sm-table-cell d-none plays-at" style="text-align: right">
|
||||
<template v-if="song.time_until_song_seconds !== null && song.time_until_song_seconds > 0 && playsIn === true">
|
||||
<% song.time_until_song_seconds.secondsToMMSS() %>
|
||||
${ song.time_until_song_seconds.secondsToMMSS() }$
|
||||
</template>
|
||||
<template v-else-if="playsIn === false && song.plays_at !== null && song.played === false">
|
||||
<% song.plays_at.timestampToHHMMSS() %>
|
||||
${ song.plays_at.timestampToHHMMSS() }$
|
||||
</template>
|
||||
</td>
|
||||
<td>
|
||||
@ -177,7 +179,7 @@
|
||||
</select>
|
||||
<select class="pagenum input-mini" title="Select page number" v-model="page_number">
|
||||
<template v-for="(i, index) in number_of_pages">
|
||||
<option :value="i"><% i %></option>
|
||||
<option :value="i">${ i }$</option>
|
||||
</template>
|
||||
</select>
|
||||
</th>
|
||||
@ -188,21 +190,21 @@
|
||||
<template v-for="(song, index) in songs">
|
||||
<tr>
|
||||
<td>
|
||||
<% song.artist %>
|
||||
${ song.artist }$
|
||||
</td>
|
||||
<td>
|
||||
<button v-on:click="request_song(song.id);" class="btn btn-link p-0 text-decoration-none"><% song.title %></button>
|
||||
<button v-on:click="request_song(song.id);" class="btn btn-link p-0 text-decoration-none">${ song.title }$</button>
|
||||
</td>
|
||||
<td>
|
||||
<template v-if="song.user === null">
|
||||
Marietje
|
||||
</template>
|
||||
<template v-else>
|
||||
<% song.user.name %>
|
||||
${ song.user.name }$
|
||||
</template>
|
||||
</td>
|
||||
<td>
|
||||
<% song.duration.secondsToMMSS() %>
|
||||
${ song.duration.secondsToMMSS() }$
|
||||
</td>
|
||||
<td>
|
||||
<button v-on:click="report_song(song.id);" class="btn btn-link p-0 text-decoration-none">
|
||||
@ -226,18 +228,34 @@
|
||||
const CAN_MOVE = {{ perms.queues.can_move|yesno:"1,0" }};
|
||||
</script>
|
||||
<script>
|
||||
const queue_vue = new Vue({
|
||||
el: '#queue-container',
|
||||
delimiters: ['<%', '%>'],
|
||||
data: {
|
||||
current_song: null,
|
||||
queue: [],
|
||||
user_data: null,
|
||||
refreshing: true,
|
||||
refreshTimer: null,
|
||||
clockInterval: null,
|
||||
started_at: null,
|
||||
playsIn: true,
|
||||
const personal_queue_vue = createApp({
|
||||
delimiters: ['${', '}$'],
|
||||
data() {
|
||||
return {
|
||||
infobar: null,
|
||||
}
|
||||
},
|
||||
}).mount('#personal-queue-container');
|
||||
const queue_vue = createApp({
|
||||
delimiters: ['${', '}$'],
|
||||
data() {
|
||||
return {
|
||||
current_song: null,
|
||||
queue: [],
|
||||
user_data: null,
|
||||
refreshing: true,
|
||||
refreshTimer: null,
|
||||
clockInterval: null,
|
||||
started_at: null,
|
||||
playsIn: true,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
playsIn: {
|
||||
handler(val, oldVal) {
|
||||
this.update_infobar();
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.clockInterval = setInterval(this.update_song_times, 1000);
|
||||
@ -303,16 +321,14 @@
|
||||
plays_in: this.playsIn,
|
||||
now_in_seconds: 0,
|
||||
}
|
||||
const now_in_seconds = Math.round((new Date()).getTime() / 1000);
|
||||
infoBar.now_in_seconds = now_in_seconds;
|
||||
let current_song_played = now_in_seconds - this.queue[0].started_at;
|
||||
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) {
|
||||
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) {
|
||||
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;
|
||||
@ -322,11 +338,11 @@
|
||||
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
|
||||
infoBar['start_personal_queue'] = infoBar['length_total_queue'] - current_song.song.duration - this.queue[1].time_until_song_seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.$emit("infobar", infoBar);
|
||||
personal_queue_vue.infobar = infoBar;
|
||||
},
|
||||
refresh() {
|
||||
if (!this.refreshing) {
|
||||
@ -412,29 +428,20 @@
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
||||
const personal_queue_vue = new Vue({
|
||||
el: '#personal-queue-container',
|
||||
delimiters: ['<%', '%>'],
|
||||
data: {
|
||||
infobar: [],
|
||||
},
|
||||
mounted() {
|
||||
queue_vue.$on("infobar", infoBar => this.infobar = infoBar);
|
||||
}
|
||||
});
|
||||
}).mount("#queue-container");
|
||||
</script>
|
||||
<script>
|
||||
const request_vue = new Vue({
|
||||
el: '#request-container',
|
||||
delimiters: ['<%', '%>'],
|
||||
data: {
|
||||
songs: [],
|
||||
total_songs: 0,
|
||||
search_input: "",
|
||||
typing_timer: null,
|
||||
page_size: 10,
|
||||
page_number: 1,
|
||||
const request_vue = createApp({
|
||||
delimiters: ['${', '}$'],
|
||||
data() {
|
||||
return {
|
||||
songs: [],
|
||||
total_songs: 0,
|
||||
search_input: "",
|
||||
typing_timer: null,
|
||||
page_size: 10,
|
||||
page_number: 1,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
search_input: {
|
||||
@ -538,7 +545,8 @@
|
||||
"Content-Type": 'application/json',
|
||||
},
|
||||
}).then(response => {
|
||||
if (response.status === 200) {
|
||||
// TODO: Communicate failure through HTTP error codes (403) instead of checking response.success.
|
||||
if (response.status === 200 && response.success) {
|
||||
return response.json();
|
||||
} else {
|
||||
throw response;
|
||||
@ -597,7 +605,7 @@
|
||||
this.page_number = page_number;
|
||||
}
|
||||
}
|
||||
});
|
||||
}).mount('#request-container');
|
||||
</script>
|
||||
<script>
|
||||
function volume_down() {
|
||||
|
||||
Reference in New Issue
Block a user