From eb52b36f45e5fed82a02cb6f815a5b97ffe23ebf Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 7 Nov 2025 11:03:06 +0000 Subject: [PATCH] Show recent activity from the actual account. --- html.go | 20 ++++++++++++++++++++ templates/dashboard.html | 22 +++++----------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/html.go b/html.go index 3fb33787..eb0e57d7 100644 --- a/html.go +++ b/html.go @@ -54,6 +54,7 @@ type ContentDashboard struct { CountServiceRequests int LastSync string Org string + RecentRequests []ServiceRequestSummary User User } type ContentPlaceholder struct { @@ -62,6 +63,11 @@ type ContentSignin struct { InvalidCredentials bool } type ContentSignup struct{} +type ServiceRequestSummary struct { + Date time.Time + Location string + Status string +} type User struct { DisplayName string Initials string @@ -123,12 +129,26 @@ func htmlDashboard(ctx context.Context, w io.Writer, user *models.User) error { if err != nil { return fmt.Errorf("Failed to get service count: %v", err) } + recentRequests, err := org.FSServicerequests(sm.OrderBy("creationdate").Desc(), sm.Limit(10)).All(ctx, PGInstance.BobDB) + if err != nil { + return fmt.Errorf("Failed to get recent service: %v", err) + } + + requests := make([]ServiceRequestSummary, 0) + for _, r := range recentRequests { + requests = append(requests, ServiceRequestSummary{ + Date: time.UnixMilli(r.Creationdate.MustGet()), + Location: r.Reqaddr1.MustGet(), + Status: "Completed", + }) + } data := ContentDashboard{ CountInspections: int(inspectionCount), CountMosquitoSources: int(sourceCount), CountServiceRequests: int(serviceCount), LastSync: syncString, Org: org.Name.MustGet(), + RecentRequests: requests, User: User{ DisplayName: user.DisplayName, Initials: extractInitials(user.DisplayName), diff --git a/templates/dashboard.html b/templates/dashboard.html index b7250469..eb848191 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -179,27 +179,15 @@ body { + {{ range $i, $sr := .RecentRequests }} - Aug 24, 2023 - Inspection - River Park Area + {{ $sr.Date | timeSince }} + Service Request + {{ $sr.Location }} Completed View - - Aug 23, 2023 - Service Request - Westside Community - Pending - View - - - Aug 22, 2023 - Source Treatment - Lakeside Avenue - In Progress - View - + {{ end }}