// Code generated by templ@(devel) DO NOT EDIT.
package components
//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 "git.src.quest/~skye/felu-ddns/internal/db"
import "fmt"
func ManagePartialDomains(domains []db.Domain) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, w io.Writer) (err error) {
templBuffer, templIsBuffer := w.(*bytes.Buffer)
if !templIsBuffer {
templBuffer = templ.GetBuffer()
defer templ.ReleaseBuffer(templBuffer)
}
ctx = templ.InitializeContext(ctx)
var_1 := templ.GetChildren(ctx)
if var_1 == nil {
var_1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
if len(domains) > 0 {
_, err = templBuffer.WriteString("<script>")
if err != nil {
return err
}
var_2 := `
function toggleApiKeyVisibility(inputId) {
var input = document.getElementById(inputId)
if (input.type === "password") {
input.type = "text";
} else {
input.type = "password";
}
}
`
_, err = templBuffer.WriteString(var_2)
if err != nil {
return err
}
_, err = templBuffer.WriteString("</script> <table class=\"table-auto\"><thead><tr><th class=\"text-start p-2\">")
if err != nil {
return err
}
var_3 := `Domain`
_, err = templBuffer.WriteString(var_3)
if err != nil {
return err
}
_, err = templBuffer.WriteString("</th><th class=\"text-start p-2\">")
if err != nil {
return err
}
var_4 := `A Record`
_, err = templBuffer.WriteString(var_4)
if err != nil {
return err
}
_, err = templBuffer.WriteString("</th><th class=\"text-start p-2\">")
if err != nil {
return err
}
var_5 := `Api Key`
_, err = templBuffer.WriteString(var_5)
if err != nil {
return err
}
_, err = templBuffer.WriteString("</th></tr></thead><tbody>")
if err != nil {
return err
}
for _, domain := range domains {
_, err = templBuffer.WriteString("<tr class=\"border\"><td><div class=\"p-2\"><span class=\"font-bold\">")
if err != nil {
return err
}
var var_6 string = domain.Domain
_, err = templBuffer.WriteString(templ.EscapeString(var_6))
if err != nil {
return err
}
_, err = templBuffer.WriteString("</span><span class=\"\">")
if err != nil {
return err
}
var var_7 string = getDomainPattern()
_, err = templBuffer.WriteString(templ.EscapeString(var_7))
if err != nil {
return err
}
_, err = templBuffer.WriteString("</span></div></td><td><div class=\"p-2\"><!--")
if err != nil {
return err
}
var_8 := ` TODO: Make this editable
And refresh the div with /manage/partials/domains
`
_, err = templBuffer.WriteString(var_8)
if err != nil {
return err
}
_, err = templBuffer.WriteString("--><input class=\"border\" value=\"")
if err != nil {
return err
}
_, err = templBuffer.WriteString(templ.EscapeString(domain.A))
if err != nil {
return err
}
_, err = templBuffer.WriteString("\"></div></td><td><div class=\"p-2\"><!--")
if err != nil {
return err
}
var_9 := ` TODO: Add refreshing `
_, err = templBuffer.WriteString(var_9)
if err != nil {
return err
}
_, err = templBuffer.WriteString("--><input class=\"border\" disabled type=\"password\" value=\"")
if err != nil {
return err
}
_, err = templBuffer.WriteString(templ.EscapeString(domain.ApiKey))
if err != nil {
return err
}
_, err = templBuffer.WriteString("\" id=\"")
if err != nil {
return err
}
_, err = templBuffer.WriteString(templ.EscapeString(fmt.Sprintf("domain_apikey_%s", domain.Id)))
if err != nil {
return err
}
_, err = templBuffer.WriteString("\"><!--")
if err != nil {
return err
}
var_10 := ` TODO: Replace with one of those eye thingies `
_, err = templBuffer.WriteString(var_10)
if err != nil {
return err
}
_, err = templBuffer.WriteString("--><input type=\"checkbox\" onclick=\"toggleApiKeyVisibility(this.previousElementSibling.id)\"><span>")
if err != nil {
return err
}
var_11 := `show`
_, err = templBuffer.WriteString(var_11)
if err != nil {
return err
}
_, err = templBuffer.WriteString("</span></div></td><td><div class=\"p-2\"><button class=\"border p-1\" hx-confirm=\"Sure?\" hx-delete=\"")
if err != nil {
return err
}
_, err = templBuffer.WriteString(templ.EscapeString(fmt.Sprintf("/manage/domains/%s", domain.Id)))
if err != nil {
return err
}
_, err = templBuffer.WriteString("\">")
if err != nil {
return err
}
var_12 := `Delete`
_, err = templBuffer.WriteString(var_12)
if err != nil {
return err
}
_, err = templBuffer.WriteString("</button></div></td></tr>")
if err != nil {
return err
}
}
_, err = templBuffer.WriteString("</tbody></table>")
if err != nil {
return err
}
}
if !templIsBuffer {
_, err = templBuffer.WriteTo(w)
}
return err
})
}