From 264fa15fb2ba5f0b9636cda44b64deb3c56aa99d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 4 Aug 2024 14:50:30 +0900 Subject: feat(backend): serve /admin/* pages from api-server --- backend/admin/templates/base.html | 25 +++++++++++++++++++ backend/admin/templates/dashboard.html | 10 ++++++++ backend/admin/templates/game_edit.html | 45 ++++++++++++++++++++++++++++++++++ backend/admin/templates/games.html | 17 +++++++++++++ backend/admin/templates/user_edit.html | 33 +++++++++++++++++++++++++ backend/admin/templates/users.html | 17 +++++++++++++ 6 files changed, 147 insertions(+) create mode 100644 backend/admin/templates/base.html create mode 100644 backend/admin/templates/dashboard.html create mode 100644 backend/admin/templates/game_edit.html create mode 100644 backend/admin/templates/games.html create mode 100644 backend/admin/templates/user_edit.html create mode 100644 backend/admin/templates/users.html (limited to 'backend/admin/templates') diff --git a/backend/admin/templates/base.html b/backend/admin/templates/base.html new file mode 100644 index 0000000..4bcdbdd --- /dev/null +++ b/backend/admin/templates/base.html @@ -0,0 +1,25 @@ + + + + ADMIN {{ .Title }} | iOSDC Japan 2024 Albatross.swift + + + + + +
+

ADMIN {{ .Title }}

+

+ This is an admin page. +

+
+ +
+
+ {{ block "content" . }}{{ end }} +
+
+ + diff --git a/backend/admin/templates/dashboard.html b/backend/admin/templates/dashboard.html new file mode 100644 index 0000000..2d7e8ad --- /dev/null +++ b/backend/admin/templates/dashboard.html @@ -0,0 +1,10 @@ +{{ template "base.html" . }} + +{{ define "content" }} +

+ Users +

+

+ Games +

+{{ end }} diff --git a/backend/admin/templates/game_edit.html b/backend/admin/templates/game_edit.html new file mode 100644 index 0000000..8bc5410 --- /dev/null +++ b/backend/admin/templates/game_edit.html @@ -0,0 +1,45 @@ +{{ template "base.html" . }} + +{{ define "breadcrumb" }} +Dashboard | Games +{{ end }} + +{{ define "content" }} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+{{ end }} diff --git a/backend/admin/templates/games.html b/backend/admin/templates/games.html new file mode 100644 index 0000000..244fc94 --- /dev/null +++ b/backend/admin/templates/games.html @@ -0,0 +1,17 @@ +{{ template "base.html" . }} + +{{ define "breadcrumb" }} +Dashboard +{{ end }} + +{{ define "content" }} + +{{ end }} diff --git a/backend/admin/templates/user_edit.html b/backend/admin/templates/user_edit.html new file mode 100644 index 0000000..9089b1e --- /dev/null +++ b/backend/admin/templates/user_edit.html @@ -0,0 +1,33 @@ +{{ template "base.html" . }} + +{{ define "breadcrumb" }} +Dashboard | Users +{{ end }} + +{{ define "content" }} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+{{ end }} diff --git a/backend/admin/templates/users.html b/backend/admin/templates/users.html new file mode 100644 index 0000000..656ad53 --- /dev/null +++ b/backend/admin/templates/users.html @@ -0,0 +1,17 @@ +{{ template "base.html" . }} + +{{ define "breadcrumb" }} +Dashboard +{{ end }} + +{{ define "content" }} + +{{ end }} -- cgit v1.2.3-70-g09d2 From d87507918f33b289ac4fc4dece8a54fa3aa34923 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 4 Aug 2024 17:24:36 +0900 Subject: feat(backend): add /logout to /admin/dashboard --- backend/admin/handlers.go | 2 +- backend/admin/templates/dashboard.html | 3 +++ backend/main.go | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'backend/admin/templates') diff --git a/backend/admin/handlers.go b/backend/admin/handlers.go index 1c7995d..f81856c 100644 --- a/backend/admin/handlers.go +++ b/backend/admin/handlers.go @@ -236,5 +236,5 @@ func (h *AdminHandler) postGameEdit(c echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - return c.String(http.StatusNoContent, "") + return c.NoContent(http.StatusNoContent) } diff --git a/backend/admin/templates/dashboard.html b/backend/admin/templates/dashboard.html index 2d7e8ad..cdb8ba1 100644 --- a/backend/admin/templates/dashboard.html +++ b/backend/admin/templates/dashboard.html @@ -7,4 +7,7 @@

Games

+
+ +
{{ end }} diff --git a/backend/main.go b/backend/main.go index 7330109..2d38ee5 100644 --- a/backend/main.go +++ b/backend/main.go @@ -83,6 +83,13 @@ func main() { adminGroup := e.Group("/admin") adminHandler.RegisterHandlers(adminGroup) + // For local dev: + // This is never used in production because the reverse proxy sends /logout + // to the app server. + e.POST("/logout", func(c echo.Context) error { + return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173/logout") + }) + gameHubs.Run() if err := e.Start(":80"); err != http.ErrServerClosed { -- cgit v1.2.3-70-g09d2