parent
8dc91d409e
commit
e11b752160
@ -0,0 +1,118 @@
|
||||
<template>
|
||||
<h1 class="text-2xl font-bold uppercase mb-10">casters management</h1>
|
||||
<div class="grid grid-cols-2 gap-x-8">
|
||||
<table class="table-auto">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Name Tag</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Real Name</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Twitter</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Image</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="item" :class="item === e._id ? 'active' : ''" @click="setItem(e)" v-for="e in store.state.casters" :key="e._id">
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.username }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.name }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.twitter }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4"><img :src="e.image" :alt="e.name"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<h2 class="text-lg font-bold">Create / Update</h2>
|
||||
<form name="form" @submit.prevent="form">
|
||||
<p class="mt-4">Caster name tag</p>
|
||||
<input v-model="username" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" required />
|
||||
<p class="mt-4">Caster real name</p>
|
||||
<input v-model="name" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" required />
|
||||
<p class="mt-4">Caster twitter</p>
|
||||
<input v-model="twitter" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" required />
|
||||
<p class="mt-4">Caster image URL</p>
|
||||
<input v-model="image" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<button class="block w-64 h-10 text-white bg-red-700 rounded-lg hover:bg-red-600">Submit</button>
|
||||
<button @click.prevent="delForm" v-if="item" class="block mt-4 w-64 h-10 text-white bg-red-700 rounded-lg hover:bg-red-600">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { inject, ref } from 'vue'
|
||||
import { create, update, del } from '../utils/websocket'
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const store = inject('store')
|
||||
|
||||
const item = ref('')
|
||||
const username = ref('')
|
||||
const name = ref('')
|
||||
const twitter = ref('')
|
||||
const image = ref('')
|
||||
|
||||
const reset = () => {
|
||||
item.value = ''
|
||||
username.value = ''
|
||||
name.value = ''
|
||||
twitter.value = ''
|
||||
image.value = ''
|
||||
}
|
||||
|
||||
const setItem = (e) => {
|
||||
item.value = e._id
|
||||
username.value = e.username
|
||||
name.value = e.name
|
||||
twitter.value = e.twitter
|
||||
image.value = e.image
|
||||
}
|
||||
|
||||
const form = () => {
|
||||
if (item.value !== '') {
|
||||
update('casters', item.value, {
|
||||
username: username.value,
|
||||
name: name.value,
|
||||
twitter: twitter.value,
|
||||
image: image.value,
|
||||
})
|
||||
} else if (name.value !== '') {
|
||||
create('casters', {
|
||||
username: username.value,
|
||||
name: name.value,
|
||||
twitter: twitter.value,
|
||||
image: image.value,
|
||||
})
|
||||
}
|
||||
reset()
|
||||
}
|
||||
|
||||
const delForm = () => {
|
||||
if (item.value) {
|
||||
del('casters', item.value)
|
||||
reset()
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
store,
|
||||
item,
|
||||
username,
|
||||
name,
|
||||
twitter,
|
||||
image,
|
||||
setItem,
|
||||
form,
|
||||
delForm,
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.item:hover {
|
||||
@apply bg-gray-300 cursor-pointer;
|
||||
}
|
||||
.item.active {
|
||||
@apply bg-gray-400;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,118 @@
|
||||
<template>
|
||||
<h1 class="text-2xl font-bold uppercase mb-10">hosts management</h1>
|
||||
<div class="grid grid-cols-2 gap-x-8">
|
||||
<table class="table-auto">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Name Tag</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Real Name</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Twitter</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Image</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="item" :class="item === e._id ? 'active' : ''" @click="setItem(e)" v-for="e in store.state.hosts" :key="e._id">
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.username }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.name }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.twitter }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4"><img :src="e.image" :alt="e.name"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<h2 class="text-lg font-bold">Create / Update</h2>
|
||||
<form name="form" @submit.prevent="form">
|
||||
<p class="mt-4">Host name tag</p>
|
||||
<input v-model="username" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" required />
|
||||
<p class="mt-4">Host real name</p>
|
||||
<input v-model="name" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" required />
|
||||
<p class="mt-4">Host twitter</p>
|
||||
<input v-model="twitter" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" required />
|
||||
<p class="mt-4">Host image URL</p>
|
||||
<input v-model="image" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<button class="block w-64 h-10 text-white bg-red-700 rounded-lg hover:bg-red-600">Submit</button>
|
||||
<button @click.prevent="delForm" v-if="item" class="block mt-4 w-64 h-10 text-white bg-red-700 rounded-lg hover:bg-red-600">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { inject, ref } from 'vue'
|
||||
import { create, update, del } from '../utils/websocket'
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const store = inject('store')
|
||||
|
||||
const item = ref('')
|
||||
const username = ref('')
|
||||
const name = ref('')
|
||||
const twitter = ref('')
|
||||
const image = ref('')
|
||||
|
||||
const reset = () => {
|
||||
item.value = ''
|
||||
username.value = ''
|
||||
name.value = ''
|
||||
twitter.value = ''
|
||||
image.value = ''
|
||||
}
|
||||
|
||||
const setItem = (e) => {
|
||||
item.value = e._id
|
||||
username.value = e.username
|
||||
name.value = e.name
|
||||
twitter.value = e.twitter
|
||||
image.value = e.image
|
||||
}
|
||||
|
||||
const form = () => {
|
||||
if (item.value !== '') {
|
||||
update('hosts', item.value, {
|
||||
username: username.value,
|
||||
name: name.value,
|
||||
twitter: twitter.value,
|
||||
image: image.value,
|
||||
})
|
||||
} else if (name.value !== '') {
|
||||
create('hosts', {
|
||||
username: username.value,
|
||||
name: name.value,
|
||||
twitter: twitter.value,
|
||||
image: image.value,
|
||||
})
|
||||
}
|
||||
reset()
|
||||
}
|
||||
|
||||
const delForm = () => {
|
||||
if (item.value) {
|
||||
del('hosts', item.value)
|
||||
reset()
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
store,
|
||||
item,
|
||||
username,
|
||||
name,
|
||||
twitter,
|
||||
image,
|
||||
setItem,
|
||||
form,
|
||||
delForm,
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.item:hover {
|
||||
@apply bg-gray-300 cursor-pointer;
|
||||
}
|
||||
.item.active {
|
||||
@apply bg-gray-400;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<h1 class="text-2xl font-bold uppercase mb-10">streams management</h1>
|
||||
<div class="grid grid-cols-2 gap-x-8">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table-auto">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Name</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Event</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Matches</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Casters</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Hosts</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="item" v-for="e in store.state.streams" :key="e._id" :class="item === e._id ? 'active' : ''" @click="setItem(e)">
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.name }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ store.state.events.filter(x => x._id === e.event)[0].name }}</td>
|
||||
<td class="border border-gray-400 text-left">
|
||||
<table v-if="e.matches" class="border border-gray-400 border-collapse mx-auto w-full h-full">
|
||||
<tbody>
|
||||
<tr v-for="p in e.matches" :key="p">
|
||||
<td class="border border-gray-400">{{ store.state.matches.filter((x) => x._id === p)[0]?.type || '' }}: {{ store.state.matches.filter((x) => x._id === p)[0]?.blue?.name || '' }} VS {{ store.state.matches.filter((x) => x._id === p)[0]?.orange?.name || '' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">
|
||||
<table v-if="e.casters">
|
||||
<tbody>
|
||||
<tr v-for="p in e.casters" :key="p">
|
||||
<td>{{ store.state.casters.filter(x => x._id === p)[0]?.name }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">
|
||||
<table v-if="e.hosts">
|
||||
<tbody>
|
||||
<tr v-for="p in e.hosts" :key="p">
|
||||
<td>{{ store.state.hosts.filter(x => x._id === p)[0]?.name }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-lg font-bold">Create / Update</h2>
|
||||
<form name="form" @submit.prevent="form">
|
||||
<p class="mt-4">Stream name</p>
|
||||
<input v-model="name" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" required />
|
||||
<p class="mt-4">Event</p>
|
||||
<select v-model="event" class="block my-4 border border-gray-500 rounded-lg bg-white w-64 h-8 px-4">
|
||||
<option v-for="r in store.state.events" :key="r._id" :value="r._id">{{ r.name }}</option>
|
||||
</select>
|
||||
<p class="mt-4">Matches</p>
|
||||
<select v-for="(n, i) in matches.length" :key="i" v-model="matches[n - 1]" class="block my-4 border border-gray-500 rounded-lg bg-white w-64 h-8 px-4">
|
||||
<option v-for="r in store.state.matches" :key="r._id" :value="r._id"><span v-if="r">{{ r.type }}: {{ r.blue.name }} VS {{ r.orange.name }}</span></option>
|
||||
</select>
|
||||
<button @click.prevent="addMatch()" class="block w-64 h-10 my-4 text-white bg-red-700 rounded-lg hover:bg-red-600">Add match</button>
|
||||
<p class="mt-4">Casters</p>
|
||||
<select v-for="(n, i) in casters.length" :key="i" v-model="casters[n - 1]" class="block my-4 border border-gray-500 rounded-lg bg-white w-64 h-8 px-4">
|
||||
<option v-for="r in store.state.casters" :key="r._id" :value="r._id">{{ r.name }}</option>
|
||||
</select>
|
||||
<button @click.prevent="addCaster()" class="block w-64 h-10 my-4 text-white bg-red-700 rounded-lg hover:bg-red-600">Add caster</button>
|
||||
<p class="mt-4">Hosts</p>
|
||||
<select v-for="(n, i) in hosts.length" :key="i" v-model="hosts[n - 1]" class="block my-4 border border-gray-500 rounded-lg bg-white w-64 h-8 px-4">
|
||||
<option v-for="r in store.state.hosts" :key="r._id" :value="r._id">{{ r.name }}</option>
|
||||
</select>
|
||||
<button @click.prevent="addHost()" class="block w-64 h-10 my-4 text-white bg-red-700 rounded-lg hover:bg-red-600">Add host</button>
|
||||
<button class="block w-64 h-10 text-white bg-red-700 rounded-lg hover:bg-red-600">Submit</button>
|
||||
<button @click.prevent="delForm" v-if="item" class="block mt-4 w-64 h-10 text-white bg-red-700 rounded-lg hover:bg-red-600">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { inject, ref } from 'vue'
|
||||
import { create, update, del } from '../utils/websocket'
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const store = inject('store')
|
||||
|
||||
const item = ref('')
|
||||
const name = ref('')
|
||||
const event = ref('')
|
||||
const matches = ref([])
|
||||
const casters = ref([])
|
||||
const hosts = ref([])
|
||||
|
||||
const addMatch = () => {
|
||||
matches.value.push('')
|
||||
}
|
||||
|
||||
const addCaster = () => {
|
||||
casters.value.push('')
|
||||
}
|
||||
|
||||
const addHost = () => {
|
||||
hosts.value.push('')
|
||||
}
|
||||
|
||||
const setItem = (e) => {
|
||||
item.value = e._id
|
||||
name.value = e.name
|
||||
event.value = e.event
|
||||
e.matches.forEach(m => {
|
||||
if (matches.value.length !== e.matches.length) {
|
||||
matches.value.push(m)
|
||||
}
|
||||
})
|
||||
e.casters.forEach(m => {
|
||||
if (casters.value.length !== e.casters.length) {
|
||||
casters.value.push(m)
|
||||
}
|
||||
})
|
||||
e.hosts.forEach(m => {
|
||||
if (hosts.value.length !== e.hosts.length) {
|
||||
hosts.value.push(m)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const reset = () => {
|
||||
item.value = ''
|
||||
name.value = ''
|
||||
event.value = ''
|
||||
matches.value = []
|
||||
casters.value = []
|
||||
hosts.value = []
|
||||
}
|
||||
|
||||
const form = () => {
|
||||
if (item.value !== '') {
|
||||
update('streams', item.value, {
|
||||
name: name.value,
|
||||
event: event.value,
|
||||
matches: matches.value,
|
||||
casters: casters.value,
|
||||
hosts: hosts.value,
|
||||
})
|
||||
} else if (name.value !== '') {
|
||||
create('streams', {
|
||||
name: name.value,
|
||||
event: event.value,
|
||||
matches: matches.value,
|
||||
casters: casters.value,
|
||||
hosts: hosts.value,
|
||||
})
|
||||
}
|
||||
reset()
|
||||
}
|
||||
|
||||
const delForm = () => {
|
||||
if (item.value) {
|
||||
del('streams', item.value)
|
||||
reset()
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
store,
|
||||
item,
|
||||
name,
|
||||
event,
|
||||
matches,
|
||||
casters,
|
||||
hosts,
|
||||
setItem,
|
||||
addMatch,
|
||||
addCaster,
|
||||
addHost,
|
||||
form,
|
||||
delForm,
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.item:hover {
|
||||
@apply bg-gray-300 cursor-pointer;
|
||||
}
|
||||
.item.active {
|
||||
@apply bg-gray-400;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,3 @@
|
||||
import { ipcRenderer } from 'electron'
|
||||
|
||||
window.ipcRenderer = ipcRenderer
|
@ -0,0 +1,91 @@
|
||||
import ws from 'ws'
|
||||
import { v4 } from 'uuid'
|
||||
import store from '../store'
|
||||
|
||||
let wss = null
|
||||
|
||||
const connections = {}
|
||||
|
||||
export const sub = []
|
||||
|
||||
let overlayStream = null
|
||||
|
||||
export const state = (data) => {
|
||||
overlayStream = data
|
||||
}
|
||||
|
||||
export const start = () => {
|
||||
if (!store.state.server) {
|
||||
store.state.server = true
|
||||
|
||||
console.warn('WS SERVER STARTED.')
|
||||
|
||||
wss = new ws.Server({
|
||||
port: 8001,
|
||||
})
|
||||
|
||||
wss.on('connection', handle)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const stop = () => {
|
||||
Object.keys(connections).forEach((k) => {
|
||||
delete connections[k]
|
||||
})
|
||||
wss.close(() => {
|
||||
wss = null
|
||||
})
|
||||
console.warn('WS SERVER CLOSED')
|
||||
}
|
||||
|
||||
export const status = () => {
|
||||
if (wss !== null)
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
export const sendAll = () => {
|
||||
Object.values(connections).forEach(v => {
|
||||
sendData(v)
|
||||
})
|
||||
}
|
||||
|
||||
const handle = (w) => {
|
||||
console.warn('NEW WS CONNECTION')
|
||||
const id = v4()
|
||||
connections[id] = w
|
||||
|
||||
sendData(w)
|
||||
|
||||
w.on('message', msg => onMsg(msg, id))
|
||||
|
||||
w.on('close', () => {
|
||||
delete connections[id]
|
||||
})
|
||||
}
|
||||
|
||||
const onMsg = (msg, id) => {
|
||||
const d = JSON.parse(msg)
|
||||
if (d.hasOwnProperty('event')) {
|
||||
if (d.event === 'read') {
|
||||
sendData(connections[id])
|
||||
} else if (d.event === 'update') {
|
||||
console.warn('RECEIVED UPDATE')
|
||||
sub.forEach(x => {
|
||||
x(d.data)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const sendData = (w) => {
|
||||
console.log('SENDING DATA')
|
||||
if (overlayStream !== null) {
|
||||
console.log(overlayStream)
|
||||
w.send(JSON.stringify({
|
||||
event: 'read',
|
||||
data: overlayStream,
|
||||
}))
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
pluginOptions: {
|
||||
electronBuilder: {
|
||||
preload: 'src/preload.js'
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue