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.
37 lines
829 B
37 lines
829 B
package admin
|
|
|
|
import (
|
|
"maps"
|
|
"fmt"
|
|
"github.com/gofiber/fiber/v2"
|
|
"zedshaw.games/webapp/data"
|
|
"zedshaw.games/webapp/api"
|
|
)
|
|
|
|
func GetPageIndex(c *fiber.Ctx) error {
|
|
var tables []string
|
|
|
|
for k := range maps.Keys(data.Models()) {
|
|
tables = append(tables, k)
|
|
}
|
|
|
|
return c.Render("admin/index", fiber.Map{"Tables": tables})
|
|
}
|
|
|
|
func GetPageTableIndex(c *fiber.Ctx) error {
|
|
table := c.Params("table")
|
|
if table == "" { return c.Redirect("/admin/") }
|
|
|
|
fmt.Println("table: ", table)
|
|
type_is := data.Models()[table]
|
|
|
|
result, err := SelectTable(table, type_is, 20, 0);
|
|
if err != nil { return api.IfErrNil(err, c) }
|
|
|
|
return c.Render("admin/table/index", fiber.Map{"Table": result})
|
|
}
|
|
|
|
func Setup(app *fiber.App) {
|
|
app.Get("/admin/", GetPageIndex);
|
|
app.Get("/admin/table/:table/", GetPageTableIndex);
|
|
}
|
|
|