From 6441aa9f8194edbb945307fd4fc17761e5366bef Mon Sep 17 00:00:00 2001 From: MaxJa4 <74194322+MaxJa4@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:42:11 +0100 Subject: [PATCH] Add full-calc --- main.go | 17 +- pages.go | 6 + templates/components/bottom_controls.html | 8 +- templates/index.html | 2 + templates/modals/full_calc.html | 324 ++++++++++++++++++++++ 5 files changed, 346 insertions(+), 11 deletions(-) create mode 100644 templates/modals/full_calc.html diff --git a/main.go b/main.go index b33841d..24e1db3 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,7 @@ func init() { "./templates/modals/delete_player.html", "./templates/modals/edit_player.html", "./templates/modals/settings.html", + "./templates/modals/full_calc.html", "./templates/components/header.html", ) if err != nil { @@ -51,7 +52,7 @@ func init() { } utils.PlayerItemTemplate, err = template.ParseFiles( - "./templates/player_list_item.html", + "./templates/shards/player_list_item.html", ) if err != nil { log.Fatal(err) @@ -88,27 +89,29 @@ func main() { log.Println("Created first activation code with ADMIN role:\n" + firstCode) } + router.Static("/static", "./static") + router.Static("/node_modules", "./node_modules") + f, _ := os.OpenFile("isc_rest.log", os.O_RDWR|os.O_APPEND|os.O_CREATE, 0660) utils.GinWriter = io.MultiWriter(f, os.Stdout) + logger := gin.LoggerWithWriter(utils.GinWriter, "/static/", "/node_modules/", "/favicon.ico") router.Use( - gin.LoggerWithWriter(utils.GinWriter, "/static"), + logger, gin.Recovery(), ) reader.Use( - gin.LoggerWithWriter(utils.GinWriter), + logger, gin.Recovery(), ) author.Use( - gin.LoggerWithWriter(utils.GinWriter), + logger, gin.Recovery(), ) admin.Use( - gin.LoggerWithWriter(utils.GinWriter), + logger, gin.Recovery(), ) - router.Static("/static", "./static") - router.GET("/login", loginPage) router.POST("/login", loginPost) router.GET("/logout", logout) diff --git a/pages.go b/pages.go index 3022c7c..fd67393 100644 --- a/pages.go +++ b/pages.go @@ -10,8 +10,14 @@ import ( ) func mainPage(c *gin.Context) { + username, ok := session.GetUsername(c) + if !ok { + username = "" + } + data := map[string]interface{}{ "UserRole": controllers.GetUserRoleByCtx(c), + "Username": username, } err := utils.MainPageTemplates.Execute(c.Writer, data) diff --git a/templates/components/bottom_controls.html b/templates/components/bottom_controls.html index 6d2ee60..ef636cc 100644 --- a/templates/components/bottom_controls.html +++ b/templates/components/bottom_controls.html @@ -3,11 +3,11 @@