This commit is contained in:
153
web/pages/admin.go
Normal file
153
web/pages/admin.go
Normal file
@@ -0,0 +1,153 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
g "maragu.dev/gomponents"
|
||||
h "maragu.dev/gomponents/html"
|
||||
|
||||
"reichard.io/antholume/web/components/ui"
|
||||
"reichard.io/antholume/web/models"
|
||||
"reichard.io/antholume/web/pages/layout"
|
||||
)
|
||||
|
||||
var _ Page = (*AdminGeneral)(nil)
|
||||
|
||||
type AdminGeneral struct{}
|
||||
|
||||
func (p *AdminGeneral) Generate(ctx models.PageContext) (g.Node, error) {
|
||||
return layout.Layout(
|
||||
ctx.WithRoute(models.AdminGeneralPage),
|
||||
h.Div(
|
||||
h.Class("w-full flex flex-col gap-4 grow"),
|
||||
backupAndRestoreSection(),
|
||||
tasksSection(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func backupAndRestoreSection() g.Node {
|
||||
return h.Div(
|
||||
h.Class("flex flex-col gap-2 grow p-4 rounded shadow-lg bg-white dark:bg-gray-700 text-gray-500 dark:text-white"),
|
||||
h.P(
|
||||
h.Class("text-lg font-semibold mb-2"),
|
||||
g.Text("Backup & Restore"),
|
||||
),
|
||||
h.Div(
|
||||
h.Class("flex flex-col gap-4"),
|
||||
backupForm(),
|
||||
restoreForm(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func backupForm() g.Node {
|
||||
return h.Form(
|
||||
h.Class("flex justify-between"),
|
||||
h.Action("./admin"),
|
||||
h.Method("POST"),
|
||||
h.Input(
|
||||
h.Type("text"),
|
||||
h.Name("action"),
|
||||
h.Value("BACKUP"),
|
||||
h.Class("hidden"),
|
||||
),
|
||||
h.Div(
|
||||
h.Class("flex gap-8"),
|
||||
h.Div(
|
||||
h.Class("flex gap-2 items-center"),
|
||||
h.Input(
|
||||
h.Type("checkbox"),
|
||||
h.ID("backup_covers"),
|
||||
h.Name("backup_types"),
|
||||
h.Value("COVERS"),
|
||||
),
|
||||
h.Label(
|
||||
h.For("backup_covers"),
|
||||
g.Text("Covers"),
|
||||
),
|
||||
),
|
||||
h.Div(
|
||||
h.Class("flex gap-2 items-center"),
|
||||
h.Input(
|
||||
h.Type("checkbox"),
|
||||
h.ID("backup_documents"),
|
||||
h.Name("backup_types"),
|
||||
h.Value("DOCUMENTS"),
|
||||
),
|
||||
h.Label(
|
||||
h.For("backup_documents"),
|
||||
g.Text("Documents"),
|
||||
),
|
||||
),
|
||||
),
|
||||
h.Div(
|
||||
h.Class("h-10 w-40"),
|
||||
ui.FormButton(g.Text("Backup"), "", ui.ButtonConfig{Variant: ui.ButtonVariantSecondary}),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func restoreForm() g.Node {
|
||||
return h.Form(
|
||||
h.Class("flex justify-between"),
|
||||
h.Action("./admin"),
|
||||
h.Method("POST"),
|
||||
g.Attr("enctype", "multipart/form-data"),
|
||||
h.Input(
|
||||
h.Type("text"),
|
||||
h.Name("action"),
|
||||
h.Value("RESTORE"),
|
||||
h.Class("hidden"),
|
||||
),
|
||||
h.Div(
|
||||
h.Class("flex items-center"),
|
||||
h.Input(
|
||||
h.Type("file"),
|
||||
h.Accept(".zip"),
|
||||
h.Name("restore_file"),
|
||||
h.Class("w-full"),
|
||||
),
|
||||
),
|
||||
h.Div(
|
||||
h.Class("h-10 w-40"),
|
||||
ui.FormButton(g.Text("Restore"), "", ui.ButtonConfig{Variant: ui.ButtonVariantSecondary}),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func tasksSection() g.Node {
|
||||
return h.Div(
|
||||
h.Class("flex flex-col grow p-4 rounded shadow-lg bg-white dark:bg-gray-700 text-gray-500 dark:text-white"),
|
||||
h.P(
|
||||
h.Class("text-lg font-semibold mb-4"),
|
||||
g.Text("Tasks"),
|
||||
),
|
||||
h.Div(
|
||||
h.Class("grid grid-cols-[1fr_auto] gap-x-4 gap-y-3 items-center"),
|
||||
g.Group(taskItem("Metadata Matching", "METADATA_MATCH")),
|
||||
g.Group(taskItem("Cache Tables", "CACHE_TABLES")),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func taskItem(name, action string) []g.Node {
|
||||
return []g.Node{
|
||||
h.P(
|
||||
h.Class("text-black dark:text-white"),
|
||||
g.Text(name),
|
||||
),
|
||||
h.Form(
|
||||
h.Action("./admin"),
|
||||
h.Method("POST"),
|
||||
h.Input(
|
||||
h.Type("text"),
|
||||
h.Name("action"),
|
||||
h.Value(action),
|
||||
h.Class("hidden"),
|
||||
),
|
||||
h.Div(
|
||||
h.Class("h-10 w-40"),
|
||||
ui.FormButton(g.Text("Run"), "", ui.ButtonConfig{Variant: ui.ButtonVariantSecondary}),
|
||||
),
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ func Navigation(ctx models.PageContext) g.Node {
|
||||
return h.Div(
|
||||
g.Attr("class", "flex items-center justify-between w-full h-16"),
|
||||
Sidebar(ctx),
|
||||
h.H1(g.Attr("class", "text-xl font-bold px-6 lg:ml-44"), g.Text(ctx.Route.Title())),
|
||||
h.H1(g.Attr("class", "text-xl font-bold whitespace-nowrap px-6 lg:ml-44"), g.Text(ctx.Route.Title())),
|
||||
Dropdown(ctx.UserInfo.Username),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user