summaryrefslogtreecommitdiff
path: root/internal/handlers/timeline.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-24 20:28:15 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-24 20:28:15 -1000
commit22efca3118676926dec4af74fe8e225606063a35 (patch)
tree9ecbf7885fb97bb0b6666452109916359ad0f59c /internal/handlers/timeline.go
parentc290113bd1a8af694b648bba4c801e00b049683a (diff)
Fix UI bugs and add Timeline view
Bug fixes: - #25: Replace 📅 with 🗓️ to avoid misleading date display - #30: Standardize background opacity (shopping items now use bg-white/5) New feature: - #11: Add Timeline view showing chronological events/tasks/meals Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/handlers/timeline.go')
-rw-r--r--internal/handlers/timeline.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/internal/handlers/timeline.go b/internal/handlers/timeline.go
new file mode 100644
index 0000000..b923d3e
--- /dev/null
+++ b/internal/handlers/timeline.go
@@ -0,0 +1,59 @@
+package handlers
+
+import (
+ "net/http"
+ "strconv"
+ "time"
+
+ "task-dashboard/internal/models"
+)
+
+// HandleTimeline renders the timeline view
+func (h *Handler) HandleTimeline(w http.ResponseWriter, r *http.Request) {
+ // Parse query params
+ startStr := r.URL.Query().Get("start")
+ daysStr := r.URL.Query().Get("days")
+
+ var start time.Time
+ if startStr != "" {
+ parsed, err := time.ParseInLocation("2006-01-02", startStr, time.Local)
+ if err == nil {
+ start = parsed
+ } else {
+ start = time.Now()
+ }
+ } else {
+ start = time.Now()
+ }
+
+ // Normalize start to beginning of day
+ start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, start.Location())
+
+ days := 3 // Default
+ if daysStr != "" {
+ if d, err := strconv.Atoi(daysStr); err == nil && d > 0 {
+ days = d
+ }
+ }
+
+ end := start.AddDate(0, 0, days)
+
+ // Call BuildTimeline
+ items, err := BuildTimeline(r.Context(), h.store, h.googleCalendarClient, start, end)
+ if err != nil {
+ JSONError(w, http.StatusInternalServerError, "Failed to build timeline", err)
+ return
+ }
+
+ data := struct {
+ Items []models.TimelineItem
+ Start time.Time
+ Days int
+ }{
+ Items: items,
+ Start: start,
+ Days: days,
+ }
+
+ HTMLResponse(w, h.templates, "timeline-tab", data)
+}