=stop timer
=displayV
This commit is contained in:
parent
5829f22163
commit
b5195ed4a3
13 changed files with 126 additions and 37 deletions
|
@ -14,9 +14,11 @@ func (w *Webapp) initApi() {
|
|||
http_api.GET("/sse", HeadersMiddleware(), stream.serveHTTP(), stream.retvalSSE())
|
||||
|
||||
http_api.POST("/startheat", w.StartHeatTimer)
|
||||
http_api.GET("/stopheat", w.StopHeatTimer)
|
||||
http_api.POST("/saveheat", w.SaveHeat)
|
||||
http_api.POST("/deleteheat", w.DeleteHeat)
|
||||
http_api.GET("/loadheats", w.LoadHeats)
|
||||
http_api.GET("/runningheat", w.LoadRunning)
|
||||
|
||||
// // Surfers
|
||||
// http_api.GET("/surfers", w.GetSurfers)
|
||||
|
|
BIN
backend/backend
BIN
backend/backend
Binary file not shown.
|
@ -7,12 +7,15 @@ import (
|
|||
scribble "github.com/nanobox-io/golang-scribble"
|
||||
)
|
||||
|
||||
func InitDb(dbAddress string) *scribble.Driver {
|
||||
type DB struct {
|
||||
Db *scribble.Driver
|
||||
}
|
||||
|
||||
func InitDb(dbAddress string) *DB {
|
||||
var err error
|
||||
var db *scribble.Driver
|
||||
var db *DB
|
||||
|
||||
db, err = scribble.New("", nil)
|
||||
db.Db, err = scribble.New("", nil)
|
||||
if err != nil {
|
||||
fmt.Println("Error", err)
|
||||
}
|
||||
|
@ -21,3 +24,21 @@ func InitDb(dbAddress string) *scribble.Driver {
|
|||
|
||||
return db
|
||||
}
|
||||
|
||||
func (db *DB) Write(table string, key string, value interface{}) error {
|
||||
err := db.Db.Write(table, key, value)
|
||||
if err != nil {
|
||||
fmt.Println("Error", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *DB) Read(table string, key string, value interface{}) error {
|
||||
err := db.Db.Read(table, key, value)
|
||||
if err != nil {
|
||||
fmt.Println("Error", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -88,6 +88,8 @@ func (w *Webapp) LoadRunning(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusNoContent, "")
|
||||
}
|
||||
|
||||
func (w *Webapp) LoadHeats(c *gin.Context) {
|
||||
|
@ -130,6 +132,20 @@ func (w *Webapp) StartHeatTimer(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, w.Stream.Duration)
|
||||
}
|
||||
|
||||
func (w *Webapp) StopHeatTimer(c *gin.Context) {
|
||||
if !w.Stream.Start {
|
||||
c.JSON(http.StatusOK, w.Stream.Duration)
|
||||
return
|
||||
}
|
||||
|
||||
stopHeat(w.DB, *w.Stream.Heat)
|
||||
w.Stream.Start = false
|
||||
w.Stream.Duration = 0
|
||||
|
||||
log.Printf("start timer %s", w.Stream.Duration)
|
||||
c.JSON(http.StatusOK, w.Stream.Duration)
|
||||
}
|
||||
|
||||
func loadHeats(db *scribble.Driver) []Heat {
|
||||
records, err := db.ReadAll("Heat")
|
||||
if err != nil {
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":"1702569208144"}
|
||||
{"version":"1702630864271"}
|
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.13280560.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/start.fa0c32bd.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.d1a939e8.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/singletons.8b54c836.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/app.a9ea6d0c.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/index.994dd985.js">
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">
|
||||
<script>
|
||||
{
|
||||
__sveltekit_i2508g = {
|
||||
__sveltekit_1u6fqm2 = {
|
||||
base: "",
|
||||
env: {}
|
||||
};
|
||||
|
@ -23,8 +23,8 @@
|
|||
const element = document.currentScript.parentElement;
|
||||
|
||||
Promise.all([
|
||||
import("/_app/immutable/entry/start.13280560.js"),
|
||||
import("/_app/immutable/entry/app.cb972752.js")
|
||||
import("/_app/immutable/entry/start.fa0c32bd.js"),
|
||||
import("/_app/immutable/entry/app.a9ea6d0c.js")
|
||||
]).then(([kit, app]) => {
|
||||
kit.start(app, element);
|
||||
});
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue