mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2024-11-17 09:27:37 +00:00
334 lines
14 KiB
Go
334 lines
14 KiB
Go
|
// Code generated by templ - DO NOT EDIT.
|
||
|
|
||
|
// templ: version: v0.2.778
|
||
|
package views
|
||
|
|
||
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||
|
|
||
|
import "github.com/a-h/templ"
|
||
|
import templruntime "github.com/a-h/templ/runtime"
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/ditatompel/xmr-remote-nodes/internal/paging"
|
||
|
)
|
||
|
|
||
|
var availablePages = []int{5, 10, 20, 50, 100}
|
||
|
|
||
|
func DtRowPerPage(url, hxTarget string, rowsPerPage int, q interface{}) templ.Component {
|
||
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||
|
return templ_7745c5c3_CtxErr
|
||
|
}
|
||
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||
|
if !templ_7745c5c3_IsBuffer {
|
||
|
defer func() {
|
||
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||
|
if templ_7745c5c3_Err == nil {
|
||
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||
|
}
|
||
|
}()
|
||
|
}
|
||
|
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_7745c5c3_Buffer.WriteString("<div class=\"max-w-sm space-y-3\"><select name=\"limit\" id=\"dt_limit\" class=\"py-2 px-3 pe-9 block bg-neutral-900 border-neutral-700 rounded-lg text-sm focus:border-orange-400 focus:ring-orange-400\" hx-get=\"")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var2 string
|
||
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s?%s", url, paging.EncodedQuery(q, []string{"limit"})))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 16, Col: 80}
|
||
|
}
|
||
|
_, 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_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"true\" hx-target=\"")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var3 string
|
||
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(hxTarget)
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 19, Col: 23}
|
||
|
}
|
||
|
_, 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("\" hx-swap=\"outerHTML\"><option disabled>CHOOSE</option> ")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
for _, page := range availablePages {
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<option value=\"")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var4 string
|
||
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", page))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 25, Col: 36}
|
||
|
}
|
||
|
_, 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("\"")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
if page == rowsPerPage {
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" selected")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(">")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var5 string
|
||
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", page))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 27, Col: 30}
|
||
|
}
|
||
|
_, 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("</option>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></div>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
return templ_7745c5c3_Err
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func DtRowCount(currentPage, rowsPerPage, totalRows int) templ.Component {
|
||
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||
|
return templ_7745c5c3_CtxErr
|
||
|
}
|
||
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||
|
if !templ_7745c5c3_IsBuffer {
|
||
|
defer func() {
|
||
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||
|
if templ_7745c5c3_Err == nil {
|
||
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||
|
}
|
||
|
}()
|
||
|
}
|
||
|
ctx = templ.InitializeContext(ctx)
|
||
|
templ_7745c5c3_Var6 := templ.GetChildren(ctx)
|
||
|
if templ_7745c5c3_Var6 == nil {
|
||
|
templ_7745c5c3_Var6 = templ.NopComponent
|
||
|
}
|
||
|
ctx = templ.ClearChildren(ctx)
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div><p class=\"text-sm\">")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
if totalRows <= 0 {
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("No entries found")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
} else {
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<b>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var7 string
|
||
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", (rowsPerPage*currentPage)-rowsPerPage+1))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 39, Col: 73}
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</b> ")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
if rowsPerPage*currentPage > totalRows {
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("- <b>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var8 string
|
||
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", totalRows))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 41, Col: 40}
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</b>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
} else {
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("- <b>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var9 string
|
||
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", rowsPerPage*currentPage))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 43, Col: 56}
|
||
|
}
|
||
|
_, 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("</b>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" <b>/ ")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var10 string
|
||
|
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", totalRows))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 45, Col: 39}
|
||
|
}
|
||
|
_, 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("</b>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p></div>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
return templ_7745c5c3_Err
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func DtPagination(url, hxTarget string, q interface{}, p paging.Pagination) templ.Component {
|
||
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||
|
return templ_7745c5c3_CtxErr
|
||
|
}
|
||
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||
|
if !templ_7745c5c3_IsBuffer {
|
||
|
defer func() {
|
||
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||
|
if templ_7745c5c3_Err == nil {
|
||
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||
|
}
|
||
|
}()
|
||
|
}
|
||
|
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_7745c5c3_Buffer.WriteString("<div><nav class=\"pagination inline-flex gap-x-2\">")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
for _, page := range p.Pages {
|
||
|
if page == -1 {
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<button class=\"cursor-not-allowed\" disabled>...</button>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
} else if page == p.CurrentPage {
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<button class=\"active\" disabled>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var12 string
|
||
|
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", page))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 58, Col: 62}
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
} else {
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<button hx-get=\"")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var13 string
|
||
|
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s?%s&page=%d", url, paging.EncodedQuery(q, []string{"page"}), page))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 61, Col: 96}
|
||
|
}
|
||
|
_, 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_7745c5c3_Buffer.WriteString("\" hx-push-url=\"true\" hx-target=\"")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var14 string
|
||
|
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(hxTarget)
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 63, Col: 26}
|
||
|
}
|
||
|
_, 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_7745c5c3_Buffer.WriteString("\" hx-swap=\"outerHTML\">")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
var templ_7745c5c3_Var15 string
|
||
|
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", page))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/handler/views/partial_datatable.templ`, Line: 65, Col: 31}
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</button>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</nav></div>")
|
||
|
if templ_7745c5c3_Err != nil {
|
||
|
return templ_7745c5c3_Err
|
||
|
}
|
||
|
return templ_7745c5c3_Err
|
||
|
})
|
||
|
}
|
||
|
|
||
|
var _ = templruntime.GeneratedTemplate
|