=priority: heat config
This commit is contained in:
parent
c6f4800273
commit
5829f22163
14 changed files with 95 additions and 52 deletions
|
@ -13,7 +13,7 @@ func (w *Webapp) initApi() {
|
||||||
// SSE
|
// SSE
|
||||||
http_api.GET("/sse", HeadersMiddleware(), stream.serveHTTP(), stream.retvalSSE())
|
http_api.GET("/sse", HeadersMiddleware(), stream.serveHTTP(), stream.retvalSSE())
|
||||||
|
|
||||||
http_api.POST("/startheat", w.StartHeat)
|
http_api.POST("/startheat", w.StartHeatTimer)
|
||||||
http_api.POST("/saveheat", w.SaveHeat)
|
http_api.POST("/saveheat", w.SaveHeat)
|
||||||
http_api.POST("/deleteheat", w.DeleteHeat)
|
http_api.POST("/deleteheat", w.DeleteHeat)
|
||||||
http_api.GET("/loadheats", w.LoadHeats)
|
http_api.GET("/loadheats", w.LoadHeats)
|
||||||
|
|
BIN
backend/backend
BIN
backend/backend
Binary file not shown.
|
@ -4,8 +4,10 @@ type Mode int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Priority Mode = iota
|
Priority Mode = iota
|
||||||
|
Start
|
||||||
Stop
|
Stop
|
||||||
Time
|
Time
|
||||||
|
UpdateHeat
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t Mode) String() string {
|
func (t Mode) String() string {
|
||||||
|
@ -16,6 +18,10 @@ func (t Mode) String() string {
|
||||||
return "stop"
|
return "stop"
|
||||||
case Time:
|
case Time:
|
||||||
return "time"
|
return "time"
|
||||||
|
case Start:
|
||||||
|
return "start"
|
||||||
|
case UpdateHeat:
|
||||||
|
return "updateHeat"
|
||||||
}
|
}
|
||||||
|
|
||||||
return "priority"
|
return "priority"
|
||||||
|
|
|
@ -3,38 +3,11 @@ package main
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
/////////// Priority
|
// ///////// Priority
|
||||||
|
|
||||||
func (w *Webapp) StartTimer(c *gin.Context) {
|
|
||||||
var msg Message
|
|
||||||
var err error
|
|
||||||
var timer time.Duration
|
|
||||||
|
|
||||||
err = c.ShouldBind(&msg)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("req error: %+v", err)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
timer, err = time.ParseDuration(msg.Duration)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("req error: %+v", err)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.Stream.Duration = timer
|
|
||||||
w.Stream.Start = true
|
|
||||||
|
|
||||||
log.Printf("start timer %s - received %s", w.Stream.Duration, msg.Duration)
|
|
||||||
c.JSON(http.StatusOK, w.Stream.Duration)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Webapp) GetPriority(c *gin.Context) {
|
func (w *Webapp) GetPriority(c *gin.Context) {
|
||||||
log.Printf("send priority %s", w.Stream.StatusPriority)
|
log.Printf("send priority %s", w.Stream.StatusPriority)
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ func (stream *SseStream) serveHTTP() gin.HandlerFunc {
|
||||||
cli := Client{
|
cli := Client{
|
||||||
Chan: clientChan,
|
Chan: clientChan,
|
||||||
IP: IPAddress(c.ClientIP()),
|
IP: IPAddress(c.ClientIP()),
|
||||||
|
Mode: Priority,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send new connection to event server
|
// Send new connection to event server
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":"1702551352225"}
|
{"version":"1702569208144"}
|
Binary file not shown.
Binary file not shown.
|
@ -5,17 +5,17 @@
|
||||||
<link rel="icon" href="/favicon.png" />
|
<link rel="icon" href="/favicon.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
|
||||||
<link rel="modulepreload" href="/_app/immutable/entry/start.99d6dd70.js">
|
<link rel="modulepreload" href="/_app/immutable/entry/start.13280560.js">
|
||||||
<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.d1a939e8.js">
|
<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.d1a939e8.js">
|
||||||
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.2b3a0a27.js">
|
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.500d5dae.js">
|
||||||
<link rel="modulepreload" href="/_app/immutable/entry/app.3faab5fc.js">
|
<link rel="modulepreload" href="/_app/immutable/entry/app.cb972752.js">
|
||||||
<link rel="modulepreload" href="/_app/immutable/chunks/index.994dd985.js">
|
<link rel="modulepreload" href="/_app/immutable/chunks/index.994dd985.js">
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover">
|
<body data-sveltekit-preload-data="hover">
|
||||||
<div style="display: contents">
|
<div style="display: contents">
|
||||||
<script>
|
<script>
|
||||||
{
|
{
|
||||||
__sveltekit_1lbm7l = {
|
__sveltekit_i2508g = {
|
||||||
base: "",
|
base: "",
|
||||||
env: {}
|
env: {}
|
||||||
};
|
};
|
||||||
|
@ -23,8 +23,8 @@
|
||||||
const element = document.currentScript.parentElement;
|
const element = document.currentScript.parentElement;
|
||||||
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
import("/_app/immutable/entry/start.99d6dd70.js"),
|
import("/_app/immutable/entry/start.13280560.js"),
|
||||||
import("/_app/immutable/entry/app.3faab5fc.js")
|
import("/_app/immutable/entry/app.cb972752.js")
|
||||||
]).then(([kit, app]) => {
|
]).then(([kit, app]) => {
|
||||||
kit.start(app, element);
|
kit.start(app, element);
|
||||||
});
|
});
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -39,7 +39,6 @@
|
||||||
</th>
|
</th>
|
||||||
{/if}
|
{/if}
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{#each heat.surfers as surfer }
|
{#each heat.surfers as surfer }
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
@ -84,13 +83,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
th.ended {
|
th.ended {
|
||||||
background-color: red;
|
background-color: lightcoral;
|
||||||
text-decoration: line-through 2px yellow;
|
text-decoration: line-through 1px lightyellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes blinker {
|
@keyframes blinker {
|
||||||
50% {
|
50% {
|
||||||
opacity: 0;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function click(id) {
|
async function click(id) {
|
||||||
|
let max = surfers.length;
|
||||||
console.log(surfers[id]);
|
console.log(surfers[id]);
|
||||||
if (surfers[id].priority === 'P') {
|
if (surfers[id].priority === 'P') {
|
||||||
for (let i in surfers) {
|
for (let i in surfers) {
|
||||||
|
@ -122,7 +123,27 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
surfers[id].priority = '5';
|
surfers[id].priority = max.toString();
|
||||||
|
} else if (surfers[id].priority === '') {
|
||||||
|
console.log(`priority empty; pressed: [${id}] ${surfers[id].priority}`);
|
||||||
|
for (let i in surfers) {
|
||||||
|
console.log(`looping(${id}): ${i} - ${surfers[i].priority}`);
|
||||||
|
if (i != id) {
|
||||||
|
if (surfers[i].priority === '') {
|
||||||
|
console.log(`empty: [${i}] ${surfers[i].priority}`);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
console.log(`not empty: [${i}] ${surfers[i].priority}`);
|
||||||
|
let pos = parseInt(surfers[i].priority) - 1;
|
||||||
|
if (pos === 1) {
|
||||||
|
surfers[i].priority = 'P';
|
||||||
|
} else {
|
||||||
|
surfers[i].priority = pos.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
surfers[id].priority = max.toString();
|
||||||
} else {
|
} else {
|
||||||
console.log(`pressed: [${id}] ${surfers[id].priority}`);
|
console.log(`pressed: [${id}] ${surfers[id].priority}`);
|
||||||
let oldpos = parseInt(surfers[id].priority);
|
let oldpos = parseInt(surfers[id].priority);
|
||||||
|
@ -137,7 +158,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
surfers[i].priority = '5';
|
surfers[i].priority = max.toString();
|
||||||
console.log(`last: [${i}] ${surfers[i].priority}`);
|
console.log(`last: [${i}] ${surfers[i].priority}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,7 +307,7 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 20%;
|
border-radius: 20%;
|
||||||
font-size: 8vh;
|
font-size: 8vh;
|
||||||
animation: blink 2s 2;
|
/* animation: blink 2s 2; */
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: black;
|
color: black;
|
||||||
|
@ -301,7 +322,7 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 20%;
|
border-radius: 20%;
|
||||||
font-size: 8vh;
|
font-size: 8vh;
|
||||||
animation: blink_white 2s 3;
|
/* animation: blink_white 2s 3; */
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
color: white;
|
color: white;
|
||||||
|
@ -317,7 +338,7 @@
|
||||||
height: 85%;
|
height: 85%;
|
||||||
border-radius: 20%;
|
border-radius: 20%;
|
||||||
font-size: 8vh;
|
font-size: 8vh;
|
||||||
animation: blink 2s 3;
|
/* animation: blink 2s 3; */
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-left: 30px;
|
margin-left: 30px;
|
||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
|
|
|
@ -2,6 +2,29 @@
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import Logo from "$lib/img/topscorer_logo_web.png"
|
import Logo from "$lib/img/topscorer_logo_web.png"
|
||||||
|
|
||||||
|
let rounds = [
|
||||||
|
"Qualifying",
|
||||||
|
"Opening",
|
||||||
|
"Elimination",
|
||||||
|
"Round of 48",
|
||||||
|
"Round of 32",
|
||||||
|
"Round of 16",
|
||||||
|
"Quarterfinal",
|
||||||
|
"Semifinal",
|
||||||
|
"Final",
|
||||||
|
];
|
||||||
|
|
||||||
|
let categories = [
|
||||||
|
"Under 12 Women",
|
||||||
|
"Under 12 Men",
|
||||||
|
"Under 14 Women",
|
||||||
|
"Under 14 Men",
|
||||||
|
"Under 16 Women",
|
||||||
|
"Under 16 Men",
|
||||||
|
"Under 18 Women",
|
||||||
|
"Under 18 Men",
|
||||||
|
];
|
||||||
|
|
||||||
$: surfers = 2;
|
$: surfers = 2;
|
||||||
|
|
||||||
$: heats = [];
|
$: heats = [];
|
||||||
|
@ -28,10 +51,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
heat = {
|
heat = {
|
||||||
number: '',
|
number: 1,
|
||||||
name: '',
|
name: '',
|
||||||
category: '',
|
category: '',
|
||||||
timer: '',
|
timer: 20,
|
||||||
surfers: surfer_list
|
surfers: surfer_list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,14 +197,24 @@
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="heat">
|
<div class="heat">
|
||||||
<label class="label" for="name">Name</label>
|
<label class="label" for="heat">Heat</label>
|
||||||
<input bind:value={heat.name} on:change={capitalize(heat, "name")} id="name" type="text">
|
<select name="heat" id="heat" bind:value={heat.name}>
|
||||||
|
{#each rounds as round}
|
||||||
|
<option value={round}>{round}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
<!-- <input bind:value={heat.name} on:change={capitalize(heat, "name")} id="name" type="text"> -->
|
||||||
<label class="label" for="number">Number</label>
|
<label class="label" for="number">Number</label>
|
||||||
<input bind:value={heat.number} id="number" type="number" min="1" max="20">
|
<input bind:value={heat.number} id="number" type="number" min="1" max="20">
|
||||||
<label class="label" for="category">Category</label>
|
<label class="label" for="category">Category</label>
|
||||||
<input bind:value={heat.category} on:change={capitalize(heat, "category")} id="category" type="text">
|
<select name="category" id="category" bind:value={heat.category}>
|
||||||
<label class="label" for="timer">Timer</label>
|
{#each categories as category}
|
||||||
<input bind:value={heat.timer} id="timer" on:keydown={(event) => {event.preventDefault()}} type="number" min="5" max="60" step="5">
|
<option value={category}>{category}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
<!-- <input bind:value={heat.category} on:change={capitalize(heat, "category")} id="category" type="text"> -->
|
||||||
|
<label class="label" for="timer">Duration</label>
|
||||||
|
<input bind:value={heat.timer} id="timer" type="number" min="5" max="60" step="5"> <!-- on:keydown={(event) => {event.preventDefault()}} -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
@ -275,6 +308,16 @@
|
||||||
padding-bottom: 2px;
|
padding-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.heat select {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
border-radius: 6px;
|
||||||
|
margin-left: 0.1rem;
|
||||||
|
margin-right: 0.1rem;
|
||||||
|
padding-top: 2px;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.surfer {
|
.surfer {
|
||||||
font-size: 1.3rem;
|
font-size: 1.3rem;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
|
|
Loading…
Add table
Reference in a new issue