Development
This commit is contained in:
parent
a78df48804
commit
fc78e20f0e
4 changed files with 33 additions and 31 deletions
|
|
@ -8,17 +8,17 @@ bp = Blueprint('action_actions', __name__)
|
|||
_VIEW = '/view/view_actions'
|
||||
|
||||
|
||||
@bp.route('/action/general_cardpendingchanges_save', methods=['POST'])
|
||||
@bp.route('/action/actions_cardoptions_save', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def general_cardpendingchanges_save():
|
||||
def actions_cardoptions_save():
|
||||
session['apply_changes_immediately'] = 'apply_changes_immediately' in request.form
|
||||
flash('Preference saved.', 'success')
|
||||
return redirect(_VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/general_cardpendingchanges_applyselected', methods=['POST'])
|
||||
@bp.route('/action/actions_cardpendingchanges_applyselected', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def general_cardpendingchanges_applyselected():
|
||||
def actions_cardpendingchanges_applyselected():
|
||||
items = get_dashboard_pending()
|
||||
if not items:
|
||||
flash('No pending changes to apply.', 'info')
|
||||
|
|
@ -36,8 +36,8 @@ def general_cardpendingchanges_applyselected():
|
|||
return redirect(_VIEW)
|
||||
|
||||
|
||||
@bp.route('/action/general_cardpendingchanges_deleteselected', methods=['POST'])
|
||||
@bp.route('/action/actions_cardpendingchanges_revertselected', methods=['POST'])
|
||||
@require_level('administrator')
|
||||
def general_cardpendingchanges_deleteselected():
|
||||
def actions_cardpendingchanges_revertselected():
|
||||
flash('Not yet implemented.', 'info')
|
||||
return redirect(_VIEW)
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ def _trim_if_needed():
|
|||
pass
|
||||
|
||||
|
||||
def _apply_on_save():
|
||||
def _apply_changes_immediately():
|
||||
try:
|
||||
return session.get('apply_changes_immediately', False)
|
||||
except Exception:
|
||||
|
|
@ -178,7 +178,7 @@ def _queue_pending_command(cmd, description=''):
|
|||
|
||||
|
||||
def _queue_command(cmd, description=''):
|
||||
if not _apply_on_save():
|
||||
if not _apply_changes_immediately():
|
||||
return _queue_pending_command(cmd, description)
|
||||
done_set = _load_done_set()
|
||||
pending = _read_pending(done_set)
|
||||
|
|
@ -243,7 +243,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, description)
|
||||
if not _apply_on_save():
|
||||
if not _apply_changes_immediately():
|
||||
return f'{action_label}. Click Apply Now on the Configuration Changes card to apply.'
|
||||
if _is_locked():
|
||||
mtime = _lock_mtime()
|
||||
|
|
|
|||
|
|
@ -601,9 +601,6 @@ def collect_tokens():
|
|||
f'<td class="table-cell">{label}</td>'
|
||||
f'<td class="table-cell">{e(user)}</td></tr>')
|
||||
pending_html = (
|
||||
'<hr class="divider">'
|
||||
'<h3 style="margin:0 0 0.75rem 0;font-size:0.85rem;font-weight:600;'
|
||||
'text-transform:uppercase;letter-spacing:0.05em;color:var(--text-muted)">Pending Changes</h3>'
|
||||
'<table class="data-table" style="margin-bottom:1rem">'
|
||||
'<thead><tr>'
|
||||
'<th class="table-header">Time</th>'
|
||||
|
|
@ -612,10 +609,15 @@ def collect_tokens():
|
|||
'</tr></thead>'
|
||||
f'<tbody>{rows}</tbody>'
|
||||
'</table>'
|
||||
'<form method="post" action="/action/general_cardpendingchanges_applyselected">'
|
||||
'<form method="post" action="/action/actions_cardpendingchanges_applyselected">'
|
||||
f'<input type="hidden" name="config_hash" value="{e(core_hash())}"/>'
|
||||
'<div class="button-row">'
|
||||
'<button type="submit" class="btn btn-primary">Apply Now</button>'
|
||||
'<button type="submit" class="btn btn-primary">Apply Selected</button>'
|
||||
'</div></form>'
|
||||
'<form method="post" action="/action/actions_cardpendingchanges_revertselected">'
|
||||
f'<input type="hidden" name="config_hash" value="{e(core_hash())}"/>'
|
||||
'<div class="button-row" style="margin-top:0.5rem">'
|
||||
'<button type="submit" class="btn btn-secondary">Revert Selected</button>'
|
||||
'</div></form>'
|
||||
)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -6,30 +6,30 @@
|
|||
"map_to": "view_overview",
|
||||
"client_requirement": "client_is_nothing+"
|
||||
},
|
||||
{
|
||||
"type": "nav_item",
|
||||
"label": "Actions",
|
||||
"map_to": "view_actions",
|
||||
"client_requirement": "client_is_administrator+"
|
||||
},
|
||||
{
|
||||
"type": "nav_menu",
|
||||
"label": "%MENU_LABEL%",
|
||||
"client_requirement": "client_is_viewer+",
|
||||
"items": [
|
||||
{ "type": "nav_item", "label": "Network Interfaces", "map_to": "view_network_interfaces", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DNS", "map_to": "view_upstream_dns", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DNS Blocking", "map_to": "view_dns_blocking", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DDNS", "map_to": "view_ddns" },
|
||||
{ "type": "nav_item", "label": "VLANs", "map_to": "view_vlans", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "Inter-VLAN Exceptions", "map_to": "view_inter_vlan", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "Port Forwarding", "map_to": "view_port_forwarding", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DHCP", "map_to": "view_dhcp" },
|
||||
{ "type": "nav_item", "label": "Host Overrides", "map_to": "view_host_overrides", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "VPN", "map_to": "view_vpn" },
|
||||
{ "type": "nav_item", "label": "Banned IPs", "map_to": "view_banned_ips", "client_requirement": "client_is_administrator+" }
|
||||
{ "type": "nav_item", "label": "Network Interfaces", "map_to": "view_network_interfaces", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DNS", "map_to": "view_upstream_dns", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DNS Blocking", "map_to": "view_dns_blocking", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DDNS", "map_to": "view_ddns" },
|
||||
{ "type": "nav_item", "label": "VLANs", "map_to": "view_vlans", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "Inter-VLAN Exceptions", "map_to": "view_inter_vlan", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "Port Forwarding", "map_to": "view_port_forwarding", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "DHCP", "map_to": "view_dhcp" },
|
||||
{ "type": "nav_item", "label": "Host Overrides", "map_to": "view_host_overrides", "client_requirement": "client_is_administrator+" },
|
||||
{ "type": "nav_item", "label": "VPN", "map_to": "view_vpn" },
|
||||
{ "type": "nav_item", "label": "Banned IPs", "map_to": "view_banned_ips", "client_requirement": "client_is_administrator+" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "nav_item",
|
||||
"label": "Actions",
|
||||
"map_to": "view_actions",
|
||||
"client_requirement": "client_is_administrator+"
|
||||
},
|
||||
{
|
||||
"type": "nav_menu",
|
||||
"label": "Profile",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue