heystreamer/views/dashboard.ejs
Bashy 19a0965eb2 Activity replay, HUDFX in the overlay, chat filter, redeem art fix
- Dashboard Recent activity: readable details (reward name, cost, variation,
  rarity, TTS, viewer message; sub tier/months; bits; raids; polls), local
  times, and a Replay button. Each row now stores the overlay message that was
  shown (activity_log.replay_json); older redeem/raid rows are rebuilt from the
  raw Twitch event.
- Fix: redeem alerts lost polaroid/art/emote since 4fda606 (they had ended up
  inside a comment), so sticker art, Power-up emotes and sound-only were gone.
- HUDFX embedded in the overlay with ?ext=hudfx (opt-in per OBS source): its
  page is served from our domain with the camcorder CSS, its settings API is
  forwarded, its Web Worker is started from a same-origin stand-in (the alert
  box needs it; blob: workers break the site CSP), and the box sits in the
  alert corner. The HUDFX URL is a field on the Settings page.
- Blerp cassette CSS kept with it (src/ext/blerp.css, pasted into the Blerp
  OBS source; Blerp itself cannot be embedded: its realtime server only
  accepts its own site).
- On-screen chat: Settings -> Hidden chatters and Hide ! commands.
- Outgoing raids are logged with a line in the server log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:29:20 +02:00

154 lines
8.2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h2>Dashboard</h2>
<div style="display:flex; gap:1rem; margin-bottom:1.5rem; flex-wrap:wrap;">
<div>
<strong>Channel:</strong>
<%= settings.channel || '<em>not set</em>' %>
</div>
<div>
<strong>OBS browser sources</strong> (1920×1080):<br>
<small>Chat only, set its audio to <em>Monitor Only (mute output)</em> so chat sounds stay off stream:</small><br>
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=chat</code><br>
<small>Everything except chat (alerts, redeems, poll, Hype Train bar, raid send-off):</small><br>
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=nochat</code><br>
<small>Chat somewhere else, e.g. in the Intermission panel (left,top,width,height in px of the 1920×1080 page; <em>up</em> = newest at the bottom):</small><br>
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=chat&amp;chat=130,640,700,360&amp;chatflow=up</code><br>
<small title="parts: chat, alerts, poll, hypebar, raid. List them (?parts=chat,raid) or exclude with no… (?parts=nochat,noraid). No ?parts = everything.">
Other combinations: hover for help · everything in one source: <code>/overlay/<%= settings.overlay_id %></code></small>
</div>
</div>
<div style="display:flex; gap:.8rem; align-items:center; margin-bottom:1.5rem;">
<button type="button" id="skip-alert" class="outline" style="width:auto; margin:0;"
title="Stops the alert that is on screen right now (sound and TTS voice too). Queued alerts carry on.">⏭ Skip current alert</button>
<small id="skip-status"></small>
</div>
<script>
document.getElementById('skip-alert').addEventListener('click', async () => {
const st = document.getElementById('skip-status');
try { const r = await fetch('/alerts/skip', { method: 'POST' }); st.textContent = r.ok ? 'Skipped' : `Failed (${r.status})`; }
catch (e) { st.textContent = 'Failed: ' + e.message; }
setTimeout(() => { st.textContent = ''; }, 3000);
});
</script>
<h3>Twitch connection</h3>
<p>
<% if (eventsubStatus.connected) { %>
<span class="badge badge-green">connected</span>
<% } else if (eventsubStatus.running) { %>
<span class="badge badge-grey">connecting…</span>
<% } else { %>
<span class="badge badge-grey">not running</span> (log in again to start)
<% } %>
<% if (eventsubStatus.subscribed.length) { %><br><small>Listening to: <%= eventsubStatus.subscribed.join(', ') %></small><% } %>
<% if (eventsubStatus.failed.length) { %><br><small style="color:#c0392b">Failed: <%= eventsubStatus.failed.join(', ') %> (log out and in again if a permission is missing)</small><% } %>
<% if (eventsubStatus.lastEventAt) { %><br><small>Last event: <%= eventsubStatus.lastEventAt %></small><% } %>
</p>
<h3>StreamElements tips</h3>
<p>
<% if (!seStatus.enabled) { %>
<span class="badge badge-grey">off</span> <small>set <code>SE_JWT</code> in <code>.env</code> (StreamElements dashboard → avatar → your channel → JWT token) and restart</small>
<% } else if (seStatus.subscribed) { %>
<span class="badge badge-green">connected</span><% if (seStatus.lastTipAt) { %> <small>last tip: <%= seStatus.lastTipAt %></small><% } %>
<% } else { %>
<span class="badge badge-grey">connecting…</span>
<% } %>
<% if (seStatus.error) { %><br><small style="color:#c0392b"><%= seStatus.error %></small><% } %>
</p>
<h3>Raid</h3>
<p><small>Start the raid here and the send-off card stays on stream (silent) until the raid happens. Same as Twitch's Raid button.</small></p>
<div style="display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin-bottom:.4rem;">
<input id="raid-target" placeholder="channel name" style="width:16rem; margin:0;">
<button type="button" id="raid-start" style="width:auto; margin:0;">Start raid</button>
<button type="button" id="raid-cancel" class="outline" style="width:auto; margin:0;">Cancel raid</button>
<small id="raid-status"></small>
</div>
<script>
(() => {
const out = document.getElementById('raid-status');
const call = async (url, body) => {
try {
const r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) });
const j = await r.json().catch(() => ({}));
out.textContent = j.ok ? (j.target ? `Raiding ${j.target}${j.viewers != null ? ' with ' + j.viewers : ''}…` : 'Raid cancelled') : `Failed: ${j.error || r.status}`;
} catch (e) { out.textContent = 'Failed: ' + e.message; }
};
document.getElementById('raid-start').addEventListener('click', () => call('/alerts/raid/start', { target: document.getElementById('raid-target').value }));
document.getElementById('raid-cancel').addEventListener('click', () => call('/alerts/raid/cancel'));
})();
</script>
<h3>Test alerts</h3>
<p><small>Sends a sample alert to the overlay (OBS). Not logged, no actions fired.</small></p>
<div id="test-alerts" style="display:flex; flex-wrap:wrap; gap:.4rem; margin-bottom:.5rem;">
<% for (const key of testKeys) { %>
<button type="button" class="outline" data-key="<%= key %>" style="width:auto; padding:.3rem .8rem; margin:0;"><%= key %></button>
<% } %>
</div>
<p><small id="test-status"></small></p>
<script>
document.querySelectorAll('#test-alerts button').forEach(b => b.addEventListener('click', async () => {
const out = document.getElementById('test-status');
try {
const r = await fetch('/alerts/test/' + encodeURIComponent(b.dataset.key), { method: 'POST' });
out.textContent = r.ok ? `Sent: ${b.dataset.key}` : `Failed (${r.status})`;
} catch (e) { out.textContent = 'Failed: ' + e.message; }
}));
</script>
<div style="display:flex; align-items:center; gap:1rem; flex-wrap:wrap;">
<h3 style="margin:0;">Recent activity</h3>
<button type="button" id="activity-reload" class="outline" style="width:auto; padding:.3rem .8rem; margin:0;">Reload</button>
<label style="margin:0;"><input type="checkbox" id="activity-auto"> auto-refresh (15 s)</label>
<small id="activity-updated"></small>
</div>
<div id="activity"><%- include('_activity') %></div>
<script>
(() => {
const box = document.getElementById('activity');
const stamp = document.getElementById('activity-updated');
const auto = document.getElementById('activity-auto');
let timer = null;
// times are stored in UTC: show them in this browser's time zone
function localTimes() {
box.querySelectorAll('time[datetime]').forEach(t => {
const d = new Date(t.getAttribute('datetime'));
if (!isNaN(d)) { t.title = t.textContent; t.textContent = d.toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' }); }
});
}
// Replay buttons (the table is re-rendered on reload, so listen on the box)
box.addEventListener('click', async ev => {
const b = ev.target.closest('.activity-replay'); if (!b) return;
const st = b.parentElement.querySelector('.activity-replay-status');
b.disabled = true; st.textContent = '…';
try {
const r = await fetch('/activity/' + encodeURIComponent(b.dataset.id) + '/replay', { method: 'POST' });
const j = await r.json().catch(() => ({}));
st.textContent = j.ok ? 'sent' : (j.error || `failed (${r.status})`);
} catch (e) { st.textContent = 'failed: ' + e.message; }
b.disabled = false;
});
localTimes();
async function reload() {
try {
const r = await fetch('/activity', { headers: { 'Accept': 'text/html' } });
if (r.redirected || !r.ok) { stamp.textContent = 'Reload failed (logged out?)'; return; }
box.innerHTML = await r.text();
localTimes();
stamp.textContent = 'Updated ' + new Date().toLocaleTimeString();
} catch (e) { stamp.textContent = 'Reload failed: ' + e.message; }
}
function setAuto(on) {
clearInterval(timer);
if (on) timer = setInterval(reload, 15000);
try { localStorage.setItem('activityAuto', on ? '1' : '0'); } catch {}
}
document.getElementById('activity-reload').addEventListener('click', reload);
auto.addEventListener('change', () => setAuto(auto.checked));
try { auto.checked = localStorage.getItem('activityAuto') === '1'; } catch {}
setAuto(auto.checked);
})();
</script>