Now have a simple table list index and a table view, but the templates aren't good enough to easily use the Go reflect data. Will find one tomorrow that's better.
This commit is contained in:
parent
d481c260c5
commit
fa7f886a59
3 changed files with 55 additions and 2 deletions
|
@ -1,13 +1,37 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"fmt"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"zedshaw.games/webapp/data"
|
||||
"zedshaw.games/webapp/api"
|
||||
)
|
||||
|
||||
func GetPageIndex(c *fiber.Ctx) error {
|
||||
return c.Render("admin/index", fiber.Map{})
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue