From dabd97e13c1b58e6b7fa01590e3a36337c9de165 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 10 Feb 2026 03:52:46 -0500 Subject: [PATCH] Dashboard: formatted timestamps (MM/DD/YYYY HH:MM TZ), inline category edit dropdown --- main.go | 23 ++++++++++++++++++ templates/dashboard.html | 50 ++++++++++++++++++++++++++-------------- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index 0f215b9..cd97d07 100644 --- a/main.go +++ b/main.go @@ -67,6 +67,7 @@ func main() { "truncate": truncateText, "categoryIcon": categoryIcon, "formatDate": formatDate, + "formatDateTime": formatDateTime, "lower": strings.ToLower, "title": strings.Title, "safe": func(s string) template.HTML { return template.HTML(s) }, @@ -164,6 +165,28 @@ func formatDate(s string) string { return s } +func formatDateTime(s string) string { + formats := []string{ + "2006-01-02T15:04:05-07:00", + "2006-01-02T15:04:05.999999-07:00", + "2006-01-02T15:04:05.999999", + "2006-01-02T15:04:05", + "2006-01-02 15:04:05", + "2006-01-02", + } + loc, _ := time.LoadLocation("America/New_York") + if loc == nil { + loc = time.UTC + } + for _, f := range formats { + if t, err := time.Parse(f, s); err == nil { + t = t.In(loc) + return t.Format("01/02/2006 3:04 PM EST") + } + } + return s +} + // Template rendering func renderTemplate(w http.ResponseWriter, name string, data interface{}) { diff --git a/templates/dashboard.html b/templates/dashboard.html index 0e3408c..b44e0e2 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -120,23 +120,17 @@ {{if .Stats.RecentUploads}}
{{range .Stats.RecentUploads}} - -
+ - - {{if .Vendor}} - - {{end}} - {{if .Amount}} - - {{end}} -
+ +
{{if eq .Status "processing"}} @@ -150,13 +144,18 @@ Error {{else}} - - {{title .Category}} - + {{end}} -

{{formatDate .ProcessedAt}}

+

{{formatDateTime .ProcessedAt}}

- +
{{end}}
{{else}} @@ -398,6 +397,23 @@ }, 2000); } + async function updateCategory(id, title, newCategory) { + try { + const res = await fetch('/api/document/' + id, { + method: 'PUT', + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({title: title, category: newCategory, notes: ''}) + }); + if (res.ok) { + showToast('Moved to ' + newCategory, 'success'); + } else { + showToast('Failed to update', 'error'); + } + } catch { + showToast('Failed to update', 'error'); + } + } + function showToast(message, type = 'info') { const colors = { success: 'bg-green-500',