Development
This commit is contained in:
parent
08ecf8f6ae
commit
e52fe9bf8a
2 changed files with 12 additions and 8 deletions
|
|
@ -17,7 +17,11 @@
|
|||
{
|
||||
"type": "info_bar",
|
||||
"variant": "info",
|
||||
"text": "%CAPTIVE_STATUS_TEXT%"
|
||||
"text": "Captive portal will be disabled if there are no VLANs specified as \"Restricted VLAN\" type \"Captive Portal\" on the Network Layout page."
|
||||
},
|
||||
{
|
||||
"type": "raw_html",
|
||||
"html": "%CAPTIVE_STATUS_BAR%"
|
||||
},
|
||||
{
|
||||
"type": "card",
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ def collect_tokens(cfg):
|
|||
cp = cfg.get('captive_portal', {})
|
||||
captive_vlans = [v for v in cfg.get('vlans', []) if v.get('restricted_vlan') == 'c']
|
||||
|
||||
if captive_vlans:
|
||||
names = ', '.join(v['name'] for v in captive_vlans)
|
||||
tokens['CAPTIVE_STATUS_TEXT'] = f"Captive portal active on: {names}."
|
||||
n = len(captive_vlans)
|
||||
if n > 0:
|
||||
variant = 'success'
|
||||
text = f'There are currently {n} captive portal VLAN{"s" if n != 1 else ""}. Captive portal is enabled.'
|
||||
else:
|
||||
tokens['CAPTIVE_STATUS_TEXT'] = (
|
||||
'No captive portal VLANs configured. '
|
||||
'Set Restricted VLAN = Captive Portal on the Network Layout page.'
|
||||
)
|
||||
variant = 'warning'
|
||||
text = 'There are currently 0 captive portal VLANs. Captive portal is disabled.'
|
||||
tokens['CAPTIVE_STATUS_BAR'] = f'<div class="info-bar info-bar-inline info-bar-{variant}">{text}</div>'
|
||||
|
||||
tokens['CAPTIVE_HTTP_PORT'] = str(cp.get('http_port', 25328))
|
||||
tokens['CAPTIVE_HTTPS_DOMAIN'] = cp.get('https_domain', '')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue