Development

This commit is contained in:
Matthew Grotke 2026-05-27 20:56:30 -04:00
parent d8d1d46fd2
commit eed1d295dc
69 changed files with 3355 additions and 3230 deletions

View file

@ -0,0 +1,50 @@
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_config, queued_msg)
bp = Blueprint('actions', __name__)
_VIEW = '/view/view_actions'
@bp.route('/action/actions_cardpending_save', methods=['POST'])
@require_level('administrator')
def actions_cardpending_save():
session['apply_changes_immediately'] = 'apply_changes_immediately' in request.form
flash('Preference saved.', 'success')
return redirect(_VIEW)
@bp.route('/action/actions_cardpending_applynow', methods=['POST'])
@require_level('administrator')
def actions_cardpending_applynow():
pending = get_dashboard_pending()
if not pending:
flash('No pending changes to apply.', 'info')
return redirect(_VIEW)
flush_pending_to_queue()
if any(cmd != 'fix problems' for _, _, cmd, _ in pending):
flash('Changes queued.', 'success')
return redirect(_VIEW)
@bp.route('/action/actions_cardhistory_revertselected', methods=['POST'])
@require_level('administrator')
def actions_cardhistory_revertselected():
selected_uuids = request.form.getlist('selected_uuids')
if not selected_uuids:
flash('No items selected.', 'info')
return redirect(_VIEW)
succeeded, failed = 0, 0
for uuid in selected_uuids:
msg, ok = revert_snapshot_to_config(uuid)
if ok:
succeeded += 1
else:
flash(msg, 'error')
failed += 1
if succeeded:
plural = 's' if succeeded != 1 else ''
flash(f'{succeeded} change{plural} reverted.', 'success')
return redirect(_VIEW)

View file

@ -0,0 +1,112 @@
{
"id": "view_actions",
"client_requirement": "client_is_viewer+",
"items": [
{
"type": "header_page_title",
"items": [
{
"type": "h1",
"text": "Actions"
},
{
"type": "p",
"text": "Apply or stage pending configuration changes."
}
]
},
{
"type": "card",
"label": "Pending Actions",
"client_requirement": "client_is_administrator+",
"items": [
{
"type": "form",
"action": "/action/actions_cardpending_applynow",
"method": "post",
"items": [
{
"type": "raw_html",
"html": "%PENDING_ACTIONS_HTML%"
},
{
"type": "button_row",
"items": [
{
"type": "button_primary",
"text": "Apply Now",
"disabled": "%NO_PENDING%"
},
{
"type": "raw_html",
"html": "%APPLY_WARNING%"
}
]
}
]
},
{
"type": "hr"
},
{
"type": "form",
"action": "/action/actions_cardpending_save",
"method": "post",
"items": [
{
"type": "field",
"label": "Apply Changes Immediately",
"name": "apply_changes_immediately",
"input_type": "checkbox",
"value": "%GENERAL_APPLY_ON_SAVE%",
"hint": "When enabled, saved changes are queued immediately. When disabled, changes accumulate in Pending Actions until you click Apply Now."
},
{
"type": "button_row",
"items": [
{
"type": "button_primary",
"action": "/action/actions_cardpending_save",
"method": "post",
"text": "Save"
},
{
"type": "button_cancel",
"text": "Cancel"
}
]
}
]
}
]
},
{
"type": "card",
"label": "Change History",
"client_requirement": "client_is_administrator+",
"items": [
{
"type": "form",
"action": "/action/actions_cardhistory_revertselected",
"method": "post",
"items": [
{
"type": "raw_html",
"html": "%CHANGE_HISTORY_HTML%"
},
{
"type": "button_row",
"items": [
{
"type": "button_danger",
"text": "Revert Selected",
"disabled": "%NO_HISTORY%"
}
]
}
]
}
]
}
]
}