forked from OwnZones/orchestration-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added feedback-streams to input-choice for multiviewer-layout
- Loading branch information
Showing
6 changed files
with
133 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/components/modal/configureOutputModal/MultiviewLayoutSettings/MultiviewLayout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { TList } from '../../../../hooks/useCreateInputArray'; | ||
import { MultiviewViewsWithId } from '../../../../hooks/useSetupMultiviewLayout'; | ||
import { MultiviewPreset } from '../../../../interfaces/preset'; | ||
import Options from '../Options'; | ||
|
||
export default function MultiviewLayout({ | ||
multiviewPresetLayout, | ||
inputList, | ||
handleChange | ||
}: { | ||
multiviewPresetLayout: MultiviewPreset; | ||
inputList: TList[] | undefined; | ||
handleChange: (id: number | undefined, value: string) => void; | ||
}) { | ||
return ( | ||
<div | ||
className={`border-4 border-p/50 relative p-2 m-2`} | ||
style={{ | ||
width: `${multiviewPresetLayout.layout.output_width}rem`, | ||
height: `${multiviewPresetLayout.layout.output_height}rem` | ||
}} | ||
> | ||
{multiviewPresetLayout.layout.views.map( | ||
(singleView: MultiviewViewsWithId) => { | ||
const { x, y, width, height, label, id } = singleView; | ||
const previewView = singleView.input_slot === 1002; | ||
const programView = singleView.input_slot === 1001; | ||
|
||
return ( | ||
<div | ||
key={x + y} | ||
className="flex items-center justify-center border-[1px] border-p/50 absolute w-full" | ||
style={{ | ||
width: `${width}rem`, | ||
height: `${height}rem`, | ||
top: `${y}rem`, | ||
left: `${x}rem` | ||
}} | ||
> | ||
{inputList && (previewView || programView) && ( | ||
<p className="flex items-center">{label}</p> | ||
)} | ||
{inputList && !previewView && !programView && ( | ||
<Options | ||
label={label} | ||
options={inputList.map((singleSource) => singleSource.label)} | ||
value={label ? label : ''} | ||
update={(value) => handleChange(id, value)} | ||
columnStyle | ||
/> | ||
)} | ||
</div> | ||
); | ||
} | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { usePipelines } from './pipelines'; | ||
import { Production } from '../interfaces/production'; | ||
|
||
export type TList = { | ||
input_slot: number; | ||
label: string; | ||
}; | ||
|
||
export function useCreateInputArray(production: Production | undefined) { | ||
const [inputList, setInputList] = useState<TList[] | undefined>(); | ||
const [pipelines] = usePipelines(); | ||
|
||
useEffect(() => { | ||
if (production && pipelines) { | ||
const list: TList[] = []; | ||
production.sources.map((source) => | ||
list.push({ | ||
input_slot: source.input_slot, | ||
label: source.label | ||
}) | ||
); | ||
pipelines.flatMap((pipeline) => | ||
pipeline.feedback_streams.flatMap((source) => { | ||
if (source.input_slot > 1000) { | ||
list.push({ | ||
input_slot: source.input_slot, | ||
label: source.name | ||
}); | ||
} | ||
}) | ||
); | ||
const uniqueList = list.filter( | ||
(item, index, self) => | ||
index === | ||
self.findIndex( | ||
(t) => t.input_slot === item.input_slot && t.label === item.label | ||
) | ||
); | ||
return setInputList(uniqueList); | ||
} | ||
}, [production, pipelines]); | ||
return { inputList }; | ||
} |