Skip to content

Commit

Permalink
UI: Don't display all results by default
Browse files Browse the repository at this point in the history
The current behaviour of the UI is to load all results - even those
which are "gone" - and display them, unpaginated, in the browser.

For large result sets this is pretty slow to load. It's also not
necessary to see expired results. Users of the UI generally just want to
know what's happening now.

This replaces the "?active" query string with "?all" and flips the
defaults around. The ActiveOnly flag in the template is now AllResults.
The button behaviour is the same - labelled as "Active only" and
green/white depending on current state.
  • Loading branch information
jamesog committed Apr 14, 2019
1 parent 64a491c commit 8b9da39
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ type indexData struct {
Authenticated bool
User User
URI string
ActiveOnly bool
AllResults bool
Submission submission
scanData
}
Expand Down Expand Up @@ -464,7 +464,7 @@ func index(w http.ResponseWriter, r *http.Request) {
ip := q.Get("ip")
firstSeen := q.Get("firstseen")
lastSeen := q.Get("lastseen")
_, activeOnly := q["active"]
_, allResults := q["all"]

results, err := resultData(ip, firstSeen, lastSeen)
if err != nil {
Expand All @@ -482,7 +482,7 @@ func index(w http.ResponseWriter, r *http.Request) {
Authenticated: true,
User: user,
URI: r.URL.Path,
ActiveOnly: activeOnly,
AllResults: allResults,
Submission: sub,
scanData: results,
}
Expand Down
2 changes: 1 addition & 1 deletion views/_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</div>
</form>
<a class="btn btn-primary navbar-btn" href="/job">New scan</a>
<a class="btn btn-{{ if .ActiveOnly }}success{{ else }}default{{ end }} navbar-btn" href="/{{ if not .ActiveOnly }}?active{{ end }}">Active only</a>
<a class="btn btn-{{ if not .AllResults }}success{{ else }}default{{ end }} navbar-btn" href="/{{ if not .AllResults }}?all{{ end }}">Active only</a>
{{ end }}
{{- if ne .User.Email "" }}
<ul class="nav navbar-nav navbar-right">
Expand Down
4 changes: 2 additions & 2 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</tr>
</thead>
<tbody>
{{- $ActiveOnly := .ActiveOnly }}
{{- $AllResults := .AllResults }}
{{- range .Results }}
{{- if not (and $ActiveOnly .Gone) }}
{{- if and $AllResults .Gone }}
<tr>
<td>
{{- if .New }}<span class="label label-danger">New</span>{{ end -}}
Expand Down

0 comments on commit 8b9da39

Please sign in to comment.