Development

This commit is contained in:
Matthew Grotke 2026-06-08 10:48:44 -04:00
parent 58534c3915
commit 114da3cd1c
3 changed files with 33 additions and 4 deletions

View file

@ -925,6 +925,16 @@ def build_table_cell(value, render_fn, col_class='', field='', row_idx=None,
inner = '<span class="badge badge-disabled">Disabled</span>' inner = '<span class="badge badge-disabled">Disabled</span>'
return f'{td_open}{inner}</td>' return f'{td_open}{inner}</td>'
if render_fn == 'badge_account_status':
v = str(value)
if v == 'Active':
inner = '<span class="badge badge-enabled">Active</span>'
elif v == 'Expired':
inner = '<span class="badge badge-danger">Expired</span>'
else:
inner = '<span class="badge badge-disabled">Disabled</span>'
return f'{td_open}{inner}</td>'
if render_fn == 'badge_yes_no': if render_fn == 'badge_yes_no':
opts = render_options or {} opts = render_options or {}
if str(value).lower() in ('true', '1', 'yes', 'enabled'): if str(value).lower() in ('true', '1', 'yes', 'enabled'):

View file

@ -38,6 +38,13 @@
"value": "all", "value": "all",
"filter_col": "vlan", "filter_col": "vlan",
"options": "%CRED_VLAN_FILTER_OPTIONS%" "options": "%CRED_VLAN_FILTER_OPTIONS%"
},
{
"type": "select",
"name": "status_filter",
"value": "all",
"filter_col": "account_status",
"options": "%STATUS_FILTER_OPTIONS%"
} }
] ]
}, },
@ -72,10 +79,10 @@
"class": "col-narrow" "class": "col-narrow"
}, },
{ {
"label": "Active", "label": "Status",
"field": "active", "field": "account_status",
"class": "col-narrow", "class": "col-narrow",
"render": "badge_yes_no" "render": "badge_account_status"
} }
], ],
"row_actions": [ "row_actions": [

View file

@ -92,6 +92,13 @@ def collect_tokens(cfg):
'<option value="802.1X">802.1X Supplicant</option>' '<option value="802.1X">802.1X Supplicant</option>'
) )
tokens['STATUS_FILTER_OPTIONS'] = (
'<option value="all">-- All Account Statuses --</option>'
'<option value="Active">Active Accounts</option>'
'<option value="Disabled">Disabled Accounts</option>'
'<option value="Expired">Expired Accounts</option>'
)
vlans = [v for v in cfg.get('vlans', []) if not v.get('is_vpn')] vlans = [v for v in cfg.get('vlans', []) if not v.get('is_vpn')]
tokens['CRED_VLAN_FILTER_OPTIONS'] = ( tokens['CRED_VLAN_FILTER_OPTIONS'] = (
'<option value="all">-- All VLANs --</option>' + '<option value="all">-- All VLANs --</option>' +
@ -130,7 +137,12 @@ def collect_tokens(cfg):
expires_seconds = r.get('expires_seconds', 0) expires_seconds = r.get('expires_seconds', 0)
is_expired = (expires_seconds > 0 and is_expired = (expires_seconds > 0 and
(r.get('date_set', 0) + expires_seconds) <= int(time.time())) (r.get('date_set', 0) + expires_seconds) <= int(time.time()))
r['active'] = r.get('enabled', 0) == 1 and not is_expired if r.get('enabled', 0) != 1:
r['account_status'] = 'Disabled'
elif is_expired:
r['account_status'] = 'Expired'
else:
r['account_status'] = 'Active'
display_rows.append(r) display_rows.append(r)
content = factory.load_json(f'{factory.PAGES_DIR}/clientcredentials/content.json') content = factory.load_json(f'{factory.PAGES_DIR}/clientcredentials/content.json')