Development
This commit is contained in:
parent
d5dfb637fc
commit
2e4921ab73
4 changed files with 48 additions and 1 deletions
|
|
@ -731,7 +731,7 @@ def config_datasource(name):
|
|||
row['local_entries'] = ''
|
||||
row['source_display'] = row.get('url', '')
|
||||
vlan_names = used_by.get(bl.get('name', ''), [])
|
||||
row['used_by'] = json.dumps([{'n': n, 'd': n} for n in vlan_names])
|
||||
row['used_by'] = json.dumps([{'n': n, 'd': ''} for n in vlan_names])
|
||||
rows.append(row)
|
||||
return rows
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,13 @@ def blocklists_delete():
|
|||
before = copy.deepcopy(items[idx])
|
||||
name = before.get('name', str(idx))
|
||||
items.pop(idx)
|
||||
|
||||
for vlan in cfg.get('vlans', []):
|
||||
current = set(vlan.get('use_blocklists', []))
|
||||
if name in current:
|
||||
current.discard(name)
|
||||
vlan['use_blocklists'] = sorted(current)
|
||||
|
||||
errors = validate.validate_config(cfg)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
|
|
@ -152,6 +159,19 @@ def blocklists_edit():
|
|||
items[idx]['save_as'] = _save_as_from_name(fields['name'], 'conf')
|
||||
items[idx].pop('local_lines', None)
|
||||
|
||||
old_name = before.get('name', '')
|
||||
used_by_vlans = set(request.form.getlist('used_by_vlans'))
|
||||
for vlan in cfg.get('vlans', []):
|
||||
vlan_name = vlan.get('name', '')
|
||||
current = set(vlan.get('use_blocklists', []))
|
||||
if old_name and old_name != fields['name']:
|
||||
current.discard(old_name)
|
||||
if vlan_name in used_by_vlans:
|
||||
current.add(fields['name'])
|
||||
else:
|
||||
current.discard(fields['name'])
|
||||
vlan['use_blocklists'] = sorted(current)
|
||||
|
||||
errors = validate.validate_config(cfg)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
|
|
@ -202,6 +222,17 @@ def addblocklist_add():
|
|||
}
|
||||
|
||||
blocklists.append(entry)
|
||||
|
||||
used_by_vlans = set(request.form.getlist('used_by_vlans'))
|
||||
for vlan in cfg.get('vlans', []):
|
||||
vlan_name = vlan.get('name', '')
|
||||
current = set(vlan.get('use_blocklists', []))
|
||||
if vlan_name in used_by_vlans:
|
||||
current.add(fields['name'])
|
||||
else:
|
||||
current.discard(fields['name'])
|
||||
vlan['use_blocklists'] = sorted(current)
|
||||
|
||||
errors = validate.validate_config(cfg)
|
||||
if errors:
|
||||
for msg in errors:
|
||||
|
|
|
|||
|
|
@ -146,6 +146,10 @@
|
|||
"type": "raw_html",
|
||||
"html": "</div>"
|
||||
},
|
||||
{
|
||||
"type": "raw_html",
|
||||
"html": "%VLAN_USED_BY_CHECKBOXES%"
|
||||
},
|
||||
{
|
||||
"type": "button_row",
|
||||
"items": [
|
||||
|
|
|
|||
|
|
@ -99,6 +99,18 @@ def collect_tokens(cfg):
|
|||
tokens['DNS_LOG_TAIL'], tokens['DNS_LOG_SUMMARY'] = _dnsblocking_log_tail(cfg)
|
||||
blocklists = cfg.get('dns_blocking', {}).get('blocklists', [])
|
||||
tokens['BLOCKLIST_EXISTING_NAMES_JS'] = json.dumps([bl.get('name', '') for bl in blocklists])
|
||||
vlans = cfg.get('vlans', [])
|
||||
vlan_checkboxes = ''.join(
|
||||
f'<label class="form-checkbox-row">'
|
||||
f'<input type="checkbox" name="used_by_vlans" value="{factory.e(v["name"])}" class="form-checkbox">'
|
||||
f' <span class="form-checkbox-label">{factory.e(v["name"])}</span>'
|
||||
f'</label>'
|
||||
for v in vlans if v.get('name')
|
||||
)
|
||||
tokens['VLAN_USED_BY_CHECKBOXES'] = (
|
||||
f'<div class="form-group"><label class="form-label">Used By</label>'
|
||||
f'<div>{vlan_checkboxes}</div></div>'
|
||||
) if vlan_checkboxes else ''
|
||||
content = factory.load_json(f'{factory.PAGES_DIR}/dnsblocking/content.json')
|
||||
for table_item in factory.iter_table_items(content.get('items', [])):
|
||||
ds = table_item.get('datasource', '')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue