Added backlite UI to the admin panel.

This commit is contained in:
mikestefanello 2025-05-02 10:18:15 -04:00
parent 52f87580a0
commit 3cfcb43031
8 changed files with 99 additions and 13 deletions

View file

@ -10,6 +10,7 @@ import (
"github.com/mikestefanello/pagoda/pkg/ui/layouts"
"github.com/mikestefanello/pagoda/pkg/ui/models"
. "maragu.dev/gomponents"
. "maragu.dev/gomponents/components"
. "maragu.dev/gomponents/html"
)
@ -38,7 +39,7 @@ func Home(ctx echo.Context, posts *models.Posts) error {
headerMsg := func() Node {
return Group{
Section(
Class("hero is-info welcome is-small mb-5"),
Class("hero is-info welcome is-small mb-3"),
Div(
Class("hero-body"),
Div(
@ -58,6 +59,28 @@ func Home(ctx echo.Context, posts *models.Posts) error {
),
),
),
Section(
Class("hero is-light is-small mb-5"),
Div(
Class("hero-body"),
Div(
Class("container"),
B(Text("Admin status: ")),
Span(
Classes{
"tag": true,
"is-success": r.IsAdmin,
"is-danger": !r.IsAdmin,
},
Text(fmt.Sprint(r.IsAdmin)),
),
If(!r.IsAdmin, Span(
Class("is-size-7 ml-3"),
Raw(`(<a href="https://github.com/mikestefanello/pagoda#create-an-admin-account">click here</a> for instructions to make an admin account)`),
)),
),
),
),
H2(Class("title"), Text("Recent posts")),
H3(Class("subtitle"), Text("Below is an example of both paging and AJAX fetching using HTMX")),
}

View file

@ -22,10 +22,19 @@ func AddTask(ctx echo.Context, form *forms.Task) error {
"",
Group{
P(Raw("Submitting this form will create an <i>ExampleTask</i> in the task queue. After the specified delay, the message will be logged by the queue processor.")),
P(Text("See pkg/tasks and the README for more information.")),
P(Raw("See <i>pkg/tasks</i> and the README for more information.")),
})
}),
form.Render(r),
Iff(r.Htmx.Target != "task", func() Node {
return components.Message(
"is-warning",
"",
Group{
If(!r.IsAdmin, P(Text("Log in as an admin in order to access the task and queue monitoring UI."))),
If(r.IsAdmin, P(Text("View all queued tasks by clicking on the Tasks link in the sidebar."))),
})
}),
}
return r.Render(layouts.Primary, g)