Modernize admin UI with React and update templates

This commit is contained in:
2025-05-24 10:51:55 +03:30
parent d35a93e4bc
commit 0f96344543
9 changed files with 153 additions and 250 deletions
+12 -7
View File
@@ -6,6 +6,7 @@ import (
"net/http"
"github.com/gin-contrib/cors"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
)
@@ -19,27 +20,31 @@ func SetupRouter() *gin.Engine {
AllowCredentials: true,
}))
r.LoadHTMLGlob("internal/web/templates/**/*")
r.LoadHTMLGlob("internal/web/templates/home/*")
auth.InitJwtTokenGenerator() // Must be befor initializing admin handler, otherwise 'panic: runtime error: invalid memory address or nil pointer dereference'
handlers.InitAdminDashboardHandler()
handlers.InitApiEndpointHandler()
handlers.InitEmbedCardHandler()
// Main page
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "home/index.html", nil)
})
// Embed card
r.GET("/embed", handlers.EmbedCardHandlerInstance.GetEmbedCard)
admin := r.Group("/admin")
// My man, this is done way more efficient and fast in .NET, specially the authentication part
admin.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "admin/index.html", nil)
})
admin.GET("/login", func(c *gin.Context) {
c.HTML(http.StatusOK, "admin/login.html", nil)
})
// admin.GET("/", func(c *gin.Context) {
// c.HTML(http.StatusOK, "admin/index.html", nil)
// })
// admin.GET("/login", func(c *gin.Context) {
// c.HTML(http.StatusOK, "admin/index.html", nil)
// })
r.Use(static.Serve("/admin", static.LocalFile("internal/web/templates/admin", true)))
adminApi := admin.Group("/api")
adminApi.POST("/login", handlers.AdminDashboardHandlerInstance.Login)
adminApi.GET("/getmedia", auth.JwtTokenGeneratorInstance.GinMiddleware(), handlers.AdminDashboardHandlerInstance.GetMedia)