Development

This commit is contained in:
Matthew Grotke 2026-05-25 23:57:34 -04:00
parent 3ee1a6f0de
commit 73d2df6be5
3 changed files with 86 additions and 97 deletions

View file

@ -255,26 +255,23 @@ def _lock_mtime():
return None
def _build_timing_msg(entry_ts, cmd, action_label='Configuration saved'):
if not _apply_changes_immediately():
return f'{action_label}. Click Apply Now on the Configuration Changes card to apply.'
def _timing_status_msg(entry_ts, action_label):
"""Return a flash message for a command already written to the queue."""
if _is_locked():
mtime = _lock_mtime()
if entry_ts is not None and mtime and entry_ts < mtime:
return f'{action_label}. Changes are being applied now.'
return f'{action_label}. Changes will be applied on the next run.'
return f'{action_label}. Your changes are being applied now...'
return f'{action_label}. Your changes will be applied on the next run.'
timing = _format_timing(_seconds_until_next_run())
if timing:
return f'{action_label}. Changes will be applied {timing}.'
if cmd is None:
return f'{action_label}. The processing service is not running.'
parts = cmd.split()
cli_cmd = f'sudo python3 {parts[0]}.py --{parts[1]}' if len(parts) == 2 else cmd
install_cmd = 'sudo python3 install.py'
from markupsafe import Markup
return Markup(f'{action_label}. The command processing service is not installed. '
f'Run <strong>{install_cmd}</strong> to enable it, '
f'or <strong>{cli_cmd}</strong> to apply manually.')
return f'{action_label}. Your changes will be applied {timing}.'
return f'{action_label}. The processing service is not running.'
def _build_timing_msg(entry_ts, action_label='Configuration saved'):
if not _apply_changes_immediately():
return f'{action_label}. Visit Actions page to apply your changes.'
return _timing_status_msg(entry_ts, action_label)
def queue_command(cmd, description=''):
@ -287,7 +284,7 @@ def queued_msg(cmd=None, description='', action_label='Configuration saved'):
entry_ts = None
if cmd is not None:
_entry_uuid, entry_ts = queue_command(cmd)
return _build_timing_msg(entry_ts, cmd, action_label)
return _build_timing_msg(entry_ts, action_label)
# Snapshot system ===================================================
@ -434,7 +431,7 @@ def save_config_with_snapshot(new_config, path, key, operation, before, after,
else:
_queue_pending_presigned(cmd, entry_uuid, entry_ts)
return _build_timing_msg(entry_ts, cmd)
return _build_timing_msg(entry_ts)
# Misc ==============================================================