Development
This commit is contained in:
parent
58534c3915
commit
114da3cd1c
3 changed files with 33 additions and 4 deletions
|
|
@ -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>'
|
||||
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':
|
||||
opts = render_options or {}
|
||||
if str(value).lower() in ('true', '1', 'yes', 'enabled'):
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@
|
|||
"value": "all",
|
||||
"filter_col": "vlan",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"label": "Active",
|
||||
"field": "active",
|
||||
"label": "Status",
|
||||
"field": "account_status",
|
||||
"class": "col-narrow",
|
||||
"render": "badge_yes_no"
|
||||
"render": "badge_account_status"
|
||||
}
|
||||
],
|
||||
"row_actions": [
|
||||
|
|
|
|||
|
|
@ -92,6 +92,13 @@ def collect_tokens(cfg):
|
|||
'<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')]
|
||||
tokens['CRED_VLAN_FILTER_OPTIONS'] = (
|
||||
'<option value="all">-- All VLANs --</option>' +
|
||||
|
|
@ -130,7 +137,12 @@ def collect_tokens(cfg):
|
|||
expires_seconds = r.get('expires_seconds', 0)
|
||||
is_expired = (expires_seconds > 0 and
|
||||
(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)
|
||||
|
||||
content = factory.load_json(f'{factory.PAGES_DIR}/clientcredentials/content.json')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue