Some checks failed
CI / build-and-test (push) Failing after 30s
REST additions: GET /topology returns mode (hidden/public/unknown) + sender/receiver group lists. POST /topology/apply confines local senders to teamsiso-input + receivers to public+teamsiso-input. POST /topology/restore returns both to public defaults.
GET /participants/{id}/thumbnail.jpg encodes the latest engine ProcessedFrame as a 192-wide JPEG. 404 when no pipeline is running. Used by the /ui control panel for live preview tiles.
Settings: ControlSurfaceEnabled now persists across sessions via UIPreferences and auto-starts the server on app launch when previously enabled.
/ui control panel rebuilt: live thumbnail per row, topology toggle card with Hide/Restore buttons, removed dead recording marker button, larger layout (920px), participant rows in single card with hover affordances.
302 lines
12 KiB
C#
302 lines
12 KiB
C#
namespace TeamsISO.App.Services;
|
|
|
|
/// <summary>
|
|
/// The HTML / CSS / JS for the embedded control panel served at
|
|
/// <c>GET /ui</c>. Single self-contained string — no external CDN deps, no
|
|
/// build step, no React. Phone-friendly remote that connects via WebSocket
|
|
/// to <c>/ws</c> and posts to the existing REST endpoints.
|
|
///
|
|
/// v2 additions:
|
|
/// - Live preview tiles per participant via GET /participants/{id}/thumbnail.jpg
|
|
/// (engine encodes the latest ProcessedFrame as a 192-wide JPEG; refreshed
|
|
/// ~1Hz alongside the WebSocket state push).
|
|
/// - Topology toggle card — shows whether raw Teams NDI sources are
|
|
/// hidden from the LAN, with Apply / Restore buttons that hit the
|
|
/// /topology/apply + /topology/restore REST endpoints. Operator still
|
|
/// has to restart Teams afterward, surfaced in a banner on apply.
|
|
/// </summary>
|
|
internal static class ControlPanelHtml
|
|
{
|
|
private const string Html = @"<!doctype html>
|
|
<html lang='en'>
|
|
<head>
|
|
<meta charset='utf-8'>
|
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
<title>TeamsISO Control</title>
|
|
<style>
|
|
:root {
|
|
--bg: #0a0a0a;
|
|
--surface: #141414;
|
|
--surface-elev: #1c1c1c;
|
|
--border: #262626;
|
|
--border-strong: #3a3b40;
|
|
--text: #f5f5f5;
|
|
--text-2: #a3a3a3;
|
|
--text-3: #6b6b6b;
|
|
--cyan: #97edf0;
|
|
--cyan-mute: #1b3537;
|
|
--cyan-text: #97edf0;
|
|
--coral: #fb819c;
|
|
--coral-bg: #3a1922;
|
|
--green: #4ade80;
|
|
--amber: #fbbf24;
|
|
}
|
|
* { box-sizing: border-box; }
|
|
html, body { margin: 0; background: var(--bg); color: var(--text);
|
|
font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
|
|
-webkit-font-smoothing: antialiased;
|
|
}
|
|
body { padding: 16px; max-width: 920px; margin: 0 auto; }
|
|
h1 {
|
|
font-size: 11px; letter-spacing: 0.12em; font-weight: 600;
|
|
text-transform: uppercase; color: var(--text-3); margin: 0 0 14px;
|
|
}
|
|
.card {
|
|
background: var(--surface); border: 1px solid var(--border);
|
|
border-radius: 12px; padding: 14px; margin-bottom: 12px;
|
|
}
|
|
.row { display: flex; align-items: center; gap: 10px; }
|
|
.row + .row { margin-top: 10px; }
|
|
.grow { flex: 1; min-width: 0; }
|
|
button {
|
|
background: var(--surface-elev); color: var(--text); border: 1px solid var(--border);
|
|
border-radius: 8px; padding: 10px 14px; cursor: pointer;
|
|
font: inherit; font-size: 13px;
|
|
transition: background 80ms ease, border-color 80ms ease;
|
|
}
|
|
button:hover { background: #242424; border-color: var(--border-strong); }
|
|
button.primary { background: var(--cyan); color: #042830; border-color: var(--cyan); font-weight: 500; }
|
|
button.primary:hover { background: #b5f2f4; }
|
|
button.danger { background: transparent; color: var(--coral); border-color: var(--coral); }
|
|
button.danger:hover { background: var(--coral-bg); }
|
|
button.live { background: var(--cyan-mute); color: var(--cyan-text); border-color: var(--cyan); }
|
|
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
|
|
.dot.cyan { background: var(--cyan); }
|
|
.dot.coral { background: var(--coral); }
|
|
.dot.green { background: var(--green); }
|
|
.dot.amber { background: var(--amber); }
|
|
.dot.gray { background: var(--text-3); }
|
|
.name { font-weight: 500; font-size: 14px; }
|
|
.sub { color: var(--text-3); font-size: 11px;
|
|
font-family: 'JetBrains Mono', 'Cascadia Mono', monospace;
|
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
.label-caps { font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
|
|
color: var(--text-3); text-transform: uppercase; }
|
|
.status {
|
|
display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
|
|
font-family: 'JetBrains Mono', 'Cascadia Mono', monospace;
|
|
font-size: 11px; color: var(--text-3);
|
|
}
|
|
.status .ok { color: var(--green); }
|
|
.status .err { color: var(--coral); }
|
|
.empty { color: var(--text-3); font-size: 12px; padding: 18px; text-align: center; }
|
|
.global-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
|
|
@media (min-width: 480px) { .global-actions { grid-template-columns: repeat(4, 1fr); } }
|
|
.participant-row { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 10px; }
|
|
.participant-row + .participant-row { margin-top: 6px; }
|
|
.participant-row.speaking { background: var(--cyan-mute); }
|
|
.preview {
|
|
width: 112px; height: 63px; flex-shrink: 0; border-radius: 6px;
|
|
background: var(--surface-elev); border: 1px solid var(--border);
|
|
object-fit: cover; display: block;
|
|
}
|
|
.preview.empty { display: flex; align-items: center; justify-content: center;
|
|
color: var(--text-3); font-family: 'JetBrains Mono', monospace; font-size: 18px; }
|
|
.topology-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
|
|
.topology-state { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
|
|
.topology-state strong { font-size: 13px; color: var(--text); }
|
|
.topology-banner { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px;
|
|
background: var(--cyan-mute); color: var(--cyan-text); font-size: 12px; display: none; }
|
|
.topology-banner.show { display: block; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>TeamsISO control surface</h1>
|
|
|
|
<div class='card'>
|
|
<div class='status'>
|
|
<span><span id='conn' class='dot gray'></span> <span id='conn-text'>connecting…</span></span>
|
|
<span id='count' class='sub'></span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class='card topology-card'>
|
|
<div class='topology-state'>
|
|
<span id='topo-dot' class='dot gray'></span>
|
|
<div>
|
|
<div class='label-caps'>Network topology</div>
|
|
<strong id='topo-label'>—</strong>
|
|
<div id='topo-detail' class='sub' style='margin-top: 2px;'></div>
|
|
</div>
|
|
</div>
|
|
<div style='display: flex; gap: 8px;'>
|
|
<button id='topo-apply' onclick='applyTopology()'>Hide Teams sources</button>
|
|
<button id='topo-restore' onclick='restoreTopology()'>Restore defaults</button>
|
|
</div>
|
|
</div>
|
|
<div id='topo-banner' class='topology-banner'></div>
|
|
|
|
<div class='card'>
|
|
<div class='global-actions'>
|
|
<button onclick='post(""/teams/mute"")'>Mute</button>
|
|
<button onclick='post(""/teams/camera"")'>Camera</button>
|
|
<button onclick='post(""/teams/share"")'>Share</button>
|
|
<button onclick='post(""/teams/leave"")'>Leave</button>
|
|
<button onclick='dropNote()'>Note…</button>
|
|
<button onclick='post(""/presets/refresh-discovery"")'>Refresh</button>
|
|
<button class='danger' onclick='post(""/presets/stop-all"")'>Stop all ISOs</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id='participants'></div>
|
|
|
|
<script>
|
|
const list = document.getElementById('participants');
|
|
const conn = document.getElementById('conn');
|
|
const connText = document.getElementById('conn-text');
|
|
const count = document.getElementById('count');
|
|
const topoDot = document.getElementById('topo-dot');
|
|
const topoLabel = document.getElementById('topo-label');
|
|
const topoDetail = document.getElementById('topo-detail');
|
|
const topoBanner = document.getElementById('topo-banner');
|
|
|
|
function setConn(state, text) {
|
|
conn.className = 'dot ' + state;
|
|
connText.textContent = text;
|
|
}
|
|
|
|
async function post(path, body) {
|
|
try {
|
|
const opts = { method: 'POST' };
|
|
if (body) { opts.headers = { 'Content-Type': 'application/json' }; opts.body = JSON.stringify(body); }
|
|
const r = await fetch(path, opts);
|
|
return r.ok ? await r.json().catch(() => null) : null;
|
|
} catch (e) { console.warn(e); return null; }
|
|
}
|
|
|
|
function dropNote() {
|
|
const text = prompt('Note (will be timestamped in the day file):');
|
|
if (text && text.trim()) post('/notes', { text: text.trim() });
|
|
}
|
|
|
|
async function fetchTopology() {
|
|
try {
|
|
const r = await fetch('/topology');
|
|
if (!r.ok) return;
|
|
const t = await r.json();
|
|
paintTopology(t);
|
|
} catch (e) { console.warn(e); }
|
|
}
|
|
|
|
function paintTopology(t) {
|
|
if (!t) return;
|
|
if (t.mode === 'hidden') {
|
|
topoDot.className = 'dot cyan';
|
|
topoLabel.textContent = 'Teams hidden from LAN';
|
|
} else if (t.mode === 'public') {
|
|
topoDot.className = 'dot amber';
|
|
topoLabel.textContent = 'Public — raw Teams visible';
|
|
} else {
|
|
topoDot.className = 'dot gray';
|
|
topoLabel.textContent = 'Unknown';
|
|
}
|
|
const sends = (t.senders || []).join(', ') || '—';
|
|
const recvs = (t.receivers || []).join(', ') || '—';
|
|
topoDetail.textContent = 'send: ' + sends + ' · recv: ' + recvs;
|
|
}
|
|
|
|
async function applyTopology() {
|
|
const r = await post('/topology/apply');
|
|
if (r && r.ok) {
|
|
topoBanner.textContent = '✓ ' + (r.note || 'Applied. Restart Microsoft Teams for it to take effect.');
|
|
topoBanner.classList.add('show');
|
|
setTimeout(() => topoBanner.classList.remove('show'), 8000);
|
|
}
|
|
fetchTopology();
|
|
}
|
|
|
|
async function restoreTopology() {
|
|
if (!confirm('Restore default NDI groups? Teams will broadcast on public again after you restart it.')) return;
|
|
const r = await post('/topology/restore');
|
|
if (r && r.ok) {
|
|
topoBanner.textContent = '✓ Defaults restored. Restart Microsoft Teams for it to take effect.';
|
|
topoBanner.classList.add('show');
|
|
setTimeout(() => topoBanner.classList.remove('show'), 8000);
|
|
}
|
|
fetchTopology();
|
|
}
|
|
|
|
function render(participants) {
|
|
if (!participants || participants.length === 0) {
|
|
list.innerHTML = ""<div class='card empty'>No participants visible. Open Teams and join a meeting; sources will populate within seconds.</div>"";
|
|
count.textContent = '';
|
|
return;
|
|
}
|
|
const live = participants.filter(p => p.isEnabled).length;
|
|
count.textContent = live + ' / ' + participants.length + ' live';
|
|
list.innerHTML = '';
|
|
const card = document.createElement('div');
|
|
card.className = 'card';
|
|
for (const p of participants) {
|
|
const row = document.createElement('div');
|
|
row.className = 'participant-row';
|
|
const stateColor = p.isEnabled ? 'cyan' : (p.isOnline ? 'gray' : 'coral');
|
|
// Live preview tile — cache-bust with a 1s-bucket query param so the
|
|
// browser refreshes the image without flickering on every WS message.
|
|
const bust = Math.floor(Date.now() / 1000);
|
|
const previewUrl = '/participants/' + p.id + '/thumbnail.jpg?t=' + bust;
|
|
row.innerHTML =
|
|
""<span class='dot "" + stateColor + ""'></span>"" +
|
|
""<img class='preview' alt='' onerror=\""this.style.display='none'; this.nextElementSibling.style.display='flex';\"" >"" +
|
|
""<div class='preview empty' style='display:none;'>—</div>"" +
|
|
""<div class='grow'>"" +
|
|
""<div class='name'></div>"" +
|
|
""<div class='sub'></div>"" +
|
|
""</div>"" +
|
|
""<button class='"" + (p.isEnabled ? 'live' : '') + ""'></button>"";
|
|
const img = row.querySelector('img.preview');
|
|
img.src = previewUrl;
|
|
row.querySelector('.name').textContent = p.displayName;
|
|
row.querySelector('.sub').textContent =
|
|
(p.stateLabel || (p.isOnline ? 'online' : 'offline')) +
|
|
(p.customName ? ' · ' + p.customName : '');
|
|
const btn = row.querySelector('button');
|
|
btn.textContent = p.isEnabled ? '● LIVE' : 'Enable';
|
|
btn.onclick = () => post('/participants/iso', {
|
|
displayName: p.displayName,
|
|
enabled: !p.isEnabled,
|
|
});
|
|
card.appendChild(row);
|
|
}
|
|
list.appendChild(card);
|
|
}
|
|
|
|
function connect() {
|
|
setConn('gray', 'connecting…');
|
|
const ws = new WebSocket(
|
|
(location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/ws');
|
|
ws.onopen = () => { setConn('green', 'live'); fetchTopology(); };
|
|
ws.onmessage = (ev) => {
|
|
try {
|
|
const m = JSON.parse(ev.data);
|
|
if (m.type === 'participants') render(m.participants);
|
|
} catch (e) { console.warn(e); }
|
|
};
|
|
ws.onclose = () => {
|
|
setConn('coral', 'disconnected — retry in 3s');
|
|
setTimeout(connect, 3000);
|
|
};
|
|
ws.onerror = () => setConn('coral', 'error');
|
|
}
|
|
|
|
connect();
|
|
// Re-poll topology every 30s in case the operator changes the machine NDI
|
|
// config externally (NDI Access Manager, manual edit). Cheap — one HTTP GET.
|
|
setInterval(fetchTopology, 30000);
|
|
</script>
|
|
</body>
|
|
</html>
|
|
";
|
|
|
|
public static string Get() => Html;
|
|
}
|