diff --git a/CHANGELOG.md b/CHANGELOG.md index d80fc64..1a37707 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ # Change Log All notable changes to this project will be documented in this file. +## [0.1.2] - 2024-02-24 +### Added +- History page by date filtered +- Responsive menu + ## [0.1.1] - 2024-02-20 ### Added - Add/Edit plan diff --git a/README.md b/README.md index 79d826f..f0d6478 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,8 @@ Or use [docker-compose](docker-compose-local.yml) ## Roadmap +- [x] History filter - [ ] Auth -- [ ] History filter - [ ] Statistics page ## Thanks diff --git a/internal/web/date.go b/internal/web/date.go index 6d2575c..a7a600a 100644 --- a/internal/web/date.go +++ b/internal/web/date.go @@ -3,7 +3,6 @@ package web import ( "net/http" "sort" - "time" "github.com/gin-gonic/gin" // "github.com/aceberg/ClickAHabit/internal/models" @@ -12,7 +11,7 @@ import ( func dateHandler(c *gin.Context) { date := c.Param("date") - today := time.Now().Format("2006-01-02") + today := setToday() if today != lastToday { setTodayChecks() diff --git a/internal/web/history.go b/internal/web/history.go index c3efa16..a5f2f75 100644 --- a/internal/web/history.go +++ b/internal/web/history.go @@ -13,10 +13,21 @@ import ( func histHandler(c *gin.Context) { var guiData models.GuiData + date := c.Param("date") + guiData.Config = appConfig allChecks = db.Select(appConfig.DBPath) - guiData.Checks = allChecks + if date == "today" { + date = setToday() + } + guiData.Version = date + + for _, check := range allChecks { + if check.Date == date { + guiData.Checks = append(guiData.Checks, check) + } + } c.HTML(http.StatusOK, "header.html", guiData) c.HTML(http.StatusOK, "history.html", guiData) diff --git a/internal/web/public/js/history.js b/internal/web/public/js/history.js new file mode 100644 index 0000000..bb7c105 --- /dev/null +++ b/internal/web/public/js/history.js @@ -0,0 +1,18 @@ + +function setFormDate(where) { + dateStr = document.getElementById('realDate').value; + + if (where) { + let year = dateStr.substring(0,4); + let month = dateStr.substring(5,7); + let day = dateStr.substring(8,10); + var date = new Date(year, month-1, day); + + date.setDate(date.getDate() + parseInt(where)); + let left = date.toLocaleDateString('en-CA'); + + window.location.href = '/history/' + left; + } else { + window.location.href = '/history/' + dateStr; + } +} \ No newline at end of file diff --git a/internal/web/public/version b/internal/web/public/version index 51e1103..cd3d0a4 100644 --- a/internal/web/public/version +++ b/internal/web/public/version @@ -1 +1 @@ -VERSION=0.1.1 \ No newline at end of file +VERSION=0.1.2 \ No newline at end of file diff --git a/internal/web/templates/header.html b/internal/web/templates/header.html index cf71afe..8da4a11 100644 --- a/internal/web/templates/header.html +++ b/internal/web/templates/header.html @@ -45,7 +45,7 @@ Plan