Skip to content

Commit

Permalink
feat: pages setup menu - creating menu and store
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon authored and olzzon committed Oct 21, 2020
1 parent 5425603 commit 70f7374
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 15 deletions.
4 changes: 4 additions & 0 deletions client/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Settings from './Settings'
import Storage from './RoutingStorage'
import MiniChannels from './MiniChannels'
import { withTranslation } from 'react-i18next'
import PagesSettings from './PagesSettings'

export interface IAppProps {
store: IStore
Expand Down Expand Up @@ -39,6 +40,8 @@ class App extends React.Component<IAppProps> {
return (
nextProps.store.settings[0].showSettings !=
this.props.store.settings[0].showSettings ||
nextProps.store.settings[0].showPagesSetup !=
this.props.store.settings[0].showPagesSetup ||
nextProps.store.settings[0].serverOnline !=
this.props.store.settings[0].serverOnline ||
nextProps.store.settings[0].showStorage !=
Expand Down Expand Up @@ -114,6 +117,7 @@ class App extends React.Component<IAppProps> {
{window.location.search.includes('minimonitor=1') && (
<MiniChannels />
)}
{this.props.store.settings[0].showPagesSetup && <PagesSettings />}
{this.props.store.settings[0].showStorage && <Storage />}
{this.props.store.settings[0].showSettings && <Settings />}
</div>
Expand Down
19 changes: 16 additions & 3 deletions client/components/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../assets/css/Channels.css'
import { Store } from 'redux'
import {
storeSetPage,
storeShowPagesSetup,
storeShowSettings,
storeShowStorage,
} from '../../server/reducers/settingsActions'
Expand Down Expand Up @@ -83,6 +84,10 @@ class Channels extends React.Component<IChannelsInjectProps & Store> {
this.props.dispatch(storeShowStorage())
}

handleShowPagesSetting() {
this.props.dispatch(storeShowPagesSetup())
}

handlePages(type: PageType, i: number | string) {
if (typeof i === 'string') {
this.props.dispatch(storeSetPage(type, i))
Expand Down Expand Up @@ -121,7 +126,7 @@ class Channels extends React.Component<IChannelsInjectProps & Store> {
}
}

const numberedButtons = []
/* const numberedButtons = []
const numberOfFaders = this.props.settings.numberOfFaders
const pageLength = this.props.settings.pageLength
for (let i = 0; i < Math.ceil(numberOfFaders / pageLength); i++) {
Expand All @@ -142,12 +147,12 @@ class Channels extends React.Component<IChannelsInjectProps & Store> {
</button>
)
}

*/
const isAllActive = curPage.type === PageType.All
return (
<React.Fragment>
{customPageButtons}
{numberedButtons}
{/*numberedButtons*/}
<button
className={ClassNames('button half', {
active: isAllActive,
Expand Down Expand Up @@ -344,6 +349,14 @@ class Channels extends React.Component<IChannelsInjectProps & Store> {
</React.Fragment>
)}
</div>
<button
className="button half channels-show-settings-button"
onClick={() => {
this.handleShowPagesSetting()
}}
>
PAGES SETUP
</button>
<div className="bot">{this.renderPageButtons()}</div>
</div>
</div>
Expand Down
11 changes: 6 additions & 5 deletions client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import { I18nextProvider } from 'react-i18next'
import i18n from './i18n'
import { IMixerProtocol } from '../server/constants/MixerProtocolInterface'

export interface ICustomPages {
id: string
label: string
faders: Array<number>
}
declare global {
interface Window {
storeRedux: any
Expand All @@ -29,11 +34,7 @@ declare global {
snapshotFileList: string[]
ccgFileList: string[]
mixerPresetList: string[]
customPagesList: Array<{
id: string
label: string
faders: Array<number>
}>
customPagesList: ICustomPages[]
}
}

Expand Down
6 changes: 6 additions & 0 deletions server/reducers/settingsActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PageType } from './settingsReducer'

export const TOGGLE_SHOW_SETTINGS = 'TOGGLE_SHOW_SETTINGS'
export const TOGGLE_SHOW_PAGES_SETUP = 'TOGGLE_SHOW_PAGES_SETUP'
export const TOGGLE_SHOW_CHAN_STRIP = 'TOGGLE_SHOW_CHAN_STRIP'
export const TOGGLE_SHOW_OPTION = 'TOGGLE_SHOW_OPTION'
export const TOGGLE_SHOW_MONITOR_OPTIONS = 'TOGGLE_SHOW_MONITOR_OPTIONS'
Expand All @@ -16,6 +17,11 @@ export const storeShowSettings = () => {
type: TOGGLE_SHOW_SETTINGS,
}
}
export const storeShowPagesSetup = () => {
return {
type: TOGGLE_SHOW_PAGES_SETUP,
}
}
export const storeShowChanStrip = (faderIndex: number) => {
return {
type: TOGGLE_SHOW_CHAN_STRIP,
Expand Down
7 changes: 7 additions & 0 deletions server/reducers/settingsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
TOGGLE_SHOW_MONITOR_OPTIONS,
SET_SERVER_ONLINE,
SET_PAGE,
TOGGLE_SHOW_PAGES_SETUP,
} from '../reducers/settingsActions'

export enum PageType {
Expand All @@ -23,6 +24,7 @@ export interface ISettings {
/** UI state (non persistant) */
showSnaps: boolean
showSettings: boolean
showPagesSetup: boolean
showChanStrip: number
showOptions: number | false
showMonitorOptions: number
Expand Down Expand Up @@ -80,6 +82,7 @@ const defaultSettingsReducerState: Array<ISettings> = [
{
showSnaps: false,
showSettings: false,
showPagesSetup: false,
showChanStrip: -1,
showOptions: false,
showMonitorOptions: -1,
Expand Down Expand Up @@ -131,6 +134,10 @@ export const settings = (
case TOGGLE_SHOW_SETTINGS:
nextState[0].showSettings = !nextState[0].showSettings
return nextState
case TOGGLE_SHOW_PAGES_SETUP:
nextState[0].showPagesSetup = !nextState[0].showPagesSetup
return nextState

case TOGGLE_SHOW_CHAN_STRIP:
if (nextState[0].showChanStrip !== action.channel) {
nextState[0].showChanStrip = action.channel
Expand Down
19 changes: 12 additions & 7 deletions storage/pages.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[
{
"id": "example",
"label": "Custom",
"faders": [0, 1, 2, 3, 4]
}
]
[
{
"id": "example",
"label": "Live",
"faders": [12, 13, 14]
},
{
"id": "studio",
"label": "Studie",
"faders": [0, 1, 2, 3, 4, 9, 11]
}
]

0 comments on commit 70f7374

Please sign in to comment.