84 lines
3.2 KiB
HTML
84 lines
3.2 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Logs — Website Checker{% endblock %}
|
|
{% block content %}
|
|
<div class="page-header">
|
|
<h1 class="page-title">Logs</h1>
|
|
</div>
|
|
|
|
<!-- Tab bar -->
|
|
<div class="tab-bar">
|
|
<a class="tab-item {{ 'active' if tab == 'activity' }}"
|
|
href="{{ url_for('admin_logs.logs', tab='activity') }}">📋 Activity Log</a>
|
|
<a class="tab-item {{ 'active' if tab == 'app' }}"
|
|
href="{{ url_for('admin_logs.logs', tab='app') }}">🖥 App Log</a>
|
|
</div>
|
|
|
|
<!-- Search / filter bar -->
|
|
<form class="filter-bar" method="get">
|
|
<input type="hidden" name="tab" value="{{ tab }}">
|
|
<input class="form-control" name="search" placeholder="Search…" value="{{ search }}">
|
|
{% if tab == 'app' %}
|
|
<select class="form-control" name="level">
|
|
<option value="">All Levels</option>
|
|
{% for lvl in ['DEBUG','INFO','WARNING','ERROR','CRITICAL'] %}
|
|
<option {{ 'selected' if level_filter == lvl }}>{{ lvl }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
{% endif %}
|
|
<select class="form-control" name="limit">
|
|
{% for n in [100, 200, 500] %}
|
|
<option value="{{ n }}" {{ 'selected' if limit == n }}>{{ n }} rows</option>
|
|
{% endfor %}
|
|
</select>
|
|
<button class="btn btn-ghost" type="submit">Filter</button>
|
|
</form>
|
|
|
|
{% if tab == 'activity' %}
|
|
<div class="card mt-2">
|
|
<table class="table table-sm">
|
|
<thead><tr><th>Time</th><th>User</th><th>Action</th><th>Entity</th><th>Detail</th></tr></thead>
|
|
<tbody>
|
|
{% for row in activity_rows %}
|
|
<tr>
|
|
<td class="text-muted nowrap">{{ row.created_at.strftime('%Y-%m-%d %H:%M:%S') if row.created_at else '—' }}</td>
|
|
<td>{{ row.username or '—' }}</td>
|
|
<td><code class="action-badge">{{ row.action }}</code></td>
|
|
<td class="text-muted">{{ row.entity or '' }} {% if row.entity_id %}#{{ row.entity_id }}{% endif %}</td>
|
|
<td class="text-muted">{{ row.detail or '' }}</td>
|
|
</tr>
|
|
{% else %}
|
|
<tr><td colspan="5" class="text-center text-muted">No records found.</td></tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<div class="card mt-2">
|
|
<div class="card-header">
|
|
<span></span>
|
|
<form method="post" action="{{ url_for('admin_logs.purge') }}"
|
|
onsubmit="return confirm('Purge old app log records?')" style="display:flex;gap:.5rem;align-items:center">
|
|
<input class="form-control" name="days" type="number" value="30" style="width:80px">
|
|
<label class="form-label mb-0">days</label>
|
|
<button class="btn btn-danger btn-sm" type="submit">Purge</button>
|
|
</form>
|
|
</div>
|
|
<table class="table table-sm">
|
|
<thead><tr><th>Time</th><th>Level</th><th>Logger</th><th>Message</th></tr></thead>
|
|
<tbody>
|
|
{% for row in app_rows %}
|
|
<tr class="log-{{ row.level | lower }}">
|
|
<td class="text-muted nowrap">{{ row.logged_at.strftime('%Y-%m-%d %H:%M:%S') if row.logged_at else '—' }}</td>
|
|
<td><span class="badge badge-log-{{ row.level | lower }}">{{ row.level }}</span></td>
|
|
<td class="text-muted">{{ row.logger_name }}</td>
|
|
<td class="log-message">{{ row.message }}</td>
|
|
</tr>
|
|
{% else %}
|
|
<tr><td colspan="4" class="text-center text-muted">No records found.</td></tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|