=priority: heat config

This commit is contained in:
Miki 2023-12-14 16:54:05 +01:00
parent c6f4800273
commit 5829f22163
14 changed files with 95 additions and 52 deletions

View file

@ -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)

Binary file not shown.

View file

@ -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"

View file

@ -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)
}
// ///////// Priority
func (w *Webapp) GetPriority(c *gin.Context) {
log.Printf("send priority %s", w.Stream.StatusPriority)

View file

@ -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

View file

@ -1 +1 @@
{"version":"1702551352225"}
{"version":"1702569208144"}

Binary file not shown.

Binary file not shown.

View file

@ -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.