Development

This commit is contained in:
Matthew Grotke 2026-05-30 15:04:55 -04:00
parent 01a636e842
commit b2264cd7b7

View file

@ -682,10 +682,7 @@ def collect_tokens():
tokens['NO_PENDING'] = 'true' if not pending_items else '' tokens['NO_PENDING'] = 'true' if not pending_items else ''
tokens['NO_DISMISSIBLE_PENDING'] = 'true' if not any(c != 'fix problems' for _, _, c, _ in pending_items) else '' tokens['NO_DISMISSIBLE_PENDING'] = 'true' if not any(c != 'fix problems' for _, _, c, _ in pending_items) else ''
tokens['APPLY_WARNING'] = ( tokens['APPLY_WARNING'] = (
f'<span class="btn-notice btn-notice-warning">' '<span class="tag" data-tooltip="Applying actions will briefly disrupt connections as network services are restarted.">note</span>'
f'{_load_icon("arrow-right")}'
f'Applying actions will briefly disrupt connections as network services are restarted.'
f'</span>'
if pending_items else '' if pending_items else ''
) )
done_ts_map = get_done_timestamps() done_ts_map = get_done_timestamps()
@ -929,13 +926,11 @@ def render_layout(view_id, content_html, tokens, page_name=None):
try: try:
import json as _j import json as _j
st = _j.load(open(HEALTH_FILE)) st = _j.load(open(HEALTH_FILE))
grouped = {'error': [], 'warning': []} problems = []
for section in ('configurations', 'logs'): for section in ('configurations', 'logs'):
for item in st.get(section, []): for item in st.get(section, []):
if item.get('status') == 'problem': if item.get('status') == 'problem':
sev = item.get('severity', 'error') problems.append(e(item.get('detail', item.get('name', ''))))
text = e(item.get('detail', item.get('name', '')))
grouped.setdefault(sev, []).append(text)
for item in st.get('services', []): for item in st.get('services', []):
if item.get('status') == 'problem': if item.get('status') == 'problem':
name = item.get('name', '') name = item.get('name', '')
@ -947,12 +942,11 @@ def render_layout(view_id, content_html, tokens, page_name=None):
if not item.get('enabled_ok'): if not item.get('enabled_ok'):
exp_parts.append(item.get('expected_enabled', 'enabled')) exp_parts.append(item.get('expected_enabled', 'enabled'))
act_parts.append(item.get('enabled', 'unknown')) act_parts.append(item.get('enabled', 'unknown'))
detail = ( problems.append(e(
f"The {utype} `{name}` is expected to be " f"The {utype} `{name}` is expected to be "
f"{' and '.join(exp_parts)} but is {' and '.join(act_parts)}." f"{' and '.join(exp_parts)} but is {' and '.join(act_parts)}."
) ))
grouped.setdefault(item.get('severity', 'error'), []).append(e(detail)) has_problems = bool(problems)
has_problems = any(items for items in grouped.values())
fix_suffix = '' fix_suffix = ''
fix_uuid = None fix_uuid = None
if has_problems: if has_problems:
@ -973,12 +967,9 @@ def render_layout(view_id, content_html, tokens, page_name=None):
fix_suffix = ('Fix pending. Click <strong>Apply Now</strong> below to fix.' fix_suffix = ('Fix pending. Click <strong>Apply Now</strong> below to fix.'
if view_id == 'actions' else if view_id == 'actions' else
'Fix pending. Visit the <strong>Actions</strong> page ASAP to apply fix.') 'Fix pending. Visit the <strong>Actions</strong> page ASAP to apply fix.')
for sev, items in grouped.items(): if problems:
if not items:
continue
cls = 'info-bar-danger' if sev == 'error' else 'info-bar-warning'
problems_list = ('<ul style="margin:0.25em 0;padding-left:1.25em">' problems_list = ('<ul style="margin:0.25em 0;padding-left:1.25em">'
+ ''.join(f'<li>{d}</li>' for d in items) + ''.join(f'<li>{d}</li>' for d in problems)
+ '</ul>') + '</ul>')
uuid_attr = (f' data-health-uuid="{e(fix_uuid)}"' uuid_attr = (f' data-health-uuid="{e(fix_uuid)}"'
if fix_uuid and _entry_ts_from_queue(fix_uuid) is not None else '') if fix_uuid and _entry_ts_from_queue(fix_uuid) is not None else '')
@ -988,7 +979,7 @@ def render_layout(view_id, content_html, tokens, page_name=None):
'<div style="font-weight:600;margin-bottom:0.25em">Health check - problems found:</div>' '<div style="font-weight:600;margin-bottom:0.25em">Health check - problems found:</div>'
+ problems_list + fix_html + problems_list + fix_html
+ '</div>') + '</div>')
problem_bars += f'<div class="info-bar {cls}">{content}</div>\n' problem_bars += f'<div class="info-bar info-bar-danger">{content}</div>\n'
except Exception: except Exception:
pass pass