From 799b5d5164e58d8869d012c6102e345fc6f4824b Mon Sep 17 00:00:00 2001 From: Matthias-vdE Date: Fri, 27 Feb 2026 10:52:05 +0100 Subject: [PATCH] Make attackers table sortable and cleanup time display. This update makes the Attackers by Total Requests table sortable by First Seen and Last Seen. It also changes the way datetimes are being displayed everywhere: Only show the time when the event happened today, show the full datetime when the event happened on another day. --- src/dependencies.py | 4 ++-- .../jinja2/dashboard/partials/attackers_table.html | 12 ++++++++++-- .../jinja2/dashboard/partials/suspicious_table.html | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/dependencies.py b/src/dependencies.py index 774d9dd..a713738 100644 --- a/src/dependencies.py +++ b/src/dependencies.py @@ -30,7 +30,7 @@ def get_templates() -> Jinja2Templates: return _templates -def _format_ts(value, time_only=False): +def _format_ts(value): """Custom Jinja2 filter for formatting ISO timestamps.""" if not value: return "N/A" @@ -39,7 +39,7 @@ def _format_ts(value, time_only=False): value = datetime.fromisoformat(value) except (ValueError, TypeError): return value - if time_only: + if value.date() == datetime.now().date(): return value.strftime("%H:%M:%S") return value.strftime("%m/%d/%Y %H:%M:%S") diff --git a/src/templates/jinja2/dashboard/partials/attackers_table.html b/src/templates/jinja2/dashboard/partials/attackers_table.html index 632137d..a235130 100644 --- a/src/templates/jinja2/dashboard/partials/attackers_table.html +++ b/src/templates/jinja2/dashboard/partials/attackers_table.html @@ -25,8 +25,16 @@ hx-swap="innerHTML"> Total Requests - First Seen - Last Seen + + First Seen + + Last Seen Location diff --git a/src/templates/jinja2/dashboard/partials/suspicious_table.html b/src/templates/jinja2/dashboard/partials/suspicious_table.html index 72a0480..4884dec 100644 --- a/src/templates/jinja2/dashboard/partials/suspicious_table.html +++ b/src/templates/jinja2/dashboard/partials/suspicious_table.html @@ -22,7 +22,7 @@ {{ activity.path | e }} {{ (activity.user_agent | default(''))[:80] | e }} - {{ activity.timestamp | format_ts(time_only=True) }} + {{ activity.timestamp | format_ts }}