diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index a9558c4..98b8ac2 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -6,18 +6,19 @@ - [x] Local Themes and JS - [x] BodyWeight Chart - [x] Weight page +- [x] Version on Config page ## IN PROGRESS +- [ ] Mobile layout ## TODO - [ ] Login/Password - [ ] Statistics page -- [ ] Mobile layout - [ ] PostgreSQL DB option -- [ ] Add exercise group with 1 button ## MAYBE +- [ ] Add exercise group with 1 button - [ ] Sets [#1](https://github.com/aceberg/ExerciseDiary/issues/1) - [ ] Weight field take decimals [#4](https://github.com/aceberg/ExerciseDiary/issues/4) - [ ] Multiple users diff --git a/internal/db/sqlite.go b/internal/db/sqlite.go index 8c26803..7184f02 100644 --- a/internal/db/sqlite.go +++ b/internal/db/sqlite.go @@ -1,7 +1,7 @@ package db import ( - // "sync" + "sync" "github.com/jmoiron/sqlx" @@ -12,7 +12,7 @@ import ( "github.com/aceberg/ExerciseDiary/internal/models" ) -// var mu sync.Mutex +var mu sync.Mutex func connect(path string) *sqlx.DB { dbx, err := sqlx.Connect("sqlite", path) @@ -23,10 +23,10 @@ func connect(path string) *sqlx.DB { func exec(path string, sqlStatement string) { - // mu.Lock() + mu.Lock() dbx := connect(path) _, err := dbx.Exec(sqlStatement) - // mu.Unlock() + mu.Unlock() check.IfError(err) } @@ -34,10 +34,10 @@ func exec(path string, sqlStatement string) { // SelectEx - select all exercises from DB func SelectEx(path string) (exes []models.Exercise) { - // mu.Lock() + mu.Lock() dbx := connect(path) err := dbx.Select(&exes, "SELECT * FROM exercises ORDER BY ID ASC") - // mu.Unlock() + mu.Unlock() check.IfError(err) @@ -47,10 +47,10 @@ func SelectEx(path string) (exes []models.Exercise) { // SelectSet - select all sets from DB func SelectSet(path string) (sets []models.Set) { - // mu.Lock() + mu.Lock() dbx := connect(path) err := dbx.Select(&sets, "SELECT * FROM sets ORDER BY ID ASC") - // mu.Unlock() + mu.Unlock() check.IfError(err) @@ -60,10 +60,10 @@ func SelectSet(path string) (sets []models.Set) { // SelectW - select all weight from DB func SelectW(path string) (w []models.BodyWeight) { - // mu.Lock() + mu.Lock() dbx := connect(path) err := dbx.Select(&w, "SELECT * FROM weight ORDER BY ID ASC") - // mu.Unlock() + mu.Unlock() check.IfError(err) diff --git a/internal/models/models.go b/internal/models/models.go index 5558220..0ba2df8 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -67,4 +67,5 @@ type GuiData struct { GroupMap map[string]string OneEx Exercise HeatMap []HeatMapData + Version string } diff --git a/internal/web/config.go b/internal/web/config.go index 9ff4a75..3119226 100644 --- a/internal/web/config.go +++ b/internal/web/config.go @@ -3,11 +3,10 @@ package web import ( "log" "net/http" - // "strconv" "github.com/gin-gonic/gin" - // "github.com/aceberg/ExerciseDiary/internal/check" + "github.com/aceberg/ExerciseDiary/internal/check" "github.com/aceberg/ExerciseDiary/internal/conf" "github.com/aceberg/ExerciseDiary/internal/models" ) @@ -19,6 +18,11 @@ func configHandler(c *gin.Context) { guiData.Themes = []string{"cerulean", "cosmo", "cyborg", "darkly", "emerald", "flatly", "grass", "journal", "litera", "lumen", "lux", "materia", "minty", "morph", "pulse", "quartz", "sand", "sandstone", "simplex", "sketchy", "slate", "solar", "spacelab", "superhero", "united", "vapor", "yeti", "zephyr"} + file, err := pubFS.ReadFile("public/version") + check.IfError(err) + version := string(file) + guiData.Version = version[8:] + c.HTML(http.StatusOK, "header.html", guiData) c.HTML(http.StatusOK, "config.html", guiData) } diff --git a/internal/web/public/version b/internal/web/public/version new file mode 100644 index 0000000..cd3d0a4 --- /dev/null +++ b/internal/web/public/version @@ -0,0 +1 @@ +VERSION=0.1.2 \ No newline at end of file diff --git a/internal/web/templates/config.html b/internal/web/templates/config.html index 9a2f7fb..9662ca1 100644 --- a/internal/web/templates/config.html +++ b/internal/web/templates/config.html @@ -50,13 +50,19 @@
● After changing Host or Port the app must be restarted
-● Please, check out my other apps on GitHub
-● Want your own Self-Hosted app written in Go? Contact and prices here
-● Please, check out my other apps on GitHub
+● Want your own Self-Hosted app written in Go? Contact and prices here