From 98f823b4d9731aa6ad75d1bb8b17fa52488582b9 Mon Sep 17 00:00:00 2001 From: claude-cc1 Date: Tue, 5 May 2026 00:10:21 +0200 Subject: [PATCH] =?UTF-8?q?CC1=20R3B-P4=20=E2=80=94=20Forenzika=20scan=20r?= =?UTF-8?q?adi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend: - enrich_router.py: POST /api/v2/forensic/scan {name} → searches civic.persons, joins person_entity_links, scans forensic_findings (by OIB + by name), synthesises per-person risk score (PEP function +30, party +15, links +5×, findings +10×, crit +20). - Forced PG_HOST to 10.10.0.2 when env says localhost (local PG disabled). Frontend: - New scan card with name input + "Pokreni" button on Forenzika section. - Renders matched persons with risk score, links, findings. - Test: "Velimir Liverić" → 2 osoba, 2 linka, OIB 91528083847 found. Co-Authored-By: Claude Opus 4.7 (1M context) --- static/sport2.html | 72 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/static/sport2.html b/static/sport2.html index 93dc41e..4edf8a8 100644 --- a/static/sport2.html +++ b/static/sport2.html @@ -2125,10 +2125,22 @@ function renderForenzikaShell(d){ ${tipovi.map(t=>'').join('')} - +
+
+
⚡ Pokreni novu analizu osobe
+
civic.persons + entity_links + forensic_findings
+
+
+ + + +
+
+
+
`; $('#fz-q').addEventListener('input', debounce(applyForenzikaFilter, 200)); @@ -2319,14 +2331,56 @@ function renderAlertPanel(a){ } async function runForensicScan(){ - const btn = event && event.target; - if(btn){ btn.disabled = true; btn.textContent = '⏳ Skeniranje…'; } - const r = await api('/v2/alerts/scan'); - if(btn){ btn.disabled = false; btn.textContent = '⚡ Pokreni novu analizu'; } - // Reload - _forenzika.alerts = null; - await loadForenzika(); - alert(r ? 'Skeniranje pokrenuto. Pronađeno alarma: '+(_forenzika.alerts||[]).length : 'Greška pri pokretanju skeniranja.'); + const inputEl = document.getElementById('fz-scan-name'); + const outEl = document.getElementById('fz-scan-out'); + if(!inputEl || !outEl) return; + const name = (inputEl.value||'').trim(); + if(name.length < 3){ outEl.innerHTML = '
Unesi barem 3 znaka
'; return; } + outEl.innerHTML = '
Skeniram civic.persons… tražim povezane entitete… provjeravam forensic_findings…
'; + const r = await apiPost('/v2/forensic/scan', {name: name}); + if(!r){ outEl.innerHTML = '
Greška pri pokretanju analize
'; return; } + const ovr = r.overall_risk_score || 0; + const ovrCls = ovr>=70?'r':(ovr>=40?'':'g'); + outEl.innerHTML = ` +
+
Overall risk
${ovr}/100
+
Pronađeno osoba
${r.matched_persons}
+
Veza
${r.total_links}
+
Findings
${r.total_findings} (${r.critical_findings} crit)
+
+ ${(r.persons||[]).length ? ` +
+ ${r.persons.map(p => { + const cls = p.risk_score>=70?'crit':(p.risk_score>=40?'crit':''); + return ` +
+
+
+
${esc(p.name)} id ${p.id} ${p.oib?'OIB '+esc(p.oib)+'':''}
+
${p.function?esc(p.function):''}${p.party?' · '+esc(p.party):''}${p.county?' · '+esc(p.county):''}
+
+ 🔗 ${(p.links||[]).length} povezanih entiteta + · ⚠ ${(p.findings||[]).length} forenzičkih nalaza + ${p.trust_tier!=null?' · trust tier '+p.trust_tier:''} +
+ ${(p.links||[]).length ? '
Veze: '+ + p.links.slice(0,8).map(l => ''+esc(l.entity_name||'#'+l.entity_id)+(l.roles?' · '+esc(l.roles):'')+'').join('')+ + ((p.links||[]).length>8?' +'+((p.links||[]).length-8)+' više':'')+ + '
' : ''} + ${(p.findings||[]).length ? '
Nalazi:
'+ + p.findings.slice(0,5).map(f => '
'+esc(f.severity)+' '+esc(f.title||f.finding_type)+'
').join('')+ + '
' : ''} +
+
+
${p.risk_score}
+
RISK
+
+
+
`; + }).join('')} +
+ ` : '
Nema pronađenih osoba s tim imenom
'} + `; } //=========== INIT ===========