Development
This commit is contained in:
parent
8f377b1839
commit
33b639a353
4 changed files with 85 additions and 8 deletions
|
|
@ -1,8 +1,10 @@
|
|||
import os
|
||||
from pathlib import Path
|
||||
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)
|
||||
revert_snapshot_to_config, queued_msg,
|
||||
SNAPSHOTS_DIR, DASHBOARD_PENDING)
|
||||
|
||||
_PAGE = Path(__file__).parent.name
|
||||
|
||||
|
|
@ -48,3 +50,28 @@ def history_revert():
|
|||
plural = 's' if succeeded != 1 else ''
|
||||
flash(f'{succeeded} change{plural} reverted.', 'success')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
|
||||
@bp.route('/action/actions/history_clear', methods=['POST'])
|
||||
@require_level('manager')
|
||||
def history_clear():
|
||||
count = 0
|
||||
for fname in os.listdir(SNAPSHOTS_DIR):
|
||||
fpath = os.path.join(SNAPSHOTS_DIR, fname)
|
||||
if os.path.isfile(fpath):
|
||||
os.remove(fpath)
|
||||
count += 1
|
||||
plural = 's' if count != 1 else ''
|
||||
flash(f'History cleared ({count} record{plural} removed).', 'success')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
||||
|
||||
@bp.route('/action/actions/pending_dismiss', methods=['POST'])
|
||||
@require_level('manager')
|
||||
def pending_dismiss():
|
||||
if not get_dashboard_pending():
|
||||
flash('No pending changes to dismiss.', 'info')
|
||||
return redirect(f'/{_PAGE}')
|
||||
open(DASHBOARD_PENDING, 'w').close()
|
||||
flash('Pending changes dismissed.', 'success')
|
||||
return redirect(f'/{_PAGE}')
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@
|
|||
{
|
||||
"type": "raw_html",
|
||||
"html": "%APPLY_WARNING%"
|
||||
},
|
||||
{
|
||||
"type": "raw_html",
|
||||
"html": "<span style='flex:1'></span>"
|
||||
},
|
||||
{
|
||||
"type": "button_danger",
|
||||
"text": "Dismiss All",
|
||||
"action": "/action/actions/pending_dismiss",
|
||||
"method": "post",
|
||||
"disabled": "%NO_PENDING%",
|
||||
"client_requirement": "client_is_manager="
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -95,11 +107,20 @@
|
|||
},
|
||||
{
|
||||
"type": "button_row",
|
||||
"justify": "space-between",
|
||||
"items": [
|
||||
{
|
||||
"type": "button_danger",
|
||||
"type": "button_secondary",
|
||||
"text": "Revert Selected",
|
||||
"disabled": "%NO_HISTORY%"
|
||||
},
|
||||
{
|
||||
"type": "button_danger",
|
||||
"text": "Clear History",
|
||||
"action": "/action/actions/history_clear",
|
||||
"method": "post",
|
||||
"disabled": "%NO_HISTORY%",
|
||||
"client_requirement": "client_is_manager="
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue