Development
This commit is contained in:
parent
eed1d295dc
commit
d9f3bd8289
45 changed files with 635 additions and 666 deletions
|
|
@ -66,23 +66,6 @@ def _load_icon(name):
|
|||
return ''
|
||||
|
||||
|
||||
def _build_view_map():
|
||||
m = {}
|
||||
if not _os.path.isdir(_PAGES_DIR):
|
||||
return m
|
||||
for name in _os.listdir(_PAGES_DIR):
|
||||
cpath = _os.path.join(_PAGES_DIR, name, 'content.json')
|
||||
if _os.path.isfile(cpath):
|
||||
try:
|
||||
with open(cpath) as f:
|
||||
d = json.load(f)
|
||||
vid = d.get('id')
|
||||
if vid:
|
||||
m[vid] = name
|
||||
except Exception:
|
||||
pass
|
||||
return m
|
||||
_VIEW_MAP = _build_view_map()
|
||||
|
||||
|
||||
# Shell helper ======================================================
|
||||
|
|
@ -2040,7 +2023,7 @@ def render_layout(view_id, content_html, tokens):
|
|||
else 'Fix pending. The processing service is not running.')
|
||||
else:
|
||||
fix_suffix = ('Fix pending. Click <strong>Apply Now</strong> below to fix.'
|
||||
if view_id == 'view_actions' else
|
||||
if view_id == 'actions' else
|
||||
'Fix pending. Visit the <strong>Actions</strong> page ASAP to apply fix.')
|
||||
for sev, items in grouped.items():
|
||||
if not items:
|
||||
|
|
@ -2062,7 +2045,7 @@ def render_layout(view_id, content_html, tokens):
|
|||
pass
|
||||
|
||||
pending_bar = ''
|
||||
if has_pending_alert and not problem_bars and view_id != 'view_actions':
|
||||
if has_pending_alert and not problem_bars and view_id != 'actions':
|
||||
pending_bar = (
|
||||
'<div class="info-bar info-bar-warning">'
|
||||
'<span>You have actions pending. Please visit the <strong>Actions</strong> page.</span>'
|
||||
|
|
@ -2114,7 +2097,7 @@ def _render_nav_item(item, active_view, level, in_dropdown=False, inherited_req=
|
|||
map_to = item.get('map_to', '')
|
||||
action = item.get('action', '')
|
||||
is_active = ' active' if map_to and map_to == active_view else ''
|
||||
pending = ' nav-item-pending' if pending_alert and map_to == 'view_actions' else ''
|
||||
pending = ' nav-item-pending' if pending_alert and map_to == 'actions' else ''
|
||||
cls = f'dropdown-item{is_active}' if in_dropdown else f'nav-item{is_active}{pending}'
|
||||
if action:
|
||||
return (
|
||||
|
|
@ -2122,7 +2105,7 @@ def _render_nav_item(item, active_view, level, in_dropdown=False, inherited_req=
|
|||
f'<button type="submit" class="{cls}">{label}</button></form>'
|
||||
)
|
||||
if map_to:
|
||||
return f'<a href="/view/{e(map_to)}" class="{cls}">{label}</a>'
|
||||
return f'<a href="/{e(map_to)}" class="{cls}">{label}</a>'
|
||||
return f'<span class="{cls}">{label}</span>'
|
||||
|
||||
if t == 'nav_menu':
|
||||
|
|
@ -2161,15 +2144,14 @@ def _inline_js():
|
|||
|
||||
@bp.route('/')
|
||||
def index():
|
||||
return _serve_view('view_overview')
|
||||
return _serve_view('overview')
|
||||
|
||||
@bp.route('/view/<view_id>')
|
||||
def view(view_id):
|
||||
return _serve_view(view_id)
|
||||
@bp.route('/<page_name>')
|
||||
def view(page_name):
|
||||
return _serve_view(page_name)
|
||||
|
||||
def _serve_view(view_id):
|
||||
page_name = _VIEW_MAP.get(view_id)
|
||||
view_def = _load_json(_os.path.join(_PAGES_DIR, page_name, 'content.json')) if page_name else None
|
||||
def _serve_view(page_name):
|
||||
view_def = _load_json(_os.path.join(_PAGES_DIR, page_name, 'content.json'))
|
||||
|
||||
if view_def is None:
|
||||
from flask import abort
|
||||
|
|
@ -2178,7 +2160,7 @@ def _serve_view(view_id):
|
|||
view_req = view_def.get('client_requirement')
|
||||
level = _client_level()
|
||||
if not _passes(view_req, level):
|
||||
return redirect('/view/view_overview' if level > 0 else '/view/view_login')
|
||||
return redirect('/overview' if level > 0 else '/accountlogin')
|
||||
|
||||
tokens = collect_tokens()
|
||||
|
||||
|
|
@ -2189,4 +2171,4 @@ def _serve_view(view_id):
|
|||
flash_html += f'<div class="info-bar info-bar-{variant} info-bar-flash"><span>{msg_html}</span></div>'
|
||||
|
||||
content_html = flash_html + render_items(view_def.get('items', []), tokens, view_req)
|
||||
return render_layout(view_id, content_html, tokens)
|
||||
return render_layout(page_name, content_html, tokens)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue