Skip to content

Commit

Permalink
Version on config page
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Jan 6, 2024
1 parent 2bde2d8 commit 70a3a8f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 21 deletions.
5 changes: 3 additions & 2 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions internal/db/sqlite.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package db

import (
// "sync"
"sync"

"github.com/jmoiron/sqlx"

Expand All @@ -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)
Expand All @@ -23,21 +23,21 @@ 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)
}

// 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)

Expand All @@ -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)

Expand All @@ -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)

Expand Down
1 change: 1 addition & 0 deletions internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ type GuiData struct {
GroupMap map[string]string
OneEx Exercise
HeatMap []HeatMapData
Version string
}
8 changes: 6 additions & 2 deletions internal/web/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions internal/web/public/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION=0.1.2
12 changes: 9 additions & 3 deletions internal/web/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@
</div>
</div>
<div class="col-md">
<div class="card border-primary">
<div class="card-header">Version</div>
<div class="card-body">
<a href="https://github.com/aceberg/ExerciseDiary/releases/tag/{{ .Version }}" target="_blank">{{ .Version }}</a>
</div>
</div>
<br>
<div class="card border-primary">
<div class="card-header">About</div>
<div class="card-body">
<p>● After changing <b>Host</b> or <b>Port</b> the app must be restarted</p>
<p>● Please, check out my other apps on <a href="https://github.com/aceberg">GitHub</a></p>
<p>● Want your own Self-Hosted app written in Go? Contact and prices <a href="https://github.com/aceberg">here</a></p>
</div>
<p>● Please, check out my other apps on <a href="https://github.com/aceberg" target="_blank">GitHub</a></p>
<p>● Want your own Self-Hosted app written in Go? Contact and prices <a href="https://github.com/aceberg" target="_blank">here</a></p>
</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions internal/web/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ <h5 class="modal-title">Add weight</h5>
<div class="card-body">
<!-- <div class="hstack gap-2"> -->
<div class="row justify-content-evenly">
<div class="col-lg-7">
<div class="col-md-8">
<!-- <div class="chart-container" style="max-width: fit-content;">
<canvas id="matrix-chart" style="max-height: 100px; width: 760px;"></canvas>
</div> -->
<div id="matrix-container" class="chart-container" style="max-height: 100px; width: 1100px;overflow-x: scroll;">
<div id="matrix-container" class="chart-container" style="max-height: 100px; width: 1150px;overflow-x: scroll;">
<canvas id="matrix-chart" style="height: 100%; width: 100%;"></canvas>
</div>
</div>
<div class="col-md-2">
<div class="col-md-3">
<div class="chart-container" style="max-width: fit-content">
<canvas id="weight-chart" style="max-height: 100px;"></canvas>
</div>
</div>
<div class="col-sm-1">
<div class="col-md">
<button class="btn del-set-button" title="Add weight" data-bs-toggle="modal" data-bs-target="#mWeight" onclick='setWeightDate()'>
<h4><i class="bi bi-window-plus"></i></h4>
</button>
Expand Down

0 comments on commit 70a3a8f

Please sign in to comment.