Update all the shit
This commit is contained in:
@ -2,6 +2,7 @@ package capture
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views/layouts"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views/components"
|
||||
import "fmt"
|
||||
import "net/url"
|
||||
@ -23,21 +24,14 @@ templ Capture(capture *models.Capture, table models.ResultTable) {
|
||||
Loading Server status...
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex w-full justify-around items-center gap-5">
|
||||
if len(table.Rows) >= 1 {
|
||||
@Medal("1. Platz", table.Rows[0].Name, "text-yellow-400")
|
||||
}
|
||||
if len(table.Rows) >= 2 {
|
||||
@Medal("2. Platz", table.Rows[1].Name, "text-gray-500")
|
||||
}
|
||||
if len(table.Rows) >= 3 {
|
||||
@Medal("3. Platz", table.Rows[2].Name, "text-amber-700")
|
||||
}
|
||||
</div>
|
||||
@Pedestal(table)
|
||||
</div>
|
||||
<div hx-get={ fmt.Sprintf("/captures/%d/table", capture.ID) } hx-trigger="every 10s">
|
||||
@components.CaptureTable(table)
|
||||
@CaptureTable(table)
|
||||
</div>
|
||||
if views.Username(ctx) != "" {
|
||||
@MapSelectTable(capture)
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@ -50,3 +44,46 @@ templ Medal(placement, name, color string) {
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ Pedestal(table models.ResultTable) {
|
||||
<div id="pedestal" hx-swap-oob="true" class="flex w-full justify-around items-center gap-5">
|
||||
if len(table.Rows) >= 1 {
|
||||
@Medal("1. Platz", table.Rows[0].Name, "text-yellow-400")
|
||||
}
|
||||
if len(table.Rows) >= 2 {
|
||||
@Medal("2. Platz", table.Rows[1].Name, "text-gray-500")
|
||||
}
|
||||
if len(table.Rows) >= 3 {
|
||||
@Medal("3. Platz", table.Rows[2].Name, "text-amber-700")
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
templ MapSelectTable(capture *models.Capture) {
|
||||
<div id="select-table" class="relative overflow-x-auto">
|
||||
<table class="w-full overflow-scroll 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">
|
||||
Map
|
||||
</th>
|
||||
for _, maps := range capture.MapScores {
|
||||
<th scope="col" class="px-6 py-3">
|
||||
{ maps.Map }
|
||||
</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="overflow-y-scroll">
|
||||
<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">Enabled</th>
|
||||
for _, maps := range capture.MapScores {
|
||||
<td class="px-6 py-4">
|
||||
<input type="checkbox" hx-target="#select-table" hx-swap="outerHTML" hx-post={ fmt.Sprintf("/captures/%d/mapscore/%d/counted/%t", capture.ID, maps.ID, !maps.Counted) } checked?={ maps.Counted }/>
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
32
views/capture/capture_card.templ
Normal file
32
views/capture/capture_card.templ
Normal file
@ -0,0 +1,32 @@
|
||||
package capture
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views/components"
|
||||
import "fmt"
|
||||
import "net/url"
|
||||
|
||||
templ CaptureCard(capture models.Capture) {
|
||||
<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={ 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">{ capture.Host }:{ capture.Port }</p>
|
||||
<div
|
||||
hx-get={ fmt.Sprintf("/server/status?host=%s&port=%s", url.QueryEscape(capture.Host), url.QueryEscape(capture.Port)) }
|
||||
hx-trigger="load, every 20s"
|
||||
>
|
||||
Loading Server status...
|
||||
</div>
|
||||
if views.Username(ctx) != "" {
|
||||
<div class="mt-4">
|
||||
@components.IconButtonRed("fa-solid fa-trash", fmt.Sprintf("/captures/%d", capture.ID))
|
||||
if capture.Active {
|
||||
@components.IconButton("fa-solid fa-stop", fmt.Sprintf("/captures/%d/stop", capture.ID))
|
||||
} else {
|
||||
@components.IconButton("fa-solid fa-play", fmt.Sprintf("/captures/%d/start", capture.ID))
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
131
views/capture/capture_card_templ.go
Normal file
131
views/capture/capture_card_templ.go
Normal file
@ -0,0 +1,131 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.707
|
||||
package capture
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import "context"
|
||||
import "io"
|
||||
import "bytes"
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views/components"
|
||||
import "fmt"
|
||||
import "net/url"
|
||||
|
||||
func CaptureCard(capture models.Capture) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 templ.SafeURL = templ.URL(fmt.Sprintf("/captures/%d", capture.ID))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var2)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(capture.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture_card.templ`, Line: 12, Col: 98}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(capture.Host)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture_card.templ`, Line: 14, Col: 72}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
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(capture.Port)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture_card.templ`, Line: 14, Col: 89}
|
||||
}
|
||||
_, 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 {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("/server/status?host=%s&port=%s", url.QueryEscape(capture.Host), url.QueryEscape(capture.Port)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture_card.templ`, Line: 16, Col: 119}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if views.Username(ctx) != "" {
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = components.IconButtonRed("fa-solid fa-trash", fmt.Sprintf("/captures/%d", capture.ID)).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if capture.Active {
|
||||
templ_7745c5c3_Err = components.IconButton("fa-solid fa-stop", fmt.Sprintf("/captures/%d/stop", capture.ID)).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = components.IconButton("fa-solid fa-play", fmt.Sprintf("/captures/%d/start", capture.ID)).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 8)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
9
views/capture/capture_card_templ.txt
Normal file
9
views/capture/capture_card_templ.txt
Normal file
@ -0,0 +1,9 @@
|
||||
<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><div hx-get=\"
|
||||
\" hx-trigger=\"load, every 20s\">Loading Server status...</div>
|
||||
<div class=\"mt-4\">
|
||||
</div>
|
||||
</div>
|
||||
@ -6,25 +6,26 @@ import (
|
||||
)
|
||||
|
||||
type CaptureFormValues struct {
|
||||
Host string
|
||||
Port string
|
||||
Name string
|
||||
Active bool
|
||||
Host string
|
||||
Port string
|
||||
Name string
|
||||
Active bool
|
||||
ValidateServer bool
|
||||
}
|
||||
|
||||
templ CaptureForm(formValues CaptureFormValues, errors map[string]string) {
|
||||
@layouts.Base() {
|
||||
@components.Form(components.FormProps{
|
||||
Title: "Create new capture",
|
||||
Action: "/new/capture",
|
||||
Method: "post",
|
||||
Title: "Create new capture",
|
||||
Action: "/new/capture",
|
||||
Method: "post",
|
||||
SubmitText: "Create capture",
|
||||
}) {
|
||||
<div>
|
||||
<label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Name</label>
|
||||
@components.Input(components.InputProps{
|
||||
Name: "name",
|
||||
Type: "text",
|
||||
Value: formValues.Name,
|
||||
Error: errors["name"],
|
||||
Placeholder: "Name for the capture",
|
||||
@ -34,6 +35,7 @@ templ CaptureForm(formValues CaptureFormValues, errors map[string]string) {
|
||||
<label for="host" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Host</label>
|
||||
@components.Input(components.InputProps{
|
||||
Name: "host",
|
||||
Type: "text",
|
||||
Value: formValues.Host,
|
||||
Error: errors["host"],
|
||||
Placeholder: "Host-Address of the capture",
|
||||
@ -43,6 +45,7 @@ templ CaptureForm(formValues CaptureFormValues, errors map[string]string) {
|
||||
<label for="port" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Port</label>
|
||||
@components.Input(components.InputProps{
|
||||
Name: "port",
|
||||
Type: "text",
|
||||
Value: formValues.Port,
|
||||
Error: errors["port"],
|
||||
Placeholder: "Port for the capture",
|
||||
|
||||
@ -48,12 +48,13 @@ func CaptureForm(formValues CaptureFormValues, errors map[string]string) templ.C
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<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 {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = components.Input(components.InputProps{
|
||||
Name: "name",
|
||||
Type: "text",
|
||||
Value: formValues.Name,
|
||||
Error: errors["name"],
|
||||
Placeholder: "Name for the capture",
|
||||
@ -61,12 +62,13 @@ func CaptureForm(formValues CaptureFormValues, errors map[string]string) templ.C
|
||||
if templ_7745c5c3_Err != nil {
|
||||
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 {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = components.Input(components.InputProps{
|
||||
Name: "host",
|
||||
Type: "text",
|
||||
Value: formValues.Host,
|
||||
Error: errors["host"],
|
||||
Placeholder: "Host-Address of the capture",
|
||||
@ -74,12 +76,13 @@ func CaptureForm(formValues CaptureFormValues, errors map[string]string) templ.C
|
||||
if templ_7745c5c3_Err != nil {
|
||||
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 {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = components.Input(components.InputProps{
|
||||
Name: "port",
|
||||
Type: "text",
|
||||
Value: formValues.Port,
|
||||
Error: errors["port"],
|
||||
Placeholder: "Port for the capture",
|
||||
@ -87,7 +90,7 @@ func CaptureForm(formValues CaptureFormValues, errors map[string]string) templ.C
|
||||
if templ_7745c5c3_Err != nil {
|
||||
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 {
|
||||
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><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>
|
||||
42
views/capture/capture_table.templ
Normal file
42
views/capture/capture_table.templ
Normal file
@ -0,0 +1,42 @@
|
||||
package capture
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||
import "strconv"
|
||||
|
||||
templ CaptureTable(table models.ResultTable) {
|
||||
<div class="relative overflow-x-auto" style="height: 50vh;">
|
||||
<table class="w-full overflow-scroll 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>
|
||||
for _, header := range table.Header {
|
||||
<th scope="col" class="px-6 py-3">
|
||||
<div>
|
||||
{ header.Title }
|
||||
</div>
|
||||
<div class="lowercase font-light">
|
||||
{ header.Subtitle }
|
||||
</div>
|
||||
</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="overflow-y-scroll">
|
||||
for _, row := range table.Rows {
|
||||
<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">
|
||||
{ row.Name }
|
||||
</th>
|
||||
<td class="px-6 py-4">
|
||||
{ strconv.Itoa(row.Total) }
|
||||
</td>
|
||||
for _, score := range row.Individual {
|
||||
<td class="px-6 py-4">
|
||||
{ strconv.Itoa(score) }
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
133
views/capture/capture_table_templ.go
Normal file
133
views/capture/capture_table_templ.go
Normal file
@ -0,0 +1,133 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.707
|
||||
package capture
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import "context"
|
||||
import "io"
|
||||
import "bytes"
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||
import "strconv"
|
||||
|
||||
func CaptureTable(table models.ResultTable) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, header := range table.Header {
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(header.Title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture_table.templ`, Line: 14, Col: 22}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(header.Subtitle)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture_table.templ`, Line: 17, Col: 25}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, row := range table.Rows {
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(row.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture_table.templ`, Line: 27, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(row.Total))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture_table.templ`, Line: 30, Col: 32}
|
||||
}
|
||||
_, 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, 8)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, score := range row.Individual {
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(strconv.Itoa(score))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture_table.templ`, Line: 34, Col: 29}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
12
views/capture/capture_table_templ.txt
Normal file
12
views/capture/capture_table_templ.txt
Normal file
@ -0,0 +1,12 @@
|
||||
<div class=\"relative overflow-x-auto\" style=\"height: 50vh;\"><table class=\"w-full overflow-scroll 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 class=\"overflow-y-scroll\">
|
||||
<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>
|
||||
8
views/capture/capture_table_update.templ
Normal file
8
views/capture/capture_table_update.templ
Normal file
@ -0,0 +1,8 @@
|
||||
package capture
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||
|
||||
templ TableWithLeaderboard(table models.ResultTable) {
|
||||
@Pedestal(table)
|
||||
@CaptureTable(table)
|
||||
}
|
||||
41
views/capture/capture_table_update_templ.go
Normal file
41
views/capture/capture_table_update_templ.go
Normal file
@ -0,0 +1,41 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.707
|
||||
package capture
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import "context"
|
||||
import "io"
|
||||
import "bytes"
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||
|
||||
func TableWithLeaderboard(table models.ResultTable) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = Pedestal(table).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = CaptureTable(table).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
@ -12,6 +12,7 @@ import "bytes"
|
||||
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/models"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views/layouts"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views"
|
||||
import "gitea.henriburau.de/haw-lan/cod4watcher/views/components"
|
||||
import "fmt"
|
||||
import "net/url"
|
||||
@ -35,20 +36,20 @@ func Capture(capture *models.Capture, table models.ResultTable) templ.Component
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex flex-col\"><div class=\"flex\"><div><div class=\"block font-bold text-lg\">")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(capture.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 15, Col: 20}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 16, Col: 20}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 2)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@ -56,63 +57,59 @@ func Capture(capture *models.Capture, table models.ResultTable) templ.Component
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"my-3 w-60\" hx-get=\"")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 3)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("/server/status?host=%s&port=%s", url.QueryEscape(capture.Host), url.QueryEscape(capture.Port)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 20, Col: 122}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 21, Col: 122}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"load, every 20s\">Loading Server status...</div></div><div class=\"flex w-full justify-around items-center gap-5\">")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 4)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(table.Rows) >= 1 {
|
||||
templ_7745c5c3_Err = Medal("1. Platz", table.Rows[0].Name, "text-yellow-400").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = Pedestal(table).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(table.Rows) >= 2 {
|
||||
templ_7745c5c3_Err = Medal("2. Platz", table.Rows[1].Name, "text-gray-500").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
if len(table.Rows) >= 3 {
|
||||
templ_7745c5c3_Err = Medal("3. Platz", table.Rows[2].Name, "text-amber-700").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div><div hx-get=\"")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 5)
|
||||
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/table", capture.ID))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 38, Col: 62}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 29, Col: 62}
|
||||
}
|
||||
_, 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_7745c5c3_Buffer.WriteString("\" hx-trigger=\"every 10s\">")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 6)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = components.CaptureTable(table).Render(ctx, templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = CaptureTable(table).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div>")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 7)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if views.Username(ctx) != "" {
|
||||
templ_7745c5c3_Err = MapSelectTable(capture).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 8)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@ -145,7 +142,7 @@ func Medal(placement, name, color string) templ.Component {
|
||||
templ_7745c5c3_Var6 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex flex-col gap-2\">")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@ -154,7 +151,7 @@ func Medal(placement, name, color string) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<i class=\"")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@ -167,33 +164,159 @@ func Medal(placement, name, color string) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></i> <span>")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(placement)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 49, Col: 14}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 43, Col: 14}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 49, Col: 23}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 43, Col: 23}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></div>")
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 13)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func Pedestal(table models.ResultTable) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var11 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var11 == nil {
|
||||
templ_7745c5c3_Var11 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 14)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(table.Rows) >= 1 {
|
||||
templ_7745c5c3_Err = Medal("1. Platz", table.Rows[0].Name, "text-yellow-400").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
if len(table.Rows) >= 2 {
|
||||
templ_7745c5c3_Err = Medal("2. Platz", table.Rows[1].Name, "text-gray-500").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
if len(table.Rows) >= 3 {
|
||||
templ_7745c5c3_Err = Medal("3. Platz", table.Rows[2].Name, "text-amber-700").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 15)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func MapSelectTable(capture *models.Capture) templ.Component {
|
||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var12 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var12 == nil {
|
||||
templ_7745c5c3_Var12 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 16)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, maps := range capture.MapScores {
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 17)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(maps.Map)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 72, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 18)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 19)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, maps := range capture.MapScores {
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 20)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("/captures/%d/mapscore/%d/counted/%t", capture.ID, maps.ID, !maps.Counted))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/capture/capture.templ`, Line: 82, Col: 172}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 21)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if maps.Counted {
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 22)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 23)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 24)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
24
views/capture/capture_templ.txt
Normal file
24
views/capture/capture_templ.txt
Normal file
@ -0,0 +1,24 @@
|
||||
<div class=\"flex flex-col\"><div class=\"flex\"><div><div class=\"block font-bold text-lg\">
|
||||
</div>
|
||||
<div class=\"my-3 w-60\" hx-get=\"
|
||||
\" hx-trigger=\"load, every 20s\">Loading Server status...</div></div>
|
||||
</div><div hx-get=\"
|
||||
\" hx-trigger=\"every 10s\">
|
||||
</div>
|
||||
</div>
|
||||
<div class=\"flex flex-col gap-2\">
|
||||
<i class=\"
|
||||
\"></i> <span>
|
||||
|
||||
</span></div>
|
||||
<div id=\"pedestal\" hx-swap-oob=\"true\" class=\"flex w-full justify-around items-center gap-5\">
|
||||
</div>
|
||||
<div id=\"select-table\" class=\"relative overflow-x-auto\"><table class=\"w-full overflow-scroll 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\">Map</th>
|
||||
<th scope=\"col\" class=\"px-6 py-3\">
|
||||
</th>
|
||||
</tr></thead> <tbody class=\"overflow-y-scroll\"><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\">Enabled</th>
|
||||
<td class=\"px-6 py-4\"><input type=\"checkbox\" hx-target=\"#select-table\" hx-swap=\"outerHTML\" hx-post=\"
|
||||
\"
|
||||
checked
|
||||
></td>
|
||||
</tr></tbody></table></div>
|
||||
Reference in New Issue
Block a user