|
|
|
|
@ -12,6 +12,7 @@ import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"git.32bit.cafe/32bitcafe/guestbook/internal/forms"
|
|
|
|
|
"git.32bit.cafe/32bitcafe/guestbook/internal/models"
|
|
|
|
|
"slices"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@ -43,7 +44,7 @@ func adminBase(title string, data CommonData) templ.Component {
|
|
|
|
|
var templ_7745c5c3_Var2 string
|
|
|
|
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 14, Col: 17}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 15, Col: 17}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
@ -56,7 +57,7 @@ func adminBase(title string, data CommonData) templ.Component {
|
|
|
|
|
var templ_7745c5c3_Var3 string
|
|
|
|
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(`{"includeIndicatorStyles":false}`)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 17, Col: 72}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 18, Col: 72}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
@ -107,7 +108,7 @@ func adminSidebar() templ.Component {
|
|
|
|
|
templ_7745c5c3_Var4 = templ.NopComponent
|
|
|
|
|
}
|
|
|
|
|
ctx = templ.ClearChildren(ctx)
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<nav aria-label=\"Admin panel navigation\"><div><section><h3>Administration</h3><ul role=\"list\"><li><a href=\"/admin/users\">Users</a></li><li><a href=\"/admin/guestbooks\">Guestbooks</a></li></ul></section></div></nav>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<nav aria-label=\"Admin panel navigation\"><div><section><h3>Administration</h3><ul role=\"list\"><li><a href=\"/admin\">Dashboard</a></li><li><a href=\"/admin/users\">Users</a></li><li><a href=\"/admin/guestbooks\">Guestbooks</a></li></ul></section></div></nav>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
@ -163,7 +164,7 @@ func AdminPanelLandingView(title string, data CommonData) templ.Component {
|
|
|
|
|
var templ_7745c5c3_Var7 string
|
|
|
|
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 54, Col: 15}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 56, Col: 15}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
@ -250,7 +251,7 @@ func AdminPanelUsersView(title string, data CommonData, users []models.User) tem
|
|
|
|
|
var templ_7745c5c3_Var11 string
|
|
|
|
|
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(u.Username)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 74, Col: 51}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 76, Col: 51}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
@ -263,7 +264,7 @@ func AdminPanelUsersView(title string, data CommonData, users []models.User) tem
|
|
|
|
|
var templ_7745c5c3_Var12 string
|
|
|
|
|
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(u.Created.Format(time.RFC3339))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 75, Col: 44}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 77, Col: 44}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
@ -276,7 +277,7 @@ func AdminPanelUsersView(title string, data CommonData, users []models.User) tem
|
|
|
|
|
var templ_7745c5c3_Var13 string
|
|
|
|
|
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(u.Email)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 76, Col: 21}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 78, Col: 21}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
@ -301,7 +302,7 @@ func AdminPanelUsersView(title string, data CommonData, users []models.User) tem
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func AdminPanelUserMgmtDetail(user models.User) templ.Component {
|
|
|
|
|
func AdminPanelUserMgmtDetail(csrfToken string, user models.User) 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 {
|
|
|
|
|
@ -322,87 +323,163 @@ func AdminPanelUserMgmtDetail(user models.User) templ.Component {
|
|
|
|
|
templ_7745c5c3_Var14 = templ.NopComponent
|
|
|
|
|
}
|
|
|
|
|
ctx = templ.ClearChildren(ctx)
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<div id=\"user-info\"><section><h3>User Info</h3><div><h5>Username</h5><p>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<div id=\"user-info\"><form><input type=\"hidden\" name=\"csrf_token\" value=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var15 string
|
|
|
|
|
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(user.Username)
|
|
|
|
|
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(csrfToken)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 92, Col: 34}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 91, Col: 59}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "</p></div><div><h5>Email</h5><p>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\"><section><h3>User Info</h3><div><h5>Username</h5><p>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var16 string
|
|
|
|
|
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email)
|
|
|
|
|
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(user.Username)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 96, Col: 31}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 96, Col: 23}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</p></div><div><h5>Joined</h5><p>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</p></div><div><h5>Email</h5><p>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var17 string
|
|
|
|
|
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(user.Created.Format(time.RFC3339))
|
|
|
|
|
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 100, Col: 54}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 100, Col: 20}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</p></div></section><section><h3>Groups</h3><ul>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</p></div><div><h5>Joined</h5><p>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var18 string
|
|
|
|
|
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(user.Created.Format(time.RFC3339))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 104, Col: 43}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</p></div></section><section><h3>Groups</h3><ul>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
for _, g := range user.Groups {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "<li>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "<li>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var18 string
|
|
|
|
|
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", getGroupName(g)))
|
|
|
|
|
var templ_7745c5c3_Var19 string
|
|
|
|
|
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", getGroupName(g)))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 107, Col: 60}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 111, Col: 46}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</li>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</li>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</ul></section><section><h3>Actions</h3>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</ul></section><section><h3>Actions</h3>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
getFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId))
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<button type=\"button\" hx-get=\"")
|
|
|
|
|
putBanUrl := fmt.Sprintf("/admin/users/%s/ban", shortIdToSlug(user.ShortId))
|
|
|
|
|
putUnbanUrl := fmt.Sprintf("/admin/users/%s/unban", shortIdToSlug(user.ShortId))
|
|
|
|
|
deleteUrl := fmt.Sprintf("/admin/users/%s", shortIdToSlug(user.ShortId))
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<button type=\"button\" hx-get=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var19 string
|
|
|
|
|
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(getFormUrl)
|
|
|
|
|
var templ_7745c5c3_Var20 string
|
|
|
|
|
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(getFormUrl)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 114, Col: 53}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 121, Col: 45}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "\" hx-target=\"#user-info\">Edit</button> <button type=\"button\" class=\"danger\">Ban</button> <button type=\"button\" class=\"danger\">Delete</button></section></div>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "\" hx-target=\"#user-info\">Edit</button> ")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
if user.ID != 1 {
|
|
|
|
|
if user.Banned.IsZero() {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "<button type=\"button\" hx-put=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var21 string
|
|
|
|
|
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(putBanUrl)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 124, Col: 46}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "\" hx-confirm=\"Are you sure you want to ban this user?\" hx-target=\"#user-info\" class=\"danger\">Ban</button>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "<button type=\"button\" hx-put=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var22 string
|
|
|
|
|
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(putUnbanUrl)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 126, Col: 48}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "\" hx-confirm=\"Are you sure you want to unban this user?\" hx-target=\"#user-info\">Unban</button>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, " <button type=\"button\" hx-delete=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var23 string
|
|
|
|
|
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(deleteUrl)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 128, Col: 48}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "\" hx-confirm=\"Are you sure you want to delete this user? This is irreversible\" class=\"danger\">Delete</button>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</section></form></div>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
@ -426,12 +503,12 @@ func AdminPanelUserMgmtView(title string, data CommonData, user models.User) tem
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
ctx = templ.InitializeContext(ctx)
|
|
|
|
|
templ_7745c5c3_Var20 := templ.GetChildren(ctx)
|
|
|
|
|
if templ_7745c5c3_Var20 == nil {
|
|
|
|
|
templ_7745c5c3_Var20 = templ.NopComponent
|
|
|
|
|
templ_7745c5c3_Var24 := templ.GetChildren(ctx)
|
|
|
|
|
if templ_7745c5c3_Var24 == nil {
|
|
|
|
|
templ_7745c5c3_Var24 = templ.NopComponent
|
|
|
|
|
}
|
|
|
|
|
ctx = templ.ClearChildren(ctx)
|
|
|
|
|
templ_7745c5c3_Var21 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
|
|
|
templ_7745c5c3_Var25 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
|
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
|
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
|
|
|
if !templ_7745c5c3_IsBuffer {
|
|
|
|
|
@ -443,7 +520,7 @@ func AdminPanelUserMgmtView(title string, data CommonData, user models.User) tem
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
ctx = templ.InitializeContext(ctx)
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<div id=\"dashboard\">")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "<div id=\"dashboard\">")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
@ -451,17 +528,17 @@ func AdminPanelUserMgmtView(title string, data CommonData, user models.User) tem
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = AdminPanelUserMgmtDetail(user).Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
|
templ_7745c5c3_Err = AdminPanelUserMgmtDetail(data.CSRFToken, user).Render(ctx, templ_7745c5c3_Buffer)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</div>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "</div>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
templ_7745c5c3_Err = adminBase(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var21), templ_7745c5c3_Buffer)
|
|
|
|
|
templ_7745c5c3_Err = adminBase(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var25), templ_7745c5c3_Buffer)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
@ -485,119 +562,117 @@ func AdminPanelUserMgmtEditForm(csrfToken string, form forms.AdminUserMgmtForm,
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
ctx = templ.InitializeContext(ctx)
|
|
|
|
|
templ_7745c5c3_Var22 := templ.GetChildren(ctx)
|
|
|
|
|
if templ_7745c5c3_Var22 == nil {
|
|
|
|
|
templ_7745c5c3_Var22 = templ.NopComponent
|
|
|
|
|
templ_7745c5c3_Var26 := templ.GetChildren(ctx)
|
|
|
|
|
if templ_7745c5c3_Var26 == nil {
|
|
|
|
|
templ_7745c5c3_Var26 = templ.NopComponent
|
|
|
|
|
}
|
|
|
|
|
ctx = templ.ClearChildren(ctx)
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "<div id=\"user-info\"><form><input type=\"hidden\" name=\"csrf_token\" value=\"")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "<div id=\"user-info\"><form><input type=\"hidden\" name=\"csrf_token\" value=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var23 string
|
|
|
|
|
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(csrfToken)
|
|
|
|
|
var templ_7745c5c3_Var27 string
|
|
|
|
|
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(csrfToken)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 133, Col: 64}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 147, Col: 59}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "\"><fieldset><h3>User Info</h3><div><h5>Username</h5><input type=\"text\" name=\"admin_username\" id=\"username\" value=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var24 string
|
|
|
|
|
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(form.Username)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 138, Col: 92}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "\" required></div><div><h5>Email</h5><input type=\"text\" name=\"admin_useremail\" id=\"useremail\" value=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var25 string
|
|
|
|
|
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(form.Email)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 142, Col: 91}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "\" required></div><div><h5>Joined</h5><p>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var26 string
|
|
|
|
|
templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(user.Created.Format(time.RFC3339))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 146, Col: 54}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "</p></div></fieldset><section><h3>Groups</h3><ul>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
for _, g := range groups {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "<li>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var27 string
|
|
|
|
|
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", getGroupName(g)))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 153, Col: 60}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "</li>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "</ul></section><section><h3>Actions</h3>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
putFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId))
|
|
|
|
|
getDetailUrl := fmt.Sprintf("/admin/users/%s/detail", shortIdToSlug(user.ShortId))
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "<button type=\"button\" hx-put=\"")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "\"><fieldset><h3>User Info</h3><div><h5>Username</h5><input type=\"text\" name=\"admin_username\" id=\"username\" value=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var28 string
|
|
|
|
|
templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(putFormUrl)
|
|
|
|
|
templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(form.Username)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 161, Col: 53}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 152, Col: 81}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "\" hx-target=\"#user-info\">Save</button> <button type=\"reset\" hx-get=\"")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "\" required></div><div><h5>Email</h5><input type=\"text\" name=\"admin_useremail\" id=\"useremail\" value=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var29 string
|
|
|
|
|
templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(getDetailUrl)
|
|
|
|
|
templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(form.Email)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 162, Col: 54}
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 156, Col: 80}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "\" hx-target=\"#user-info\">Cancel</button></section></form></div>")
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "\" required></div><div><h5>Joined</h5><p>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var30 string
|
|
|
|
|
templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(user.Created.Format(time.RFC3339))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 160, Col: 43}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "</p></div></fieldset><section><fieldset><h3>Groups</h3>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
isAdmin := slices.Contains(user.Groups, models.AdminGroup)
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "<input type=\"checkbox\" name=\"admin_usergroup_admin\" id=\"usergroup_admin\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
if isAdmin {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, " checked")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if user.ID == 1 {
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, " disabled")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "> <label for=\"usergroup_admin\">Administrator</label> <input type=\"checkbox\" name=\"admin_usergroup_user\" id=\"usergroup_user\" checked disabled> <label for=\"usergroup_user\">User</label></fieldset></section><section><h3>Actions</h3>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
putFormUrl := fmt.Sprintf("/admin/users/%s/edit", shortIdToSlug(user.ShortId))
|
|
|
|
|
getDetailUrl := fmt.Sprintf("/admin/users/%s/detail", shortIdToSlug(user.ShortId))
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "<button type=\"button\" hx-put=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var31 string
|
|
|
|
|
templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(putFormUrl)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 177, Col: 45}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "\" hx-target=\"#user-info\">Save</button> <button type=\"reset\" hx-get=\"")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
var templ_7745c5c3_Var32 string
|
|
|
|
|
templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(getDetailUrl)
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/admin.templ`, Line: 178, Col: 46}
|
|
|
|
|
}
|
|
|
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "\" hx-target=\"#user-info\">Cancel</button></section></form></div>")
|
|
|
|
|
if templ_7745c5c3_Err != nil {
|
|
|
|
|
return templ_7745c5c3_Err
|
|
|
|
|
}
|
|
|
|
|
|