Development
This commit is contained in:
parent
6221ee3691
commit
4150c6ef6e
4 changed files with 141 additions and 13 deletions
|
|
@ -4,7 +4,7 @@ import json, re, subprocess, os, sys, html as html_mod
|
|||
import sanitize
|
||||
import validation as validate
|
||||
from datetime import datetime, timezone
|
||||
from config_utils import core_hash, get_pending_entries, get_dashboard_pending, load_snapshot_for_uuid, _seconds_until_next_run, _format_timing, _is_locked, _lock_mtime, WEB_APP_DISPLAY_NAME, CONFIGS_DIR, DATA_DIR
|
||||
from config_utils import core_hash, get_pending_entries, get_dashboard_pending, get_dashboard_done, load_snapshot_for_uuid, _seconds_until_next_run, _format_timing, _is_locked, _lock_mtime, WEB_APP_DISPLAY_NAME, CONFIGS_DIR, DATA_DIR
|
||||
|
||||
bp = Blueprint('view_page', __name__)
|
||||
|
||||
|
|
@ -594,7 +594,7 @@ def collect_tokens():
|
|||
pending_items = get_dashboard_pending()
|
||||
if pending_items:
|
||||
rows = ''
|
||||
for _uuid, ts, cmd, user in pending_items:
|
||||
for _uuid, ts, _cmd, user in pending_items:
|
||||
snap = load_snapshot_for_uuid(_uuid)
|
||||
dt_str = datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M')
|
||||
snap_desc = e(snap['description']) if snap else ''
|
||||
|
|
@ -604,7 +604,6 @@ def collect_tokens():
|
|||
rows += (f'<tr>'
|
||||
f'<td class="table-cell"><input type="checkbox" name="selected_uuids" value="{e(_uuid)}"/></td>'
|
||||
f'<td class="table-cell">{e(dt_str)}</td>'
|
||||
f'<td class="table-cell">{e(cmd)}</td>'
|
||||
f'<td class="table-cell">{snap_desc}</td>'
|
||||
f'<td class="table-cell">{before_html}</td>'
|
||||
f'<td class="table-cell">{after_html}</td>'
|
||||
|
|
@ -620,7 +619,6 @@ def collect_tokens():
|
|||
'<thead><tr>'
|
||||
f'<th class="table-header">{select_all}</th>'
|
||||
'<th class="table-header">Time</th>'
|
||||
'<th class="table-header">Action</th>'
|
||||
'<th class="table-header">Description</th>'
|
||||
'<th class="table-header">Before</th>'
|
||||
'<th class="table-header">After</th>'
|
||||
|
|
@ -634,6 +632,45 @@ def collect_tokens():
|
|||
pending_html = ''
|
||||
tokens['PENDING_CHANGES_HTML'] = pending_html
|
||||
|
||||
done_items = get_dashboard_done()
|
||||
if done_items:
|
||||
hist_rows = ''
|
||||
for _uuid, applied_ts in done_items:
|
||||
snap = load_snapshot_for_uuid(_uuid)
|
||||
if applied_ts:
|
||||
dt_str = datetime.fromtimestamp(applied_ts).strftime('%Y-%m-%d %H:%M')
|
||||
else:
|
||||
dt_str = '-'
|
||||
snap_desc = e(snap['description']) if snap else ''
|
||||
before_html = _render_snap_val(snap.get('before') if snap else None)
|
||||
after_html = _render_snap_val(snap.get('after') if snap else None)
|
||||
snap_id = e(_uuid[:8]) if snap else ''
|
||||
snap_user = e(snap['user']) if snap else ''
|
||||
hist_rows += (f'<tr>'
|
||||
f'<td class="table-cell">{e(dt_str)}</td>'
|
||||
f'<td class="table-cell">{snap_desc}</td>'
|
||||
f'<td class="table-cell">{before_html}</td>'
|
||||
f'<td class="table-cell">{after_html}</td>'
|
||||
f'<td class="table-cell">{snap_id}</td>'
|
||||
f'<td class="table-cell">{snap_user}</td>'
|
||||
f'</tr>')
|
||||
history_html = (
|
||||
'<table class="data-table" style="margin-bottom:1rem">'
|
||||
'<thead><tr>'
|
||||
'<th class="table-header">Applied</th>'
|
||||
'<th class="table-header">Description</th>'
|
||||
'<th class="table-header">Before</th>'
|
||||
'<th class="table-header">After</th>'
|
||||
'<th class="table-header">Snapshot</th>'
|
||||
'<th class="table-header">User</th>'
|
||||
'</tr></thead>'
|
||||
f'<tbody>{hist_rows}</tbody>'
|
||||
'</table>'
|
||||
)
|
||||
else:
|
||||
history_html = ''
|
||||
tokens['CHANGE_HISTORY_HTML'] = history_html
|
||||
|
||||
servers = dns.get('upstream_servers', [])
|
||||
tokens['DNS_STRICT_ORDER'] = 'true' if dns.get('strict_order') else 'false'
|
||||
tokens['DNS_CACHE_SIZE'] = str(dns.get('cache_size', '-'))
|
||||
|
|
@ -1030,8 +1067,9 @@ def _render_item(item, tokens, inherited_req=None):
|
|||
method = e(item.get('method', 'post'))
|
||||
inner = render_items(item.get('items', []), tokens, req)
|
||||
hash_field = f'<input type="hidden" name="config_hash" value="{e(core_hash())}"/>'
|
||||
originals = json.dumps(_collect_form_originals(item.get('items', []), tokens))
|
||||
orig_field = f'<input type="hidden" name="original_values" value="{e(originals)}"/>'
|
||||
originals = _collect_form_originals(item.get('items', []), tokens)
|
||||
orig_field = (f'<input type="hidden" name="original_values" value="{e(json.dumps(originals))}"/>'
|
||||
if originals else '')
|
||||
return f'<form action="{action}" method="{method}">{hash_field}{orig_field}{inner}</form>'
|
||||
|
||||
if t == 'hidden':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue