Skip to content

Commit

Permalink
log_list: Added magic handling for post requests to update the counts…
Browse files Browse the repository at this point in the history
… too
  • Loading branch information
fingon committed May 9, 2024
1 parent 4d31083 commit 4bb7542
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ local Lixie instance which probably does not exist.

- add error messages if log retrieval fails

- fix fts to update counters too

## Big features

- Optimize rule evaluation (it could be also used when generating rules for
Expand Down
8 changes: 7 additions & 1 deletion log.templ
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ templ LogList(m LogListModel) {
</ul>
}
@Col(2) {
<div class="float-end">
<div
class="float-end"
id="counts"
if m.Post {
hx-swap-oob="counts"
}
>
{ strconv.Itoa(m.TotalCount) } log entries
<br/>
{ strconv.Itoa(m.FilteredCount) } shown
Expand Down
5 changes: 4 additions & 1 deletion log_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ type LogListModel struct {
DisableActions bool
DisablePagination bool

// Is this post request (.. sigh ..)
Post bool

// Convenience results from filter()
EnableAccurateCounting bool
FilteredCount int
Expand Down Expand Up @@ -177,7 +180,7 @@ func logListHandler(db *data.Database) http.Handler {
http.Error(w, err.Error(), 400)
return
}
model := LogListModel{Config: config, DB: db, Limit: 20}
model := LogListModel{Config: config, DB: db, Limit: 20, Post: r.Method == "POST"}
model.Filter()
err = LogList(model).Render(r.Context(), w)
if err != nil {
Expand Down
16 changes: 13 additions & 3 deletions log_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4bb7542

Please sign in to comment.