Skip to content

Commit

Permalink
(control) Clean up filtering UX in Events table
Browse files Browse the repository at this point in the history
  • Loading branch information
vlofgren committed Jan 18, 2024
1 parent 01b312f commit 67ee6f4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
Expand Up @@ -12,10 +12,7 @@

import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;

@Singleton
public class EventLogService {
Expand All @@ -41,15 +38,13 @@ public Object eventsListModel(Request request, Response response) {

List<EventLogTypeFilter> typeFilterList = new ArrayList<>();
List<String> typenames = getTypeNames();
typeFilterList.add(new EventLogTypeFilter("Show All", "", typeParam == null));
for (String typename : typenames) {
typeFilterList.add(new EventLogTypeFilter(typename, typename,
typename.equalsIgnoreCase(typeParam)));
}

List<EventLogServiceFilter> serviceFilterList = new ArrayList<>();
List<String> serviceNames = getServiceNames();
serviceFilterList.add(new EventLogServiceFilter("Show All", "", serviceParam == null));
for (String serviceName : serviceNames) {
serviceFilterList.add(new EventLogServiceFilter(serviceName, serviceName,
serviceName.equalsIgnoreCase(serviceParam)));
Expand Down Expand Up @@ -84,6 +79,9 @@ else if (typeParam != null) {
"events", entries,
"types", typeFilterList,
"services", serviceFilterList,
"serviceParam", Objects.requireNonNullElse(serviceParam, ""),
"typeParam", Objects.requireNonNullElse(typeParam, ""),
"afterParam", Objects.requireNonNullElse(afterParam, ""),
"next", next,
"elFilter", elFilter);

Expand Down
Expand Up @@ -9,24 +9,38 @@
<th>Message</th>
</tr>
<tr>

<form method="GET" action="/events">
<td>
<select name="service" id="service">
{{#each services}}<option value="{{value}}" {{#if current}}selected{{/if}} >{{name}}</option>{{/each}}
</select>
{{#if services}}
<div class="btn-group">
<button type="button" class="btn btn-secondary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
{{#if serviceParam}}{{serviceParam}}{{else}}Filter{{/if}}
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="?type={{typeParam}}&after={{afterParam}}">Show All</a></li>
{{#each services}}
<li><a class="dropdown-item" href="?service={{name}}&type={{typeParam}}&after={{afterParam}}">{{name}} {{#if current}}*{{/if}}</a></li>
{{/each}}
</ul>
</div>
{{/if}}
</td>
<td colspan="2"></td>
<td>
<select name="type" id="type">
{{#each types}}<option value="{{value}}" {{#if current}}selected{{/if}} >{{name}}</option>{{/each}}
</select>
</td>
<td>
<input type="submit" value="Filter Results">
{{#if types}}
<div class="btn-group">
<button type="button" class="btn btn-secondary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
{{#if typeParam}}{{typeParam}}{{else}}Filter{{/if}}
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="?service={{serviceParam}}&after={{afterParam}}">Show All</a></li>
{{#each types}}
<li><a class="dropdown-item" href="?type={{value}}&service={{serviceParam}}&after={{afterParam}}">{{name}} {{#if current}}*{{/if}}</a></li>
{{/each}}
</ul>
</div>
{{/if}}
</td>
</form>

<td></td>
</tr>
{{#each events}}
<tr>
Expand Down
Expand Up @@ -20,7 +20,7 @@
</button>
<ul class="dropdown-menu">
{{#each inboxes}}
<li><a class="dropdown-item" href="/message-queue?inbox={{this}}">{{this}}&nbsp;</a></li>
<li><a class="dropdown-item" href="/message-queue?inbox={{this}}">{{this}}</a></li>
{{/each}}
</ul>
</div>
Expand Down

0 comments on commit 67ee6f4

Please sign in to comment.