heystreamer/views/actions.ejs
Bashy 6c7facadce
Some checks failed
CI / check (push) Has been cancelled
rework
2026-04-26 23:00:55 +03:00

88 lines
3.4 KiB
Text

<h2>Actions</h2>
<p><small>Map Twitch events to sounds, videos, or on-screen alerts.</small></p>
<details>
<summary>Add new action</summary>
<form method="POST" action="/actions" style="margin-top:1rem;">
<div style="display:grid; grid-template-columns:1fr 1fr; gap:1rem;">
<label>Name <input type="text" name="name" required placeholder="e.g. Sub sound"></label>
<label>
Event type
<select name="event_type" required>
<option value="sub">Sub</option>
<option value="gift_sub">Gift sub</option>
<option value="bits">Bits</option>
<option value="channel_points">Channel points</option>
<option value="command">Chat command</option>
<option value="follow">Follow</option>
<option value="raid">Raid</option>
</select>
</label>
<label>
Event detail <small>(tier / min bits / command name / reward ID)</small>
<input type="text" name="event_detail" placeholder="Optional">
</label>
<label>
Action type
<select name="action_type" required>
<option value="sound">Sound</option>
<option value="video">Video</option>
<option value="alert">Alert text</option>
</select>
</label>
<label>
Media file
<select name="media_file_id">
<option value="">— none —</option>
<% for (const f of media) { %>
<option value="<%= f.id %>"><%= f.original_name %> (<%= f.media_type %>)</option>
<% } %>
</select>
</label>
<label>Alert text <input type="text" name="alert_text" placeholder="{username} just subbed!"></label>
<label>Cooldown (seconds) <input type="number" name="cooldown_seconds" value="0" min="0"></label>
</div>
<button type="submit">Add action</button>
</form>
</details>
<% if (actions.length === 0) { %>
<p><em>No actions yet.</em></p>
<% } else { %>
<figure>
<table>
<thead>
<tr>
<th>Name</th>
<th>Event</th>
<th>Detail</th>
<th>Action</th>
<th>Cooldown</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<% for (const a of actions) { %>
<tr>
<td><%= a.name %></td>
<td><code><%= a.event_type %></code></td>
<td><%= a.event_detail || '—' %></td>
<td><code><%= a.action_type %></code></td>
<td><%= a.cooldown_seconds %>s</td>
<td>
<span class="badge <%= a.enabled ? 'badge-green' : 'badge-grey' %>">
<%= a.enabled ? 'on' : 'off' %>
</span>
</td>
<td style="display:flex; gap:0.5rem;">
<form method="POST" action="/actions/<%= a.id %>/test"><button type="submit" class="outline" style="padding:0.2rem 0.6rem; font-size:0.8rem;">Test</button></form>
<form method="POST" action="/actions/<%= a.id %>/toggle"><button type="submit" class="outline" style="padding:0.2rem 0.6rem; font-size:0.8rem;"><%= a.enabled ? 'Disable' : 'Enable' %></button></form>
<form method="POST" action="/actions/<%= a.id %>/delete" onsubmit="return confirm('Delete this action?')"><button type="submit" class="outline" style="padding:0.2rem 0.6rem; font-size:0.8rem; color:#f88;">Delete</button></form>
</td>
</tr>
<% } %>
</tbody>
</table>
</figure>
<% } %>