Files

100 lines
3.8 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends 'base.html' %}
{% block title %}Audit Log IT Asset Management{% endblock %}
{% block breadcrumb %}
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.index') }}">Home</a></li>
<li class="breadcrumb-item active">Audit Log</li>
{% endblock %}
{% block content %}
<div class="page-header mb-4">
<h1><i class="bi bi-shield-check me-2"></i>Audit Log</h1>
</div>
<form method="GET" class="row g-2 mb-3">
<div class="col-md-2">
<select name="table" class="form-select form-select-sm" onchange="this.form.submit()">
<option value="">All tables</option>
{% for t in tables %}
<option value="{{ t }}" {% if table_filter == t %}selected{% endif %}>{{ t }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<select name="action" class="form-select form-select-sm" onchange="this.form.submit()">
<option value="">All actions</option>
{% for a in actions %}
<option value="{{ a }}" {% if action_filter == a %}selected{% endif %}>{{ a }}</option>
{% endfor %}
</select>
</div>
<div class="col-auto">
<a href="{{ url_for('audit.index') }}" class="btn btn-sm btn-outline-secondary">Clear</a>
</div>
</form>
<div class="card border-0 shadow-sm">
<div class="table-responsive">
<table class="table table-sm table-hover mb-0">
<thead class="table-light">
<tr>
<th>Date/Time</th>
<th>Performed By</th>
<th>Action</th>
<th>Table</th>
<th>Record</th>
<th>Description</th>
<th>IP</th>
</tr>
</thead>
<tbody>
{% for e in pagination.items %}
<tr>
<td class="text-nowrap">{{ e.performed_at.strftime('%d/%m/%Y %H:%M') if e.performed_at else '—' }}</td>
<td>{{ e.performed_by.username if e.performed_by else '<system>' }}</td>
<td>
{% set colours = {'create':'success','update':'primary','delete':'danger','mask':'purple','assign':'info','return':'warning','import':'secondary'} %}
<span class="badge bg-{{ colours.get(e.action, 'secondary') }}">{{ e.action }}</span>
</td>
<td><code>{{ e.table_name }}</code></td>
<td>{{ e.record_id or '—' }}</td>
<td>{{ e.description or '—' }}</td>
<td><small class="text-muted">{{ e.ip_address or '—' }}</small></td>
</tr>
{% else %}
<tr><td colspan="7" class="text-center text-muted py-4">No audit entries found.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% if pagination.pages > 1 %}
<div class="card-footer bg-white d-flex justify-content-between align-items-center py-2">
<small class="text-muted">Showing {{ pagination.first }}{{ pagination.last }} of {{ pagination.total }}</small>
<nav>
<ul class="pagination pagination-sm mb-0">
{% if pagination.has_prev %}
<li class="page-item">
<a class="page-link" href="{{ url_for('audit.index', page=pagination.prev_num, table=table_filter, action=action_filter) }}"></a>
</li>
{% endif %}
{% for p in pagination.iter_pages() %}
{% if p %}
<li class="page-item {% if p == pagination.page %}active{% endif %}">
<a class="page-link" href="{{ url_for('audit.index', page=p, table=table_filter, action=action_filter) }}">{{ p }}</a>
</li>
{% else %}
<li class="page-item disabled"><span class="page-link"></span></li>
{% endif %}
{% endfor %}
{% if pagination.has_next %}
<li class="page-item">
<a class="page-link" href="{{ url_for('audit.index', page=pagination.next_num, table=table_filter, action=action_filter) }}"></a>
</li>
{% endif %}
</ul>
</nav>
</div>
{% endif %}
</div>
{% endblock %}