Skip to content

Commit

Permalink
Release 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Feb 24, 2024
1 parent 5c1afe9 commit 6e8f637
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ Or use [docker-compose](docker-compose-local.yml)

## Roadmap

- [x] History filter
- [ ] Auth
- [ ] History filter
- [ ] Statistics page

## Thanks
Expand Down
3 changes: 1 addition & 2 deletions internal/web/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package web
import (
"net/http"
"sort"
"time"

"github.com/gin-gonic/gin"
// "github.com/aceberg/ClickAHabit/internal/models"
Expand All @@ -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()
Expand Down
13 changes: 12 additions & 1 deletion internal/web/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions internal/web/public/js/history.js
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 1 addition & 1 deletion internal/web/public/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=0.1.1
VERSION=0.1.2
2 changes: 1 addition & 1 deletion internal/web/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<a class="nav-link active" href="/plan/">Plan</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/history/">History</a>
<a class="nav-link active" href="/history/today">History</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/config/">Config</a>
Expand Down
16 changes: 15 additions & 1 deletion internal/web/templates/history.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{{ define "history.html" }}

<link rel="stylesheet" type="text/css" href="/fs/public/css/index.css" />
<script src="/fs/public/js/history.js"></script>
<body>
<div class="container-lg mt-3 table-responsive">
<div class="card border-primary">
<div class="card-header">
<div class="row">
<div class="col-md"></div>
<div class="col-md">
<div class="gap-3 hstack">
<button onclick='setFormDate(-1)' class="btn tr-button"><i class="bi bi-arrow-left-square" title="Back"></i></button>
<input type="date" value="{{ .Version }}" class="m-auto form-control" onchange='setFormDate()' id="realDate" style="width: 70%;">
<button onclick='setFormDate(+1)' class="btn tr-button"><i class="bi bi-arrow-right-square" title="Forward"></i></button>
</div>
</div>
<div class="col-md"></div>
</div>
</div>
<div class="card-body table-responsive">
<table class="table table-striped table-hover">
<thead>
Expand Down
8 changes: 7 additions & 1 deletion internal/web/today.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ import (
"github.com/aceberg/ClickAHabit/internal/models"
)

func setToday() string {
date := time.Now().Format("2006-01-02")

return date
}

func setTodayChecks() {

date := time.Now().Format("2006-01-02")
date := setToday()
lastToday = date
setChecksForDate(date)
}
Expand Down
20 changes: 10 additions & 10 deletions internal/web/webgui.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ func Gui(dirPath, nodePath string) {

router.StaticFS("/fs/", http.FS(pubFS)) // public

router.GET("/", indexHandler) // index.go
router.GET("/add/:id", addHandler) // add.go
router.GET("/config/", configHandler) // config.go
router.GET("/date/:date", dateHandler) // date.go
router.GET("/histdel/:id", histDel) // history.go
router.GET("/history/", histHandler) // history.go
router.GET("/plan/", planHandler) // plan.go
router.GET("/planedit/:id", editHandler) // plan-edit.go
router.GET("/plandel/:id", planDel) // plan.go
router.GET("/update/:date", updatePlan) // update.go
router.GET("/", indexHandler) // index.go
router.GET("/add/:id", addHandler) // add.go
router.GET("/config/", configHandler) // config.go
router.GET("/date/:date", dateHandler) // date.go
router.GET("/histdel/:id", histDel) // history.go
router.GET("/history/:date", histHandler) // history.go
router.GET("/plan/", planHandler) // plan.go
router.GET("/planedit/:id", editHandler) // plan-edit.go
router.GET("/plandel/:id", planDel) // plan.go
router.GET("/update/:date", updatePlan) // update.go

router.POST("/config/", saveConfigHandler) // config.go
router.POST("/planedit/", savePlanHandler) // plan-edit.go
Expand Down

0 comments on commit 6e8f637

Please sign in to comment.