From 0afdd32b135495c64ff8e4a44e4f512af814ea0f Mon Sep 17 00:00:00 2001 From: aceberg <1502200+aceberg@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:24:38 +0700 Subject: [PATCH] Sort Exs --- internal/db/edit.go | 7 ++++--- internal/models/models.go | 1 + internal/web/exercise.go | 1 + internal/web/index.go | 10 +++++++--- internal/web/public/favicon.png | Bin 0 -> 11557 bytes internal/web/templates/exercise.html | 4 ++++ internal/web/templates/header.html | 2 +- 7 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 internal/web/public/favicon.png diff --git a/internal/db/edit.go b/internal/db/edit.go index a62dfd5..e95b5c2 100644 --- a/internal/db/edit.go +++ b/internal/db/edit.go @@ -12,6 +12,7 @@ func Create(path string) { sqlStatement := `CREATE TABLE IF NOT EXISTS exercises ( "ID" INTEGER PRIMARY KEY, "GR" TEXT, + "PLACE" TEXT, "NAME" TEXT, "DESCR" TEXT, "IMAGE" TEXT, @@ -35,14 +36,14 @@ func Create(path string) { // InsertEx - insert one exercise into DB func InsertEx(path string, ex models.Exercise) { - sqlStatement := `INSERT INTO exercises (GR, NAME, DESCR, IMAGE, COLOR, WEIGHT, REPS) - VALUES ('%s','%s','%s','%s','%s','%d','%d');` + sqlStatement := `INSERT INTO exercises (GR, PLACE, NAME, DESCR, IMAGE, COLOR, WEIGHT, REPS) + VALUES ('%s','%s','%s','%s','%s','%s','%d','%d');` ex.Group = quoteStr(ex.Group) ex.Name = quoteStr(ex.Name) ex.Descr = quoteStr(ex.Descr) - sqlStatement = fmt.Sprintf(sqlStatement, ex.Group, ex.Name, ex.Descr, ex.Image, ex.Color, ex.Weight, ex.Reps) + sqlStatement = fmt.Sprintf(sqlStatement, ex.Group, ex.Place, ex.Name, ex.Descr, ex.Image, ex.Color, ex.Weight, ex.Reps) exec(path, sqlStatement) } diff --git a/internal/models/models.go b/internal/models/models.go index 8c8394a..59bd442 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -17,6 +17,7 @@ type Conf struct { type Exercise struct { ID int `db:"ID"` Group string `db:"GR"` + Place string `db:"PLACE"` Name string `db:"NAME"` Descr string `db:"DESCR"` Image string `db:"IMAGE"` diff --git a/internal/web/exercise.go b/internal/web/exercise.go index bc64b37..7892279 100644 --- a/internal/web/exercise.go +++ b/internal/web/exercise.go @@ -43,6 +43,7 @@ func saveExerciseHandler(c *gin.Context) { var oneEx models.Exercise oneEx.Group = c.PostForm("group") + oneEx.Place = c.PostForm("place") oneEx.Name = c.PostForm("name") oneEx.Descr = c.PostForm("descr") diff --git a/internal/web/index.go b/internal/web/index.go index 7611674..081e283 100644 --- a/internal/web/index.go +++ b/internal/web/index.go @@ -3,6 +3,7 @@ package web import ( "fmt" "net/http" + "sort" "github.com/gin-gonic/gin" @@ -20,14 +21,18 @@ func indexHandler(c *gin.Context) { guiData.ExData = exData guiData.GroupMap = createGroupMap() + // Sort exercises by Place + sort.Slice(guiData.ExData.Exs, func(i, j int) bool { + return guiData.ExData.Exs[i].Place < guiData.ExData.Exs[j].Place + }) + c.HTML(http.StatusOK, "header.html", guiData) c.HTML(http.StatusOK, "index.html", guiData) } func createGroupMap() map[string]string { - - grMap := make(map[string]string) i := 0 + grMap := make(map[string]string) for _, ex := range exData.Exs { @@ -37,6 +42,5 @@ func createGroupMap() map[string]string { i = i + 1 } } - return grMap } diff --git a/internal/web/public/favicon.png b/internal/web/public/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..2c3a6345bddb0497c8d232a8203f8c56451c3f4e GIT binary patch literal 11557 zcmeHtcTiK`x9>?plWGA0X)2+KhzLk06a@kTf^;d;q)8VDJwcHwCG-wodKc+Z5*r{@ zsnVk~>7lof-1xh5|G6`F=G~e5X5PHHnPg7R&fe>sv-ir{YkfYSsK+|$47As10RUit zYdp{g05JJ07@(mdANCQWr{n{Lw+h^VhWrYmv5O?1U+~Z{^#%aOFMmIv6k$dVawGf8 zhbAwdxIcgCXYFMV`1$$WadLCj6k*yHd=BZlO?5W9dDi-Pop5{p2 z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-s3ibSlVxaPrQjPpRtudjt71G)Voi|IK-BN@6x0%VCcchdo^l4I0#H-AfrW0*+shnmhdHiW8z zsNk4hoSjtL-n!36_HiOcg$u?Z#4vzOfvQ??$8#B9N{3lwf}*kU8ki2rsU1~xr{2`I zBxwG|x!QzacZ$-_F352I4{%WY{T#OWGz{0rFC{pbw9*j7iFjaY-&?< zbHR)ArV*v|XYC($1$)W5+rLlIX!*x^}PZL{0*Y8t!8dHVJ9X2T1&0V0zJ@9Myn z7D@!i-R3S#Wl=X7si&FIly$|>6SxslWObkrUkpkrvE7d&-}h|@a16pXW6}T89C{1l z{h%CcqaV&mFS{EVEBf3^GQCX4iKR50+Pf7vgJ+Z;cRg?teX9_oBzfx@+A6Rc?>7_v zaGroup + + Place in group + + Name diff --git a/internal/web/templates/header.html b/internal/web/templates/header.html index eefdb07..269820d 100644 --- a/internal/web/templates/header.html +++ b/internal/web/templates/header.html @@ -7,7 +7,7 @@ - +