diff --git a/docker/routlin-dash/app/action_actions.py b/docker/routlin-dash/app/action_actions.py index 9e281a3..39e7163 100644 --- a/docker/routlin-dash/app/action_actions.py +++ b/docker/routlin-dash/app/action_actions.py @@ -1,7 +1,7 @@ from flask import Blueprint, request, redirect, flash, session from auth import require_level from config_utils import (flush_pending_to_queue, get_dashboard_pending, - revert_snapshot_to_core, + revert_snapshot_to_config, queued_msg, _is_locked, _format_timing, _seconds_until_next_run) bp = Blueprint('action_actions', __name__) @@ -36,6 +36,13 @@ def actions_cardpending_applynow(): return redirect(_VIEW) +@bp.route('/action/queue_core_apply', methods=['POST']) +@require_level('administrator') +def queue_core_apply(): + flash(queued_msg('core apply', action_label='Apply queued'), 'success') + return redirect(_VIEW) + + @bp.route('/action/actions_cardhistory_revertselected', methods=['POST']) @require_level('administrator') def actions_cardhistory_revertselected(): @@ -45,7 +52,7 @@ def actions_cardhistory_revertselected(): return redirect(_VIEW) succeeded, failed = 0, 0 for uuid in selected_uuids: - msg, ok = revert_snapshot_to_core(uuid) + msg, ok = revert_snapshot_to_config(uuid) if ok: succeeded += 1 else: diff --git a/docker/routlin-dash/app/config_utils.py b/docker/routlin-dash/app/config_utils.py index 568212c..bc420f6 100644 --- a/docker/routlin-dash/app/config_utils.py +++ b/docker/routlin-dash/app/config_utils.py @@ -328,7 +328,7 @@ def _items_match(item, ref): return item == ref -def revert_snapshot_to_core(entry_uuid): +def revert_snapshot_to_config(entry_uuid): """Apply the inverse of a snapshot to config.json and queue a new pending change. Returns (flash_message, success_bool). @@ -388,10 +388,10 @@ def load_snapshot_for_uuid(entry_uuid): return None -def save_config_with_snapshot(new_core, path, key, operation, before, after, +def save_config_with_snapshot(new_config, path, key, operation, before, after, description='', cmd='core apply', queue=True): """ - Write a .snapshots/{ts}-{uuid}.json file, save new_core to disk, and + Write a .snapshots/{ts}-{uuid}.json file, save new_config to disk, and optionally create a pending queue entry. Returns a flash message string. queue=False: skips queueing and records the change directly in @@ -420,7 +420,7 @@ def save_config_with_snapshot(new_core, path, key, operation, before, after, with open(os.path.join(SNAPSHOTS_DIR, f'{entry_ts}-{entry_uuid}.json'), 'w') as f: json.dump(snapshot, f, indent=2) - save_config(new_core) + save_config(new_config) if not queue: with open(DASHBOARD_DONE, 'a') as f: diff --git a/docker/routlin-dash/app/view_page.py b/docker/routlin-dash/app/view_page.py index 75551c9..0af3419 100644 --- a/docker/routlin-dash/app/view_page.py +++ b/docker/routlin-dash/app/view_page.py @@ -1700,7 +1700,17 @@ def render_layout(view_id, content_html, tokens): + '') fix_html = '' if fix_cmds: - fix_items = ''.join(f'
{e(c)}{e(c)}