From 135a6267dbf4da1e608446ee3a11968455791d9d Mon Sep 17 00:00:00 2001 From: sorcier Date: Wed, 11 Nov 2026 23:21:23 +0100 Subject: [PATCH] ui(ucp): cartes journal appels mobile style iPhone (v2.5.7) --- ucp/assets/ucp.js | 90 +++++++++++++++++++++++++++++++++-------------- ucp/index.php | 8 ++++- version.json | 3 +- 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/ucp/assets/ucp.js b/ucp/assets/ucp.js index 548d784..b05cbf7 100644 --- a/ucp/assets/ucp.js +++ b/ucp/assets/ucp.js @@ -607,7 +607,8 @@ function debounceLoadCdr() { async function loadPersonalCdr() { const tbody = document.getElementById('ucp-cdr-tbody'); - if (!tbody) return; + const mobileBox = document.getElementById('ucp-cdr-mobile-list'); + if (!tbody && !mobileBox) return; try { const res = await ucpApiCall('get_personal_cdr', 'GET', { @@ -625,46 +626,83 @@ async function loadPersonalCdr() { document.getElementById('ucp-cdr-missed').textContent = String(stats.missed); if (!calls.length) { - tbody.innerHTML = `Aucun appel correspondant.`; + if (tbody) tbody.innerHTML = `Aucun appel correspondant.`; + if (mobileBox) mobileBox.innerHTML = `
Aucun appel correspondant.
`; return; } - tbody.innerHTML = calls.map(c => { - const dirMap = { - inbound: '↘ Entrant', - outbound: '↗ Sortant', - internal: '⇄ Interne', - }; + const dirMap = { + inbound: '↘ Entrant', + outbound: '↗ Sortant', + internal: '⇄ Interne', + }; + + const formatParty = (name, num) => { + if (name && num && name !== num) { + return `
${escapeHtml(name)}
${escapeHtml(num)}
`; + } + return `${escapeHtml(num || name || '—')}`; + }; + + const formatInlineParty = (name, num) => { + if (name && num && name !== num) { + return `${escapeHtml(name)} (${escapeHtml(num)})`; + } + return `${escapeHtml(num || name || '—')}`; + }; + + const rowsHtml = []; + const cardsHtml = []; + + calls.forEach(c => { const ok = c.disposition === 'ANSWERED'; const stBadge = ok ? `${escapeHtml(c.status_label || 'Répondu')}` : `${escapeHtml(c.status_label || 'Manqué')}`; - const srcNum = String(c.caller_number ?? c.src ?? ''); - const srcName = String(c.caller_name ?? ''); - const dstNum = String(c.callee_number ?? c.dst ?? ''); - const dstName = String(c.callee_name ?? ''); + const dirBadge = dirMap[c.direction] || escapeHtml(c.direction_label || c.direction); + const srcNum = String(c.caller_number ?? c.src ?? ''); + const srcName = String(c.caller_name ?? ''); + const dstNum = String(c.callee_number ?? c.dst ?? ''); + const dstName = String(c.callee_name ?? ''); + const durText = escapeHtml(c.billsec_formatted || formatDuration(c.billsec || c.duration || 0)); + const dtText = escapeHtml(c.datetime_formatted || c.datetime || ''); - const formatParty = (name, num) => { - if (name && num && name !== num) { - return `
${escapeHtml(name)}
${escapeHtml(num)}
`; - } - return `${escapeHtml(num || name || '—')}`; - }; - - return ` + rowsHtml.push(` - ${escapeHtml(c.datetime_formatted || c.datetime || '')} - ${dirMap[c.direction] || escapeHtml(c.direction_label || c.direction)} + ${dtText} + ${dirBadge} ${formatParty(srcName, srcNum)} ${formatParty(dstName, dstNum)} - ${escapeHtml(c.billsec_formatted || formatDuration(c.billsec || c.duration || 0))} + ${durText} ${stBadge} - `; - }).join(''); + `); + + cardsHtml.push(` +
+
+
+ ${dirBadge} + ${stBadge} +
+ ⏱ ${durText} +
+
+ ${formatInlineParty(srcName, srcNum)} + → + ${formatInlineParty(dstName, dstNum)} +
+
${dtText}
+
+ `); + }); + + if (tbody) tbody.innerHTML = rowsHtml.join(''); + if (mobileBox) mobileBox.innerHTML = cardsHtml.join(''); } catch (err) { - tbody.innerHTML = `${escapeHtml(err.message)}`; + if (tbody) tbody.innerHTML = `${escapeHtml(err.message)}`; + if (mobileBox) mobileBox.innerHTML = `
${escapeHtml(err.message)}
`; } } diff --git a/ucp/index.php b/ucp/index.php index d9667d2..d01281a 100644 --- a/ucp/index.php +++ b/ucp/index.php @@ -350,7 +350,13 @@ $csrfToken = UcpAuth::getCsrfToken(); class="px-3 py-2 rounded-xl bg-slate-50 border border-slate-300 text-xs text-slate-900 focus:bg-white focus:outline-none focus:border-indigo-500"> -
+ +
+
Chargement…
+
+ + +