Add expandable rows to dashboard tables
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e9758499ff
commit
536aee1f31
4 files changed
+88
-3
No files matched your search
@@ -31,7 +31,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<h2>Letzte 50 Fänge</h2>
|
<h2>Letzte 50 Fänge <span class="hint">Zeile anklicken zum Aufklappen</span></h2>
|
||||||
@if (data.Recent.Count == 0)
|
@if (data.Recent.Count == 0)
|
||||||
{
|
{
|
||||||
<p class="muted">Noch nichts gefangen.</p>
|
<p class="muted">Noch nichts gefangen.</p>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var trapEvent in data.Recent)
|
@foreach (var trapEvent in data.Recent)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr data-expand="event:@trapEvent.Id" tabindex="0" aria-expanded="false">
|
||||||
<td class="nowrap">@trapEvent.StartedAt.ToLocalTime().ToString("dd.MM. HH:mm:ss")</td>
|
<td class="nowrap">@trapEvent.StartedAt.ToLocalTime().ToString("dd.MM. HH:mm:ss")</td>
|
||||||
<td class="mono">@trapEvent.RemoteIp</td>
|
<td class="mono">@trapEvent.RemoteIp</td>
|
||||||
<td class="mono clip" title="@trapEvent.Target">@trapEvent.Target</td>
|
<td class="mono clip" title="@trapEvent.Target">@trapEvent.Target</td>
|
||||||
@@ -71,6 +71,8 @@
|
|||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<script src="@Assets["dashboard.js"]" defer></script>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private DashboardData? _data;
|
private DashboardData? _data;
|
||||||
private DateTime _loadedAt;
|
private DateTime _loadedAt;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var entry in Entries)
|
@foreach (var entry in Entries)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr data-expand="@($"{KeyLabel}:{entry.Key}")" tabindex="0" aria-expanded="false">
|
||||||
<td class="mono clip" title="@entry.Key">@entry.Key</td>
|
<td class="mono clip" title="@entry.Key">@entry.Key</td>
|
||||||
<td class="num">@entry.Count.ToString("N0")</td>
|
<td class="num">@entry.Count.ToString("N0")</td>
|
||||||
<td class="num">@Formatting.Duration(entry.HoldTime)</td>
|
<td class="num">@Formatting.Duration(entry.HoldTime)</td>
|
||||||
|
|||||||
@@ -157,6 +157,35 @@ tbody tr:last-child td {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr[data-expand] {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hint {
|
||||||
|
margin-left: 8px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr[data-expand]:hover td {
|
||||||
|
background: color-mix(in srgb, var(--text) 4%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
tr[data-expand]:focus-visible {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr[data-expand].open td {
|
||||||
|
background: color-mix(in srgb, var(--accent) 7%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.open .clip {
|
||||||
|
white-space: normal;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
.outcome {
|
.outcome {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
(() => {
|
||||||
|
const storageKey = "flypaper.expanded";
|
||||||
|
|
||||||
|
const load = () => {
|
||||||
|
try {
|
||||||
|
return new Set(JSON.parse(sessionStorage.getItem(storageKey) ?? "[]"));
|
||||||
|
} catch {
|
||||||
|
return new Set();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const save = keys => {
|
||||||
|
try {
|
||||||
|
sessionStorage.setItem(storageKey, JSON.stringify([...keys]));
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const stored = load();
|
||||||
|
const expanded = new Set();
|
||||||
|
|
||||||
|
for (const row of document.querySelectorAll("tr[data-expand]")) {
|
||||||
|
const key = row.dataset.expand;
|
||||||
|
|
||||||
|
const apply = open => {
|
||||||
|
row.classList.toggle("open", open);
|
||||||
|
row.setAttribute("aria-expanded", String(open));
|
||||||
|
open ? expanded.add(key) : expanded.delete(key);
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggle = () => {
|
||||||
|
apply(!row.classList.contains("open"));
|
||||||
|
save(expanded);
|
||||||
|
};
|
||||||
|
|
||||||
|
apply(stored.has(key));
|
||||||
|
|
||||||
|
row.addEventListener("click", () => {
|
||||||
|
if (!window.getSelection()?.isCollapsed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toggle();
|
||||||
|
});
|
||||||
|
|
||||||
|
row.addEventListener("keydown", event => {
|
||||||
|
if (event.key === "Enter" || event.key === " ") {
|
||||||
|
event.preventDefault();
|
||||||
|
toggle();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
save(expanded);
|
||||||
|
})();
|
||||||
Reference in new issue
Block a user