Add node status page

This commit is contained in:
Timotej Lazar 2023-07-07 09:16:51 +02:00
parent 4ef3efbc68
commit 6b72316076
3 changed files with 30 additions and 1 deletions

View file

@ -86,4 +86,18 @@ def create_app(test_config=None):
def home():
return flask.render_template('index.html')
@app.route('/nodes')
@flask_login.login_required
def nodes():
try:
if not flask_login.current_user.is_admin:
return flask.Response('forbidden', status=403, mimetype='text/plain')
with db.locked('nodes'):
version = db.load('settings').get('version')
nodes = db.read('nodes')
return flask.render_template('nodes.html', version=version, nodes=nodes)
except Exception as e:
return flask.Response(f'something went catastrophically wrong: {e}',
status=400, mimetype='text/plain')
return app

View file

@ -1,9 +1,11 @@
{% extends 'base.html' %}
{% block content %}
<dl>
{% if current_user.is_admin %}
<section>
<dl>
<dt><a href="{{ url_for('nodes') }}">Status</a>
<dd>status opek v požarnem zidu
<dt><a href="{{ url_for('config.index') }}">Nastavitve</a>
<dd>nastavitve aplikacije FRIwall
<dt><a href="{{ url_for('config.edit', name='ipsets') }}">Obsegi IP</a>
@ -16,10 +18,12 @@
<dd>statične 1:1 preslikave naslovov za strežniška omrežja
<dt><a href="{{ url_for('config.edit', name='groups') }}">Skupine</a>
<dd>preslikave uporabnikov LDAP v pisarniška omrežja
</dl>
</section>
{% endif %}
<section>
<dl>
<dt><a href="{{ url_for('vpn.index') }}">VPN</a>
<dd>urejanje ključev za WireGuard VPN
<dt><a href="{{ url_for('rules.manage') }}">Pravila</a>

11
web/templates/nodes.html Normal file
View file

@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% block content %}
<p>
Trenutna različica nastavitev: {{ version }}
<ul>
{% for node, node_version in nodes.items() %}
<li>{{ node }}: <span style="color: {% if node_version|string == version|string %}green{% else %}red{% endif %};">{{ node_version }}</span>
{% endfor %}
</ul>
{% endblock %}