[Added filter by content type for message in web admin handler Adrian Georgescu **20260802084347 Ignore-this: 902a35caae6fa2a301e4d7feb940dbd3ccd3122a84ebdbac0145c3621938f71d14ea75e57af1e615 ] hunk ./sylk/applications/webrtcgateway/web.py 1204 +// Per-day message list: full set for the current view plus the +// client-side content-type filter selected in the dropdown above it. +let dayMsgAll = []; +let dayMsgTypeFilter = ''; + +function msgDayRowsHtml(msgs) { + const account = msgFilters.account; + const dirArrow = d => d === 'outgoing' ? '→' : d === 'incoming' ? '←' : ''; + return msgs.length ? msgs.map(m => ` + + ${esc((m.created_at || '').slice(11, 19) || m.created_at || '')} + ${dirArrow(m.direction)} + ${esc(m.contact)} + ${esc(m.content_type)} + ${esc(m.state)} + ${esc(m.message_id)} + `).join('') + : `${dayMsgTypeFilter ? 'No messages of this content type on this day.' : 'No messages on this day.'}`; +} + +// Re-render just the day-message rows for the picked content type — the +// day's messages are already loaded, so no refetch is needed. +function msgFilterDay(type) { + dayMsgTypeFilter = type || ''; + const tb = $('msgDayTbody'); + if (!tb) return; + const msgs = dayMsgTypeFilter + ? dayMsgAll.filter(m => (m.content_type || 'unknown') === dayMsgTypeFilter) + : dayMsgAll; + tb.innerHTML = msgDayRowsHtml(msgs); + const cnt = $('msgDayCount'); + if (cnt) cnt.textContent = Number(msgs.length).toLocaleString(); +} + hunk ./sylk/applications/webrtcgateway/web.py 1296 - const dirArrow = d => d === 'outgoing' ? '→' : d === 'incoming' ? '←' : ''; hunk ./sylk/applications/webrtcgateway/web.py 1297 - const dayList = dayMsgs ? ` + // Snapshot the day's messages and reset the content-type filter every + // time the view reloads (new account / contact / date). + dayMsgAll = dayMsgs || []; + dayMsgTypeFilter = ''; + const dayList = dayMsgs ? (() => { + // Content types present in this day's messages, for the filter dropdown. + const dayTypeCounts = {}; + dayMsgAll.forEach(m => { const t = m.content_type || 'unknown'; dayTypeCounts[t] = (dayTypeCounts[t] || 0) + 1; }); + const typeOpts = [``] + .concat(Object.keys(dayTypeCounts).sort().map(t => + ``)).join(''); + return ` hunk ./sylk/applications/webrtcgateway/web.py 1310 - ${Number(dayMsgs.length).toLocaleString()} message(s) on ${esc(msgDateLabel(j.date))}${j.contact ? ` with ${esc(j.contact)}` : ''}, by time - + ${Number(dayMsgAll.length).toLocaleString()} message(s) on ${esc(msgDateLabel(j.date))}${j.contact ? ` with ${esc(j.contact)}` : ''}, by time +
+ + +
+
hunk ./sylk/applications/webrtcgateway/web.py 1323 - ${ - dayMsgs.length ? dayMsgs.map(m => ` - - - - - - - - `).join('') - : `` - }
${esc((m.created_at || '').slice(11, 19) || m.created_at || '')}${dirArrow(m.direction)}${esc(m.contact)}${esc(m.content_type)}${esc(m.state)}${esc(m.message_id)}
No messages on this day.
+ ${msgDayRowsHtml(dayMsgAll)} hunk ./sylk/applications/webrtcgateway/web.py 1325 - ` : ''; + `; + })() : '';