(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.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
@Singleton
public class EventLogService {
@ -41,7 +38,6 @@ public class EventLogService {
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)));
@ -49,7 +45,6 @@ public class EventLogService {
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)));
@ -84,6 +79,9 @@ public class EventLogService {
"events", entries,
"types", typeFilterList,
"services", serviceFilterList,
"serviceParam", Objects.requireNonNullElse(serviceParam, ""),
"typeParam", Objects.requireNonNullElse(typeParam, ""),
"afterParam", Objects.requireNonNullElse(afterParam, ""),
"next", next,
"elFilter", elFilter);

View File

@ -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>
{{#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>
<td>
<input type="submit" value="Filter Results">
</td>
</form>
<td></td>
</tr>
{{#each events}}
<tr>

View File

@ -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>