feat(display-attendies): finish ui
This commit is contained in:
parent
cdd5e74693
commit
c0f4455d05
7 changed files with 85 additions and 40 deletions
|
@ -1,6 +1,8 @@
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"ulmer-furs.de/pretix-proxy/v2/app/service"
|
"ulmer-furs.de/pretix-proxy/v2/app/service"
|
||||||
)
|
)
|
||||||
|
@ -19,3 +21,19 @@ func GetAttendiesByEventPublic(c *fiber.Ctx) error {
|
||||||
c.JSON(attendies)
|
c.JSON(attendies)
|
||||||
return c.SendStatus(fiber.StatusOK)
|
return c.SendStatus(fiber.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetAttendiesByEventPublicTable(c *fiber.Ctx) error {
|
||||||
|
name := c.Params("name")
|
||||||
|
event, err := service.Get_db_event_by_event(name)
|
||||||
|
if err != nil {
|
||||||
|
return c.Status(fiber.ErrNotFound.Code).SendString("event not found")
|
||||||
|
}
|
||||||
|
attendies, err := service.GetAttendiesByEventPrivacy(event, false)
|
||||||
|
if err != nil {
|
||||||
|
return c.Status(fiber.ErrNotFound.Code).SendString("attendies not found")
|
||||||
|
}
|
||||||
|
return c.Render("app/views/index", fiber.Map{
|
||||||
|
"Title": fmt.Sprintf("%s Attendies", *event.Event),
|
||||||
|
"Attendies": attendies,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func PublicRoutes(app *fiber.App) {
|
func PublicRoutes(app *fiber.App) {
|
||||||
|
ui := app.Group("/ui")
|
||||||
|
attendiesUi := ui.Group("/attendies")
|
||||||
|
attendiesUi.Get("/:name", controller.GetAttendiesByEventPublicTable)
|
||||||
apiv1 := app.Group("/api/v1/public")
|
apiv1 := app.Group("/api/v1/public")
|
||||||
attendies := apiv1.Group("/attendies")
|
attendies := apiv1.Group("/attendies")
|
||||||
webhooks := apiv1.Group("/webhooks")
|
webhooks := apiv1.Group("/webhooks")
|
||||||
|
|
35
src/app/static/styles/style.css
Normal file
35
src/app/static/styles/style.css
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
body {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: #151719;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
min-width: 60vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tableHeading {
|
||||||
|
background-color: #fae4b9;
|
||||||
|
}
|
||||||
|
|
||||||
|
th, td {
|
||||||
|
border-style: hidden;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody>tr:nth-child(even) {
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody>tr:nth-child(odd) {
|
||||||
|
background-color: #e9e9e9;
|
||||||
|
}
|
|
@ -4,14 +4,12 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
|
<link rel="stylesheet" href="/static/styles/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>{{.Title}}</h1>
|
<main>
|
||||||
<p>Events count: <span id="count">{{.Count}}</span></p>
|
<h1>{{.Title}}</h1>
|
||||||
<script>
|
{{template "table" .}}
|
||||||
counter = parseInt(document.getElementById("count").innerHTML)
|
</main>
|
||||||
console.log(counter + 1)
|
|
||||||
</script>
|
|
||||||
{{template "table" .}}
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,36 +1,18 @@
|
||||||
{{define "table"}}
|
{{define "table"}}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<thead>
|
||||||
<th>Name</th>
|
<tr class="tableHeading">
|
||||||
<th>Organizer</th>
|
<th>Name</th>
|
||||||
<th>Event</th>
|
<th>Role</th>
|
||||||
<th>ItemIdBadge</th>
|
|
||||||
<th>ItemIdRestaurant</th>
|
|
||||||
<th>ItemIdParticipation</th>
|
|
||||||
<th>QuestionIdRole</th>
|
|
||||||
<th>QuestionIdName</th>
|
|
||||||
<th>OptionIdSuiter</th>
|
|
||||||
<th>OptionIdGuest</th>
|
|
||||||
<th>OptionIdSpotter</th>
|
|
||||||
<th>OptionIdPhotograph</th>
|
|
||||||
<th>OptionIdSpecialAnimal</th>
|
|
||||||
</tr>
|
|
||||||
{{range .Events}}
|
|
||||||
<tr>
|
|
||||||
<td>{{.Name}}</td>
|
|
||||||
<td>{{.Organizer}}</td>
|
|
||||||
<td>{{.Event}}</td>
|
|
||||||
<td>{{.ItemIdBadge}}</td>
|
|
||||||
<td>{{.ItemIdRestaurant}}</td>
|
|
||||||
<td>{{.ItemIdParticipation}}</td>
|
|
||||||
<td>{{.QuestionIdRole}}</td>
|
|
||||||
<td>{{.QuestionIdName}}</td>
|
|
||||||
<td>{{.OptionIdSuiter}}</td>
|
|
||||||
<td>{{.OptionIdGuest}}</td>
|
|
||||||
<td>{{.OptionIdSpotter}}</td>
|
|
||||||
<td>{{.OptionIdPhotograph}}</td>
|
|
||||||
<td>{{.OptionIdSpecialAnimal}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{range .Attendies}}
|
||||||
|
<tr>
|
||||||
|
<td>{{.Nickname}}</td>
|
||||||
|
<td>{{.Role.Name}}</td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{end}}
|
|
@ -5,14 +5,20 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||||
"github.com/gofiber/template/html/v2"
|
"github.com/gofiber/template/html/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var App *fiber.App
|
var App *fiber.App
|
||||||
|
|
||||||
func SetupFiber(viewFS embed.FS) {
|
func SetupFiber(viewFS embed.FS, staticFS embed.FS) {
|
||||||
engine := html.NewFileSystem(http.FS(viewFS), ".html")
|
engine := html.NewFileSystem(http.FS(viewFS), ".html")
|
||||||
App = fiber.New(fiber.Config{
|
App = fiber.New(fiber.Config{
|
||||||
Views: engine,
|
Views: engine,
|
||||||
})
|
})
|
||||||
|
App.Use("/static", filesystem.New(filesystem.Config{
|
||||||
|
Root: http.FS(staticFS),
|
||||||
|
PathPrefix: "app/static",
|
||||||
|
Browse: true,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,15 @@ import (
|
||||||
//go:embed app/views/*
|
//go:embed app/views/*
|
||||||
var viewFS embed.FS
|
var viewFS embed.FS
|
||||||
|
|
||||||
|
//go:embed app/static/*
|
||||||
|
var staticFS embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config.LoadEnv()
|
config.LoadEnv()
|
||||||
config.Connect()
|
config.Connect()
|
||||||
config.SetupValidator()
|
config.SetupValidator()
|
||||||
config.SetupMiddlewares()
|
config.SetupMiddlewares()
|
||||||
config.SetupFiber(viewFS)
|
config.SetupFiber(viewFS, staticFS)
|
||||||
config.SetupCors()
|
config.SetupCors()
|
||||||
config.SetupHttp()
|
config.SetupHttp()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue