added option to view the NFC logfile as super admin
This commit is contained in:
parent
c02d5465ea
commit
f48f78997c
|
@ -10,7 +10,8 @@ parser.add_argument("--nfc_socket", default="/tmp/nfc.sock", help="socket for ha
|
||||||
parser.add_argument("--template_folder", default="templates", help="path to Flask templates folder")
|
parser.add_argument("--template_folder", default="templates", help="path to Flask templates folder")
|
||||||
parser.add_argument("--static_folder", default="static", help="path to Flask static folder")
|
parser.add_argument("--static_folder", default="static", help="path to Flask static folder")
|
||||||
parser.add_argument("--admin_file", help="Path to file for creating super admin users")
|
parser.add_argument("--admin_file", help="Path to file for creating super admin users")
|
||||||
parser.add_argument("--log_file", default="/var/log/webinterface.log", help="Path to log file")
|
parser.add_argument("--log_file", default="/var/log/webinterface.log", help="Path to flask log file")
|
||||||
|
parser.add_argument("--nfc_log", default="/var/log/nfc.log", help="Path to nfc log file")
|
||||||
parser.add_argument("--ldap_url", default="ldaps://ldap.imaginaerraum.de",
|
parser.add_argument("--ldap_url", default="ldaps://ldap.imaginaerraum.de",
|
||||||
help="URL for LDAP server for alternative user authorization")
|
help="URL for LDAP server for alternative user authorization")
|
||||||
parser.add_argument("--mqtt_host", default="10.10.21.2", help="IP address of MQTT broker")
|
parser.add_argument("--mqtt_host", default="10.10.21.2", help="IP address of MQTT broker")
|
||||||
|
|
|
@ -31,6 +31,9 @@
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
<a class="dropdown-item" href="{{ url_for('register') }}">Token Registrierung</a>
|
<a class="dropdown-item" href="{{ url_for('register') }}">Token Registrierung</a>
|
||||||
<a class="dropdown-item" href="{{ url_for('list_tokens') }}">Token Übersicht</a>
|
<a class="dropdown-item" href="{{ url_for('list_tokens') }}">Token Übersicht</a>
|
||||||
|
{% if current_user.has_role('super_admin') %}
|
||||||
|
<a class="dropdown-item" href="{{ url_for('token_log') }}">Token Log</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
23
imaginaerraum_door_admin/templates/token_log.html
Normal file
23
imaginaerraum_door_admin/templates/token_log.html
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block header %}
|
||||||
|
{% block title %}<h1>Token Log</h1>{% endblock %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<td>Date</td>
|
||||||
|
<td>Timestamp</td>
|
||||||
|
<td>Message</td>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for line in log %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ line[0] }}</td>
|
||||||
|
<td>{{ line[1] }}</td>
|
||||||
|
<td>{{ line[2] }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
|
@ -458,6 +458,20 @@ def create_application(config):
|
||||||
inactive_tokens = {t: data for t, data in tokens.items() if data['inactive']}
|
inactive_tokens = {t: data for t, data in tokens.items() if data['inactive']}
|
||||||
return render_template('tokens.html', assigned_tokens=assigned_tokens, inactive_tokens=inactive_tokens)
|
return render_template('tokens.html', assigned_tokens=assigned_tokens, inactive_tokens=inactive_tokens)
|
||||||
|
|
||||||
|
@app.route('/token-log')
|
||||||
|
@roles_required('super_admin')
|
||||||
|
def token_log():
|
||||||
|
log = []
|
||||||
|
try:
|
||||||
|
with open(config.nfc_log) as f:
|
||||||
|
log += f.readlines()
|
||||||
|
log.reverse()
|
||||||
|
log = map(lambda l: l.split(' ', 2), log)
|
||||||
|
return render_template('token_log.html', log=log)
|
||||||
|
except Exception as e:
|
||||||
|
flash(f"NFC logfile {Path(config.nfc_log).absolute()} konnte nicht gelesen werden. Exception: {e}")
|
||||||
|
return redirect('/')
|
||||||
|
|
||||||
# routes for registering, editing and deleting tokens
|
# routes for registering, editing and deleting tokens
|
||||||
@app.route('/register-token', methods=['GET', 'POST'])
|
@app.route('/register-token', methods=['GET', 'POST'])
|
||||||
@roles_required('admin')
|
@roles_required('admin')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user