Add more gitignore
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
|||||||
|
./assets/index.js
|
||||||
|
./assets/styles.js
|
||||||
|
|
||||||
local.db
|
local.db
|
||||||
# Created by https://www.toptal.com/developers/gitignore/api/go
|
# Created by https://www.toptal.com/developers/gitignore/api/go
|
||||||
# Edit at https://www.toptal.com/developers/gitignore?templates=go
|
# Edit at https://www.toptal.com/developers/gitignore?templates=go
|
||||||
|
|||||||
3093
assets/index.js
3093
assets/index.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
BIN
cod4watcher
Executable file
BIN
cod4watcher
Executable file
Binary file not shown.
1
go.mod
1
go.mod
@ -5,6 +5,7 @@ go 1.22.2
|
|||||||
require github.com/a-h/templ v0.2.707
|
require github.com/a-h/templ v0.2.707
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||||
|
|||||||
2
go.sum
2
go.sum
@ -1,5 +1,7 @@
|
|||||||
github.com/a-h/templ v0.2.707 h1:T1Gkd2ugbRglZ9rYw/VBchWOSZVKmetDbBkm4YubM7U=
|
github.com/a-h/templ v0.2.707 h1:T1Gkd2ugbRglZ9rYw/VBchWOSZVKmetDbBkm4YubM7U=
|
||||||
github.com/a-h/templ v0.2.707/go.mod h1:5cqsugkq9IerRNucNsI4DEamdHPsoGMQy99DzydLhM8=
|
github.com/a-h/templ v0.2.707/go.mod h1:5cqsugkq9IerRNucNsI4DEamdHPsoGMQy99DzydLhM8=
|
||||||
|
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/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/go-chi/chi v1.5.5 h1:vOB/HbEMt9QqBqErz07QehcOKHaWFtuj87tTDVz2qXE=
|
github.com/go-chi/chi v1.5.5 h1:vOB/HbEMt9QqBqErz07QehcOKHaWFtuj87tTDVz2qXE=
|
||||||
|
|||||||
10
main.go
10
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gitea.henriburau.de/haw-lan/cod4watcher/models"
|
"gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||||
"gitea.henriburau.de/haw-lan/cod4watcher/routes"
|
"gitea.henriburau.de/haw-lan/cod4watcher/routes"
|
||||||
@ -29,9 +30,18 @@ func main() {
|
|||||||
cs := services.NewCaptureService(persistence)
|
cs := services.NewCaptureService(persistence)
|
||||||
server := routes.NewServer(cs)
|
server := routes.NewServer(cs)
|
||||||
|
|
||||||
|
doneChan := make(chan bool)
|
||||||
|
scanner, err := services.NewScanner(persistence, time.Second*10, doneChan)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
go scanner.Scan()
|
||||||
|
|
||||||
router.Handle("/*", public())
|
router.Handle("/*", public())
|
||||||
router.Get("/health", routes.Make(server.HandleHealth))
|
router.Get("/health", routes.Make(server.HandleHealth))
|
||||||
router.Get("/captures/{captureID}", routes.Make(server.HandleCapture))
|
router.Get("/captures/{captureID}", routes.Make(server.HandleCapture))
|
||||||
|
router.Delete("/captures/{captureID}", routes.Make(server.HandleCaptureDelete))
|
||||||
router.Get("/new/capture", routes.Make(server.HandleCaptureForm))
|
router.Get("/new/capture", routes.Make(server.HandleCaptureForm))
|
||||||
router.Post("/new/capture", routes.Make(server.HandleCaptureCreate))
|
router.Post("/new/capture", routes.Make(server.HandleCaptureCreate))
|
||||||
router.Get("/", routes.Make(server.HandleHome))
|
router.Get("/", routes.Make(server.HandleHome))
|
||||||
|
|||||||
@ -11,27 +11,26 @@ import (
|
|||||||
type MapScoreList []MapScore
|
type MapScoreList []MapScore
|
||||||
|
|
||||||
type Capture struct {
|
type Capture struct {
|
||||||
ID int64 `bun:",pk,autoincrement"`
|
ID int64 `bun:",pk,autoincrement"`
|
||||||
Host string
|
Host string `bun:",notnull"`
|
||||||
Port string
|
Port string `bun:",notnull"`
|
||||||
Name string
|
Name string `bun:",unique,notnull"`
|
||||||
Active bool
|
Active bool `bun:",notnull"`
|
||||||
Start time.Time
|
Start time.Time `bun:",notnull,default:current_timestamp"`
|
||||||
MapScores MapScoreList `bun:"rel:has-many,join:id=capture_id"`
|
MapScores MapScoreList `bun:"rel:has-many,join:id=capture_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MapScore struct {
|
type MapScore struct {
|
||||||
ID int64 `bun:",pk,autoincrement"`
|
ID int64 `bun:",pk,autoincrement"`
|
||||||
CaptureID int64 `bun:"capture_id"`
|
CaptureID int64 `bun:"capture_id"`
|
||||||
StartTime time.Time
|
StartTime time.Time `bun:",notnull"`
|
||||||
Map string
|
Map string `bun:",notnull"`
|
||||||
ScoreList []Score `bun:"rel:has-many,join:id=mapscore_id"`
|
ScoreList []Score `bun:"rel:has-many,join:id=mapscore_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Score struct {
|
type Score struct {
|
||||||
ID int64 `bun:",pk,autoincrement"`
|
Name string `bun:",pk,notnull"`
|
||||||
MapScoreID int64 `bun:"mapscore_id"`
|
MapScoreID int64 `bun:"mapscore_id,pk,notnull"`
|
||||||
Name string
|
|
||||||
Score int
|
Score int
|
||||||
Ping int
|
Ping int
|
||||||
}
|
}
|
||||||
@ -57,7 +56,7 @@ func (msl MapScoreList) BuildTable() *ResultTable {
|
|||||||
Header: []ResultTableHeader{{Title: "Name"}, {Title: "Total"}},
|
Header: []ResultTableHeader{{Title: "Name"}, {Title: "Total"}},
|
||||||
}
|
}
|
||||||
|
|
||||||
userMapRows := make(map[string]*ResultTableRow)
|
userMapRows := make(map[string]int)
|
||||||
|
|
||||||
for mapIndex, mapScore := range msl {
|
for mapIndex, mapScore := range msl {
|
||||||
rt.Header = append(rt.Header, ResultTableHeader{
|
rt.Header = append(rt.Header, ResultTableHeader{
|
||||||
@ -73,12 +72,12 @@ func (msl MapScoreList) BuildTable() *ResultTable {
|
|||||||
Individual: make([]int, len(msl)),
|
Individual: make([]int, len(msl)),
|
||||||
})
|
})
|
||||||
|
|
||||||
userMapRows[score.Name] = &rt.Rows[len(rt.Rows)-1]
|
userMapRows[score.Name] = len(rt.Rows) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
row := userMapRows[score.Name]
|
row := userMapRows[score.Name]
|
||||||
row.Total = row.Total + score.Score
|
rt.Rows[row].Total = rt.Rows[row].Total + score.Score
|
||||||
row.Individual[mapIndex] = score.Score
|
rt.Rows[row].Individual[mapIndex] = score.Score
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,13 @@ import (
|
|||||||
type Persistence interface {
|
type Persistence interface {
|
||||||
CreateCapture(context.Context, *Capture) error
|
CreateCapture(context.Context, *Capture) error
|
||||||
GetCaptures(context.Context) ([]Capture, error)
|
GetCaptures(context.Context) ([]Capture, error)
|
||||||
|
GetCapturesByID(context.Context, int64) (*Capture, error)
|
||||||
|
DeleteCapture(context.Context, int64) error
|
||||||
|
|
||||||
|
GetRecentMapScore(context.Context, int64) (*MapScore, error)
|
||||||
|
CreateMapScore(context.Context, *MapScore) error
|
||||||
|
|
||||||
|
CreateOrUpdateScores(context.Context, []Score) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type SQLitePersistence struct {
|
type SQLitePersistence struct {
|
||||||
@ -51,8 +58,53 @@ func (s *SQLitePersistence) GetCaptures(ctx context.Context) ([]Capture, error)
|
|||||||
return captures, nil
|
return captures, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SQLitePersistence) GetCapturesByID(ctx context.Context, id int64) (*Capture, error) {
|
||||||
|
capture := Capture{
|
||||||
|
ID: id,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := s.db.NewSelect().Model(&capture).WherePK().Relation("MapScores").Relation("MapScores.ScoreList").Scan(ctx)
|
||||||
|
|
||||||
|
return &capture, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SQLitePersistence) DeleteCapture(ctx context.Context, id int64) error {
|
||||||
|
capture := Capture{
|
||||||
|
ID: id,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := s.db.NewDelete().Model(&capture).WherePK().Exec(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SQLitePersistence) CreateCapture(ctx context.Context, capture *Capture) error {
|
func (s *SQLitePersistence) CreateCapture(ctx context.Context, capture *Capture) error {
|
||||||
_, err := s.db.NewInsert().Model(capture).Exec(ctx)
|
_, err := s.db.NewInsert().Model(capture).Exec(ctx)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SQLitePersistence) GetRecentMapScore(ctx context.Context, captureid int64) (*MapScore, error) {
|
||||||
|
var scores []MapScore
|
||||||
|
|
||||||
|
err := s.db.NewSelect().Model(&scores).Where("capture_id = ?", captureid).Limit(1).Order("start_time DESC").Scan(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(scores) <= 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &scores[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SQLitePersistence) CreateMapScore(ctx context.Context, mapscore *MapScore) error {
|
||||||
|
_, err := s.db.NewInsert().Model(mapscore).Exec(ctx)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SQLitePersistence) CreateOrUpdateScores(ctx context.Context, scores []Score) error {
|
||||||
|
_, err := s.db.NewInsert().Model(&scores).On("CONFLICT (name, mapscore_id) DO UPDATE").Exec(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package routes
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gitea.henriburau.de/haw-lan/cod4watcher/models"
|
"gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||||
"gitea.henriburau.de/haw-lan/cod4watcher/views/capture"
|
"gitea.henriburau.de/haw-lan/cod4watcher/views/capture"
|
||||||
@ -11,12 +12,12 @@ import (
|
|||||||
|
|
||||||
func (s *Server) HandleCapture(w http.ResponseWriter, r *http.Request) error {
|
func (s *Server) HandleCapture(w http.ResponseWriter, r *http.Request) error {
|
||||||
captureString := chi.URLParam(r, "captureID")
|
captureString := chi.URLParam(r, "captureID")
|
||||||
captureID, err := strconv.Atoi(captureString)
|
captureID, err := strconv.ParseInt(captureString, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
foundCapture, err := s.cs.GetCaptureById(captureID)
|
foundCapture, err := s.cs.GetCaptureById(r.Context(), captureID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -24,6 +25,21 @@ func (s *Server) HandleCapture(w http.ResponseWriter, r *http.Request) error {
|
|||||||
return Render(w, r, capture.Capture(foundCapture))
|
return Render(w, r, capture.Capture(foundCapture))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) HandleCaptureDelete(w http.ResponseWriter, r *http.Request) error {
|
||||||
|
captureString := chi.URLParam(r, "captureID")
|
||||||
|
captureID, err := strconv.ParseInt(captureString, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.cs.DeleteCapture(r.Context(), captureID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return hxRedirect(w, r, "/")
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) HandleCaptureForm(w http.ResponseWriter, r *http.Request) error {
|
func (s *Server) HandleCaptureForm(w http.ResponseWriter, r *http.Request) error {
|
||||||
return Render(w, r, capture.CaptureForm(capture.CaptureFormValues{}, map[string]string{}))
|
return Render(w, r, capture.CaptureForm(capture.CaptureFormValues{}, map[string]string{}))
|
||||||
}
|
}
|
||||||
@ -34,14 +50,23 @@ func (s *Server) HandleCaptureCreate(w http.ResponseWriter, r *http.Request) err
|
|||||||
return Render(w, r, capture.CaptureForm(formValues, errors))
|
return Render(w, r, capture.CaptureForm(formValues, errors))
|
||||||
}
|
}
|
||||||
|
|
||||||
capture := &models.Capture{
|
newCapture := &models.Capture{
|
||||||
Host: formValues.Host,
|
Host: formValues.Host,
|
||||||
Port: formValues.Port,
|
Port: formValues.Port,
|
||||||
Name: formValues.Name,
|
Name: formValues.Name,
|
||||||
Active: true,
|
Active: true,
|
||||||
|
Start: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
err := s.cs.CreateCapture(r.Context(), capture)
|
_, err := s.cs.GetServerStatus(r.Context(), newCapture)
|
||||||
|
if err != nil {
|
||||||
|
errors["host"] = err.Error()
|
||||||
|
errors["port"] = err.Error()
|
||||||
|
|
||||||
|
return Render(w, r, capture.CaptureForm(formValues, errors))
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.cs.CreateCapture(r.Context(), newCapture)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,11 +11,6 @@ type CaptureService struct {
|
|||||||
p models.Persistence
|
p models.Persistence
|
||||||
}
|
}
|
||||||
|
|
||||||
var mockCaptures = []models.Capture{
|
|
||||||
{ID: 1, Host: "80.57.28.137", Port: "28960", Active: true, Name: "Gungame HAW-LAN 11", Start: time.Now().Add(-1 * time.Hour)},
|
|
||||||
{ID: 1, Host: "80.57.28.137", Port: "28960", Active: true, Name: "Gungame HAW-LAN 12", Start: time.Now().Add(-5 * time.Minute)},
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCaptureService(persistence models.Persistence) *CaptureService {
|
func NewCaptureService(persistence models.Persistence) *CaptureService {
|
||||||
return &CaptureService{
|
return &CaptureService{
|
||||||
p: persistence,
|
p: persistence,
|
||||||
@ -26,6 +21,10 @@ func (cs *CaptureService) CreateCapture(ctx context.Context, capture *models.Cap
|
|||||||
return cs.p.CreateCapture(ctx, capture)
|
return cs.p.CreateCapture(ctx, capture)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cs *CaptureService) DeleteCapture(ctx context.Context, id int64) error {
|
||||||
|
return cs.p.DeleteCapture(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
func (cs *CaptureService) GetActiveCapures(ctx context.Context) ([]models.Capture, error) {
|
func (cs *CaptureService) GetActiveCapures(ctx context.Context) ([]models.Capture, error) {
|
||||||
captures, err := cs.p.GetCaptures(ctx)
|
captures, err := cs.p.GetCaptures(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -42,26 +41,20 @@ func (cs *CaptureService) GetActiveCapures(ctx context.Context) ([]models.Captur
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *CaptureService) GetCaptureById(id int) (*models.Capture, error) {
|
func (cs *CaptureService) GetServerStatus(ctx context.Context, capture *models.Capture) (*models.CoD4ServerStatus, error) {
|
||||||
capture := mockCaptures[0]
|
|
||||||
server, err := models.NewCOD4ServerStatus(capture.Host, capture.Port, time.Second)
|
server, err := models.NewCOD4ServerStatus(capture.Host, capture.Port, time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
status, err := server.GetServerStatus()
|
return server.GetServerStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cs *CaptureService) GetCaptureById(ctx context.Context, id int64) (*models.Capture, error) {
|
||||||
|
capture, err := cs.p.GetCapturesByID(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
capture.MapScores = []models.MapScore{
|
return capture, nil
|
||||||
{
|
|
||||||
ID: 0,
|
|
||||||
StartTime: status.MapStartTime,
|
|
||||||
Map: status.MapName,
|
|
||||||
ScoreList: status.Score,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return &capture, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
97
services/scanner.go
Normal file
97
services/scanner.go
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"log/slog"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Scanner struct {
|
||||||
|
p models.Persistence
|
||||||
|
done chan bool
|
||||||
|
interval time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewScanner(p models.Persistence, interval time.Duration, done chan bool) (*Scanner, error) {
|
||||||
|
return &Scanner{
|
||||||
|
p, done, interval,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Scanner) Scan() {
|
||||||
|
ticker := time.NewTicker(s.interval)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-s.done:
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
ctx := context.Background()
|
||||||
|
slog.Info("starting update")
|
||||||
|
|
||||||
|
captures, err := s.p.GetCaptures(ctx)
|
||||||
|
if err != nil {
|
||||||
|
slog.Error("cannot get captures", "err", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, capture := range captures {
|
||||||
|
if capture.Active {
|
||||||
|
err := s.fetchInformation(ctx, capture)
|
||||||
|
if err != nil {
|
||||||
|
slog.Error("failed to update captures", "err", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Scanner) fetchInformation(ctx context.Context, capture models.Capture) error {
|
||||||
|
server, err := models.NewCOD4ServerStatus(capture.Host, capture.Port, time.Second)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
status, err := server.GetServerStatus()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
slog.Info("fetched data", "host", capture.Host, "map", status.MapName)
|
||||||
|
|
||||||
|
recentMap, err := s.p.GetRecentMapScore(ctx, capture.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if recentMap == nil || recentMap.StartTime.Before(status.MapStartTime) {
|
||||||
|
newMap := models.MapScore{
|
||||||
|
CaptureID: capture.ID,
|
||||||
|
StartTime: status.MapStartTime,
|
||||||
|
Map: status.MapName,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := s.p.CreateMapScore(ctx, &newMap)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
recentMap, err = s.p.GetRecentMapScore(ctx, capture.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var scores []models.Score
|
||||||
|
for _, score := range status.Score {
|
||||||
|
score.MapScoreID = recentMap.ID
|
||||||
|
scores = append(scores, score)
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.p.CreateOrUpdateScores(ctx, scores)
|
||||||
|
}
|
||||||
BIN
tmp/bin/main
Executable file
BIN
tmp/bin/main
Executable file
Binary file not shown.
@ -38,7 +38,7 @@ func CaptureForm(formValues CaptureFormValues, errors map[string]string) templ.C
|
|||||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"w-full mx-auto max-w-96 p-4 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700\"><form class=\"space-y-6\" action=\"/new/capture\" method=\"post\"><h5 class=\"text-xl font-medium text-gray-900 dark:text-white\">Create new capture</h5><div><label for=\"name\" class=\"block mb-2 text-sm font-medium text-gray-900 dark:text-white\">Name</label>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ func CaptureForm(formValues CaptureFormValues, errors map[string]string) templ.C
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div><label for=\"host\" class=\"block mb-2 text-sm font-medium text-gray-900 dark:text-white\">Host</label>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ func CaptureForm(formValues CaptureFormValues, errors map[string]string) templ.C
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div><label for=\"port\" class=\"block mb-2 text-sm font-medium text-gray-900 dark:text-white\">Port</label>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ func CaptureForm(formValues CaptureFormValues, errors map[string]string) templ.C
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><button type=\"submit\" method=\"post\" class=\"w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800\">Create capture</button></form></div>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
4
views/capture/capture_form_templ.txt
Normal file
4
views/capture/capture_form_templ.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<div class=\"w-full mx-auto max-w-96 p-4 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700\"><form class=\"space-y-6\" action=\"/new/capture\" method=\"post\"><h5 class=\"text-xl font-medium text-gray-900 dark:text-white\">Create new capture</h5><div><label for=\"name\" class=\"block mb-2 text-sm font-medium text-gray-900 dark:text-white\">Name</label>
|
||||||
|
</div><div><label for=\"host\" class=\"block mb-2 text-sm font-medium text-gray-900 dark:text-white\">Host</label>
|
||||||
|
</div><div><label for=\"port\" class=\"block mb-2 text-sm font-medium text-gray-900 dark:text-white\">Port</label>
|
||||||
|
</div><button type=\"submit\" method=\"post\" class=\"w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800\">Create capture</button></form></div>
|
||||||
@ -33,7 +33,7 @@ func Capture(capture *models.Capture) templ.Component {
|
|||||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex flex-col\"><div class=\"block font-bold text-lg\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ func Capture(capture *models.Capture) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"block\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ func Capture(capture *models.Capture) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(":")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ func Capture(capture *models.Capture) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ func Capture(capture *models.Capture) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
5
views/capture/capture_templ.txt
Normal file
5
views/capture/capture_templ.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<div class=\"flex flex-col\"><div class=\"block font-bold text-lg\">
|
||||||
|
</div><div class=\"block\">
|
||||||
|
:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -5,9 +5,11 @@ import "github.com/mergestat/timediff"
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
templ CaptureCard(capture models.Capture) {
|
templ CaptureCard(capture models.Capture) {
|
||||||
<a href={ templ.URL(fmt.Sprintf("/captures/%d", capture.ID)) } class="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">
|
<div class="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">
|
||||||
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">{ capture.Name }</h5>
|
<a href={ templ.URL(fmt.Sprintf("/captures/%d", capture.ID)) } >
|
||||||
|
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">{ capture.Name }</h5>
|
||||||
|
</a>
|
||||||
<p class="font-normal text-gray-700 dark:text-gray-400">{ timediff.TimeDiff(capture.Start) }</p>
|
<p class="font-normal text-gray-700 dark:text-gray-400">{ timediff.TimeDiff(capture.Start) }</p>
|
||||||
<button type="button" class="py-1 px-2 bg-red-500 text-white rounded-xl">Delete</button>
|
<button type="button" hx-delete={ fmt.Sprintf("/captures/%d", capture.ID) } class="mt-10 py-1 px-2 bg-red-500 text-white rounded-xl">Delete</button>
|
||||||
</a>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ func CaptureCard(capture models.Capture) templ.Component {
|
|||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
templ_7745c5c3_Var1 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<a href=\"")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -36,33 +36,46 @@ func CaptureCard(capture models.Capture) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700\"><h5 class=\"mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var3 string
|
var templ_7745c5c3_Var3 string
|
||||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(capture.Name)
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(capture.Name)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/components/capture_card.templ`, Line: 9, Col: 97}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/components/capture_card.templ`, Line: 10, Col: 98}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h5><p class=\"font-normal text-gray-700 dark:text-gray-400\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var4 string
|
var templ_7745c5c3_Var4 string
|
||||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(timediff.TimeDiff(capture.Start))
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(timediff.TimeDiff(capture.Start))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/components/capture_card.templ`, Line: 10, Col: 92}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/components/capture_card.templ`, Line: 12, Col: 92}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><button type=\"button\" class=\"py-1 px-2 bg-red-500 text-white rounded-xl\">Delete</button></a>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var5 string
|
||||||
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("/captures/%d", capture.ID))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/components/capture_card.templ`, Line: 13, Col: 75}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
5
views/components/capture_card_templ.txt
Normal file
5
views/components/capture_card_templ.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<div class=\"block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700\"><a href=\"
|
||||||
|
\"><h5 class=\"mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white\">
|
||||||
|
</h5></a><p class=\"font-normal text-gray-700 dark:text-gray-400\">
|
||||||
|
</p><button type=\"button\" hx-delete=\"
|
||||||
|
\" class=\"mt-10 py-1 px-2 bg-red-500 text-white rounded-xl\">Delete</button></div>
|
||||||
@ -26,12 +26,12 @@ func CaptureTable(table models.ResultTable) templ.Component {
|
|||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
templ_7745c5c3_Var1 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"relative overflow-x-auto\"><table class=\"w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400\"><thead class=\"text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400\"><tr>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
for _, header := range table.Header {
|
for _, header := range table.Header {
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<th scope=\"col\" class=\"px-6 py-3\"><div>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ func CaptureTable(table models.ResultTable) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"lowercase font-light\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -57,17 +57,17 @@ func CaptureTable(table models.ResultTable) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></th>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</tr></thead> <tbody>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
for _, row := range table.Rows {
|
for _, row := range table.Rows {
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<tr class=\"bg-white border-b dark:bg-gray-800 dark:border-gray-700\"><th scope=\"row\" class=\"px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ func CaptureTable(table models.ResultTable) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</th><td class=\"px-6 py-4\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -93,12 +93,12 @@ func CaptureTable(table models.ResultTable) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 8)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
for _, score := range row.Individual {
|
for _, score := range row.Individual {
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<td class=\"px-6 py-4\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -111,17 +111,17 @@ func CaptureTable(table models.ResultTable) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</td>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</tr>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</tbody></table></div>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
12
views/components/capture_table_templ.txt
Normal file
12
views/components/capture_table_templ.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<div class=\"relative overflow-x-auto\"><table class=\"w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400\"><thead class=\"text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400\"><tr>
|
||||||
|
<th scope=\"col\" class=\"px-6 py-3\"><div>
|
||||||
|
</div><div class=\"lowercase font-light\">
|
||||||
|
</div></th>
|
||||||
|
</tr></thead> <tbody>
|
||||||
|
<tr class=\"bg-white border-b dark:bg-gray-800 dark:border-gray-700\"><th scope=\"row\" class=\"px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white\">
|
||||||
|
</th><td class=\"px-6 py-4\">
|
||||||
|
</td>
|
||||||
|
<td class=\"px-6 py-4\">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody></table></div>
|
||||||
@ -30,7 +30,7 @@ func Input(props InputProps) templ.Component {
|
|||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
templ_7745c5c3_Var1 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<input type=\"text\" name=\"")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ func Input(props InputProps) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" id=\"")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ func Input(props InputProps) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" value=\"")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ func Input(props InputProps) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white\" placeholder=\"")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -82,12 +82,12 @@ func Input(props InputProps) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" required> ")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
if props.Error != "" {
|
if props.Error != "" {
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<span class=\"text-red-500\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ func Input(props InputProps) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
7
views/components/input_templ.txt
Normal file
7
views/components/input_templ.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<input type=\"text\" name=\"
|
||||||
|
\" id=\"
|
||||||
|
\" value=\"
|
||||||
|
\" class=\"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white\" placeholder=\"
|
||||||
|
\" required>
|
||||||
|
<span class=\"text-red-500\">
|
||||||
|
</span>
|
||||||
@ -23,7 +23,7 @@ func Nagivation() templ.Component {
|
|||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
templ_7745c5c3_Var1 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<nav class=\"bg-gray-800\"><div class=\"mx-auto max-w-7xl\"><div class=\"relative flex h-16 items-center justify-between\"><div class=\"flex flex-1 items-center justify-center sm:items-stretch sm:justify-start\"><div class=\"flex flex-shrink-0 items-center\"><span class=\"text-white pr-2 font-bold\">Turnier-Tracker</span> <img class=\"h-8 w-auto\" src=\"/assets/logo.svg\" alt=\"Your Company\"></div><div class=\"hidden sm:ml-6 sm:block\"><div class=\"flex space-x-4\"><!-- Current: \"bg-gray-900 text-white\", Default: \"text-gray-300 hover:bg-gray-700 hover:text-white\" --><a href=\"/\" class=\"bg-gray-900 text-white rounded-md px-3 py-2 text-sm font-medium\" aria-current=\"page\">Dashboard</a> <a href=\"/about\" class=\"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium\">About</a></div></div></div><div class=\"absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0\"></div></div></div></nav>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
1
views/components/navbar_templ.txt
Normal file
1
views/components/navbar_templ.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
<nav class=\"bg-gray-800\"><div class=\"mx-auto max-w-7xl\"><div class=\"relative flex h-16 items-center justify-between\"><div class=\"flex flex-1 items-center justify-center sm:items-stretch sm:justify-start\"><div class=\"flex flex-shrink-0 items-center\"><span class=\"text-white pr-2 font-bold\">Turnier-Tracker</span> <img class=\"h-8 w-auto\" src=\"/assets/logo.svg\" alt=\"Your Company\"></div><div class=\"hidden sm:ml-6 sm:block\"><div class=\"flex space-x-4\"><!-- Current: \"bg-gray-900 text-white\", Default: \"text-gray-300 hover:bg-gray-700 hover:text-white\" --><a href=\"/\" class=\"bg-gray-900 text-white rounded-md px-3 py-2 text-sm font-medium\" aria-current=\"page\">Dashboard</a> <a href=\"/about\" class=\"text-gray-300 hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium\">About</a></div></div></div><div class=\"absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0\"></div></div></div></nav>
|
||||||
@ -25,7 +25,7 @@ func Base() templ.Component {
|
|||||||
templ_7745c5c3_Var1 = templ.NopComponent
|
templ_7745c5c3_Var1 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html lang=\"en\"><head><title>CoD 4 Turnier-Tracker</title><link rel=\"icon\" type=\"image/x-icon\" href=\"/assets/favicon.ico\"><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><link rel=\"stylesheet\" href=\"/assets/styles.css\"><script src=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/js/all.min.js\"></script></head><body class=\"antialiased\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ func Base() templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"mx-auto max-w-7xl mt-10 flex gap-3 flex-wrap\">")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ func Base() templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><script src=\"/assets/index.js\"></script></body></html>")
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
3
views/layouts/base_templ.txt
Normal file
3
views/layouts/base_templ.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<!doctype html><html lang=\"en\"><head><title>CoD 4 Turnier-Tracker</title><link rel=\"icon\" type=\"image/x-icon\" href=\"/assets/favicon.ico\"><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><link rel=\"stylesheet\" href=\"/assets/styles.css\"><script src=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/js/all.min.js\"></script></head><body class=\"antialiased\">
|
||||||
|
<div class=\"mx-auto max-w-7xl mt-10 flex gap-3 flex-wrap\">
|
||||||
|
</div><script src=\"/assets/index.js\"></script></body></html>
|
||||||
Reference in New Issue
Block a user