=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
|
||||
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("/deleteheat", w.DeleteHeat)
|
||||
http_api.GET("/loadheats", w.LoadHeats)
|
||||
|
|
BIN
backend/backend
BIN
backend/backend
Binary file not shown.
|
@ -4,8 +4,10 @@ type Mode int
|
|||
|
||||
const (
|
||||
Priority Mode = iota
|
||||
Start
|
||||
Stop
|
||||
Time
|
||||
UpdateHeat
|
||||
)
|
||||
|
||||
func (t Mode) String() string {
|
||||
|
@ -16,6 +18,10 @@ func (t Mode) String() string {
|
|||
return "stop"
|
||||
case Time:
|
||||
return "time"
|
||||
case Start:
|
||||
return "start"
|
||||
case UpdateHeat:
|
||||
return "updateHeat"
|
||||
}
|
||||
|
||||
return "priority"
|
||||
|
|
|
@ -3,38 +3,11 @@ package main
|
|||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ///////// 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) {
|
||||
log.Printf("send priority %s", w.Stream.StatusPriority)
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ func (stream *SseStream) serveHTTP() gin.HandlerFunc {
|
|||
cli := Client{
|
||||
Chan: clientChan,
|
||||
IP: IPAddress(c.ClientIP()),
|
||||
Mode: Priority,
|
||||
}
|
||||
|
||||
// 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" />
|
||||
<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/singletons.2b3a0a27.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/app.3faab5fc.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.500d5dae.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/app.cb972752.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/index.994dd985.js">
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">
|
||||
<script>
|
||||
{
|
||||
__sveltekit_1lbm7l = {
|
||||
__sveltekit_i2508g = {
|
||||
base: "",
|
||||
env: {}
|
||||
};
|
||||
|
@ -23,8 +23,8 @@
|
|||
const element = document.currentScript.parentElement;
|
||||
|
||||
Promise.all([
|
||||
import("/_app/immutable/entry/start.99d6dd70.js"),
|
||||
import("/_app/immutable/entry/app.3faab5fc.js")
|
||||
import("/_app/immutable/entry/start.13280560.js"),
|
||||
import("/_app/immutable/entry/app.cb972752.js")
|
||||
]).then(([kit, app]) => {
|
||||
kit.start(app, element);
|
||||
});
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -39,7 +39,6 @@
|
|||
</th>
|
||||
{/if}
|
||||
</tr>
|
||||
|
||||
{#each heat.surfers as surfer }
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -84,13 +83,13 @@
|
|||
}
|
||||
|
||||
th.ended {
|
||||
background-color: red;
|
||||
text-decoration: line-through 2px yellow;
|
||||
background-color: lightcoral;
|
||||
text-decoration: line-through 1px lightyellow;
|
||||
}
|
||||
|
||||
@keyframes blinker {
|
||||
50% {
|
||||
opacity: 0;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@
|
|||
}
|
||||
|
||||
async function click(id) {
|
||||
let max = surfers.length;
|
||||
console.log(surfers[id]);
|
||||
if (surfers[id].priority === 'P') {
|
||||
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 {
|
||||
console.log(`pressed: [${id}] ${surfers[id].priority}`);
|
||||
let oldpos = parseInt(surfers[id].priority);
|
||||
|
@ -137,7 +158,7 @@
|
|||
}
|
||||
}
|
||||
} else {
|
||||
surfers[i].priority = '5';
|
||||
surfers[i].priority = max.toString();
|
||||
console.log(`last: [${i}] ${surfers[i].priority}`);
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +307,7 @@
|
|||
height: 100%;
|
||||
border-radius: 20%;
|
||||
font-size: 8vh;
|
||||
animation: blink 2s 2;
|
||||
/* animation: blink 2s 2; */
|
||||
margin-right: auto;
|
||||
background-color: white;
|
||||
color: black;
|
||||
|
@ -301,7 +322,7 @@
|
|||
height: 100%;
|
||||
border-radius: 20%;
|
||||
font-size: 8vh;
|
||||
animation: blink_white 2s 3;
|
||||
/* animation: blink_white 2s 3; */
|
||||
margin-right: auto;
|
||||
background-color: black;
|
||||
color: white;
|
||||
|
@ -317,7 +338,7 @@
|
|||
height: 85%;
|
||||
border-radius: 20%;
|
||||
font-size: 8vh;
|
||||
animation: blink 2s 3;
|
||||
/* animation: blink 2s 3; */
|
||||
margin-right: auto;
|
||||
margin-left: 30px;
|
||||
background-color: #ccc;
|
||||
|
|
|
@ -2,6 +2,29 @@
|
|||
import { onMount } from 'svelte';
|
||||
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;
|
||||
|
||||
$: heats = [];
|
||||
|
@ -28,10 +51,10 @@
|
|||
});
|
||||
|
||||
heat = {
|
||||
number: '',
|
||||
number: 1,
|
||||
name: '',
|
||||
category: '',
|
||||
timer: '',
|
||||
timer: 20,
|
||||
surfers: surfer_list
|
||||
}
|
||||
}
|
||||
|
@ -174,14 +197,24 @@
|
|||
|
||||
<div class="container">
|
||||
<div class="heat">
|
||||
<label class="label" for="name">Name</label>
|
||||
<input bind:value={heat.name} on:change={capitalize(heat, "name")} id="name" type="text">
|
||||
<label class="label" for="heat">Heat</label>
|
||||
<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>
|
||||
<input bind:value={heat.number} id="number" type="number" min="1" max="20">
|
||||
<label class="label" for="category">Category</label>
|
||||
<input bind:value={heat.category} on:change={capitalize(heat, "category")} id="category" type="text">
|
||||
<label class="label" for="timer">Timer</label>
|
||||
<input bind:value={heat.timer} id="timer" on:keydown={(event) => {event.preventDefault()}} type="number" min="5" max="60" step="5">
|
||||
<select name="category" id="category" bind:value={heat.category}>
|
||||
{#each categories as category}
|
||||
<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>
|
||||
|
||||
<hr>
|
||||
|
@ -275,6 +308,16 @@
|
|||
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 {
|
||||
font-size: 1.3rem;
|
||||
margin-top: 2px;
|
||||
|
|
Loading…
Add table
Reference in a new issue