Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
|
fd92f333f9 | 1 year ago |
|
a11f5c80e4 | 1 year ago |
|
957599f3a3 | 1 year ago |
|
76cf93cbb9 | 1 year ago |
|
bbda7f09ca | 1 year ago |
|
a8b9138ede | 1 year ago |
|
68c909a1aa | 1 year ago |
|
e55b6e949e | 1 year ago |
@ -0,0 +1,2 @@
|
||||
$env:NODE_OPTIONS = "--openssl-legacy-provider"
|
||||
npm run electron:build
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,231 @@
|
||||
<template>
|
||||
<h1 class="text-2xl font-bold uppercase mb-10">stats 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">Player Name</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Player Name Arabic</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Player Name Japanese</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Image</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Image Full?</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Win Title</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Win %</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Goals Title</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Goals</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Shots Title</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Shots</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Saves Title</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Saves</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Assists Title</th>
|
||||
<th class="border border-gray-400 text-left px-8 py-4">Assists</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="item" :class="item === e._id ? 'active' : ''" @click="setItem(e)" v-for="e in store.state.stats" :key="e._id">
|
||||
<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" dir="rtl">{{ e.name_arabic ?? '' }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.name_jpn ?? '' }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4"><img :src="e.image" :alt="e.name"></td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.image_full }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.win_name }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.win }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.goals_name }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.goals }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.shots_name }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.shots }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.saves_name }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.saves }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.assists_name }}</td>
|
||||
<td class="border border-gray-400 text-left px-8 py-4">{{ e.assists }}</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">Player 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">Player name arabic (optional)</p>
|
||||
<input v-model="name_arabic" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Player name japanese (optional)</p>
|
||||
<input v-model="name_jpn" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">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" />
|
||||
<p class="mt-4">Image Full Size?</p>
|
||||
<input v-model="image_full" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="checkbox" />
|
||||
<p class="mt-4">Win Title</p>
|
||||
<input v-model="win_name" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Win %</p>
|
||||
<input v-model="win" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Goals Title</p>
|
||||
<input v-model="goals_name" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Goals</p>
|
||||
<input v-model="goals" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Shots Title</p>
|
||||
<input v-model="shots_name" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Shots</p>
|
||||
<input v-model="shots" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Saves Title</p>
|
||||
<input v-model="saves_name" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Saves</p>
|
||||
<input v-model="saves" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Assists Title</p>
|
||||
<input v-model="assists_name" class="block my-4 border border-gray-500 rounded-lg w-64 h-8 px-4" type="text" />
|
||||
<p class="mt-4">Assists</p>
|
||||
<input v-model="assists" 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 name = ref('')
|
||||
const name_arabic = ref('')
|
||||
const name_jpn = ref('')
|
||||
const image = ref('')
|
||||
const image_full = ref(false)
|
||||
const win_name = ref('')
|
||||
const win = ref('')
|
||||
const goals_name = ref('')
|
||||
const goals = ref('')
|
||||
const shots_name = ref('')
|
||||
const shots = ref('')
|
||||
const saves_name = ref('')
|
||||
const saves = ref('')
|
||||
const assists_name = ref('')
|
||||
const assists = ref('')
|
||||
|
||||
const reset = () => {
|
||||
item.value = ''
|
||||
name.value = ''
|
||||
name_arabic.value = ''
|
||||
name_jpn.value = ''
|
||||
image.value = ''
|
||||
image_full.value = false
|
||||
win_name.value = ''
|
||||
win.value = ''
|
||||
goals_name.value = ''
|
||||
goals.value = ''
|
||||
shots_name.value = ''
|
||||
shots.value = ''
|
||||
saves_name.value = ''
|
||||
saves.value = ''
|
||||
assists_name.value = ''
|
||||
assists.value = ''
|
||||
}
|
||||
|
||||
const setItem = (e) => {
|
||||
item.value = e._id
|
||||
name.value = e.name
|
||||
name_arabic.value = e.name_arabic
|
||||
name_jpn.value = e.name_jpn
|
||||
image.value = e.image
|
||||
image_full.value = e.image_full
|
||||
win_name.value = e.win_name
|
||||
win.value = e.win
|
||||
goals_name.value = e.goals_name
|
||||
goals.value = e.goals
|
||||
shots_name.value = e.shots
|
||||
shots.value = e.shots
|
||||
saves_name.value = e.saves_name
|
||||
saves.value = e.saves
|
||||
assists_name.value = e.assists_name
|
||||
assists.value = e.assists
|
||||
}
|
||||
|
||||
const form = () => {
|
||||
if (item.value !== '') {
|
||||
update('stats', item.value, {
|
||||
name: name.value,
|
||||
name_arabic: name_arabic.value,
|
||||
name_jpn: name_jpn.value,
|
||||
image: image.value,
|
||||
image_full: image_full.value,
|
||||
win_name: win_name.value,
|
||||
win: win.value,
|
||||
goals_name: goals_name.value,
|
||||
goals: goals.value,
|
||||
shots_name: shots_name.value,
|
||||
shots: shots.value,
|
||||
saves_name: saves_name.value,
|
||||
saves: saves.value,
|
||||
assists_name: assists_name.value,
|
||||
assists: assists.value,
|
||||
})
|
||||
} else if (name.value !== '') {
|
||||
create('stats', {
|
||||
name: name.value,
|
||||
name_arabic: name_arabic.value,
|
||||
name_jpn: name_jpn.value,
|
||||
image: image.value,
|
||||
image_full: image_full.value,
|
||||
win_name: win_name.value,
|
||||
win: win.value,
|
||||
goals_name: goals_name.value,
|
||||
goals: goals.value,
|
||||
shots_name: shots_name.value,
|
||||
shots: shots.value,
|
||||
saves_name: saves_name.value,
|
||||
saves: saves.value,
|
||||
assists_name: assists_name.value,
|
||||
assists: assists.value,
|
||||
})
|
||||
}
|
||||
reset()
|
||||
}
|
||||
|
||||
const delForm = () => {
|
||||
if (item.value) {
|
||||
del('stats', item.value)
|
||||
reset()
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
store,
|
||||
item,
|
||||
name,
|
||||
name_arabic,
|
||||
name_jpn,
|
||||
image,
|
||||
image_full,
|
||||
win_name,
|
||||
win,
|
||||
goals_name,
|
||||
goals,
|
||||
shots_name,
|
||||
shots,
|
||||
saves_name,
|
||||
saves,
|
||||
assists_name,
|
||||
assists,
|
||||
setItem,
|
||||
form,
|
||||
delForm,
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.item:hover {
|
||||
@apply bg-gray-300 cursor-pointer;
|
||||
}
|
||||
.item.active {
|
||||
@apply bg-gray-400;
|
||||
}
|
||||
</style>
|
@ -1,3 +1,7 @@
|
||||
import { ipcRenderer } from 'electron'
|
||||
import { contextBridge, ipcRenderer } from 'electron'
|
||||
|
||||
contextBridge.exposeInMainWorld('ipcRenderer', {
|
||||
invoke: (a, b = null) => ipcRenderer.invoke(a, b),
|
||||
on: (a, b = null) => ipcRenderer.on(a, b),
|
||||
})
|
||||
|
||||
window.ipcRenderer = ipcRenderer
|
@ -0,0 +1,108 @@
|
||||
import ws from 'ws'
|
||||
import { v4 } from 'uuid'
|
||||
|
||||
let relay = null
|
||||
let rl = null
|
||||
|
||||
const connections = {}
|
||||
|
||||
export const sub = []
|
||||
|
||||
let overlayStream = null
|
||||
|
||||
export const state = (data) => {
|
||||
overlayStream = data
|
||||
}
|
||||
|
||||
export const start = () => {
|
||||
console.warn('RELAY SERVER STARTED.')
|
||||
|
||||
relay = new ws.Server({
|
||||
port: 49322,
|
||||
})
|
||||
|
||||
relay.on('connection', handle)
|
||||
|
||||
rl = new ws.WebSocket('ws://localhost:49122')
|
||||
rl.onopen = () => {
|
||||
console.warn('RL connected at ws://localhost:49122');
|
||||
}
|
||||
|
||||
rl.onclose = () => {
|
||||
console.warn('Lost connection to RL, not retrying');
|
||||
if (relay) {
|
||||
stop()
|
||||
}
|
||||
rl = null
|
||||
}
|
||||
|
||||
rl.on('message', (e) => {
|
||||
console.warn('Received event from RL')
|
||||
Object.values(connections).forEach(v => {
|
||||
const d = JSON.parse(e)
|
||||
v.send(JSON.stringify(d));
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const stop = () => {
|
||||
console.log('Received relay stop')
|
||||
Object.keys(connections).forEach((k) => {
|
||||
delete connections[k]
|
||||
})
|
||||
relay.close(() => {
|
||||
relay = null
|
||||
})
|
||||
console.warn('RELAY SERVER CLOSED')
|
||||
}
|
||||
|
||||
export const status = () => {
|
||||
if (relay !== null)
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
export const sendAll = () => {
|
||||
Object.values(connections).forEach(v => {
|
||||
sendData(v)
|
||||
})
|
||||
}
|
||||
|
||||
const handle = (w) => {
|
||||
console.warn('NEW RELAY CONNECTION')
|
||||
const id = v4()
|
||||
connections[id] = w
|
||||
|
||||
sendData(w)
|
||||
|
||||
w.on('message', msg => console.log(msg))
|
||||
|
||||
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,
|
||||
}))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue