You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
976 B
42 lines
976 B
package admin_table
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
. "MY/webapp/common"
|
|
)
|
|
|
|
func GetPageSelectOne(c *fiber.Ctx) error {
|
|
_, err := AuthCheck(c, true)
|
|
if err != nil { return c.Redirect("/") }
|
|
|
|
table := c.Params("table")
|
|
id, err := c.ParamsInt("id", -1)
|
|
if err != nil || id < 0 { return IfErrNil(err, c) }
|
|
|
|
return c.Render("admin/table/view", fiber.Map{
|
|
"table": table,
|
|
"id": id,
|
|
})
|
|
}
|
|
|
|
func GetPageContent(c *fiber.Ctx) error {
|
|
_, err := AuthCheck(c, true)
|
|
if err != nil { return c.Redirect("/") }
|
|
|
|
table := c.Params("table")
|
|
|
|
headers := Schema(table)
|
|
|
|
return c.Render("admin/table/contents", fiber.Map{
|
|
"table": table,
|
|
"headers": headers,
|
|
})
|
|
}
|
|
|
|
func SetupPages(app *fiber.App) {
|
|
AddAuthedPage(app, true, "admin/table/", "admin/table/index")
|
|
AddAuthedPage(app, true, "admin/table/new/:table/", "admin/table/new")
|
|
|
|
app.Get("admin/table/:table/", GetPageContent)
|
|
app.Get("/admin/table/:table/:id/", GetPageSelectOne)
|
|
}
|
|
|