Tri colonnes hostname, uptime, reboot (asc/desc) avec indicateur fleche
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
df03852c86
commit
2ac263e80a
@ -153,6 +153,29 @@ async def audit_full_list(request: Request, db=Depends(get_db)):
|
||||
q = search.lower()
|
||||
audits = [a for a in audits if q in a.hostname.lower()]
|
||||
|
||||
# Tri
|
||||
sort = request.query_params.get("sort", "hostname")
|
||||
sort_dir = request.query_params.get("dir", "asc")
|
||||
if sort == "hostname":
|
||||
audits.sort(key=lambda a: a.hostname.lower(), reverse=(sort_dir == "desc"))
|
||||
elif sort == "uptime":
|
||||
def uptime_days(a):
|
||||
u = a.uptime or ""
|
||||
d = 0
|
||||
import re as _re
|
||||
m = _re.search(r"(\d+) year", u)
|
||||
if m: d += int(m.group(1)) * 365
|
||||
m = _re.search(r"(\d+) month", u)
|
||||
if m: d += int(m.group(1)) * 30
|
||||
m = _re.search(r"(\d+) week", u)
|
||||
if m: d += int(m.group(1)) * 7
|
||||
m = _re.search(r"(\d+) day", u)
|
||||
if m: d += int(m.group(1))
|
||||
return d
|
||||
audits.sort(key=uptime_days, reverse=(sort_dir == "desc"))
|
||||
elif sort == "reboot":
|
||||
audits.sort(key=lambda a: (1 if a.reboot_required else 0), reverse=(sort_dir == "desc"))
|
||||
|
||||
# Pagination
|
||||
total_filtered = len(audits)
|
||||
total_pages = max(1, (total_filtered + per_page - 1) // per_page)
|
||||
@ -164,6 +187,7 @@ async def audit_full_list(request: Request, db=Depends(get_db)):
|
||||
"app_name": APP_NAME, "audits": audits_page, "kpis": kpis,
|
||||
"filter": filtre, "search": search, "domain": domain,
|
||||
"all_domains": all_domains, "all_zones": all_zones,
|
||||
"sort": sort, "sort_dir": sort_dir,
|
||||
"page": page, "total_pages": total_pages, "total_filtered": total_filtered,
|
||||
"msg": request.query_params.get("msg"),
|
||||
})
|
||||
|
||||
@ -94,15 +94,15 @@
|
||||
<div class="card overflow-x-auto">
|
||||
<table class="w-full table-cyber text-xs">
|
||||
<thead><tr>
|
||||
<th class="text-left p-2">Hostname</th>
|
||||
<th class="text-left p-2"><a href="/audit-full?sort=hostname&dir={% if sort == 'hostname' and sort_dir == 'asc' %}desc{% else %}asc{% endif %}{% if filter %}&filter={{ filter }}{% endif %}{% if search %}&q={{ search }}{% endif %}{% if domain %}&domain={{ domain }}{% endif %}" class="hover:text-cyber-accent">Hostname {% if sort == 'hostname' %}{{ '▲' if sort_dir == 'asc' else '▼' }}{% endif %}</a></th>
|
||||
<th class="p-2">OS</th>
|
||||
<th class="p-2">Kernel</th>
|
||||
<th class="p-2">Uptime</th>
|
||||
<th class="p-2"><a href="/audit-full?sort=uptime&dir={% if sort == 'uptime' and sort_dir == 'desc' %}asc{% else %}desc{% endif %}{% if filter %}&filter={{ filter }}{% endif %}{% if search %}&q={{ search }}{% endif %}{% if domain %}&domain={{ domain }}{% endif %}" class="hover:text-cyber-accent">Uptime {% if sort == 'uptime' %}{{ '▲' if sort_dir == 'asc' else '▼' }}{% endif %}</a></th>
|
||||
<th class="p-2">Services</th>
|
||||
<th class="p-2">Process</th>
|
||||
<th class="p-2">Ports</th>
|
||||
<th class="p-2">Conn</th>
|
||||
<th class="p-2">Reboot</th>
|
||||
<th class="p-2"><a href="/audit-full?sort=reboot&dir={% if sort == 'reboot' and sort_dir == 'desc' %}asc{% else %}desc{% endif %}{% if filter %}&filter={{ filter }}{% endif %}{% if search %}&q={{ search }}{% endif %}{% if domain %}&domain={{ domain }}{% endif %}" class="hover:text-cyber-accent">Reboot {% if sort == 'reboot' %}{{ '▲' if sort_dir == 'asc' else '▼' }}{% endif %}</a></th>
|
||||
<th class="p-2">Date</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user