added log filter
Build and Publish / Build and Publish Docker Image (push) Successful in 1m43s

This commit is contained in:
ab
2026-09-20 20:11:18 +03:00
parent 95154c56e7
commit 866118497f
4 changed files with 61 additions and 3 deletions
+39 -2
View File
@@ -84,7 +84,15 @@
</div>
<div class="analytics-log-card">
<h2>{{ t.analytics_log_title }}</h2>
<div class="analytics-log-head">
<h2>{{ t.analytics_log_title }}</h2>
<div class="analytics-metric-toggles analytics-log-filters">
<span class="toggles-label">{{ t.analytics_log_show }}:</span>
<label><input type="checkbox" class="log-type-toggle" data-type="landing_view"> {{ t.analytics_ev_landing_view }}</label>
<label><input type="checkbox" class="log-type-toggle" data-type="portal_open" checked> {{ t.analytics_ev_portal_open }}</label>
<label><input type="checkbox" class="log-type-toggle" data-type="media_view" checked> {{ t.analytics_ev_media_view }}</label>
</div>
</div>
<div class="analytics-log" id="anLog"></div>
</div>
@@ -117,7 +125,9 @@
.an-media-missing { width:40px; height:40px; border-radius:6px; background:#f0f0f3; display:inline-flex; align-items:center; justify-content:center; color:#bbb; flex:0 0 auto; }
.analytics-log-card { background:#fff; border-radius:12px; padding:16px; box-shadow:0 1px 4px rgba(0,0,0,.06); margin-top:20px; }
.analytics-log-card h2 { font-size:1rem; margin:0 0 10px; }
.analytics-log-card h2 { font-size:1rem; margin:0; }
.analytics-log-head { display:flex; flex-wrap:wrap; gap:10px 18px; align-items:center; justify-content:space-between; margin-bottom:10px; }
.analytics-log-filters { margin-bottom:0; }
.analytics-log { max-height:460px; overflow-y:auto; border:1px solid #f0f0f0; border-radius:8px; }
.an-log-row { display:flex; gap:12px; align-items:flex-start; padding:10px 12px; border-bottom:1px solid #f5f5f5; font-size:.85rem; }
.an-log-row:last-child { border-bottom:none; }
@@ -496,13 +506,36 @@
return row;
}
function selectedLogTypes() {
var types = [];
document.querySelectorAll('.log-type-toggle').forEach(function (cb) {
if (cb.checked) { types.push(cb.getAttribute('data-type')); }
});
return types;
}
function resetLog() {
logEl.replaceChildren();
logCursor = null;
logLoading = false;
logDone = false;
loadLog();
}
function loadLog() {
if (logLoading || logDone) { return; }
var types = selectedLogTypes();
if (types.length === 0) {
logEl.replaceChildren(logStatus(L.log_empty));
logDone = true;
return;
}
logLoading = true;
var busy = logStatus(L.loading);
logEl.appendChild(busy);
var params = new URLSearchParams({ limit: '40' });
if (logCursor) { params.set('before', logCursor); }
types.forEach(function (t) { params.append('types', t); });
fetch('/admin/analytics/events?' + params.toString(), { credentials: 'same-origin' })
.then(function (r) { return r.json(); })
.then(function (data) {
@@ -534,6 +567,10 @@
if (logEl.scrollTop + logEl.clientHeight >= logEl.scrollHeight - 40) { loadLog(); }
});
document.querySelectorAll('.log-type-toggle').forEach(function (cb) {
cb.addEventListener('change', resetLog);
});
initChart();
setRange(30);
load();