307 lines
13 KiB
HTML
307 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr"><head>
|
|
<meta charset="UTF-8">
|
|
<title>Contacts Segmentation · B2B / B2C / Industry</title>
|
|
<style>
|
|
body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;background:#0a0e27;color:#e4e8f7;margin:0;padding:24px;min-height:100vh}
|
|
h1{color:#6ba3ff;border-bottom:2px solid #1e3a8a;padding-bottom:8px}
|
|
h2{color:#c084fc;margin-top:32px}
|
|
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px;margin:16px 0}
|
|
.card{background:#141933;border:1px solid #263161;border-radius:8px;padding:18px}
|
|
.big{font-size:30px;font-weight:bold}
|
|
.b2b{color:#10b981}
|
|
.b2c{color:#3b82f6}
|
|
.unknown{color:#f59e0b}
|
|
.sub{color:#9ca8d3;font-size:12px;margin-top:4px}
|
|
table{width:100%;border-collapse:collapse;font-size:13px}
|
|
th,td{padding:8px 12px;border-bottom:1px solid #263161;text-align:left}
|
|
th{background:#1e2549;color:#9ca8d3;font-size:11px;text-transform:uppercase}
|
|
.badge{display:inline-block;padding:2px 8px;border-radius:4px;font-size:10px;font-weight:bold;text-transform:uppercase}
|
|
.bg-b2b{background:#10b981;color:#fff}
|
|
.bg-b2c{background:#3b82f6;color:#fff}
|
|
.bg-unknown{background:#6b7280;color:#fff}
|
|
.bar-container{width:100%;height:6px;background:#1e2549;border-radius:3px;overflow:hidden;margin-top:4px}
|
|
.bar{height:100%;background:linear-gradient(90deg,#6ba3ff 0%,#c084fc 100%)}
|
|
.skeleton{display:inline-block;width:80px;height:28px;background:linear-gradient(90deg,#263161,#1e2549,#263161);background-size:200% 100%;animation:skel 1.5s infinite;border-radius:4px}
|
|
@keyframes skel{0%{background-position:200% 0}100%{background-position:-200% 0}}
|
|
.refresh{color:#9ca8d3;font-size:11px;margin-top:24px;text-align:right}
|
|
#toast{position:fixed;bottom:24px;right:24px;padding:16px 24px;background:#ef4444;color:#fff;border-radius:8px;display:none;z-index:1000}
|
|
.num{font-family:'SF Mono',Monaco,monospace;color:#6ba3ff;text-align:right}
|
|
</style></head>
|
|
<body>
|
|
<h1>👥 Contacts Segmentation · B2B / B2C / Industry Live</h1>
|
|
<p style="color:#9ca8d3">Classification automatique par domain (doctrine 63) · Auto-refresh 30s · 0 hardcode · API: /api/contacts-segmentation-live.php</p>
|
|
|
|
<h2>Classification progress</h2>
|
|
<div class="grid">
|
|
<div class="card"><h3>Leads (pool massive)</h3>
|
|
<div class="big" id="leads-pct"><span class="skeleton"></span></div>
|
|
<div class="sub" id="leads-sub">—</div>
|
|
<div class="bar-container"><div class="bar" id="leads-bar" style="width:0%"></div></div>
|
|
</div>
|
|
<div class="card"><h3>Send contacts</h3>
|
|
<div class="big" id="sc-pct"><span class="skeleton"></span></div>
|
|
<div class="sub" id="sc-sub">—</div>
|
|
<div class="bar-container"><div class="bar" id="sc-bar" style="width:0%"></div></div>
|
|
</div>
|
|
<div class="card"><h3>Weval leads (B2B scraped)</h3>
|
|
<div class="big" id="wl-total"><span class="skeleton"></span></div>
|
|
<div class="sub" id="wl-sub">—</div>
|
|
</div>
|
|
<div class="card"><h3>Pipeline companies</h3>
|
|
<div class="big" id="pc-total"><span class="skeleton"></span></div>
|
|
<div class="sub">B2B classified</div>
|
|
</div>
|
|
</div>
|
|
|
|
<h2>Segmentation globale</h2>
|
|
<div class="grid" id="seg-grid"></div>
|
|
|
|
<h2>Industries B2B (tous sources combinés)</h2>
|
|
<div class="card">
|
|
<table>
|
|
<thead><tr><th>#</th><th>Industry</th><th>Count</th><th>Répartition</th></tr></thead>
|
|
<tbody id="ind-tbody"><tr><td colspan="4"><span class="skeleton"></span></td></tr></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<h2>🚀 B2B CRM Pipeline Contacts (NEW IMPORT 17avr)</h2>
|
|
<div class="card">
|
|
<table>
|
|
<thead><tr><th>Industry (B2B only)</th><th>Contacts</th></tr></thead>
|
|
<tbody id="pip-tbody"><tr><td colspan="2"><span class="skeleton"></span></td></tr></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<h2>🎯 Top Decision Makers</h2>
|
|
<div class="card">
|
|
<table>
|
|
<thead><tr><th>Job Title</th><th>Count</th></tr></thead>
|
|
<tbody id="dm-tbody"><tr><td colspan="2"><span class="skeleton"></span></td></tr></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<h2>📥 Contacts by Source</h2>
|
|
<div class="card">
|
|
<table>
|
|
<thead><tr><th>Source</th><th>Count</th></tr></thead>
|
|
<tbody id="src-tbody"><tr><td colspan="2"><span class="skeleton"></span></td></tr></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<h2>Pipeline companies breakdown (classé manuel)</h2>
|
|
<div class="card">
|
|
<table>
|
|
<thead><tr><th>Industry</th><th>Companies</th></tr></thead>
|
|
<tbody id="pc-tbody"><tr><td colspan="2"><span class="skeleton"></span></td></tr></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<h2>Top B2B domains (auto-découverts)</h2>
|
|
<div class="card">
|
|
<table>
|
|
<thead><tr><th>Industry</th><th>Domain</th><th>Count</th></tr></thead>
|
|
<tbody id="dom-tbody"><tr><td colspan="3"><span class="skeleton"></span></td></tr></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="refresh" id="refresh-info">Connecting...</div>
|
|
<div id="toast"></div>
|
|
|
|
<script>
|
|
function showToast(msg) {
|
|
const t = document.getElementById('toast');
|
|
t.textContent = msg;
|
|
t.style.display = 'block';
|
|
setTimeout(() => t.style.display = 'none', 5000);
|
|
}
|
|
function fmt(n) { return (n || 0).toLocaleString('fr-FR'); }
|
|
|
|
async function loadData() {
|
|
try {
|
|
const r = await fetch('/api/contacts-segmentation-live.php');
|
|
if (!r.ok) throw new Error('HTTP ' + r.status);
|
|
const d = await r.json();
|
|
|
|
// Progress
|
|
const p = d.progress || {};
|
|
document.getElementById('leads-pct').textContent = (p.leads_pct || 0) + '%';
|
|
document.getElementById('leads-sub').textContent = fmt(p.leads_classified) + ' / ' + fmt(p.leads_total);
|
|
document.getElementById('leads-bar').style.width = (p.leads_pct || 0) + '%';
|
|
|
|
document.getElementById('sc-pct').textContent = (p.send_contacts_pct || 0) + '%';
|
|
document.getElementById('sc-sub').textContent = fmt(p.send_contacts_classified) + ' / ' + fmt(p.send_contacts_total);
|
|
document.getElementById('sc-bar').style.width = (p.send_contacts_pct || 0) + '%';
|
|
|
|
const wlB2B = d.summary?.weval_leads?.B2B || 0;
|
|
const wlTot = (d.summary?.weval_leads?.B2B || 0) + (d.summary?.weval_leads?.B2C || 0) + (d.summary?.weval_leads?.UNCLASSIFIED || 0);
|
|
document.getElementById('wl-total').textContent = fmt(wlB2B);
|
|
document.getElementById('wl-sub').textContent = 'B2B / ' + fmt(wlTot) + ' total';
|
|
|
|
document.getElementById('pc-total').textContent = fmt(p.pipeline_companies_total);
|
|
|
|
// Segmentation globale
|
|
const sg = document.getElementById('seg-grid');
|
|
sg.innerHTML = '';
|
|
for (const [tbl, stats] of Object.entries(d.summary || {})) {
|
|
const total = Object.values(stats).reduce((a,b) => a+b, 0);
|
|
const b2b = stats.B2B || 0;
|
|
const b2c = stats.B2C || 0;
|
|
const unk = (stats.UNKNOWN || 0) + (stats.UNCLASSIFIED || 0);
|
|
const card = document.createElement('div');
|
|
card.className = 'card';
|
|
card.innerHTML = `<h3>${tbl}</h3>
|
|
<div style="font-size:13px;margin:8px 0">
|
|
<div><span class="b2b">●</span> B2B: <strong>${fmt(b2b)}</strong></div>
|
|
<div><span class="b2c">●</span> B2C: <strong>${fmt(b2c)}</strong></div>
|
|
<div><span class="unknown">●</span> Unknown: <strong>${fmt(unk)}</strong></div>
|
|
</div>
|
|
<div class="sub">Total: ${fmt(total)}</div>`;
|
|
sg.appendChild(card);
|
|
}
|
|
|
|
// Industries B2B
|
|
const indTbody = document.getElementById('ind-tbody');
|
|
indTbody.innerHTML = '';
|
|
const industries = d.industries_b2b || {};
|
|
const maxInd = Math.max(...Object.values(industries), 1);
|
|
let i = 0;
|
|
for (const [ind, cnt] of Object.entries(industries)) {
|
|
i++;
|
|
const pct = (cnt / maxInd) * 100;
|
|
const tr = document.createElement('tr');
|
|
tr.innerHTML = `<td>${i}</td><td>${ind}</td><td class="num">${fmt(cnt)}</td>
|
|
<td><div class="bar-container"><div class="bar" style="width:${pct}%"></div></div></td>`;
|
|
indTbody.appendChild(tr);
|
|
if (i >= 20) break;
|
|
}
|
|
|
|
// Pipeline companies
|
|
// B2B Pipeline Contacts
|
|
const pipTbody = document.getElementById('pip-tbody');
|
|
if (pipTbody) {
|
|
pipTbody.innerHTML = '';
|
|
for (const [ind, cnt] of Object.entries(d.industries_pipeline_contacts_b2b || {})) {
|
|
const tr = document.createElement('tr');
|
|
tr.innerHTML = `<td>${ind}</td><td class="num">${fmt(cnt)}</td>`;
|
|
pipTbody.appendChild(tr);
|
|
}
|
|
}
|
|
// Decision makers
|
|
const dmTbody = document.getElementById('dm-tbody');
|
|
if (dmTbody) {
|
|
dmTbody.innerHTML = '';
|
|
(d.top_decision_makers || []).forEach(item => {
|
|
const tr = document.createElement('tr');
|
|
tr.innerHTML = `<td>${item.title}</td><td class="num">${fmt(item.count)}</td>`;
|
|
dmTbody.appendChild(tr);
|
|
});
|
|
}
|
|
// Sources
|
|
const srcTbody = document.getElementById('src-tbody');
|
|
if (srcTbody) {
|
|
srcTbody.innerHTML = '';
|
|
for (const [src, cnt] of Object.entries(d.contacts_by_source || {})) {
|
|
const tr = document.createElement('tr');
|
|
tr.innerHTML = `<td><code>${src}</code></td><td class="num">${fmt(cnt)}</td>`;
|
|
srcTbody.appendChild(tr);
|
|
}
|
|
}
|
|
|
|
const pcTbody = document.getElementById('pc-tbody');
|
|
pcTbody.innerHTML = '';
|
|
for (const [ind, cnt] of Object.entries(d.pipeline_companies || {})) {
|
|
const tr = document.createElement('tr');
|
|
tr.innerHTML = `<td>${ind}</td><td class="num">${fmt(cnt)}</td>`;
|
|
pcTbody.appendChild(tr);
|
|
}
|
|
|
|
// Top B2B domains
|
|
const domTbody = document.getElementById('dom-tbody');
|
|
domTbody.innerHTML = '';
|
|
(d.top_b2b_domains || []).forEach(item => {
|
|
const tr = document.createElement('tr');
|
|
tr.innerHTML = `<td><span class="badge bg-b2b">${item.industry}</span></td>
|
|
<td><code>${item.domain}</code></td>
|
|
<td class="num">${fmt(item.count)}</td>`;
|
|
domTbody.appendChild(tr);
|
|
});
|
|
|
|
document.getElementById('refresh-info').textContent =
|
|
'Last refresh: ' + new Date(d.ts).toLocaleString('fr-FR') + ' · Auto-refresh in 30s';
|
|
} catch (e) {
|
|
showToast('Erreur: ' + e.message);
|
|
document.getElementById('refresh-info').textContent = 'Error: ' + e.message;
|
|
}
|
|
}
|
|
loadData();
|
|
setInterval(loadData, 30000);
|
|
</script>
|
|
|
|
<!-- === OPUS UNIVERSAL DRILL-DOWN v1 19avr — append-only, doctrine #14 === -->
|
|
<script>
|
|
(function(){
|
|
if (window.__opusUniversalDrill) return; window.__opusUniversalDrill = true;
|
|
var d = document;
|
|
var m = d.createElement('div');
|
|
m.id = 'opus-udrill';
|
|
m.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,0.82);backdrop-filter:blur(6px);display:none;align-items:center;justify-content:center;z-index:99995;padding:20px;cursor:pointer';
|
|
var inner = d.createElement('div');
|
|
inner.id = 'opus-udrill-in';
|
|
inner.style.cssText = 'max-width:900px;width:100%;max-height:90vh;overflow:auto;background:#0b0d15;border:1px solid rgba(99,102,241,0.35);border-radius:14px;padding:28px;cursor:default;box-shadow:0 20px 60px rgba(0,0,0,0.6);color:#e2e8f0;font:14px/1.55 Inter,system-ui,sans-serif';
|
|
inner.addEventListener('click', function(e){ e.stopPropagation(); });
|
|
m.appendChild(inner);
|
|
m.addEventListener('click', function(){ m.style.display='none'; });
|
|
d.addEventListener('keydown', function(e){ if(e.key==='Escape') m.style.display='none'; });
|
|
(d.body || d.documentElement).appendChild(m);
|
|
|
|
function openCard(card) {
|
|
// Clone card content + show close btn + increase font-size
|
|
var html = '<div style="display:flex;justify-content:flex-end;margin-bottom:14px"><button id="opus-udrill-close" style="padding:6px 14px;background:#171b2a;border:1px solid rgba(99,102,241,0.25);color:#e2e8f0;border-radius:8px;cursor:pointer;font-size:12px">✕ Fermer (Esc)</button></div>';
|
|
html += '<div style="transform-origin:top left;font-size:1.05em">' + card.outerHTML + '</div>';
|
|
inner.innerHTML = html;
|
|
d.getElementById('opus-udrill-close').onclick = function(){ m.style.display='none'; };
|
|
m.style.display = 'flex';
|
|
}
|
|
|
|
function wire(root) {
|
|
var sels = '.card,[class*="card"],.kpi,[class*="kpi"],.stat,[class*="stat"],.tile,[class*="tile"],.metric,[class*="metric"],.widget,[class*="widget"]';
|
|
var cards = root.querySelectorAll(sels);
|
|
for (var i = 0; i < cards.length; i++) {
|
|
var c = cards[i];
|
|
if (c.__opusWired) continue;
|
|
if (c.closest('button, a, input, select, textarea, #opus-udrill')) continue;
|
|
var r = c.getBoundingClientRect();
|
|
if (r.width < 60 || r.height < 40) continue;
|
|
c.__opusWired = true;
|
|
c.style.cursor = 'pointer';
|
|
c.setAttribute('role','button');
|
|
c.setAttribute('tabindex','0');
|
|
c.addEventListener('click', function(ev){
|
|
// If a more-specific drill is already active (e.g. pp-card custom), let it handle
|
|
if (ev.target.closest('[data-pp-id]') && window.__opusDrillInit) return;
|
|
if (ev.target.closest('a,button,input,select')) return;
|
|
ev.preventDefault(); ev.stopPropagation();
|
|
openCard(this);
|
|
});
|
|
c.addEventListener('keydown', function(ev){ if(ev.key==='Enter'||ev.key===' '){ev.preventDefault();openCard(this);} });
|
|
}
|
|
}
|
|
|
|
// Initial + mutation observer
|
|
var initRun = function(){ wire(d.body || d.documentElement); };
|
|
if (d.readyState === 'loading') d.addEventListener('DOMContentLoaded', initRun);
|
|
else initRun();
|
|
var mo = new MutationObserver(function(muts){
|
|
var newCard = false;
|
|
for (var i=0;i<muts.length;i++) if (muts[i].addedNodes.length) { newCard = true; break; }
|
|
if (newCard) initRun();
|
|
});
|
|
mo.observe(d.body || d.documentElement, {childList:true, subtree:true});
|
|
})();
|
|
</script>
|
|
<!-- === OPUS UNIVERSAL DRILL-DOWN END === -->
|
|
|
|
<script src="/api/archi-meta-badge.js" defer></script>
|
|
</body></html>
|