diff --git a/src/components/modal/configureOutputModal/ConfigureOutputModal.tsx b/src/components/modal/configureOutputModal/ConfigureOutputModal.tsx index c048947..c7cbcc6 100644 --- a/src/components/modal/configureOutputModal/ConfigureOutputModal.tsx +++ b/src/components/modal/configureOutputModal/ConfigureOutputModal.tsx @@ -9,6 +9,7 @@ import toast from 'react-hot-toast'; import { MultiviewSettings } from '../../../interfaces/multiview'; import MultiviewSettingsConfig from './MultiviewSettings'; import PipelineSettingsConfig from './PipelineSettings'; +import MultiviewLayoutSettings from './MultiviewLayoutSettings'; import { IconPlus, IconTrash } from '@tabler/icons-react'; export interface OutputStream { @@ -70,6 +71,7 @@ export function ConfigureOutputModal({ const [portDuplicateIndexes, setPortDuplicateIndexes] = useState( [] ); + const [modalOpen, setModalOpen] = useState(null); const t = useTranslate(); useEffect(() => { @@ -87,6 +89,7 @@ export function ConfigureOutputModal({ }, [preset]); const clearInputs = () => { + setModalOpen(null); setMultiviews(preset.pipelines[0].multiviews || []); setOutputStreams(defaultState(preset.pipelines)); onClose(); @@ -264,73 +267,80 @@ export function ConfigureOutputModal({ return ( clearInputs()}> -
- {preset.pipelines.map((pipeline, i) => { - return ( - o.pipelineIndex === i)} - addStream={addStream} - updateStream={updateStream} - updateStreams={updateStreams} - deleteStream={deleteStream} - /> - ); - })} - {multiviews && - multiviews.length > 0 && - multiviews.map((singleItem, index) => { + {!modalOpen && ( +
+ {preset.pipelines.map((pipeline, i) => { return ( -
-
-
- - handleUpdateMultiview(input, index) - } - portDuplicateError={ - portDuplicateIndexes.length > 0 - ? portDuplicateIndexes.includes(index) - : false - } - /> -
1 ? 'justify-between' : 'justify-end' - }`} - > - {multiviews.length > 1 && ( - - )} - {multiviews.length === index + 1 && ( - - )} -
-
-
+ o.pipelineIndex === i)} + addStream={addStream} + updateStream={updateStream} + updateStreams={updateStreams} + deleteStream={deleteStream} + /> ); })} -
+ {multiviews && + multiviews.length > 0 && + multiviews.map((singleItem, index) => { + return ( +
+
+
+ setModalOpen(input)} + lastItem={multiviews.length === index + 1} + multiview={singleItem} + handleUpdateMultiview={(input) => + handleUpdateMultiview(input, index) + } + portDuplicateError={ + portDuplicateIndexes.length > 0 + ? portDuplicateIndexes.includes(index) + : false + } + /> +
1 + ? 'justify-between' + : 'justify-end' + }`} + > + {multiviews.length > 1 && ( + + )} + {multiviews.length === index + 1 && ( + + )} +
+
+
+ ); + })} +
+ )} + {!!modalOpen && } clearInputs()} onSave={onSave} />
); diff --git a/src/components/modal/configureOutputModal/MultiviewLayoutSettings.tsx b/src/components/modal/configureOutputModal/MultiviewLayoutSettings.tsx new file mode 100644 index 0000000..17cc775 --- /dev/null +++ b/src/components/modal/configureOutputModal/MultiviewLayoutSettings.tsx @@ -0,0 +1,101 @@ +import { useEffect, useState } from 'react'; +import { useMultiviewPresets } from '../../../hooks/multiviewPreset'; +import Options from './Options'; +import { MultiviewPreset } from '../../../interfaces/preset'; +import toast from 'react-hot-toast'; +import { useTranslate } from '../../../i18n/useTranslate'; + +export default function MultiviewLayoutSettings({ + configMode +}: { + configMode: string; +}) { + const [selectedMultiviewPreset, setSelectedMultiviewPreset] = useState< + MultiviewPreset | undefined + >(); + const [multiviewPresets, loading] = useMultiviewPresets(); + const t = useTranslate(); + + const multiviewPresetNames = multiviewPresets?.map((preset) => preset.name) + ? multiviewPresets?.map((preset) => preset.name) + : []; + + useEffect(() => { + // if (multiview) { + // setSelectedMultiviewPreset(multiview); + // return; + // } + if (multiviewPresets && multiviewPresets[0]) { + console.log(multiviewPresets); + setSelectedMultiviewPreset(multiviewPresets[0]); + } + }, [multiviewPresets]); + + const handlePresetUpdate = (name: string) => { + const selected = multiviewPresets?.find((m) => m.name === name); + if (!selected) { + toast.error(t('preset.no_multiview_found')); + return; + } + setSelectedMultiviewPreset(selected); + }; + + const handleChange = (key: string, value: string) => { + console.log('onChange: ', key, value); + }; + + const renderPresetModel = () => { + if (selectedMultiviewPreset) { + const presetHeight = + selectedMultiviewPreset.layout.output_height / 40 + 0.5; + const presetWidth = + selectedMultiviewPreset.layout.output_width / 40 + 0.5; + + return ( +
+ {selectedMultiviewPreset.layout.views.map((singleView) => { + return ( +
+ singleView.label + )} + value={'string'} + update={(value) => handleChange('videoFormat', value)} + columnStyle + /> +
+ ); + })} +
+ ); + } + }; + + return ( +
+ {renderPresetModel()} +
+ handlePresetUpdate(value)} + /> +
+
+ ); +} diff --git a/src/components/modal/configureOutputModal/MultiviewSettings.tsx b/src/components/modal/configureOutputModal/MultiviewSettings.tsx index e742005..9fef700 100644 --- a/src/components/modal/configureOutputModal/MultiviewSettings.tsx +++ b/src/components/modal/configureOutputModal/MultiviewSettings.tsx @@ -6,17 +6,22 @@ import { MultiviewPreset } from '../../../interfaces/preset'; import Input from './Input'; import Options from './Options'; import toast from 'react-hot-toast'; +import { IconSettings } from '@tabler/icons-react'; type MultiviewSettingsProps = { + lastItem: boolean; multiview?: MultiviewSettings; handleUpdateMultiview: (multiview: MultiviewSettings) => void; portDuplicateError: boolean; + openConfigModal: (input: string) => void; }; export default function MultiviewSettingsConfig({ + lastItem, multiview, handleUpdateMultiview, - portDuplicateError + portDuplicateError, + openConfigModal }: MultiviewSettingsProps) { const t = useTranslate(); const [multiviewPresets, loading] = useMultiviewPresets(); @@ -24,6 +29,11 @@ export default function MultiviewSettingsConfig({ MultiviewPreset | undefined >(multiview); + const [modalOpen, setModalOpen] = useState(false); + const toggleConfigModal = () => { + setModalOpen((state) => !state); + }; + useEffect(() => { if (multiview) { setSelectedMultiviewPreset(multiview); @@ -142,16 +152,47 @@ export default function MultiviewSettingsConfig({ const multiviewOrPreset = multiview ? multiview : selectedMultiviewPreset; return ( -
+

{t('preset.multiview_output_settings')}

- handleSetSelectedMultiviewPreset(value)} - /> +
+ handleSetSelectedMultiviewPreset(value)} + /> + {lastItem && ( + <> + + {modalOpen && ( +
+ + +
+ )} + + )} +