Development

This commit is contained in:
Matthew Grotke 2026-06-09 12:07:38 -04:00
parent eae133f18e
commit 66be049f14
2 changed files with 11 additions and 11 deletions

View file

@ -49,8 +49,12 @@ def _last_dl_time():
def blocklist_stats_html(cfg):
db_rows = config_utils._bl_db_rows()
last_dl = _last_dl_time()
db_rows = config_utils._bl_db_rows()
last_dl = _last_dl_time()
bl_vlans = {}
for vlan in cfg.get('vlans', []):
for bl_name in vlan.get('use_blocklists', []):
bl_vlans.setdefault(bl_name, []).append(vlan['name'])
rows = ''
for bl in cfg.get('dns_blocking', {}).get('blocklists', []):
name = bl.get('name', '')
@ -90,12 +94,15 @@ def blocklist_stats_html(cfg):
warn = WARN_ICON
else:
warn = ''
vlan_names = bl_vlans.get(name, [])
used_by = ', '.join(factory.e(v) for v in vlan_names) if vlan_names else '<span class="text-muted">Not used by any VLANs</span>'
rows += (
'<tr>'
f'<td class="table-cell">{factory.e(name)}</td>'
f'<td class="table-cell">{entries}</td>'
f'<td class="table-cell">{size_str}</td>'
f'<td class="table-cell">{factory.e(last_refreshed)}{warn}</td>'
f'<td class="table-cell">{used_by}</td>'
'</tr>'
)
if not rows:
@ -106,6 +113,7 @@ def blocklist_stats_html(cfg):
'<th class="table-header">Entries</th>'
'<th class="table-header">Size</th>'
'<th class="table-header">Last Refreshed</th>'
'<th class="table-header">Used by VLAN(s)</th>'
'</tr></thead>'
f'<tbody>{rows}</tbody></table>'
)