Stats per stream and period, public stats page, dashboard settings, Card alert style

Statistics
- Per day and per stream statistics (src/periodstats.js, one generic stat_day table), backfilled
  once from the older tables; Stream / Week / Month / Year / All time views, Community and Streams tabs.
- Viewer count every 5 minutes and title / category history per stream (EventSub channel.update):
  viewer graph, games played (donut), games in the streams list.
- Twitch sync (src/twitchsync.js): followers with follow dates, current subs, mods, VIPs, all-time
  bits, channel emotes, past streams from VODs. Twitch analytics CSV import (src/twitchcsv.js).
- Public stats page on its own host (Settings -> Stats and data): no message text, no bots,
  !hideme / !showme opt-out. Viewer page: roles, follow age, sub status, bits, a menu for rarely used actions.
- StreamElements watch-time importer removed (already imported minutes stay as a baseline).

Dashboard
- Settings and Actions with a left sidebar; each settings page saves only its own fields.
  Connections (Twitch, StreamElements token now set here, HUDFX), OBS links (hidden behind an eye
  toggle) with a link builder, Chat (sound picked from the media library), TTS, Stats and data,
  Backup (export / import the whole setup), Advanced. Time zone setting for the stats pages.
- Actions -> Alerts: alert style, pictures, sounds, bits tiers and card colours, stored in the
  database (src/theme.js); an old file-based theme is imported once. Alert preview page
  (/actions/alerts/preview, tools/preview/export.js for a static copy).
- Old /actions page removed; Actions = Redeems / Alerts / TTS voices / Media.

Alerts
- New plain Card style for everyone (public/alerts/card.js); Polaroid, Cassette and the TTS letter
  stay as optional looks. Redeem variations can be Card, Cassette, Sound only or Video.

Repo
- No channel data in git: the channel's art, stickers and sounds stay on disk (gitignored) and are
  picked in the dashboard; examples for the server config (apache.example.sh, .env.example).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-11-23 11:22:49 +02:00
parent 5bf4bffaa0
commit c481ca92cb
57 changed files with 3080 additions and 774 deletions

View file

