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
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"ulmer-furs.de/pretix-proxy/v2/app/service"
|
||||
)
|
||||
|
@ -19,3 +21,19 @@ func GetAttendiesByEventPublic(c *fiber.Ctx) error {
|
|||
c.JSON(attendies)
|
||||
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) {
|
||||
ui := app.Group("/ui")
|
||||
attendiesUi := ui.Group("/attendies")
|
||||
attendiesUi.Get("/:name", controller.GetAttendiesByEventPublicTable)
|
||||
apiv1 := app.Group("/api/v1/public")
|
||||
attendies := apiv1.Group("/attendies")
|
||||
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 name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{.Title}}</title>
|
||||
<link rel="stylesheet" href="/static/styles/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{.Title}}</h1>
|
||||
<p>Events count: <span id="count">{{.Count}}</span></p>
|
||||
<script>
|
||||
counter = parseInt(document.getElementById("count").innerHTML)
|
||||
console.log(counter + 1)
|
||||
</script>
|
||||
{{template "table" .}}
|
||||
<main>
|
||||
<h1>{{.Title}}</h1>
|
||||
{{template "table" .}}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -1,36 +1,18 @@
|
|||
{{define "table"}}
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Organizer</th>
|
||||
<th>Event</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>
|
||||
<thead>
|
||||
<tr class="tableHeading">
|
||||
<th>Name</th>
|
||||
<th>Role</th>
|
||||
</tr>
|
||||
{{end}}
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Attendies}}
|
||||
<tr>
|
||||
<td>{{.Nickname}}</td>
|
||||
<td>{{.Role.Name}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{end}}
|
|
@ -5,14 +5,20 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||
"github.com/gofiber/template/html/v2"
|
||||
)
|
||||
|
||||
var App *fiber.App
|
||||
|
||||
func SetupFiber(viewFS embed.FS) {
|
||||
func SetupFiber(viewFS embed.FS, staticFS embed.FS) {
|
||||
engine := html.NewFileSystem(http.FS(viewFS), ".html")
|
||||
App = fiber.New(fiber.Config{
|
||||
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/*
|
||||
var viewFS embed.FS
|
||||
|
||||
//go:embed app/static/*
|
||||
var staticFS embed.FS
|
||||
|
||||
func main() {
|
||||
config.LoadEnv()
|
||||
config.Connect()
|
||||
config.SetupValidator()
|
||||
config.SetupMiddlewares()
|
||||
config.SetupFiber(viewFS)
|
||||
config.SetupFiber(viewFS, staticFS)
|
||||
config.SetupCors()
|
||||
config.SetupHttp()
|
||||
|
||||
|
|
Loading…
Reference in a new issue