MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / fetchDashboardStatsForSelection

Function fetchDashboardStatsForSelection

web/scripts/ragnar_modern.js:8398–8428  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

8396 _ndBusy(btn, true, 'Listening…');
8397 out.classList.remove('hidden');
8398 out.innerHTML = '<p class="text-sm text-gray-400">Passively capturing DTP frames (hellos are ~30s apart)…</p>';
8399 try {
8400 _dtpFillIfaces();
8401 const qs = '?seconds=' + encodeURIComponent(secs) + (iface ? '&interface=' + encodeURIComponent(iface) : '');
8402 const d = await fetchAPI('/api/net/dtp-watch' + qs);
8403 if (!d || d.success === false) {
8404 const msg = (d && d.error) || 'failed';
8405 let extra = '';
8406 if (d && d.missing_tool) extra = ' <button onclick="installNetTool(\'tcpdump\', this, runDtpWatch)" class="ml-2 underline text-cyan-400">Install tcpdump</button>';
8407 out.innerHTML = '<p class="text-sm text-red-400">Error: ' + escapeHtml(msg) + extra + '</p>';
8408 return;
8409 }
8410 const [cls, label] = _DTP_VERDICT_STYLE[d.verdict] || _DTP_VERDICT_STYLE.unknown;
8411 let html = `<div class="mb-2 px-3 py-2 rounded border ${cls} text-sm">${label}</div>`;
8412 html += `<p class="text-xs text-gray-500 mb-2">Interface: ${escapeHtml(d.interface || '—')} · ${d.seconds}s · ${d.packet_count} DTP frame(s), ${d.speaker_count} speaker(s)${d.learned ? ' · <span class="text-gray-400">baseline learned now</span>' : ''}</p>`;
8413 if ((d.speakers || []).length) {
8414 html += '<table class="min-w-full text-xs text-gray-300 whitespace-nowrap"><thead>' +
8415 '<tr class="text-left text-gray-500"><th class="px-2 py-1">Speaker MAC</th><th class="px-2 py-1">Status</th><th class="px-2 py-1">Trunk?</th><th class="px-2 py-1">Status</th></tr>' +
8416 '</thead><tbody>' +
8417 d.speakers.map(sp => {
8418 const badge = sp.baseline ? '<span class="text-green-400">✓ known</span>' : '<span class="text-amber-300">? new</span>';
8419 const forming = sp.forming ? '<span class="text-red-300">forming</span>' : '<span class="text-gray-500">no</span>';
8420 return `<tr class="border-t border-slate-800">
8421 <td class="px-2 py-1 font-mono ${sp.baseline ? '' : 'text-amber-300'}">${escapeHtml(sp.src)}</td>
8422 <td class="px-2 py-1 font-mono">${escapeHtml(sp.status)}</td>
8423 <td class="px-2 py-1">${forming}</td>
8424 <td class="px-2 py-1">${badge}</td>
8425 </tr>`;
8426 }).join('') +
8427 '</tbody></table>';
8428 }
8429 if (d.reasons && d.reasons.length) {
8430 html += '<ul class="text-xs text-gray-400 mt-2 list-disc pl-5">' +
8431 d.reasons.map(r => '<li>' + escapeHtml(r) + '</li>').join('') + '</ul>';

Calls 2

fetchAPIFunction · 0.70

Tested by

no test coverage detected