@ -14,6 +14,45 @@
.badge-green { background: #1a7a1a; color: #a8f0a8; }
.badge-red { background: #7a1a1a; color: #f0a8a8; }
.badge-grey { background: #333; color: #aaa; }
nav ul li a.on { color: var(--pico-color); font-weight: 700; }
/* left sidebar of Actions / Settings */
main.with-side { max-width: 1400px; margin: 0 auto; }
.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 2rem; align-items: start; }
.side { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .15rem; }
.side-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--pico-muted-color); margin: 0 0 .4rem .75rem; }
.side a { display: block; padding: .45rem .75rem; border-radius: 8px; text-decoration: none; color: var(--pico-muted-color); font-size: .95rem; }
.side a:hover { background: var(--pico-card-background-color); color: var(--pico-color); }
.side a.on { background: var(--pico-primary-background); color: #fff; font-weight: 600; }
@media (max-width: 800px) {
.shell { grid-template-columns: 1fr; gap: 1rem; }
.side { position: static; flex-direction: row; flex-wrap: wrap; }
.side-title { display: none; }
}
/* settings pages: one card per group, label left, control right */
.set-h { margin: 0 0 .3rem; }
.set-intro { color: var(--pico-muted-color); margin: 0 0 1.2rem; }
.set-card { border: 1px solid var(--pico-muted-border-color); border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1.2rem; }
.set-card > h3 { font-size: 1.05rem; margin: 0 0 .8rem; }
.set-row { display: grid; grid-template-columns: minmax(180px, 280px) minmax(0, 1fr); gap: .4rem 1.4rem; align-items: start; padding: .7rem 0; border-top: 1px solid var(--pico-muted-border-color); }
.set-card > h3 + .set-row, .set-card > .set-row:first-child { border-top: 0; padding-top: 0; }
.set-row > .lbl { font-weight: 600; font-size: .92rem; }
.set-row > .lbl small { display: block; font-weight: 400; color: var(--pico-muted-color); font-size: .8rem; margin-top: .15rem; }
.set-row input:not([type=checkbox]):not([type=radio]), .set-row select, .set-row textarea { margin: 0; }
.set-row label { margin: 0; }
@media (max-width: 700px) { .set-row { grid-template-columns: 1fr; } }
.set-inline { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.set-inline > * { margin: 0 !important; }
.btn-auto { width: auto !important; }
.savebar-set { position: sticky; bottom: 0; display: flex; gap: .8rem; align-items: center; padding: .7rem 0; background: var(--pico-background-color); border-top: 1px solid var(--pico-muted-border-color); margin-top: .5rem; z-index: 5; }
.savebar-set button { width: auto; margin: 0; }
.flash { padding: .5rem .8rem; border-radius: 8px; margin: 0 0 1rem; background: rgba(63,185,80,.15); border: 1px solid rgba(63,185,80,.5); }
.flash.err { background: rgba(248,136,136,.12); border-color: #f88; }
.copy { display: flex; gap: .4rem; align-items: center; }
.copy code { flex: 1; overflow-x: auto; white-space: nowrap; padding: .35rem .55rem; }
.copy button { width: auto; margin: 0; padding: .25rem .7rem; font-size: .8rem; }
/* sensitive values (OBS links, HUDFX link, tokens): blurred until the eye is clicked; Copy still copies them */
.secret:not(.shown) { filter: blur(6px); user-select: none; pointer-events: none; }
.eye { width: auto !important; margin: 0 !important; padding: .25rem .55rem !important; font-size: .9rem !important; line-height: 1; }
</style>
</head>
<body>
@ -22,28 +61,56 @@
<li><a class="nav-brand" href="/">HeyStreamer</a></li>
</ul>
<ul>
<li><a href="/">Dashboard</a></li>
<li><a href="/redeems">Redeems</a></li>
<li><a href="/tts">TTS</a></li>
<li><a href="/actions">Actions</a></li>
<li><a href="/media">Media</a></li>
<li><a href="/stats">Stats</a></li>
<li><a href="/settings">Settings</a></li>
<% const top = locals.sidebar ? locals.sidebar.name : ''; %>
<li><a href="/" class="<%= !top && locals.navActive === 'dashboard' ? 'on' : '' %>">Dashboard</a></li>
<li><a href="/redeems" class="<%= top === 'actions' ? 'on' : '' %>">Actions</a></li>
<li><a href="/stats" class="<%= locals.navActive === 'stats' ? 'on' : '' %>">Stats</a></li>
<li><a href="/settings" class="<%= top === 'settings' ? 'on' : '' %>">Settings</a></li>
<% if (locals.user) { %>
<li><a href="/auth/logout">Logout (<%= user.login %>)</a></li>
<% } %>
</ul>
</nav>
<main class="container">
<%- body %>
<main class="container<%= locals.sidebar ? '-fluid with-side' : '' %>">
<% if (locals.sidebar) { %>
<div class="shell">
<aside class="side">
<div class="side-title"><%= sidebar.title %></div>
<% for (const i of sidebar.items) { %>
<a href="<%= i.href %>" class="<%= i.on ? 'on' : '' %>"<% if (i.hint) { %> title="<%= i.hint %>"<% } %>><%= i.label %></a>
<% } %>
</aside>
<section class="pane"><%- body %></section>
</div>
<% } else { %>
<%- body %>
<% } %>
</main>
<script>
// eye buttons: <button data-reveal="#id"> shows / hides a blurred .secret element or a password input
document.addEventListener('click', e => {
const b = e.target.closest('[data-reveal]');
if (!b) return;
const t = document.querySelector(b.dataset.reveal);
if (!t) return;
const show = t.tagName === 'INPUT' ? t.type === 'password' : !t.classList.contains('shown');
if (t.tagName === 'INPUT') t.type = show ? 'text' : 'password'; else t.classList.toggle('shown', show);
b.textContent = show ? '🙈' : '👁'; b.title = show ? 'Hide' : 'Show';
});
// copy buttons: <button data-copy="text"> or data-copy-from="#id"
document.addEventListener('click', e => {
const b = e.target.closest('[data-copy],[data-copy-from]');
if (!b) return;
const text = b.dataset.copy ?? document.querySelector(b.dataset.copyFrom)?.textContent ?? '';
navigator.clipboard?.writeText(text).then(() => { const l = b.textContent; b.textContent = 'Copied'; setTimeout(() => { b.textContent = l; }, 1200); });
});
// Two-click delete instead of a browser confirm() dialog: first click arms the button, second submits.
document.addEventListener('click', e => {
const b = e.target.closest('button[data-confirm]');
if (!b) return;
if (b.dataset.armed) { b.form.requestSubmit(); return; }
b.dataset.armed = '1'; b.dataset.label = b.textContent; b.textContent = 'Really delete?';
if (b.dataset.armed) { if (b.type !== 'submit') b.form.requestSubmit(); return; } // armed submit button: let it submit
e.preventDefault();
b.dataset.armed = '1'; b.dataset.label = b.textContent; b.textContent = b.dataset.confirm || 'Really delete?';
b.style.fontWeight = '700';
setTimeout(() => { delete b.dataset.armed; b.textContent = b.dataset.label; b.style.fontWeight = ''; }, 4000);
});