Compare commits

...
Sign in to create a new pull request.

10 commits

13 changed files with 940 additions and 866 deletions

View file

@ -1,20 +1,7 @@
# foundation-vue
# Syng web client
This template should help get you started developing with Vue 3 in Vite.
This is the web client for [Syng](https://github.com/christofsteel/syng)
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development

1622
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "syng-web",
"version": "2.0.0",
"version": "2.0.4",
"scripts": {
"dev": "vite",
"build": "vite build",

View file

@ -34,7 +34,8 @@ const state = ref({
'uid': null,
'double_entry': {'artist': null, 'title': null, 'reason': null},
'waiting_room_policy': null,
'config': {}
'config': {},
'kiosk': false
})
onMounted(() => {
@ -73,6 +74,7 @@ function update_config(config) {
state.socket.emit("update_config", {"config": config})
close_config()
}
function setKiosk(kiosk) { state.value.kiosk = kiosk }
function search() {
var yt_checker = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
@ -102,39 +104,39 @@ function checked_append_with_name(entry, name) {
$("#getusername").foundation("open");
} else {
$("#getusername").foundation("close");
raw_append(entry.ident, name, entry.source, state.value.uid);
raw_append(entry.ident, name, entry.source, entry.title, entry.artist, state.value.uid);
}
}
function append_anyway(ident, name, source, uid) {
function append_anyway(entry) {
$("#getusername").foundation("close");
$("#alreadyqueued").foundation("close");
state.value.current_name = null;
state.value.current_entry = null;
state.value.double_entry = {'artist': null, 'title': null, 'reason': null};
state.socket.emit("append-anyway", {"ident": ident, "performer": name, "source": source, "uid": uid });
state.socket.emit("append-anyway", {"ident": entry.ident, "performer": entry.performer, "source": entry.source, "title": entry.title, "artist": entry.artist, "uid": null });
$("#queue-tab-title").click();
}
function raw_append(ident, name, source, uid) {
function raw_append(ident, name, source, title, artist, uid) {
$("#getusername").foundation("close");
$("#alreadyqueued").foundation("close");
state.value.current_name = null;
state.value.current_entry = null;
state.value.double_entry = {'artist': null, 'title': null, 'reason': null};
state.socket.emit("append", {"ident": ident, "performer": name, "source": source, "uid": uid });
state.socket.emit("append", {"ident": ident, "performer": name, "source": source, "title":title, "artist": artist,"uid": uid });
$("#queue-tab-title").click();
}
function wait_append(ident, name, source, uid) {
function wait_append(entry) {
$("#getusername").foundation("close");
$("#alreadyqueued").foundation("close");
state.socket.emit("waiting-room-append", {"ident": entry.ident, "performer": entry.performer, "source": entry.source, "title": entry.title, "artist": entry.artist, "uid": null });
state.value.current_name = null;
state.value.current_entry = null;
state.socket.emit("waiting-room-append", {"ident": ident, "performer": name, "source": source, "uid": uid });
$("#queue-tab-title").click();
}
@ -173,6 +175,10 @@ function moveUp(uuid) {
state.socket.emit("move-up", {"uuid": uuid})
}
function moveTo(data) {
state.socket.emit("move-to", data)
}
function skip(uuid) {
state.socket.emit("skip", {"uuid": uuid})
}
@ -264,10 +270,8 @@ function joinRoom() {
} else {
state.value.join_msg = "<strong>No such room!</strong> <br/>" +
"Please use the correct room code your organizer provided you.<br/>" +
"To host your own syng powered karaoke parties, please download and " +
"install <a href='https://git.k-fortytwo.de/christofsteel/syng2.git' " +
"target='_blank'>Syng</a> and run it with <pre>syng-client " +
state.value.server + "</pre>"
"To host your own syng powered karaoke events, please download and " +
"install <a href='https://github.com/christofsteel/syng' target='_blank'>Syng</a>"
if(state.value.joined) {
state.socket.disconnect()
setTimeout(() => connect(), 2000)
@ -279,7 +283,7 @@ function joinRoom() {
<template>
<div class="page">
<div class="row" id="main-content">
<div class="row" :id="state.kiosk ? 'main-content-kiosk' : 'main-content'">
<MobileLayout
v-show="state.is_small"
:state="state"
@ -289,6 +293,7 @@ function joinRoom() {
@skip="skip"
@skipCurrent="skipCurrent"
@moveUp="moveUp"
@moveTo="moveTo"
@waitingRoomToQueue="waitingRoomToQueue"
/>
<DesktopLayout
@ -300,6 +305,7 @@ function joinRoom() {
@skip="skip"
@skipCurrent="skipCurrent"
@moveUp="moveUp"
@moveTo="moveTo"
@waitingRoomToQueue="waitingRoomToQueue"
/>
<WelcomeReveal
@ -309,11 +315,13 @@ function joinRoom() {
:joinMsg="state.join_msg"
:name="state.name"
:secret="state.secret"
:kiosk="state.kiosk"
@connect="connect"
@update:room="setRoomCode"
@update:name="setName"
@update:server="setServer"
@update:secret="setSecret"
@update:kiosk="setKiosk"
/>
<GetUserName
:current_name="state.current_name"
@ -323,11 +331,12 @@ function joinRoom() {
@close_name="close_name"
/>
<AlreadyQueued
@append="append_anyway(state.current_entry.ident, state.name ? state.name : state.current_name, state.current_entry.source, state.uid)"
@wait="(uid) => wait_append(state.current_entry.ident, state.name ? state.name : state.current_name, state.current_entry.source, null)"
@append="append_anyway"
@wait="wait_append"
@cancel="close_already_queued"
:waiting_room_policy="state.waiting_room_policy"
:double_entry="state.double_entry"
:current_entry="state.current_entry"
/>
<div class="reveal" id="msg" data-reveal>
{{ state.last_msg }}
@ -339,7 +348,7 @@ function joinRoom() {
<Footer
:name="state.name"
:admin="state.admin"
:show_name="state.show_name"
:kiosk="state.kiosk"
@update:name="setName"
@logout="emptyLocalStorageAndLogout"
@config="show_config"
@ -362,10 +371,15 @@ function joinRoom() {
height: 100%;
position: relative;
}
#main-content {
height: calc(100vh - 50px);
max-height: 100vh;
max-width: 100vw;
}
#main-content-kiosk {
height: 100vh;
max-height: 100vh;
max-width: 100vw;
}
</style>

View file

@ -1,6 +1,6 @@
<script setup>
const emits = defineEmits(["append", "wait", "cancel"]);
const props = defineProps(["double_entry", "waiting_room_policy"]);
const props = defineProps(["double_entry", "current_entry", "waiting_room_policy"]);
</script>
<template>
<div class="reveal" id="alreadyqueued" data-reveal >
@ -10,21 +10,20 @@ const props = defineProps(["double_entry", "waiting_room_policy"]);
</p>
<p>To give everyone a chance to sing, you are limited to one song in the active queue, but you can add yourself to the <b>waiting room</b>.
Songs in the waiting room will be added to the queue, once your old song leaves the queue.</p>
<p>If you think this is an error, you can
<p>If you think this is an error, you can</p>
<ul>
<li>choose another name, or</li>
<li>add it to the waiting room and talk to the organizers for manual insertion into the queue.</li>
</ul>
</p>
<div class="grid-x">
<div class="cell medium-6 small-12 btn">
<button class="button expanded" @click="$emit('wait', double_entry.reason == 'uid' ? double_entry.uid : null)">Add to waiting room</button>
<button class="button expanded" @click="$emit('wait', current_entry)">Add to waiting room</button>
</div>
<div class="cell medium-6 small-12 btn">
<button class="button expanded alert" @click="$emit('cancel')">Cancel</button>
</div>
<div v-show="waiting_room_policy && waiting_room_policy.toLowerCase() == 'optional'" class="cell medium-12 small-12 btn">
<button class="button expanded" @click="$emit('append')">Append Anyway</button>
<button class="button expanded" @click="$emit('append', current_entry)">Append Anyway</button>
</div>
</div>
</div>

View file

@ -4,7 +4,7 @@ import QueueDesktop from './QueueDesktop.vue'
import RecentDesktop from './RecentDesktop.vue'
const props = defineProps(['state']);
const emit = defineEmits(['update:searchTerm', 'search', 'append', 'skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue'])
const emit = defineEmits(['update:searchTerm', 'search', 'append', 'skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue', 'moveTo'])
</script>
@ -18,6 +18,7 @@ const emit = defineEmits(['update:searchTerm', 'search', 'append', 'skip', 'skip
:admin="state.admin"
@skip="(uuid) => $emit('skip', uuid)"
@moveUp="(uuid) => $emit('moveUp', uuid)"
@moveTo="(data) => $emit('moveTo', data)"
@skipCurrent="$emit('skipCurrent')"
@waitingRoomToQueue="(uuid) => $emit('waitingRoomToQueue', uuid)"
/>

View file

@ -1,7 +1,7 @@
<script setup>
import { computed } from 'vue'
const props = defineProps(['admin', 'entry', 'current', 'firstStartedAt', 'offset', 'currentTime', 'waitingRoom'])
const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue'])
const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue', 'moveTo'])
function skip() {
if(props.current) {
@ -16,6 +16,9 @@ const eta = computed(() =>{
let startTime = new Date(props.firstStartedAt * 1000)
let playBackSeconds = (now - startTime) / 1000
let etaSeconds = Math.round(props.offset - playBackSeconds)
if (etaSeconds < 0) {
etaSeconds = 0
}
if (isNaN(etaSeconds)) {
return null
@ -24,10 +27,56 @@ const eta = computed(() =>{
}
})
const dragging = (e) => {
const data = {
uuid: props.entry.uuid,
index: $(e.target.closest('li')).index()}
console.log(data)
e.dataTransfer.clearData()
e.dataTransfer.setData('application/json', JSON.stringify(data))
e.dataTransfer.effectAllowed = 'move'
}
const dragend = (e) => {
e.preventDefault()
e.target.closest('li').classList.remove('draggedoverBottom')
e.target.closest('li').classList.remove('draggedoverTop')
}
const dropped = (e) => {
e.preventDefault()
e.target.closest('li').classList.remove('draggedoverBottom')
e.target.closest('li').classList.remove('draggedoverTop')
const drop_index = $(e.target.closest('li')).index()
const element = JSON.parse(e.dataTransfer.getData('application/json'))
if (element.index < drop_index) {
emits('moveTo', {"uuid": element.uuid , "target": drop_index + 1})
} else {
emits('moveTo', {"uuid": element.uuid , "target": drop_index})
}
}
const dragover = (e) => {
e.preventDefault()
e.dataTransfer.dropEffect = 'move'
const element = JSON.parse(e.dataTransfer.getData('application/json'))
const index = $(e.target.closest('li')).index()
if (index < element.index) {
e.target.closest('li').classList.add('draggedoverTop')
} else {
e.target.closest('li').classList.add('draggedoverBottom')
}
}
const dragleave = (e) => {
e.preventDefault()
e.target.closest('li').classList.remove('draggedoverTop')
e.target.closest('li').classList.remove('draggedoverBottom')
}
</script>
<template>
<li :class="[{ current: current }, {waitingRoom: waitingRoom}]">
<li :class="[{ current: current }, {waitingRoom: waitingRoom}]" :draggable="admin" @dragstart="dragging" @dragend="dragend" @dragover="dragover" @dragleave="dragleave" @drop="dropped">
<div class="grid-x">
<div class="cell" :class="{'small-9': admin}">
<span class="artist">{{ entry.artist }}</span>
@ -45,12 +94,12 @@ const eta = computed(() =>{
@click="$emit('waitingRoomToQueue', entry.uuid)" >
<font-awesome-icon icon="fa-solid fa-arrows-up-to-line" />
</button>
<button
class="button warning fright"
v-if="!current && !waitingRoom"
@click="$emit('moveUp', entry.uuid)" >
<font-awesome-icon icon="fa-solid fa-arrow-up" />
</button>
<!-- <button -->
<!-- class="button warning fright" -->
<!-- v-if="!current && !waitingRoom" -->
<!-- @click="$emit('moveUp', entry.uuid)" > -->
<!-- <font-awesome-icon icon="fa-solid fa-arrow-up" /> -->
<!-- </button> -->
</div>
</div>
@ -76,4 +125,12 @@ const eta = computed(() =>{
content: "in ";
}
.draggedoverTop {
border-top: 2px solid #008000;
}
.draggedoverBottom {
border-bottom: 2px solid #008000;
}
</style>

View file

@ -1,9 +1,9 @@
<script setup>
const props = defineProps(['name', 'admin', 'show_name'])
const props = defineProps(['name', 'admin', 'kiosk'])
const emits = defineEmits(['update:name', 'logout', 'config'])
</script>
<template>
<footer>
<footer v-if="!kiosk">
Name: <span
class="userName"
@keyup.enter="(evt) => evt.target.blur()"

View file

@ -5,7 +5,7 @@ import RecentTab from './RecentTab.vue'
import TabHeader from './TabHeader.vue'
const props = defineProps(['state']);
const emit = defineEmits(['update:searchTerm', 'search', 'append', 'skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue'])
const emit = defineEmits(['update:searchTerm', 'search', 'append', 'skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue', 'moveTo'])
</script>
@ -23,9 +23,10 @@ const emit = defineEmits(['update:searchTerm', 'search', 'append', 'skip', 'skip
:queue="state.queue"
:admin="state.admin"
:waiting_room="state.waiting_room"
:waiting_room_enabled="state.waiting_room_enabled"
:waiting_room_policy="state.waiting_room_policy"
@skip="(uuid) => $emit('skip', uuid)"
@moveUp="(uuid) => $emit('moveUp', uuid)"
@moveTo="(data) => $emit('moveTo', data)"
@skipCurrent="$emit('skipCurrent')"
@waitingRoomToQueue="(uuid) => $emit('waitingRoomToQueue', uuid)"
/>

View file

@ -2,7 +2,7 @@
import QueueInner from './QueueInner.vue'
const props = defineProps(['queue', 'waiting_room', 'admin', 'waiting_room_policy']);
const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue'])
const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue', 'moveTo'])
</script>
<template>
@ -15,6 +15,7 @@ const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue'
:waiting_room_policy="waiting_room_policy"
@skip="(uuid) => $emit('skip', uuid)"
@moveUp="(uuid) => $emit('moveUp', uuid)"
@moveTo="(data) => $emit('moveTo', data)"
@skipCurrent="$emit('skipCurrent')"
@waitingRoomToQueue="(uuid) => $emit('waitingRoomToQueue', uuid)"
/>

View file

@ -3,7 +3,7 @@ import { onMounted, reactive } from 'vue'
import Entry from './Entry.vue'
const props = defineProps(['queue', 'waiting_room', 'admin', 'waiting_room_policy']);
const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue'])
const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue', 'moveTo'])
let currentTime = reactive({time: Date.now()})
@ -23,12 +23,15 @@ function offset(index) {
}
return _offset
}
</script>
<template>
<div class="vsplit">
<div id="queue-list-wrapper" class="results">
<ul id="queue" class="vertical menu">
<ul id="queue" class="vertical menu" @drop="dropHandler">
<Entry
v-for="(entry, index) in queue"
:entry="entry"
@ -40,6 +43,7 @@ function offset(index) {
@skip="(uuid) => $emit('skip', uuid)"
@skipCurrent="$emit('skipCurrent')"
@moveUp="(uuid) => $emit('moveUp', uuid)"
@moveTo="(data) => $emit('moveTo', data)"
/>
</ul>
<div v-show="waiting_room_policy" class="header">Waiting room</div>

View file

@ -2,7 +2,7 @@
import QueueInner from './QueueInner.vue'
const props = defineProps(['queue', 'waiting_room', 'admin', 'waiting_room_policy']);
const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue'])
const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue', 'moveTo'])
</script>
<template>
@ -16,6 +16,7 @@ const emits = defineEmits(['skip', 'skipCurrent', 'moveUp', 'waitingRoomToQueue'
@moveUp="(uuid) => $emit('moveUp', uuid)"
@skipCurrent="$emit('skipCurrent')"
@waitingRoomToQueue="(uuid) => $emit('waitingRoomToQueue', uuid)"
@moveTo="(data) => $emit('moveTo', data)"
/>
</div>
</template>

View file

@ -2,8 +2,8 @@
import { onMounted, onBeforeUnmount } from 'vue'
import $ from 'jquery'
const emits = defineEmits(['connect', 'update:room', 'update:name', 'update:server', 'update:secret'])
const props = defineProps(['room', 'server', 'secret', 'name', 'joinMsg'])
const emits = defineEmits(['connect', 'update:room', 'update:name', 'update:server', 'update:secret', 'update:kiosk'])
const props = defineProps(['room', 'server', 'secret', 'name', 'joinMsg', 'kiosk'])
onMounted(() => {
$(document).foundation();
@ -54,6 +54,11 @@ onBeforeUnmount(() => {
<input type="password" @input="$emit('update:secret', $event.target.value)" :value="secret" placeholder="Leave free, if not admin">
</label>
</div>
<div class="medium-12 cell">
<label>Kiosk mode
<input type="checkbox" id="kiosk" @change="$emit('update:kiosk', $event.target.checked)">
</label>
</div>
</div>
</div>
</div>