diff --git a/backend/api.go b/backend/api.go index 2984406..7256b87 100644 --- a/backend/api.go +++ b/backend/api.go @@ -8,6 +8,7 @@ func (w *Webapp) initApi() { http_api := w.Engine.Group("/api") http_api.GET("/priority", w.GetPriority) + http_api.GET("/load", w.LoadHeats) http_api.POST("/priority", w.SetPriority) http_api.POST("/start", w.StartTimer) diff --git a/backend/backend b/backend/backend index 64c0912..1dd975c 100755 Binary files a/backend/backend and b/backend/backend differ diff --git a/backend/priority.go b/backend/priority.go index 81c48e3..efdb01f 100644 --- a/backend/priority.go +++ b/backend/priority.go @@ -1,6 +1,8 @@ package main import ( + "encoding/json" + "fmt" "log" "net/http" "time" @@ -35,6 +37,27 @@ func (w *Webapp) StartTimer(c *gin.Context) { c.JSON(http.StatusOK, w.Stream.Duration) } +func (w *Webapp) LoadHeats(c *gin.Context) { + records, err := w.DB.ReadAll("Heat") + if err != nil { + fmt.Printf("read error: %+v", err) + } + + heats := make([]Heat, 0) + for _, record := range records { + var heat Heat + err = json.Unmarshal([]byte(record), &heat) + if err != nil { + fmt.Printf("decode error: %+v", err) + } + heats = append(heats, heat) + } + + c.JSON(http.StatusOK, heats) + + log.Printf("heats: %+v", heats) +} + func (w *Webapp) GetPriority(c *gin.Context) { log.Printf("send priority %s", w.Stream.StatusPriority) diff --git a/backend/static/_app/version.json b/backend/static/_app/version.json index 38cc5ea..f1898ad 100644 --- a/backend/static/_app/version.json +++ b/backend/static/_app/version.json @@ -1 +1 @@ -{"version":"1702469015168"} \ No newline at end of file +{"version":"1702477632110"} \ No newline at end of file diff --git a/backend/static/_app/version.json.br b/backend/static/_app/version.json.br index e3d675d..df0519c 100644 Binary files a/backend/static/_app/version.json.br and b/backend/static/_app/version.json.br differ diff --git a/backend/static/_app/version.json.gz b/backend/static/_app/version.json.gz index f8e4135..49bc444 100644 Binary files a/backend/static/_app/version.json.gz and b/backend/static/_app/version.json.gz differ diff --git a/backend/static/index.html b/backend/static/index.html index 113e3db..7938ce7 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -5,17 +5,17 @@ - + - - - + + +