+backend
+frontend empty
This commit is contained in:
parent
54a47c8a95
commit
b1745ede2e
59 changed files with 1197 additions and 13 deletions
25
backend/api.go
Normal file
25
backend/api.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
func (w *Webapp) initApi() {
|
||||
|
||||
stream := NewServer()
|
||||
|
||||
w.Stream = stream
|
||||
|
||||
http_api := w.Engine.Group("/api")
|
||||
http_api.GET("/priority", w.GetPriority)
|
||||
http_api.POST("/priority", w.SetPriority)
|
||||
|
||||
// // Surfers
|
||||
// http_api.GET("/surfers", w.GetSurfers)
|
||||
// http_api.POST("/updatesurfer", w.UpdateSurfer)
|
||||
// http_api.POST("/deletesurfer", w.DeleteSurfer)
|
||||
|
||||
// // Users
|
||||
// http_api.GET("/users", w.GetUsers)
|
||||
// http_api.POST("/updateuser", w.UpdateUser)
|
||||
// http_api.POST("/deleteuser", w.DeleteUser)
|
||||
|
||||
// SSE
|
||||
http_api.GET("/sse", HeadersMiddleware(), stream.serveHTTP(), stream.retvalSSE())
|
||||
}
|
BIN
backend/backend
Executable file
BIN
backend/backend
Executable file
Binary file not shown.
37
backend/color.go
Normal file
37
backend/color.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package main
|
||||
|
||||
type Color int
|
||||
|
||||
const (
|
||||
Gray Color = iota
|
||||
Black
|
||||
Blue
|
||||
Red
|
||||
Yellow
|
||||
Green
|
||||
White
|
||||
Magenta
|
||||
)
|
||||
|
||||
func (c Color) String() string {
|
||||
switch c {
|
||||
case Gray:
|
||||
return "gray"
|
||||
case Black:
|
||||
return "black"
|
||||
case Blue:
|
||||
return "blue"
|
||||
case Red:
|
||||
return "red"
|
||||
case Yellow:
|
||||
return "yellow"
|
||||
case Green:
|
||||
return "green"
|
||||
case White:
|
||||
return "white"
|
||||
case Magenta:
|
||||
return "magenta"
|
||||
}
|
||||
|
||||
return "gray"
|
||||
}
|
23
backend/db.go
Normal file
23
backend/db.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
scribble "github.com/nanobox-io/golang-scribble"
|
||||
)
|
||||
|
||||
func InitDb(dbAddress string) *scribble.Driver {
|
||||
|
||||
var err error
|
||||
var db *scribble.Driver
|
||||
|
||||
db, err = scribble.New("", nil)
|
||||
if err != nil {
|
||||
fmt.Println("Error", err)
|
||||
}
|
||||
|
||||
log.Printf("App: %+v", db)
|
||||
|
||||
return db
|
||||
}
|
39
backend/go.mod
Normal file
39
backend/go.mod
Normal file
|
@ -0,0 +1,39 @@
|
|||
module backend
|
||||
|
||||
go 1.21.4
|
||||
|
||||
require (
|
||||
github.com/gin-contrib/cors v1.5.0
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/nanobox-io/golang-scribble v0.0.0-20190309225732-aa3e7c118975
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.10.1 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
||||
github.com/chenzhuoyu/iasm v0.9.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.15.5 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/jcelliott/lumber v0.0.0-20160324203708-dd349441af25 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
golang.org/x/arch v0.5.0 // indirect
|
||||
golang.org/x/crypto v0.14.0 // indirect
|
||||
golang.org/x/net v0.16.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
106
backend/go.sum
Normal file
106
backend/go.sum
Normal file
|
@ -0,0 +1,106 @@
|
|||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
||||
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
|
||||
github.com/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc=
|
||||
github.com/bytedance/sonic v1.10.1/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
|
||||
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
|
||||
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
|
||||
github.com/gin-contrib/cors v1.5.0 h1:DgGKV7DDoOn36DFkNtbHrjoRiT5ExCe+PC9/xp7aKvk=
|
||||
github.com/gin-contrib/cors v1.5.0/go.mod h1:TvU7MAZ3EwrPLI2ztzTt3tqgvBCq+wn8WpZmfADjupI=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
|
||||
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.15.5 h1:LEBecTWb/1j5TNY1YYG2RcOUN3R7NLylN+x8TTueE24=
|
||||
github.com/go-playground/validator/v10 v10.15.5/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/jcelliott/lumber v0.0.0-20160324203708-dd349441af25 h1:EFT6MH3igZK/dIVqgGbTqWVvkZ7wJ5iGN03SVtvvdd8=
|
||||
github.com/jcelliott/lumber v0.0.0-20160324203708-dd349441af25/go.mod h1:sWkGw/wsaHtRsT9zGQ/WyJCotGWG/Anow/9hsAcBWRw=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
|
||||
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/nanobox-io/golang-scribble v0.0.0-20190309225732-aa3e7c118975 h1:zm/Rb2OsnLWCY88Njoqgo4X6yt/lx3oBNWhepX0AOMU=
|
||||
github.com/nanobox-io/golang-scribble v0.0.0-20190309225732-aa3e7c118975/go.mod h1:4Mct/lWCFf1jzQTTAaWtOI7sXqmG+wBeiBfT4CxoaJk=
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
|
||||
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
|
||||
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.5.0 h1:jpGode6huXQxcskEIpOCvrU+tzo81b6+oFLUYXWtH/Y=
|
||||
golang.org/x/arch v0.5.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
|
||||
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
12
backend/hash.go
Normal file
12
backend/hash.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func CalcId(str string, len int) string {
|
||||
id := sha256.Sum256([]byte(str))
|
||||
|
||||
return fmt.Sprintf("%X", id)[0:len]
|
||||
}
|
21
backend/main.go
Normal file
21
backend/main.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var port string
|
||||
|
||||
Db := InitDb(os.Getenv("DB"))
|
||||
|
||||
webapp := InitHttp(Db)
|
||||
|
||||
if p := os.Getenv("PORT"); p == "" {
|
||||
port = "8080"
|
||||
} else {
|
||||
port = p
|
||||
}
|
||||
|
||||
webapp.Engine.Run(":" + port)
|
||||
}
|
22
backend/msgmode.go
Normal file
22
backend/msgmode.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
type Mode int
|
||||
|
||||
const (
|
||||
Priority Mode = iota
|
||||
Users
|
||||
Time
|
||||
)
|
||||
|
||||
func (t Mode) String() string {
|
||||
switch t {
|
||||
case Priority:
|
||||
return "priority"
|
||||
case Users:
|
||||
return "users"
|
||||
case Time:
|
||||
return "time"
|
||||
}
|
||||
|
||||
return "priority"
|
||||
}
|
62
backend/priority.go
Normal file
62
backend/priority.go
Normal file
|
@ -0,0 +1,62 @@
|
|||
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
|
||||
|
||||
err = c.ShouldBind(&msg)
|
||||
if err != nil {
|
||||
log.Printf("req error: %+v", err)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
w.Stream.Duration, 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.Start = true
|
||||
|
||||
log.Printf("start timer %s", w.Stream.Duration)
|
||||
c.JSON(http.StatusOK, w.Stream.Duration)
|
||||
}
|
||||
|
||||
func (w *Webapp) GetPriority(c *gin.Context) {
|
||||
log.Printf("send priority %s", w.Stream.StatusPriority)
|
||||
|
||||
c.JSON(http.StatusOK, w.Stream.StatusPriority)
|
||||
}
|
||||
|
||||
func (w *Webapp) SetPriority(c *gin.Context) {
|
||||
var msg Message
|
||||
var err error
|
||||
|
||||
log.Printf("set priority %s", c.Request.Body)
|
||||
|
||||
err = c.ShouldBind(&msg)
|
||||
if err != nil {
|
||||
log.Printf("req error: %+v", err)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, "OK")
|
||||
|
||||
log.Printf("msg %+v", msg)
|
||||
|
||||
w.Stream.StatusPriority = msg.Priority
|
||||
|
||||
w.Stream.SendPriority(msg.Priority)
|
||||
}
|
205
backend/sse.go
Normal file
205
backend/sse.go
Normal file
|
@ -0,0 +1,205 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"log"
|
||||
)
|
||||
|
||||
type SurferLive struct {
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
Score string `json:"score"`
|
||||
Priority string `json:"priority"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Surfers []SurferLive `json:"surfers"`
|
||||
Priority []string `json:"priority"`
|
||||
Duration string `json:"duration"`
|
||||
Source string `json:"source"`
|
||||
Msg string `json:"msg"`
|
||||
Mode string `json:"mode"`
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
Chan ClientChan
|
||||
IP IPAddress
|
||||
Mode Mode
|
||||
}
|
||||
|
||||
type ClientChan chan Message
|
||||
|
||||
type IPAddress string
|
||||
|
||||
type PriorityStream struct {
|
||||
// Events are pushed to this channel by the main events-gathering routine
|
||||
Message chan Message
|
||||
|
||||
// New client connections
|
||||
NewClients chan Client //chan string
|
||||
|
||||
// Closed client connections
|
||||
ClosedClients chan ClientChan
|
||||
|
||||
// Total client connections
|
||||
TotalClients map[ClientChan]IPAddress //bool
|
||||
|
||||
StatusPriority []string
|
||||
Duration time.Duration
|
||||
Start bool
|
||||
}
|
||||
|
||||
// Initialize event and Start procnteessing requests
|
||||
func NewServer() (sse *PriorityStream) {
|
||||
sse = &PriorityStream{
|
||||
Message: make(chan Message),
|
||||
NewClients: make(chan Client),
|
||||
ClosedClients: make(chan ClientChan),
|
||||
TotalClients: make(map[ClientChan]IPAddress),
|
||||
Start: false,
|
||||
}
|
||||
|
||||
go sse.listen()
|
||||
|
||||
go sse.timer()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// It Listens all incoming requests from clients.
|
||||
// Handles addition and removal of clients and broadcast messages to clients.
|
||||
func (stream *PriorityStream) listen() {
|
||||
for {
|
||||
select {
|
||||
// Add new available client
|
||||
case client := <-stream.NewClients:
|
||||
stream.TotalClients[client.Chan] = client.IP
|
||||
log.Printf("Client added. %d - %s registered clients", len(stream.TotalClients), client.IP)
|
||||
|
||||
// Remove closed client
|
||||
case client := <-stream.ClosedClients:
|
||||
ip := stream.TotalClients[client]
|
||||
delete(stream.TotalClients, client)
|
||||
close(client)
|
||||
log.Printf("Removed client. %d - %s registered clients", len(stream.TotalClients), ip)
|
||||
|
||||
// Broadcast message to client
|
||||
case eventMsg := <-stream.Message:
|
||||
for clientMessageChan := range stream.TotalClients {
|
||||
clientMessageChan <- eventMsg
|
||||
log.Printf("Message %+v sent to %s", eventMsg, stream.TotalClients[clientMessageChan])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func HeadersMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Writer.Header().Set("Content-Type", "text/event-stream")
|
||||
c.Writer.Header().Set("Cache-Control", "no-cache")
|
||||
c.Writer.Header().Set("Connection", "keep-alive")
|
||||
c.Writer.Header().Set("Transfer-Encoding", "chunked")
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func (stream *PriorityStream) serveHTTP() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
// Initialize client channel
|
||||
clientChan := make(ClientChan)
|
||||
|
||||
cli := Client{
|
||||
Chan: clientChan,
|
||||
IP: IPAddress(c.ClientIP()),
|
||||
}
|
||||
|
||||
// Send new connection to event server
|
||||
stream.NewClients <- cli
|
||||
|
||||
defer func() {
|
||||
// Send closed connection to event server
|
||||
stream.ClosedClients <- clientChan
|
||||
}()
|
||||
|
||||
c.Set("clientChan", clientChan)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func (stream *PriorityStream) retvalSSE() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
|
||||
if len(stream.StatusPriority) > 0 {
|
||||
stream.SendPriority(stream.StatusPriority)
|
||||
log.Printf("update priority %+v", stream.StatusPriority)
|
||||
}
|
||||
|
||||
v, ok := c.Get("clientChan")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
clientChan, ok := v.(ClientChan)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
c.Stream(func(w io.Writer) bool {
|
||||
// Stream message to client from message channel
|
||||
if msg, ok := <-clientChan; ok {
|
||||
c.SSEvent("message", msg)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (stream *PriorityStream) SendPriority(pri []string) {
|
||||
stream.Message <- Message{
|
||||
Priority: pri,
|
||||
Mode: Priority.String(),
|
||||
}
|
||||
}
|
||||
|
||||
func (stream *PriorityStream) timer() {
|
||||
if stream.Start {
|
||||
timer := time.NewTimer(stream.Duration)
|
||||
for {
|
||||
select {
|
||||
case <-timer.C:
|
||||
stream.Start = false
|
||||
msg := Message{
|
||||
Msg: "stop",
|
||||
Mode: Time.String(),
|
||||
}
|
||||
stream.Message <- msg
|
||||
return
|
||||
default:
|
||||
if len(stream.TotalClients) > 0 {
|
||||
currentTimer := fmt.Sprintf("The Current Time Is %v", formatTime(stream.Duration))
|
||||
|
||||
msg := Message{
|
||||
Msg: currentTimer,
|
||||
Mode: Time.String(),
|
||||
}
|
||||
|
||||
// Send current time to clients message channel
|
||||
stream.Message <- msg
|
||||
time.Sleep(time.Second * 1)
|
||||
stream.Duration = stream.Duration - time.Second
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func formatTime(d time.Duration) string {
|
||||
minutes := int(d.Minutes()) % 60
|
||||
seconds := int(d.Seconds()) % 60
|
||||
return fmt.Sprintf("%02d:%02d", minutes, seconds)
|
||||
}
|
1
backend/static/_app/immutable/chunks/index.a21d6cee.js
Normal file
1
backend/static/_app/immutable/chunks/index.a21d6cee.js
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/static/_app/immutable/chunks/index.a21d6cee.js.br
Normal file
BIN
backend/static/_app/immutable/chunks/index.a21d6cee.js.br
Normal file
Binary file not shown.
BIN
backend/static/_app/immutable/chunks/index.a21d6cee.js.gz
Normal file
BIN
backend/static/_app/immutable/chunks/index.a21d6cee.js.gz
Normal file
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
function k(){}function x(t,n){for(const e in n)t[e]=n[e];return t}function w(t){return t()}function z(){return Object.create(null)}function j(t){t.forEach(w)}function F(t){return typeof t=="function"}function P(t,n){return t!=t?n==n:t!==n||t&&typeof t=="object"||typeof t=="function"}function S(t){return Object.keys(t).length===0}function E(t,...n){if(t==null){for(const o of n)o(void 0);return k}const e=t.subscribe(...n);return e.unsubscribe?()=>e.unsubscribe():e}function U(t,n,e){t.$$.on_destroy.push(E(n,e))}function A(t,n,e,o){if(t){const r=g(t,n,e,o);return t[0](r)}}function g(t,n,e,o){return t[1]&&o?x(e.ctx.slice(),t[1](o(n))):e.ctx}function B(t,n,e,o){if(t[2]&&o){const r=t[2](o(e));if(n.dirty===void 0)return r;if(typeof r=="object"){const a=[],f=Math.max(n.dirty.length,r.length);for(let s=0;s<f;s+=1)a[s]=n.dirty[s]|r[s];return a}return n.dirty|r}return n.dirty}function C(t,n,e,o,r,a){if(r){const f=g(n,e,o,a);t.p(f,r)}}function D(t){if(t.ctx.length>32){const n=[],e=t.ctx.length/32;for(let o=0;o<e;o++)n[o]=-1;return n}return-1}let i;function d(t){i=t}function m(){if(!i)throw new Error("Function called outside component initialization");return i}function G(t){m().$$.on_mount.push(t)}function H(t){m().$$.after_update.push(t)}const l=[],p=[];let u=[];const b=[],y=Promise.resolve();let h=!1;function v(){h||(h=!0,y.then(q))}function I(){return v(),y}function O(t){u.push(t)}const _=new Set;let c=0;function q(){if(c!==0)return;const t=i;do{try{for(;c<l.length;){const n=l[c];c++,d(n),M(n.$$)}}catch(n){throw l.length=0,c=0,n}for(d(null),l.length=0,c=0;p.length;)p.pop()();for(let n=0;n<u.length;n+=1){const e=u[n];_.has(e)||(_.add(e),e())}u.length=0}while(l.length);for(;b.length;)b.pop()();h=!1,_.clear(),d(t)}function M(t){if(t.fragment!==null){t.update(),j(t.before_update);const n=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,n),t.after_update.forEach(O)}}function J(t){const n=[],e=[];u.forEach(o=>t.indexOf(o)===-1?n.push(o):e.push(o)),e.forEach(o=>o()),u=n}export{H as a,p as b,A as c,B as d,U as e,z as f,D as g,q as h,F as i,S as j,O as k,J as l,i as m,k as n,G as o,d as p,w as q,j as r,P as s,I as t,C as u,l as v,v as w};
|
|
@ -0,0 +1,4 @@
|
|||
o <20>Βqο!6¥mƒ‘ΥLZlοΝ―Pκ„V<E2809E>
|
||||
#( '<27>EΫΪY6ή]™\η“6w<36>΄ώp4uφΣιΗv 4Ζ eΦε»ΖP<CE96>ύμ'*uΤΕΦ¥Ή-n.ΐΉKA“’(|\ΆUΫΝ?<3F>a<EFBFBD>V<EFBFBD>σ,§cqΰςδΠJ„+¥³–D<E28093>!#>eb@k<>~c£Zπzϊ<7A>l,<2C>―ΰΡ+>Ι‡ί`οχό<CF87>=―–‘†(ά™\Δύρ<CF8D>Κ6Iiυ<69>µRί—σsj¤<CΘΨ’ϋµFΘ)-p|<7C>$Ν(Θς}φϋ}΄ϊφ#YΚΊs‹=Η2¦ΪΒΠ’eswZεχ΄!3£Xmπ6Ag·0m<30>hBk<05>ΟάΊοkμ)έ΄75ρcK€Y7¦ ’κ «
|
||||
••^`4πVqx…ƒ5zΝ]ί]<5D><>ην/ΐ³ςϋ+‰µ:…4³Υ<C2B3>α£3S"Η<Uδ§υ‘ΦΒ>AΟίεO’'qγSp)§Β¬q<C2AC>)^1Ρ—@^―ο~1–I<E28093>‡cBφΝκ©8YΠλ$θNs»‹ϊJT<4A>cνώu5$£vAρpέΣ[]σ:#{CκROτ¨΄›<1F>Hθk²P${υ-m–>΄p„@¦Τ<1E>ΎΆ5κ:K‘®4™[ΰDρ‰Ύ†<CE8E>ΞƒT;ηUνρjΌΫ|³ςzΘ?<0E>~ΎΪx +4|ή}1‹~©ν“5<E2809C>ΌβrΎµΠβZ©«<C2A9>?u—6†ΈΧm”–ΈinYυ<59>ς<C2AD>ϋΎ`<60>Ο>¬Βlqς¥<CF82>W?<3F>Μq΄PM™s/x`§Ύφ=r3Ύ~$<24>dύ„·mNFηnίYQ½“Z»¥§wσ„i&- έΫb)Qεw<CEB5>ήΟΥώϊI{ΒΦΥ‡2πΝΟΘ®λ:r ρτ_ckΟ‰ρΥxmU3²{1l<Ό'λ<10>BΞ3;/ς-Τ‡€%\[$– j³
:E|)πΩέ`}<7D>Η–£ΗΗΓ΄¬<CE84>ωΫό<CEAB>DU}ιI,Ω}/Η%Ξΰχ\2έ"Ο<>π±8θυ…ν7Q|rHd¤ψΑ<CF88> “²ΰ½@©Τ`xΠBq2Ώ"CΓωω£ /jp–h4ωG'93[²»®HΫρ*XtiS><3E>ο,™¤Ι|‹iΣ"[Α#SF ‹f<±i•ΪΧW:Y7.:Ί<>β!<21>9Ζp>ψ†„H)!γ
|
||||
rή΅ΰJξ b5K@®<>ΘAΠƒd<01>Πά‚α,«¦£s?BD®…
|
BIN
backend/static/_app/immutable/chunks/scheduler.e108d1fd.js.gz
Normal file
BIN
backend/static/_app/immutable/chunks/scheduler.e108d1fd.js.gz
Normal file
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
import{n as d,s as m}from"./scheduler.e108d1fd.js";const u=[];function p(e,t=d){let n;const o=new Set;function r(s){if(m(e,s)&&(e=s,n)){const c=!u.length;for(const l of o)l[1](),u.push(l,e);if(c){for(let l=0;l<u.length;l+=2)u[l][0](u[l+1]);u.length=0}}}function i(s){r(s(e))}function a(s,c=d){const l=[s,c];return o.add(l),o.size===1&&(n=t(r,i)||d),s(e),()=>{o.delete(l),o.size===0&&n&&(n(),n=null)}}return{set:r,update:i,subscribe:a}}var g;const E=((g=globalThis.__sveltekit_10p5els)==null?void 0:g.base)??"";var k;const w=((k=globalThis.__sveltekit_10p5els)==null?void 0:k.assets)??E,A="1701780449523",y="sveltekit:snapshot",I="sveltekit:scroll",x="sveltekit:index",_={tap:1,hover:2,viewport:3,eager:4,off:-1};function O(e){let t=e.baseURI;if(!t){const n=e.getElementsByTagName("base");t=n.length?n[0].href:e.URL}return t}function U(){return{x:pageXOffset,y:pageYOffset}}function f(e,t){return e.getAttribute(`data-sveltekit-${t}`)}const b={..._,"":_.hover};function v(e){let t=e.assignedSlot??e.parentNode;return(t==null?void 0:t.nodeType)===11&&(t=t.host),t}function L(e,t){for(;e&&e!==t;){if(e.nodeName.toUpperCase()==="A"&&e.hasAttribute("href"))return e;e=v(e)}}function N(e,t){let n;try{n=new URL(e instanceof SVGAElement?e.href.baseVal:e.href,document.baseURI)}catch{}const o=e instanceof SVGAElement?e.target.baseVal:e.target,r=!n||!!o||S(n,t)||(e.getAttribute("rel")||"").split(/\s+/).includes("external"),i=(n==null?void 0:n.origin)===location.origin&&e.hasAttribute("download");return{url:n,external:r,target:o,download:i}}function P(e){let t=null,n=null,o=null,r=null,i=null,a=null,s=e;for(;s&&s!==document.documentElement;)o===null&&(o=f(s,"preload-code")),r===null&&(r=f(s,"preload-data")),t===null&&(t=f(s,"keepfocus")),n===null&&(n=f(s,"noscroll")),i===null&&(i=f(s,"reload")),a===null&&(a=f(s,"replacestate")),s=v(s);function c(l){switch(l){case"":case"true":return!0;case"off":case"false":return!1;default:return null}}return{preload_code:b[o??"off"],preload_data:b[r??"off"],keep_focus:c(t),noscroll:c(n),reload:c(i),replace_state:c(a)}}function h(e){const t=p(e);let n=!0;function o(){n=!0,t.update(a=>a)}function r(a){n=!1,t.set(a)}function i(a){let s;return t.subscribe(c=>{(s===void 0||n&&c!==s)&&a(s=c)})}return{notify:o,set:r,subscribe:i}}function R(){const{set:e,subscribe:t}=p(!1);let n;async function o(){clearTimeout(n);try{const r=await fetch(`${w}/_app/version.json`,{headers:{pragma:"no-cache","cache-control":"no-cache"}});if(!r.ok)return!1;const a=(await r.json()).version!==A;return a&&(e(!0),clearTimeout(n)),a}catch{return!1}}return{subscribe:t,check:o}}function S(e,t){return e.origin!==location.origin||!e.pathname.startsWith(t)}function V(e){e.client}const Y={url:h({}),page:h({}),navigating:p(null),updated:R()};export{x as I,_ as P,I as S,y as a,N as b,P as c,Y as d,E as e,L as f,O as g,V as h,S as i,U as s};
|
BIN
backend/static/_app/immutable/chunks/singletons.5178810a.js.br
Normal file
BIN
backend/static/_app/immutable/chunks/singletons.5178810a.js.br
Normal file
Binary file not shown.
BIN
backend/static/_app/immutable/chunks/singletons.5178810a.js.gz
Normal file
BIN
backend/static/_app/immutable/chunks/singletons.5178810a.js.gz
Normal file
Binary file not shown.
1
backend/static/_app/immutable/entry/app.72ed0e5f.js
Normal file
1
backend/static/_app/immutable/entry/app.72ed0e5f.js
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/static/_app/immutable/entry/app.72ed0e5f.js.br
Normal file
BIN
backend/static/_app/immutable/entry/app.72ed0e5f.js.br
Normal file
Binary file not shown.
BIN
backend/static/_app/immutable/entry/app.72ed0e5f.js.gz
Normal file
BIN
backend/static/_app/immutable/entry/app.72ed0e5f.js.gz
Normal file
Binary file not shown.
3
backend/static/_app/immutable/entry/start.92e5ab9c.js
Normal file
3
backend/static/_app/immutable/entry/start.92e5ab9c.js
Normal file
File diff suppressed because one or more lines are too long
BIN
backend/static/_app/immutable/entry/start.92e5ab9c.js.br
Normal file
BIN
backend/static/_app/immutable/entry/start.92e5ab9c.js.br
Normal file
Binary file not shown.
BIN
backend/static/_app/immutable/entry/start.92e5ab9c.js.gz
Normal file
BIN
backend/static/_app/immutable/entry/start.92e5ab9c.js.gz
Normal file
Binary file not shown.
1
backend/static/_app/immutable/nodes/0.e3dbbdbf.js
Normal file
1
backend/static/_app/immutable/nodes/0.e3dbbdbf.js
Normal file
|
@ -0,0 +1 @@
|
|||
import{s as l,c as r,u as i,g as u,d as f}from"../chunks/scheduler.e108d1fd.js";import{S as _,i as c,d as p,t as d}from"../chunks/index.a21d6cee.js";const m=!0,g=!1,$="always",v=Object.freeze(Object.defineProperty({__proto__:null,prerender:m,ssr:g,trailingSlash:$},Symbol.toStringTag,{value:"Module"}));function y(n){let s;const a=n[1].default,e=r(a,n,n[0],null);return{c(){e&&e.c()},l(t){e&&e.l(t)},m(t,o){e&&e.m(t,o),s=!0},p(t,[o]){e&&e.p&&(!s||o&1)&&i(e,a,t,t[0],s?f(a,t[0],o,null):u(t[0]),null)},i(t){s||(p(e,t),s=!0)},o(t){d(e,t),s=!1},d(t){e&&e.d(t)}}}function S(n,s,a){let{$$slots:e={},$$scope:t}=s;return n.$$set=o=>{"$$scope"in o&&a(0,t=o.$$scope)},[t,e]}class j extends _{constructor(s){super(),c(this,s,S,y,l,{})}}export{j as component,v as universal};
|
BIN
backend/static/_app/immutable/nodes/0.e3dbbdbf.js.br
Normal file
BIN
backend/static/_app/immutable/nodes/0.e3dbbdbf.js.br
Normal file
Binary file not shown.
BIN
backend/static/_app/immutable/nodes/0.e3dbbdbf.js.gz
Normal file
BIN
backend/static/_app/immutable/nodes/0.e3dbbdbf.js.gz
Normal file
Binary file not shown.
1
backend/static/_app/immutable/nodes/1.83202d09.js
Normal file
1
backend/static/_app/immutable/nodes/1.83202d09.js
Normal file
|
@ -0,0 +1 @@
|
|||
import{s as x,n as _,e as S}from"../chunks/scheduler.e108d1fd.js";import{S as j,i as q,g as f,m as d,s as y,h as g,j as h,n as v,f as u,c as C,a as m,x as $,o as E}from"../chunks/index.a21d6cee.js";import{d as H}from"../chunks/singletons.5178810a.js";const P=()=>{const s=H;return{page:{subscribe:s.page.subscribe},navigating:{subscribe:s.navigating.subscribe},updated:s.updated}},k={subscribe(s){return P().page.subscribe(s)}};function w(s){var b;let t,r=s[0].status+"",o,n,i,c=((b=s[0].error)==null?void 0:b.message)+"",l;return{c(){t=f("h1"),o=d(r),n=y(),i=f("p"),l=d(c)},l(e){t=g(e,"H1",{});var a=h(t);o=v(a,r),a.forEach(u),n=C(e),i=g(e,"P",{});var p=h(i);l=v(p,c),p.forEach(u)},m(e,a){m(e,t,a),$(t,o),m(e,n,a),m(e,i,a),$(i,l)},p(e,[a]){var p;a&1&&r!==(r=e[0].status+"")&&E(o,r),a&1&&c!==(c=((p=e[0].error)==null?void 0:p.message)+"")&&E(l,c)},i:_,o:_,d(e){e&&(u(t),u(n),u(i))}}}function z(s,t,r){let o;return S(s,k,n=>r(0,o=n)),[o]}let F=class extends j{constructor(t){super(),q(this,t,z,w,x,{})}};export{F as component};
|
BIN
backend/static/_app/immutable/nodes/1.83202d09.js.br
Normal file
BIN
backend/static/_app/immutable/nodes/1.83202d09.js.br
Normal file
Binary file not shown.
BIN
backend/static/_app/immutable/nodes/1.83202d09.js.gz
Normal file
BIN
backend/static/_app/immutable/nodes/1.83202d09.js.gz
Normal file
Binary file not shown.
1
backend/static/_app/immutable/nodes/2.01200e4b.js
Normal file
1
backend/static/_app/immutable/nodes/2.01200e4b.js
Normal file
|
@ -0,0 +1 @@
|
|||
import{s as o,n as t}from"../chunks/scheduler.e108d1fd.js";import{S as s,i as x,g as i,h as M,y as E,l as c,a as J,f as W}from"../chunks/index.a21d6cee.js";const f="data:image/png;base64,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";function h(A){let e,r=`<img src="${f}" alt="TopScorer"/>`;return{c(){e=i("div"),e.innerHTML=r,this.h()},l(a){e=M(a,"DIV",{style:!0,"data-svelte-h":!0}),E(e)!=="svelte-b4qvfi"&&(e.innerHTML=r),this.h()},h(){c(e,"background-color","black")},m(a,n){J(a,e,n)},p:t,i:t,o:t,d(a){a&&W(e)}}}class d extends s{constructor(e){super(),x(this,e,null,h,o,{})}}export{d as component};
|
BIN
backend/static/_app/immutable/nodes/2.01200e4b.js.br
Normal file
BIN
backend/static/_app/immutable/nodes/2.01200e4b.js.br
Normal file
Binary file not shown.
BIN
backend/static/_app/immutable/nodes/2.01200e4b.js.gz
Normal file
BIN
backend/static/_app/immutable/nodes/2.01200e4b.js.gz
Normal file
Binary file not shown.
1
backend/static/_app/version.json
Normal file
1
backend/static/_app/version.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":"1701780449523"}
|
BIN
backend/static/_app/version.json.br
Normal file
BIN
backend/static/_app/version.json.br
Normal file
Binary file not shown.
BIN
backend/static/_app/version.json.gz
Normal file
BIN
backend/static/_app/version.json.gz
Normal file
Binary file not shown.
BIN
backend/static/favicon.png
Normal file
BIN
backend/static/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
35
backend/static/index.html
Normal file
35
backend/static/index.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/start.92e5ab9c.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.e108d1fd.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.5178810a.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/entry/app.72ed0e5f.js">
|
||||
<link rel="modulepreload" href="/_app/immutable/chunks/index.a21d6cee.js">
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">
|
||||
<script>
|
||||
{
|
||||
__sveltekit_10p5els = {
|
||||
base: "",
|
||||
env: {}
|
||||
};
|
||||
|
||||
const element = document.currentScript.parentElement;
|
||||
|
||||
Promise.all([
|
||||
import("/_app/immutable/entry/start.92e5ab9c.js"),
|
||||
import("/_app/immutable/entry/app.72ed0e5f.js")
|
||||
]).then(([kit, app]) => {
|
||||
kit.start(app, element);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
3
backend/static/index.html.br
Normal file
3
backend/static/index.html.br
Normal file
|
@ -0,0 +1,3 @@
|
|||
ŒÔQÍæÙ®¶•¹’˜K¸§"¾¨¾F‚FsÖè
|
||||
c*ôC®ˆ#’³Lz,Eµ]ÍÑÃ_H ç6w{
|
||||
V‡ÊwˆÙÌ8@nñ<6E>ð·EêAÙ€E€‡ög²?XäUŠŽSé”{saé ©/ó:бÔÒYÇY—`9Í×Uì¦éÒÝÍo‹"þo[=/ìRè°+ÊöÊÙ!zUEîÈ’UÉuÅSºZuœË|ºlZ–,å ³ê@0O
+ ôqi-WäÊ(ø¢œ`!âbÉqÃxÂÐ<C382><o‹§Ä>œâhàRL<52>Ø»Ô/ÊÓ”{Y*K«ãAú$Ý"6Ä3"1檺0ßÎáüSóï¢2-Å<>Ûh¾ÿ@8’ðwÌ"øSsüÚ|ã|©°#ù2/ãp/Ó\ÛÃCçÐ9ŠéÒ¢Âa?†ÁºVvH?0#ˆ7þÁ¨§iJ»v@ùç<C3B9>BÝ‘9ú#
|
BIN
backend/static/index.html.gz
Normal file
BIN
backend/static/index.html.gz
Normal file
Binary file not shown.
117
backend/surfers.go
Normal file
117
backend/surfers.go
Normal file
|
@ -0,0 +1,117 @@
|
|||
package main
|
||||
|
||||
type Surfer struct {
|
||||
Dbid string `json:"dbid"`
|
||||
Id string `json:"id"`
|
||||
Firstname string `json:"firstname"`
|
||||
Lastname string `json:"lastname"`
|
||||
}
|
||||
|
||||
///////////// Surfers
|
||||
|
||||
// func (w *Webapp) GetSurfers(c *gin.Context) {
|
||||
// var cursor uint64
|
||||
|
||||
// var surfersKeys []string
|
||||
|
||||
// cursor = 0
|
||||
|
||||
// log.Printf("start scanning %+v", c.ClientIP())
|
||||
// for {
|
||||
// var keys []string
|
||||
// var err error
|
||||
// log.Printf("scan: cursor = %d", cursor)
|
||||
// keys, cursor, err = w.DB.Redis.Scan(w.DB.Ctx, cursor, "surfer:*", 10).Result()
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// log.Printf("ret scan: cursor = %d", cursor)
|
||||
|
||||
// log.Printf("scan: %+v", keys)
|
||||
|
||||
// surfersKeys = append(surfersKeys, keys...)
|
||||
|
||||
// if cursor == 0 {
|
||||
// log.Printf("end scan: cursor = %d", cursor)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
|
||||
// var surfers []Surfer
|
||||
|
||||
// for u := range surfersKeys {
|
||||
// surf := Surfer{}
|
||||
// ret := w.DB.Redis.HMGet(w.DB.Ctx, surfersKeys[u], "firstname", "lastname", "id", "sex", "birthdate", "stance", "hometown")
|
||||
|
||||
// ret.Scan(&surf)
|
||||
// surf.Dbid = strings.Split(surfersKeys[u], ":")[1]
|
||||
|
||||
// log.Printf("surfer: %+v", surf)
|
||||
// surfers = append(surfers, surf)
|
||||
// }
|
||||
|
||||
// slices.SortFunc(surfers,
|
||||
// func(a, b Surfer) int {
|
||||
// return cmp.Compare(a.Id, b.Id)
|
||||
// })
|
||||
|
||||
// log.Printf("surfers: %+v", surfers)
|
||||
|
||||
// c.JSON(http.StatusOK, surfers)
|
||||
// }
|
||||
|
||||
// func (w *Webapp) DeleteSurfer(c *gin.Context) {
|
||||
// var surfer Surfer
|
||||
// var err error
|
||||
|
||||
// err = c.ShouldBind(&surfer)
|
||||
// if err != nil {
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
// return
|
||||
// }
|
||||
|
||||
// id := CalcId(surfer.Firstname+surfer.Lastname, _MaxLen)
|
||||
|
||||
// log.Printf("deleting: %+v", "surfer:"+id)
|
||||
|
||||
// res, err := w.DB.Redis.HGetAll(w.DB.Ctx, "surfer:"+id).Result()
|
||||
// if err != nil || len(res) == 0 {
|
||||
// log.Printf("del error: %+v", err)
|
||||
// c.JSON(http.StatusNotFound, gin.H{"status": "Not Found"})
|
||||
// return
|
||||
// }
|
||||
|
||||
// log.Printf("found: %+v", res)
|
||||
|
||||
// err = w.DB.Redis.Del(w.DB.Ctx, "surfer:"+id).Err()
|
||||
// if err != nil {
|
||||
// log.Printf("del error: %+v", err)
|
||||
// }
|
||||
|
||||
// log.Printf("del: %+v", surfer)
|
||||
|
||||
// c.JSON(http.StatusOK, gin.H{"status": "deleted"})
|
||||
// }
|
||||
|
||||
// func (w *Webapp) UpdateSurfer(c *gin.Context) {
|
||||
// var surfer Surfer
|
||||
// var err error
|
||||
|
||||
// err = c.ShouldBind(&surfer)
|
||||
// if err != nil {
|
||||
// log.Printf("req error: %+v", err)
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
// return
|
||||
// }
|
||||
|
||||
// surfer.Dbid = CalcId(surfer.Firstname+surfer.Lastname, _MaxLen)
|
||||
|
||||
// err = w.DB.Redis.HSet(w.DB.Ctx, "surfer:"+surfer.Dbid, surfer).Err()
|
||||
// if err != nil {
|
||||
// log.Printf("set error: %+v", err)
|
||||
// }
|
||||
|
||||
// log.Printf("new: %+v", surfer)
|
||||
|
||||
// c.JSON(http.StatusOK, gin.H{"status": "added"})
|
||||
// }
|
135
backend/users.go
Normal file
135
backend/users.go
Normal file
|
@ -0,0 +1,135 @@
|
|||
package main
|
||||
|
||||
type User struct {
|
||||
Dbid string `json:"dbid"`
|
||||
Id string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Email string `json:"email"`
|
||||
Group string `json:"group"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
///////////////// Users
|
||||
|
||||
// func (w *Webapp) GetUsers(c *gin.Context) {
|
||||
// var cursor uint64
|
||||
|
||||
// var users []string
|
||||
|
||||
// cursor = 0
|
||||
// log.Printf("start scanning %+v", c.ClientIP())
|
||||
// for {
|
||||
// var keys []string
|
||||
// var err error
|
||||
// keys, cursor, err = w.DB.Redis.Scan(w.DB.Ctx, cursor, "user:*", 10).Result()
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
|
||||
// log.Printf("scan: %+v", keys)
|
||||
|
||||
// users = append(users, keys...)
|
||||
|
||||
// if cursor == 0 {
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
|
||||
// var retval []User
|
||||
|
||||
// for u := range users {
|
||||
// usr := User{}
|
||||
// hmget := w.DB.Redis.HMGet(w.DB.Ctx, users[u], "username", "email", "group", "enabled")
|
||||
// hmget.Scan(&usr)
|
||||
|
||||
// log.Printf("user: %+v", usr)
|
||||
// retval = append(retval, usr)
|
||||
// }
|
||||
|
||||
// slices.SortFunc(retval,
|
||||
// func(a, b User) int {
|
||||
// return cmp.Compare(a.Username, b.Username)
|
||||
// })
|
||||
|
||||
// c.JSON(http.StatusOK, retval)
|
||||
// }
|
||||
|
||||
// func (w *Webapp) UpdateUser(c *gin.Context) {
|
||||
// var user User
|
||||
|
||||
// if err := c.ShouldBind(&user); err != nil {
|
||||
// log.Printf("req error: %+v", err)
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
// return
|
||||
// }
|
||||
|
||||
// user.Dbid = CalcId(user.Username, 8)
|
||||
|
||||
// ret := w.DB.Redis.HExists(w.DB.Ctx, "user:"+user.Dbid, "username").Val()
|
||||
// if !ret {
|
||||
// log.Printf("Exists: %+v", ret)
|
||||
// err := w.DB.Redis.HSet(w.DB.Ctx, "user:"+user.Dbid, user).Err()
|
||||
// if err != nil {
|
||||
// log.Printf("set error: %+v", err)
|
||||
// }
|
||||
// } else {
|
||||
// err := w.DB.Redis.HSet(w.DB.Ctx, "user:"+user.Dbid, "email", user.Email, "group", user.Group, "enabled", user.Enabled).Err()
|
||||
// if err != nil {
|
||||
// log.Printf("set error: %+v", err)
|
||||
// }
|
||||
// }
|
||||
|
||||
// log.Printf("new: %+v", user)
|
||||
|
||||
// c.JSON(http.StatusOK, gin.H{"status": "added"})
|
||||
// }
|
||||
|
||||
// // func UpdateUser(c *gin.Context) {
|
||||
// // var user common.User
|
||||
|
||||
// // if err := c.ShouldBind(&user); err != nil {
|
||||
// // c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
// // return
|
||||
// // }
|
||||
|
||||
// // id := common.Id(user.Username, 8)
|
||||
|
||||
// // if err := db.Db.Redis.HSet(db.Db.Ctx, "user:"+id, "email", user.Email, "group", user.Group, "enabled", user.Enabled).Err(); err != nil {
|
||||
// // log.Fatalf("set error: %+v", err)
|
||||
// // }
|
||||
|
||||
// // log.Printf("update: %+v", user)
|
||||
|
||||
// // c.JSON(http.StatusOK, gin.H{"status": "updated"})
|
||||
// // }
|
||||
|
||||
// func (w *Webapp) DeleteUser(c *gin.Context) {
|
||||
// var user User
|
||||
|
||||
// if err := c.ShouldBind(&user); err != nil {
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
// return
|
||||
// }
|
||||
|
||||
// id := CalcId(user.Username, 8)
|
||||
|
||||
// log.Printf("deleting: %+v", "user:"+id)
|
||||
|
||||
// res, err := w.DB.Redis.HGetAll(w.DB.Ctx, "user:"+id).Result()
|
||||
// if err != nil || len(res) == 0 {
|
||||
// log.Printf("del error: %+v", err)
|
||||
// c.JSON(http.StatusNotFound, gin.H{"status": "Not Found"})
|
||||
// return
|
||||
// }
|
||||
|
||||
// log.Printf("found: %+v", res)
|
||||
|
||||
// if err := w.DB.Redis.Del(w.DB.Ctx, "user:"+id).Err(); err != nil {
|
||||
// log.Printf("del error: %+v", err)
|
||||
// }
|
||||
|
||||
// log.Printf("del: %+v", user)
|
||||
|
||||
// c.JSON(http.StatusOK, gin.H{"status": "deleted"})
|
||||
// }
|
56
backend/webapp.go
Normal file
56
backend/webapp.go
Normal file
|
@ -0,0 +1,56 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
scribble "github.com/nanobox-io/golang-scribble"
|
||||
)
|
||||
|
||||
type Webapp struct {
|
||||
Engine *gin.Engine
|
||||
Stream *PriorityStream
|
||||
DB *scribble.Driver
|
||||
}
|
||||
|
||||
const _MaxLen = 8
|
||||
|
||||
func InitHttp(d *scribble.Driver) *Webapp {
|
||||
|
||||
router := gin.Default()
|
||||
router.Use(cors.Default())
|
||||
|
||||
wapp := &Webapp{
|
||||
Engine: router,
|
||||
DB: d,
|
||||
}
|
||||
|
||||
wapp.initApi()
|
||||
// wapp.initAuth()
|
||||
|
||||
display := router.Group("/display")
|
||||
display.Static("/", "./static/display")
|
||||
|
||||
video := router.Group("/videowall")
|
||||
video.Static("/", "./static/videowall")
|
||||
|
||||
priority := router.Group("/priority")
|
||||
priority.Static("/", "./static/priority")
|
||||
|
||||
sapp := router.Group("/_app")
|
||||
sapp.Static("/", "./static/_app")
|
||||
|
||||
static := router.Group("/static")
|
||||
static.Static("/", "./static/static")
|
||||
|
||||
router.StaticFile("/", "./static/index.html")
|
||||
router.StaticFile("/favicon.png", "./static/favicon.png")
|
||||
|
||||
router.ForwardedByClientIP = true
|
||||
router.SetTrustedProxies([]string{"127.0.0.1"})
|
||||
|
||||
log.Printf("WebApp: %+v", wapp)
|
||||
|
||||
return wapp
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue