Development
This commit is contained in:
parent
21db91d512
commit
be7ccd3390
4 changed files with 67 additions and 52 deletions
|
|
@ -57,7 +57,7 @@ def _check_ip_conflicts(ip, vlan):
|
|||
try:
|
||||
if (ipaddress.IPv4Address(pool_start) <= ipaddress.IPv4Address(ip)
|
||||
<= ipaddress.IPv4Address(pool_end)):
|
||||
return f'{ip} falls within the dynamic pool range ({pool_start}–{pool_end}).'
|
||||
return f'{ip} falls within the dynamic pool range ({pool_start}-{pool_end}).'
|
||||
except Exception:
|
||||
pass
|
||||
identity_ips = {s['ip'] for s in vlan.get('server_identities', []) if s.get('ip')}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ CONFIGS_DIR = '/configs'
|
|||
LEVEL_RANK = {'nothing': 0, 'viewer': 1, 'administrator': 2, 'manager': 3}
|
||||
|
||||
|
||||
# -- Access level --------------------------------------------------------------
|
||||
# Access level ======================================================
|
||||
|
||||
def _client_level():
|
||||
return LEVEL_RANK.get(session.get('access_level', 'nothing'), 0)
|
||||
|
|
@ -36,7 +36,7 @@ def _passes(req, level):
|
|||
return False
|
||||
|
||||
|
||||
# -- File loaders --------------------------------------------------------------
|
||||
# File loaders ======================================================
|
||||
|
||||
def _load_json(path):
|
||||
try:
|
||||
|
|
@ -58,7 +58,7 @@ def _load_css():
|
|||
return ''
|
||||
|
||||
|
||||
# -- Shell helper --------------------------------------------------------------
|
||||
# Shell helper ======================================================
|
||||
|
||||
def _run(cmd):
|
||||
try:
|
||||
|
|
@ -166,7 +166,7 @@ def _resolve_iface(vlan, core):
|
|||
return lan if vid == 1 else f'{lan}.{vid}'
|
||||
|
||||
|
||||
# -- Live data loaders ---------------------------------------------------------
|
||||
# Live data loaders =================================================
|
||||
|
||||
def _live_dhcp_leases():
|
||||
rows = []
|
||||
|
|
@ -233,7 +233,7 @@ def _fmt_bytes(n):
|
|||
return f'{n:.1f} TB'
|
||||
|
||||
|
||||
# -- Config data loaders -------------------------------------------------------
|
||||
# Config data loaders ===============================================
|
||||
|
||||
def _config_datasource(name):
|
||||
core = _load_core()
|
||||
|
|
@ -307,7 +307,7 @@ def _config_datasource(name):
|
|||
row['credentials'] = f"U: {p.get('username', '-')}"
|
||||
elif ptype in ('cloudflare', 'duckdns'):
|
||||
tok = p.get('api_token', '')
|
||||
row['credentials'] = f'API Token: {tok[:8]}…' if tok else '(not set)'
|
||||
row['credentials'] = f'API Token: {tok[:8]}...' if tok else '(not set)'
|
||||
else:
|
||||
row['credentials'] = '-'
|
||||
row['hostnames'] = json.dumps(p.get('hostnames', p.get('subdomains', [])))
|
||||
|
|
@ -343,7 +343,7 @@ def _config_datasource(name):
|
|||
return []
|
||||
|
||||
|
||||
# -- Live stat helpers ---------------------------------------------------------
|
||||
# Live stat helpers =================================================
|
||||
|
||||
def _get_dnsmasq_stats():
|
||||
stats = {'queries': '-', 'hits': '-', 'hit_rate': '-',
|
||||
|
|
@ -492,7 +492,7 @@ def _vpn_info():
|
|||
return {}
|
||||
|
||||
|
||||
# -- Token collection ----------------------------------------------------------
|
||||
# Token collection ==================================================
|
||||
|
||||
def collect_tokens():
|
||||
tokens = {}
|
||||
|
|
@ -650,7 +650,7 @@ def collect_tokens():
|
|||
return tokens
|
||||
|
||||
|
||||
# -- HTML helpers --------------------------------------------------------------
|
||||
# HTML helpers ======================================================
|
||||
|
||||
def e(text):
|
||||
return html_mod.escape(str(text))
|
||||
|
|
@ -686,7 +686,7 @@ def _expand_fields(obj, tokens):
|
|||
return obj
|
||||
|
||||
|
||||
# -- Content item renderers ----------------------------------------------------
|
||||
# Content item renderers ============================================
|
||||
|
||||
def render_items(items, tokens, inherited_req=None):
|
||||
level = _client_level()
|
||||
|
|
@ -1325,7 +1325,7 @@ def _load_datasource(spec):
|
|||
return []
|
||||
|
||||
|
||||
# -- Layout renderer -----------------------------------------------------------
|
||||
# Layout renderer ===================================================
|
||||
|
||||
def render_layout(view_id, content_html, tokens):
|
||||
css = _load_css()
|
||||
|
|
@ -1433,7 +1433,7 @@ def _render_nav_item(item, active_view, level, in_dropdown=False, inherited_req=
|
|||
return ''
|
||||
|
||||
|
||||
# -- Inline JavaScript ---------------------------------------------------------
|
||||
# Inline JavaScript =================================================
|
||||
|
||||
def _inline_js():
|
||||
return r"""
|
||||
|
|
@ -1988,7 +1988,7 @@ var validateEl;
|
|||
range: 'Octet out of range' },
|
||||
url: { invalid_char: 'Invalid character', invalid_struct: 'Invalid URL format' },
|
||||
port: { invalid_char: 'Digits only', out_of_range: 'Must be between 1 and 65535' },
|
||||
ipv4cidr: { invalid_char: 'Invalid character', invalid_struct: 'Prefix must be 0–32',
|
||||
ipv4cidr: { invalid_char: 'Invalid character', invalid_struct: 'Prefix must be 0-32',
|
||||
invalid_range: 'Octet out of range' },
|
||||
endpoint: { invalid_char: 'Invalid character', invalid_struct: 'Invalid hostname or IP',
|
||||
invalid_range: 'Octet out of range', invalid: 'Invalid IP address' },
|
||||
|
|
@ -2027,7 +2027,7 @@ var validateEl;
|
|||
}
|
||||
};
|
||||
|
||||
// Regular fields (not inside editable lists) — initial state + expose _triggerValidate
|
||||
// Regular fields (not inside editable lists) - initial state + expose _triggerValidate
|
||||
document.querySelectorAll('input[data-validate]').forEach(function(el) {
|
||||
if (el.closest('.editable-list')) return;
|
||||
el._triggerValidate = function() { validateEl(el); };
|
||||
|
|
@ -2072,7 +2072,7 @@ var validateEl;
|
|||
submitBtns.forEach(function(b) { b.disabled = true; });
|
||||
cancelBtns.forEach(function(b) { b.disabled = true; });
|
||||
|
||||
// Only track fields named in original — naturally excludes config_hash,
|
||||
// Only track fields named in original - naturally excludes config_hash,
|
||||
// row_index, etc., while including hidden inputs (e.g. picker values).
|
||||
function snapshot() {
|
||||
var state = {};
|
||||
|
|
@ -2342,7 +2342,7 @@ function startApplyPoller(uuid, bar, mine) {
|
|||
"""
|
||||
|
||||
|
||||
# -- Routes --------------------------------------------------------------------
|
||||
# Routes ============================================================
|
||||
|
||||
@bp.route('/')
|
||||
def index():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue