From 4835f7c4b6124e333ee07ce38316110253d3136c Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Tue, 14 Apr 2026 09:45:05 -0400 Subject: [PATCH] feat: redesign SCTE35Trigger with amber broadcast controls --- frontend/src/components/SCTE35Trigger.tsx | 119 ++++++++++++++++++---- 1 file changed, 102 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/SCTE35Trigger.tsx b/frontend/src/components/SCTE35Trigger.tsx index ca5a33f..19ddb88 100644 --- a/frontend/src/components/SCTE35Trigger.tsx +++ b/frontend/src/components/SCTE35Trigger.tsx @@ -4,46 +4,131 @@ interface SCTE35TriggerProps { onInject: (eventId: number, durationSeconds: number) => Promise; } +interface LogEntry { + time: string; + eventId: number; + duration: number; +} + export function SCTE35Trigger({ onInject }: SCTE35TriggerProps) { + const [eventId, setEventId] = useState(1001); const [duration, setDuration] = useState(30); const [isInjecting, setIsInjecting] = useState(false); - const [lastInjected, setLastInjected] = useState(null); + const [log, setLog] = useState([]); const handleInject = async () => { setIsInjecting(true); try { - // Generate event ID from current timestamp (Date.now() & 0xFFFFFFFF ensures 32-bit) - const eventId = Date.now() & 0xFFFFFFFF; await onInject(eventId, duration); - setLastInjected(new Date().toLocaleTimeString()); + const now = new Date(); + const pad = (n: number) => String(n).padStart(2, '0'); + const time = `${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`; + setLog(prev => [{ time, eventId, duration }, ...prev].slice(0, 8)); + setEventId(prev => prev + 1); } finally { setIsInjecting(false); } }; - return ( -
-

SCTE35 Ad Marker

+ const inputStyle: React.CSSProperties = { + background: 'rgba(0,0,0,0.35)', + border: '1px solid var(--border)', + borderRadius: 3, + padding: '9px 12px', + fontFamily: 'var(--font-mono)', + fontSize: 13, + color: 'var(--text-primary)', + outline: 'none', + width: '100%', + }; -
- + const labelStyle: React.CSSProperties = { + fontFamily: 'var(--font-ui)', + fontSize: 10, + fontWeight: 700, + letterSpacing: '0.3em', + textTransform: 'uppercase', + color: 'var(--text-muted)', + display: 'block', + marginBottom: 6, + }; + + return ( +
+ +
+ setEventId(Number(e.target.value))} + style={inputStyle} + /> +
+ +
+ + ) => setDuration(Number(e.target.value))} - className="w-full bg-gray-700 text-white border border-gray-600 rounded px-3 py-2" + onChange={e => setDuration(Number(e.target.value))} + style={inputStyle} />
- {lastInjected && ( -

Last injected: {lastInje \ No newline at end of file + {log.length > 0 && ( +

+ {log.map((entry, i) => ( +
+ {entry.time} + EVT#{entry.eventId} + {entry.duration}s splice +
+ ))} +
+ )} + +
+ ); +}