Skip to content

Commit

Permalink
feat: CCG channelsettings emit action for selecting new channel inputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Jan 28, 2020
1 parent d61dab7 commit 6f807cd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
20 changes: 9 additions & 11 deletions client/components/CcgChannelSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import '../assets/css/CcgChannelSettings.css';
import { ICasparCGMixerGeometry } from '../../server/constants/MixerProtocolInterface';
import { Store } from 'redux';
import { connect } from 'react-redux';
import { SET_OPTION } from '../../server/reducers/channelActions'
import { TOGGLE_SHOW_OPTION } from '../../server/reducers/settingsActions'
import { SOCKET_SET_INPUT_OPTION } from '../../server/constants/SOCKET_IO_DISPATCHERS';

interface IChannelSettingsInjectProps {
label: string,
Expand All @@ -19,30 +18,29 @@ interface IChannelProps {

class CcgChannelInputSettings extends React.PureComponent<IChannelProps & IChannelSettingsInjectProps & Store> {
mixerProtocol: ICasparCGMixerGeometry | undefined;
channelIndex: number;

constructor(props: any) {
super(props);
this.channelIndex = this.props.channelIndex;
const protocol = window.mixerProtocol as ICasparCGMixerGeometry;
if (protocol.sourceOptions) {
this.mixerProtocol = protocol;
}
}

handleOption = (prop: string, option: string) => {
this.props.dispatch({
type: SET_OPTION,
channel: this.channelIndex,
prop,
option
})
window.socketIoClient.emit( SOCKET_SET_INPUT_OPTION,
{
channel: this.props.channelIndex,
prop: prop,
option: option
}
)
}

render() {
return (
<div className="channel-settings-body">
<h2>{this.props.label || ("CH " + (this.channelIndex + 1))}</h2>
<h2>{this.props.label || ("CH " + (this.props.channelIndex + 1))} INPUT :</h2>
{this.mixerProtocol &&
this.mixerProtocol.sourceOptions &&
Object.getOwnPropertyNames(this.mixerProtocol.sourceOptions.options).map(prop => {
Expand Down
8 changes: 7 additions & 1 deletion server/MainThreadHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import {
SOCKET_SET_FULL_STORE,
SOCKET_SET_STORE_FADER,
SOCKET_SET_STORE_CHANNEL,
SOCKET_SET_LO_MID
SOCKET_SET_LO_MID,
SOCKET_SET_INPUT_OPTION
} from './constants/SOCKET_IO_DISPATCHERS'
import {
TOGGLE_PGM,
Expand Down Expand Up @@ -184,6 +185,11 @@ export class MainThreadHandlers {
this.updateFullClientStore()
})
)
.on(SOCKET_SET_INPUT_OPTION, (
(payload: any) => {
mixerGenericConnection.updateChannelSettings(payload.channel, payload.prop, payload.option)
})
)
.on(SOCKET_SET_AUX_LEVEL, (
(payload: any) => {
logger.verbose('Set Auxlevel Channel:' + String(payload.channel), {})
Expand Down
2 changes: 2 additions & 0 deletions server/constants/SOCKET_IO_DISPATCHERS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const SOCKET_SET_FADERLEVEL = 'FaderLevel'
export const SOCKET_SET_ASSIGNED_FADER = 'setAssignedFader'
export const SOCKET_SET_FADER_MONITOR = 'FaderMonitor'
export const SOCKET_SET_AUX_LEVEL = 'setAuxLevel'
export const SOCKET_SET_INPUT_OPTION = 'setInputOption'
export const SOCKET_SET_THRESHOLD = 'setThreshold'
export const SOCKET_SET_RATIO = 'setRatio'
export const SOCKET_SET_LOW = 'setLow'
Expand All @@ -20,6 +21,7 @@ export const SOCKET_TOGGLE_IGNORE = 'toggleIgnore'
export const SOCKET_NEXT_MIX = 'nextMix'
export const SOCKET_CLEAR_PST = 'clearPst'


// Div:
export const SOCKET_SAVE_SETTINGS = 'saveSettings'
export const SOCKET_RESTART_SERVER = 'restartServer'
Expand Down
1 change: 0 additions & 1 deletion server/reducers/channelActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ export const SET_SINGLE_CH_STATE = 'SET_SINGLE_CH_STATE'
export const FADE_ACTIVE = 'FADE_ACTIVE'
export const SET_ASSIGNED_FADER = 'SET_ASSIGNED_FADER'
export const SET_PRIVATE = 'SET_PRIVATE'
export const SET_OPTION = 'SET_OPTION'

6 changes: 0 additions & 6 deletions server/reducers/channelsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
SET_OUTPUT_LEVEL,
SET_ASSIGNED_FADER,
SET_COMPLETE_CH_STATE,
SET_OPTION,
SET_PRIVATE,
FADE_ACTIVE,
SET_AUX_LEVEL,
Expand Down Expand Up @@ -85,11 +84,6 @@ export const channels = ((state = defaultChannelsReducerState([1]), action: any)
}
nextState[0].channel[action.channel].private![action.tag] = action.value;
return nextState;
case SET_OPTION:
// TODO: This should be changed, as it´s not the "redux" way of handling it.
// @ts-ignore
// mixerGenericConnection.updateChannelSettings(action.channel, action.prop, action.option);
return nextState;
default:
return nextState;
}
Expand Down

0 comments on commit 6f807cd

Please sign in to comment.