Development
This commit is contained in:
parent
66be049f14
commit
54a0bff14c
3 changed files with 5 additions and 11 deletions
|
|
@ -731,7 +731,7 @@ def config_datasource(name):
|
||||||
row['local_entries'] = ''
|
row['local_entries'] = ''
|
||||||
row['source_display'] = row.get('url', '')
|
row['source_display'] = row.get('url', '')
|
||||||
vlan_names = used_by.get(bl.get('name', ''), [])
|
vlan_names = used_by.get(bl.get('name', ''), [])
|
||||||
row['used_by'] = json.dumps([{'n': n, 'd': ''} for n in vlan_names])
|
row['used_by'] = json.dumps([{'n': n, 'd': ''} for n in vlan_names]) if vlan_names else '<span class="text-muted">Not used by any VLANs</span>'
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -988,6 +988,8 @@ def build_table_cell(value, render_fn, col_class='', field='', row_idx=None,
|
||||||
if render_fn == 'tag_list':
|
if render_fn == 'tag_list':
|
||||||
opts = render_options or {}
|
opts = render_options or {}
|
||||||
prefer_short = opts.get('prefer_short', False)
|
prefer_short = opts.get('prefer_short', False)
|
||||||
|
if value.startswith('<'):
|
||||||
|
return f'{td_open}{value}</td>'
|
||||||
try:
|
try:
|
||||||
items = json.loads(value) if value.startswith('[') else [s.strip() for s in value.split(',')]
|
items = json.loads(value) if value.startswith('[') else [s.strip() for s in value.split(',')]
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,6 @@ def _last_dl_time():
|
||||||
def blocklist_stats_html(cfg):
|
def blocklist_stats_html(cfg):
|
||||||
db_rows = config_utils._bl_db_rows()
|
db_rows = config_utils._bl_db_rows()
|
||||||
last_dl = _last_dl_time()
|
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 = ''
|
rows = ''
|
||||||
for bl in cfg.get('dns_blocking', {}).get('blocklists', []):
|
for bl in cfg.get('dns_blocking', {}).get('blocklists', []):
|
||||||
name = bl.get('name', '')
|
name = bl.get('name', '')
|
||||||
|
|
@ -94,15 +90,12 @@ def blocklist_stats_html(cfg):
|
||||||
warn = WARN_ICON
|
warn = WARN_ICON
|
||||||
else:
|
else:
|
||||||
warn = ''
|
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 += (
|
rows += (
|
||||||
'<tr>'
|
'<tr>'
|
||||||
f'<td class="table-cell">{factory.e(name)}</td>'
|
f'<td class="table-cell">{factory.e(name)}</td>'
|
||||||
f'<td class="table-cell">{entries}</td>'
|
f'<td class="table-cell">{entries}</td>'
|
||||||
f'<td class="table-cell">{size_str}</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">{factory.e(last_refreshed)}{warn}</td>'
|
||||||
f'<td class="table-cell">{used_by}</td>'
|
|
||||||
'</tr>'
|
'</tr>'
|
||||||
)
|
)
|
||||||
if not rows:
|
if not rows:
|
||||||
|
|
@ -113,7 +106,6 @@ def blocklist_stats_html(cfg):
|
||||||
'<th class="table-header">Entries</th>'
|
'<th class="table-header">Entries</th>'
|
||||||
'<th class="table-header">Size</th>'
|
'<th class="table-header">Size</th>'
|
||||||
'<th class="table-header">Last Refreshed</th>'
|
'<th class="table-header">Last Refreshed</th>'
|
||||||
'<th class="table-header">Used by VLAN(s)</th>'
|
|
||||||
'</tr></thead>'
|
'</tr></thead>'
|
||||||
f'<tbody>{rows}</tbody></table>'
|
f'<tbody>{rows}</tbody></table>'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue