(control) Clean up filtering UX in Events table

This commit is contained in:
Viktor Lofgren 2024-01-18 12:35:39 +01:00
parent 01b312f14c
commit 67ee6f4126
3 changed files with 32 additions and 20 deletions

View File

@ -12,10 +12,7 @@ import spark.Response;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Singleton @Singleton
public class EventLogService { public class EventLogService {
@ -41,7 +38,6 @@ public class EventLogService {
List<EventLogTypeFilter> typeFilterList = new ArrayList<>(); List<EventLogTypeFilter> typeFilterList = new ArrayList<>();
List<String> typenames = getTypeNames(); List<String> typenames = getTypeNames();
typeFilterList.add(new EventLogTypeFilter("Show All", "", typeParam == null));
for (String typename : typenames) { for (String typename : typenames) {
typeFilterList.add(new EventLogTypeFilter(typename, typename, typeFilterList.add(new EventLogTypeFilter(typename, typename,
typename.equalsIgnoreCase(typeParam))); typename.equalsIgnoreCase(typeParam)));
@ -49,7 +45,6 @@ public class EventLogService {
List<EventLogServiceFilter> serviceFilterList = new ArrayList<>(); List<EventLogServiceFilter> serviceFilterList = new ArrayList<>();
List<String> serviceNames = getServiceNames(); List<String> serviceNames = getServiceNames();
serviceFilterList.add(new EventLogServiceFilter("Show All", "", serviceParam == null));
for (String serviceName : serviceNames) { for (String serviceName : serviceNames) {
serviceFilterList.add(new EventLogServiceFilter(serviceName, serviceName, serviceFilterList.add(new EventLogServiceFilter(serviceName, serviceName,
serviceName.equalsIgnoreCase(serviceParam))); serviceName.equalsIgnoreCase(serviceParam)));
@ -84,6 +79,9 @@ public class EventLogService {
"events", entries, "events", entries,
"types", typeFilterList, "types", typeFilterList,
"services", serviceFilterList, "services", serviceFilterList,
"serviceParam", Objects.requireNonNullElse(serviceParam, ""),
"typeParam", Objects.requireNonNullElse(typeParam, ""),
"afterParam", Objects.requireNonNullElse(afterParam, ""),
"next", next, "next", next,
"elFilter", elFilter); "elFilter", elFilter);

View File

@ -9,24 +9,38 @@
<th>Message</th> <th>Message</th>
</tr> </tr>
<tr> <tr>
<form method="GET" action="/events">
<td> <td>
<select name="service" id="service"> {{#if services}}
{{#each services}}<option value="{{value}}" {{#if current}}selected{{/if}} >{{name}}</option>{{/each}} <div class="btn-group">
</select> <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>
<td colspan="2"></td> <td colspan="2"></td>
<td> <td>
<select name="type" id="type"> {{#if types}}
{{#each types}}<option value="{{value}}" {{#if current}}selected{{/if}} >{{name}}</option>{{/each}} <div class="btn-group">
</select> <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> </td>
<td> <td></td>
<input type="submit" value="Filter Results">
</td>
</form>
</tr> </tr>
{{#each events}} {{#each events}}
<tr> <tr>

View File

@ -20,7 +20,7 @@
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
{{#each inboxes}} {{#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}} {{/each}}
</ul> </ul>
</div> </div>