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",
|
"type": "info_bar",
|
||||||
"variant": "info",
|
"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",
|
"type": "card",
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,14 @@ def collect_tokens(cfg):
|
||||||
cp = cfg.get('captive_portal', {})
|
cp = cfg.get('captive_portal', {})
|
||||||
captive_vlans = [v for v in cfg.get('vlans', []) if v.get('restricted_vlan') == 'c']
|
captive_vlans = [v for v in cfg.get('vlans', []) if v.get('restricted_vlan') == 'c']
|
||||||
|
|
||||||
if captive_vlans:
|
n = len(captive_vlans)
|
||||||
names = ', '.join(v['name'] for v in captive_vlans)
|
if n > 0:
|
||||||
tokens['CAPTIVE_STATUS_TEXT'] = f"Captive portal active on: {names}."
|
variant = 'success'
|
||||||
|
text = f'There are currently {n} captive portal VLAN{"s" if n != 1 else ""}. Captive portal is enabled.'
|
||||||
else:
|
else:
|
||||||
tokens['CAPTIVE_STATUS_TEXT'] = (
|
variant = 'warning'
|
||||||
'No captive portal VLANs configured. '
|
text = 'There are currently 0 captive portal VLANs. Captive portal is disabled.'
|
||||||
'Set Restricted VLAN = Captive Portal on the Network Layout page.'
|
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_HTTP_PORT'] = str(cp.get('http_port', 25328))
|
||||||
tokens['CAPTIVE_HTTPS_DOMAIN'] = cp.get('https_domain', '')
|
tokens['CAPTIVE_HTTPS_DOMAIN'] = cp.get('https_domain', '')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue