fixed, scheduler, added search to log, added advanced search

This commit is contained in:
2026-04-05 18:55:09 +02:00
parent 076733fb53
commit 66b32ded36
4 changed files with 124 additions and 3 deletions
+68 -3
View File
@@ -3,7 +3,7 @@
{% block content %}
<h1>Verarbeitungslog</h1>
<div style="display:flex; gap:1rem; align-items:end; flex-wrap:wrap; margin-bottom:1rem;">
<div style="display:flex; gap:1rem; align-items:end; flex-wrap:wrap; margin-bottom:0.5rem;">
<label style="margin-bottom:0;">
Konto
<select id="log-account" onchange="loadLogs()" style="margin-bottom:0;">
@@ -23,16 +23,56 @@
<option value="error">Fehler</option>
</select>
</label>
<label style="margin-bottom:0; flex:1; min-width:200px;">
Schnellsuche
<input type="search" id="log-search" placeholder="überall suchen..." style="margin-bottom:0;" onkeydown="if(event.key==='Enter') loadLogs()">
</label>
<div role="group" style="margin-bottom:0;">
<button class="outline small" onclick="loadLogs()">Aktualisieren</button>
<button class="outline small" onclick="loadLogs()">Suchen</button>
<button class="outline small contrast" onclick="clearLogs()">Log leeren</button>
</div>
<label style="margin-bottom:0; margin-left:auto;">
<label style="margin-bottom:0;">
<input type="checkbox" id="auto-refresh" onchange="toggleAutoRefresh()" style="margin-bottom:0;">
Auto-Refresh (5s)
</label>
</div>
<details style="margin-bottom:1rem;">
<summary>Erweiterte Suche (UND-verknüpft)</summary>
<div class="grid" style="margin-top:0.5rem;">
<label style="margin-bottom:0;">
Betreff
<input type="search" id="search-subject" placeholder="z.B. Rechnung" style="margin-bottom:0;" onkeydown="if(event.key==='Enter') loadLogs()">
</label>
<label style="margin-bottom:0;">
Absender
<input type="search" id="search-from" placeholder="z.B. shop@example.com" style="margin-bottom:0;" onkeydown="if(event.key==='Enter') loadLogs()">
</label>
<label style="margin-bottom:0;">
Regel
<input type="search" id="search-rule" placeholder="z.B. Newsletter" style="margin-bottom:0;" onkeydown="if(event.key==='Enter') loadLogs()">
</label>
</div>
<div class="grid" style="margin-top:0.5rem;">
<label style="margin-bottom:0;">
Nachricht
<input type="search" id="search-message" placeholder="z.B. Aktion ausgeführt" style="margin-bottom:0;" onkeydown="if(event.key==='Enter') loadLogs()">
</label>
<label style="margin-bottom:0;">
Details
<input type="search" id="search-details" placeholder="z.B. TREFFER" style="margin-bottom:0;" onkeydown="if(event.key==='Enter') loadLogs()">
</label>
<label style="margin-bottom:0;">
Ordner
<input type="search" id="search-folder" placeholder="z.B. INBOX" style="margin-bottom:0;" onkeydown="if(event.key==='Enter') loadLogs()">
</label>
</div>
<div style="margin-top:0.5rem;">
<button class="outline small" onclick="loadLogs()">Erweitert suchen</button>
<button class="outline small contrast" onclick="clearAdvancedSearch()">Felder leeren</button>
</div>
</details>
<div id="log-stats" style="margin-bottom:1rem;"></div>
<div id="log-container">
@@ -85,9 +125,24 @@ async function loadLogs(offset = 0) {
const level = document.getElementById('log-level').value;
const container = document.getElementById('log-container');
const search = document.getElementById('log-search').value.trim();
const searchSubject = document.getElementById('search-subject').value.trim();
const searchFrom = document.getElementById('search-from').value.trim();
const searchRule = document.getElementById('search-rule').value.trim();
const searchMessage = document.getElementById('search-message').value.trim();
const searchDetails = document.getElementById('search-details').value.trim();
const searchFolder = document.getElementById('search-folder').value.trim();
let url = `/api/logs/?limit=${PAGE_SIZE}&offset=${offset}`;
if (accountId) url += `&account_id=${accountId}`;
if (level) url += `&level=${level}`;
if (search) url += `&search=${encodeURIComponent(search)}`;
if (searchSubject) url += `&search_subject=${encodeURIComponent(searchSubject)}`;
if (searchFrom) url += `&search_from=${encodeURIComponent(searchFrom)}`;
if (searchRule) url += `&search_rule=${encodeURIComponent(searchRule)}`;
if (searchMessage) url += `&search_message=${encodeURIComponent(searchMessage)}`;
if (searchDetails) url += `&search_details=${encodeURIComponent(searchDetails)}`;
if (searchFolder) url += `&search_folder=${encodeURIComponent(searchFolder)}`;
try {
const resp = await fetch(url);
@@ -196,6 +251,16 @@ function escapeHtml(text) {
return div.innerHTML;
}
function clearAdvancedSearch() {
document.getElementById('search-subject').value = '';
document.getElementById('search-from').value = '';
document.getElementById('search-rule').value = '';
document.getElementById('search-message').value = '';
document.getElementById('search-details').value = '';
document.getElementById('search-folder').value = '';
loadLogs();
}
// Initial load
loadLogs();
</script>