Spaces:
Paused
Paused
PTT panel: talkgroup chips, floor indicator, hold-to-talk
Browse files
web/src/components/PttPanel.jsx
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export default function PttPanel({
|
| 2 |
+
groups, floors, selected, setSelected,
|
| 3 |
+
onTalkStart, onTalkStop, talking, muted, setMuted,
|
| 4 |
+
}) {
|
| 5 |
+
const floor = selected != null ? floors[selected] : null;
|
| 6 |
+
const busy = floor && floor.memberId !== 0;
|
| 7 |
+
|
| 8 |
+
return (
|
| 9 |
+
<section className="panel ptt-panel">
|
| 10 |
+
<h2>Push to talk</h2>
|
| 11 |
+
<div className="chips">
|
| 12 |
+
{groups.map((g) => (
|
| 13 |
+
<button
|
| 14 |
+
key={g.id}
|
| 15 |
+
className={`chip ${selected === g.id ? 'active' : ''}`}
|
| 16 |
+
style={{ '--c': g.color }}
|
| 17 |
+
onClick={() => setSelected(g.id)}
|
| 18 |
+
>
|
| 19 |
+
{g.name}{floors[g.id] ? ' ●' : ''}
|
| 20 |
+
</button>
|
| 21 |
+
))}
|
| 22 |
+
</div>
|
| 23 |
+
<div className="floor">
|
| 24 |
+
{floor ? (
|
| 25 |
+
<span className="talking">🎙 {floor.name} is talking</span>
|
| 26 |
+
) : (
|
| 27 |
+
<span className="muted">Floor open</span>
|
| 28 |
+
)}
|
| 29 |
+
</div>
|
| 30 |
+
<button
|
| 31 |
+
className="ptt"
|
| 32 |
+
disabled={!selected || busy}
|
| 33 |
+
onMouseDown={onTalkStart}
|
| 34 |
+
onMouseUp={onTalkStop}
|
| 35 |
+
onMouseLeave={() => talking && onTalkStop()}
|
| 36 |
+
onTouchStart={(e) => { e.preventDefault(); onTalkStart(); }}
|
| 37 |
+
onTouchEnd={(e) => { e.preventDefault(); onTalkStop(); }}
|
| 38 |
+
>
|
| 39 |
+
{talking ? '● TALKING' : 'HOLD TO TALK'}
|
| 40 |
+
</button>
|
| 41 |
+
<p className="muted small">
|
| 42 |
+
Select a talkgroup, then hold the button. One speaker per group —
|
| 43 |
+
the floor indicator shows who has it.
|
| 44 |
+
</p>
|
| 45 |
+
<label className="muted small">
|
| 46 |
+
<input type="checkbox" style={{ width: 'auto' }} checked={muted} onChange={(e) => setMuted(e.target.checked)} />{' '}
|
| 47 |
+
Mute incoming audio
|
| 48 |
+
</label>
|
| 49 |
+
</section>
|
| 50 |
+
);
|
| 51 |
+
}
|