Show recent activity from the actual account.
This commit is contained in:
parent
ed1b878b8d
commit
eb52b36f45
2 changed files with 25 additions and 17 deletions
20
html.go
20
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),
|
||||
|
|
|
|||
|
|
@ -179,27 +179,15 @@ body {
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range $i, $sr := .RecentRequests }}
|
||||
<tr>
|
||||
<td>Aug 24, 2023</td>
|
||||
<td>Inspection</td>
|
||||
<td>River Park Area</td>
|
||||
<td>{{ $sr.Date | timeSince }}</td>
|
||||
<td>Service Request</td>
|
||||
<td>{{ $sr.Location }}</td>
|
||||
<td><span class="badge bg-success">Completed</span></td>
|
||||
<td><a href="#" class="btn btn-sm btn-outline-primary">View</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Aug 23, 2023</td>
|
||||
<td>Service Request</td>
|
||||
<td>Westside Community</td>
|
||||
<td><span class="badge bg-warning">Pending</span></td>
|
||||
<td><a href="#" class="btn btn-sm btn-outline-primary">View</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Aug 22, 2023</td>
|
||||
<td>Source Treatment</td>
|
||||
<td>Lakeside Avenue</td>
|
||||
<td><span class="badge bg-info">In Progress</span></td>
|
||||
<td><a href="#" class="btn btn-sm btn-outline-primary">View</a></td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue