diff --git a/frontend/src/components/ConfigPanel.tsx b/frontend/src/components/ConfigPanel.tsx new file mode 100644 index 0000000..843e30e --- /dev/null +++ b/frontend/src/components/ConfigPanel.tsx @@ -0,0 +1,157 @@ +import React, { useState, useEffect } from 'react'; +import { RecorderConfig, CodecType } from '../types'; + +interface ConfigPanelProps { + portIndex: number; + currentConfig: RecorderConfig | null; + onSave: (config: RecorderConfig) => void; + onClose: () => void; +} + +export function ConfigPanel({ portIndex, currentConfig, onSave, onClose }: ConfigPanelProps) { + // State for each config field + const [codec, setCodec] = useState('PRORES'); + const [bitrate, setBitrate] = useState('185M'); + const [qualityProfile, setQualityProfile] = useState('hq'); + const [recordingPath, setRecordingPath] = useState('/recordings/port_{port_index}_{timestamp}.mxf'); + const [srtEnabled, setSrtEnabled] = useState(false); + const [srtDestination, setSrtDestination] = useState(''); + const [previewEnabled, setPreviewEnabled] = useState(true); + + // Initialize from currentConfig if provided + useEffect(() => { + if (currentConfig) { + setCodec(currentConfig.codec); + setBitrate(currentConfig.bitrate); + setQualityProfile(currentConfig.quality_profile); + setRecordingPath(currentConfig.recording_path); + setSrtEnabled(currentConfig.srt_enabled); + setSrtDestination(currentConfig.srt_destination); + setPreviewEnabled(currentConfig.preview_enabled); + } + }, [currentConfig]); + + const handleSave = () => { + const config: RecorderConfig = { + port_index: portIndex, + codec, + bitrate, + quality_profile: qualityProfile, + recording_path: recordingPath, + srt_enabled: srtEnabled, + srt_destination: srtDestination, + preview_enabled: previewEnabled, + }; + onSave(config); + onClose(); + }; + + return ( +
+
+

Configure Port {portIndex}

+ + {/* Codec Selection */} +
+ + +
+ + {/* Quality Profile - only show for ProRes */} + {codec === 'PRORES' && ( +
+ + +
+ )} + + {/* Bitrate - only show for DNxHD or H264 */} + {(codec === 'DNXHD' || codec === 'H264') && ( +
+ + ) => setBitrate(e.target.value)} + placeholder="e.g., 185M, 50M" + className="w-full bg-gray-700 text-white border border-gray-600 rounded px-3 py-2 mb-3" + /> +
+ )} + + {/* Recording Path */} +
+ + ) => setRecordingPath(e.target.value)} + className="w-full bg-gray-700 text-white border border-gray-600 rounded px-3 py-2 mb-1" + /> +

Use {'{timestamp}'} and {'{port_index}'} as placeholders

+
+ + {/* SRT Enabled Checkbox */} +
+ +
+ + {/* SRT Destination - only show when SRT enabled */} + {srtEnabled && ( +
+ + ) => setSrtDestination(e.target.value)} + placeholder="srt://destination.example.com:9000" + className="w-full bg-gray-700 text-white border border-gray-600 rounded px-3 py-2 mb-3" + /> +
+ )} + + {/* Preview Enabled Checkbox */} +
+ +
+ + {/* Action Buttons */} +
+