feature(admin): initial adin portal navigation
nclazz/soundwerft/pipeline/head This commit looks good
Details
nclazz/soundwerft/pipeline/head This commit looks good
Details
closes: #37master
parent
45fca7ecc7
commit
0214f4c0ed
|
@ -19,3 +19,15 @@ func Authenticated(h *handler.Handler) echo.MiddlewareFunc {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Admin(h *handler.Handler) echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
usr := h.User(c)
|
||||
if usr != nil && usr.IsAdmin {
|
||||
return next(c)
|
||||
}
|
||||
return h.HardRedirect(c, h.View(c).URLString("/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"git.l--n.de/nclazz/soundwerft/api/guard"
|
||||
"git.l--n.de/nclazz/soundwerft/api/handler"
|
||||
"git.l--n.de/nclazz/soundwerft/api/web/templates/admin"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func Routes(h *handler.Handler) {
|
||||
g := h.Echo.Group("/admin", guard.Authenticated(h), guard.Admin(h))
|
||||
g.GET("", getHomePage(h))
|
||||
g.GET("/", getHomePage(h))
|
||||
g.GET("/manage", getHomePage(h))
|
||||
g.GET("/manage/", getHomePage(h))
|
||||
g.GET("/manage/accounts", getAccountsPage(h))
|
||||
g.GET("/manage/application", getApplicationPage(h))
|
||||
g.GET("/manage/jobs", getJobsPage(h))
|
||||
}
|
||||
|
||||
func getHomePage(h *handler.Handler) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
return h.Render(c, admin.HomePage(h.View(c)))
|
||||
}
|
||||
}
|
||||
|
||||
func getAccountsPage(h *handler.Handler) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
return h.Render(c, admin.AccountsPage(h.View(c)))
|
||||
}
|
||||
}
|
||||
|
||||
func getApplicationPage(h *handler.Handler) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
return h.Render(c, admin.ApplicationPage(h.View(c)))
|
||||
}
|
||||
}
|
||||
|
||||
func getJobsPage(h *handler.Handler) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
return h.Render(c, admin.JobsPage(h.View(c)))
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package api
|
|||
import (
|
||||
"fmt"
|
||||
"git.l--n.de/nclazz/soundwerft/api/handler"
|
||||
"git.l--n.de/nclazz/soundwerft/api/handler/admin"
|
||||
"git.l--n.de/nclazz/soundwerft/api/handler/artist"
|
||||
"git.l--n.de/nclazz/soundwerft/api/handler/json"
|
||||
"git.l--n.de/nclazz/soundwerft/api/handler/pages"
|
||||
|
@ -51,6 +52,7 @@ func (a *API) routes() {
|
|||
pages.Routes(h)
|
||||
user.Routes(h)
|
||||
artist.Routes(h)
|
||||
admin.Routes(h)
|
||||
|
||||
for _, r := range a.echo.Routes() {
|
||||
slog.Debug("router", "route", fmt.Sprintf("%s %s", r.Method, r.Path))
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"git.l--n.de/nclazz/soundwerft/api/web"
|
||||
"git.l--n.de/nclazz/soundwerft/api/web/templates/partials"
|
||||
)
|
||||
|
||||
|
||||
templ HomePage(view web.View) {
|
||||
@partials.Document(view) {
|
||||
@Navigation(view, CurrentPageDashboard)
|
||||
@Dashboard(view)
|
||||
}
|
||||
}
|
||||
|
||||
templ AccountsPage(view web.View) {
|
||||
@partials.Document(view) {
|
||||
@Navigation(view, CurrentPageAccounts)
|
||||
@ManageAccounts(view)
|
||||
}
|
||||
}
|
||||
|
||||
templ ApplicationPage(view web.View) {
|
||||
@partials.Document(view) {
|
||||
@Navigation(view, CurrentPageApplication)
|
||||
@ManageApplication(view)
|
||||
}
|
||||
}
|
||||
|
||||
templ JobsPage(view web.View) {
|
||||
@partials.Document(view) {
|
||||
@Navigation(view, CurrentPageJobs)
|
||||
@ManageJobs(view)
|
||||
}
|
||||
}
|
||||
|
||||
templ Dashboard(view web.View) {
|
||||
<h3>Dashboard</h3>
|
||||
}
|
||||
|
||||
templ ManageAccounts(view web.View) {
|
||||
<h3>Manage Accounts</h3>
|
||||
}
|
||||
|
||||
templ ManageApplication(view web.View) {
|
||||
<h3>Manage Application</h3>
|
||||
}
|
||||
|
||||
templ ManageJobs(view web.View) {
|
||||
<h3>Manage Tasks and Jobs</h3>
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"git.l--n.de/nclazz/soundwerft/api/web"
|
||||
)
|
||||
|
||||
type CurrentPage int
|
||||
const (
|
||||
CurrentPageDashboard CurrentPage = iota
|
||||
CurrentPageAccounts
|
||||
CurrentPageApplication
|
||||
CurrentPageJobs
|
||||
)
|
||||
|
||||
templ Navigation(view web.View, current CurrentPage) {
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="nav-item">
|
||||
<a class={"nav-link", templ.KV("active", current == CurrentPageDashboard)}
|
||||
hx-boost="true"
|
||||
hx-target="#main"
|
||||
hx-select="#main"
|
||||
href={ view.URL("/admin") }>
|
||||
Dashboard
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class={"nav-link", templ.KV("active", current == CurrentPageAccounts)}
|
||||
hx-boost="true"
|
||||
hx-target="#main"
|
||||
hx-select="#main"
|
||||
href={ view.URL("/admin/manage/accounts") }>
|
||||
Accounts
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class={"nav-link", templ.KV("active", current == CurrentPageApplication)}
|
||||
hx-boost="true"
|
||||
hx-target="#main"
|
||||
hx-select="#main"
|
||||
href={ view.URL("/admin/manage/application") }>
|
||||
Application
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class={"nav-link", templ.KV("active", current == CurrentPageJobs)}
|
||||
hx-boost="true"
|
||||
hx-target="#main"
|
||||
hx-select="#main"
|
||||
href={ view.URL("/admin/manage/jobs") }>
|
||||
Application
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
}
|
Loading…
Reference in New Issue