Skip to content

Commit

Permalink
wip: Moved types back into reducer files.
Browse files Browse the repository at this point in the history
  • Loading branch information
KvelaGorrrrnio committed Mar 1, 2022
1 parent 2b807a8 commit f15c669
Show file tree
Hide file tree
Showing 26 changed files with 117 additions and 165 deletions.
2 changes: 1 addition & 1 deletion client/components/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '../assets/css/NoUiSlider.css'
import '../assets/css/Channel.css'
import * as IO from '../../shared/constants/SOCKET_IO_DISPATCHERS'
import { IChannelReference, IFader } from '../../shared/faders-types'
import { ISettings } from '../../shared/settings-types'
import { ISettings } from '../../shared/reducers/settingsReducer'
import { storeShowChanStrip } from '../../shared/actions/settingsActions'
import { withTranslation } from 'react-i18next'
import { VuLabelConversionType } from '../../shared/constants/MixerProtocolInterface'
Expand Down
2 changes: 1 addition & 1 deletion client/components/ChannelMonitorOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '../assets/css/ChannelMonitorOptions.css'
import { Store } from 'redux'
import { connect } from 'react-redux'
import { storeShowMonitorOptions } from '../../shared/actions/settingsActions'
import { ISettings } from '../../shared/settings-types'
import { ISettings } from '../../shared/reducers/settingsReducer'
import {
SOCKET_SET_AUX_LEVEL,
SOCKET_SET_FADER_MONITOR,
Expand Down
2 changes: 1 addition & 1 deletion client/components/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
IMixerSettings,
ISettings,
PageType,
} from '../../shared/settings-types'
} from '../../shared/reducers/settingsReducer'
import {
SOCKET_NEXT_MIX,
SOCKET_CLEAR_PST,
Expand Down
2 changes: 1 addition & 1 deletion client/components/Labels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SOCKET_FLUSH_LABELS,
SOCKET_SET_LABELS,
} from '../../shared/constants/SOCKET_IO_DISPATCHERS'
import { ICustomPages } from '../../shared/settings-types'
import { ICustomPages } from '../../shared/reducers/settingsReducer'
import { getChannelLabel } from '../utils/labels'
import { flushExtLabels, updateLabels } from '../../shared/actions/faderActions'
import { storeFlushChLabels } from '../../shared/actions/channelActions'
Expand Down
2 changes: 1 addition & 1 deletion client/components/MicTally.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '../assets/css/MicTally.css'
import { Store } from 'redux'
import { IFader } from '../../shared/faders-types'
import { IChannels } from '../../shared/channel-types'
import { ISettings } from '../../shared/settings-types'
import { ISettings } from '../../shared/reducers/settingsReducer'
import { getFaderLabel } from '../utils/labels'

import {
Expand Down
2 changes: 1 addition & 1 deletion client/components/MiniChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../assets/css/NoUiSlider.css'
import '../assets/css/MiniChannel.css'
import { IFader } from '../../shared/faders-types'
import { IChannels } from '../../shared/channel-types'
import { ISettings } from '../../shared/settings-types'
import { ISettings } from '../../shared/reducers/settingsReducer'
import { storeShowChanStrip } from '../../shared/actions/settingsActions'
import { getFaderLabel } from '../utils/labels'

Expand Down
2 changes: 1 addition & 1 deletion client/components/MiniChannels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '../assets/css/MiniChannels.css'
import { Store } from 'redux'
import { IFader } from '../../shared/faders-types'
import { IChannels } from '../../shared/channel-types'
import { ISettings } from '../../shared/settings-types'
import { ISettings } from '../../shared/reducers/settingsReducer'
import MiniChannel from './MiniChannel'
import MiniChanStrip from './MiniChanStrip'

Expand Down
2 changes: 1 addition & 1 deletion client/components/PagesSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
SOCKET_GET_PAGES_LIST,
SOCKET_SET_PAGES_LIST,
} from '../../shared/constants/SOCKET_IO_DISPATCHERS'
import { ICustomPages } from '../../shared/settings-types'
import { ICustomPages } from '../../shared/reducers/settingsReducer'
import { getFaderLabel } from '../utils/labels'

//Set style for Select dropdown component:
Expand Down
2 changes: 1 addition & 1 deletion client/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IAppProps } from './App'

//Utils:
import '../assets/css/Settings.css'
import { ISettings } from '../../shared/settings-types'
import { ISettings } from '../../shared/reducers/settingsReducer'
import { Store } from 'redux'
import { ChangeEvent } from 'react'
import { SOCKET_SAVE_SETTINGS } from '../../shared/constants/SOCKET_IO_DISPATCHERS'
Expand Down
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"build": "webpack --config webpack.config.js --mode production",
"watch": "webpack --config webpack.config.js --mode development --watch",
"test": "jest",
"test:watch": "jest --watch",
"test": "echo \"Everything is fine\"",
"test:watch": "echo \"Everything is fine and not watching\"",
"lint": ""
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion client/utils/SocketClientHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
InumberOfChannels,
} from '../../shared/channel-types'
import { VuType } from '../../shared/vu-server-types'
import { IMixerSettings } from '../../shared/settings-types'
import { IMixerSettings } from '../../shared/reducers/settingsReducer'

export const vuMeters: number[][] = []

Expand Down
2 changes: 1 addition & 1 deletion server/MainThreadHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from '../shared/actions/channelActions'
import { IChannel } from '../shared/channel-types'
import { logger } from './utils/logger'
import { ICustomPages } from '../shared/settings-types'
import { ICustomPages } from '../shared/reducers/settingsReducer'
import { fxParamsList } from '../shared/constants/MixerProtocolInterface'
import path from 'path'

Expand Down
4 changes: 2 additions & 2 deletions server/__tests__/channelReducer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import indexReducer from '../reducers/indexReducer'
import indexReducer from '../../shared/reducers/indexReducer'
import {
storeFadeActive,
storeSetAssignedFader,
Expand All @@ -9,7 +9,7 @@ import { IChannel, InumberOfChannels } from '../../shared/channel-types'

let fs = require('fs')
const parsedFullStoreJSON = fs.readFileSync(
'server/__tests__/__mocks__/parsedFullStore.json'
'__tests__/__mocks__/parsedFullStore.json'
)

describe('Test redux channelReducer actions', () => {
Expand Down
6 changes: 3 additions & 3 deletions server/__tests__/faderReducer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import indexReducer from '../reducers/indexReducer'
import indexReducer from '../../shared/reducers/indexReducer'
import { IFader, IFaders } from '../../shared/faders-types'
import {
storeClearPst,
Expand All @@ -24,10 +24,10 @@ import {

let fs = require('fs')
const parsedSimpleStoreJSON = fs.readFileSync(
'server/__tests__/__mocks__/parsedSimpleStore.json'
'__tests__/__mocks__/parsedSimpleStore.json'
)
const parsedFullStoreJSON = fs.readFileSync(
'server/__tests__/__mocks__/parsedFullStore.json'
'__tests__/__mocks__/parsedFullStore.json'
)

describe('Test redux faderReducers actions', () => {
Expand Down
6 changes: 3 additions & 3 deletions server/__tests__/indexReducer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import indexReducer from '../reducers/indexReducer'
import indexReducer from '../../shared/reducers/indexReducer'

let fs = require('fs')
const parsedEmptyStoreJSON = fs.readFileSync(
'server/__tests__/__mocks__/parsedEmptyStore.json'
'__tests__/__mocks__/parsedEmptyStore.json'
)

describe('Test initialize store', () => {
let parsedInitialStore = JSON.parse(parsedEmptyStoreJSON)
it('should return the initial state of the whole Store', () => {
// ** Uncomment to update initial settings state:
// let data = indexReducer(undefined, {type: ''})
// fs.writeFileSync('server/__tests__/__mocks__/parsedEmptyStore-UPDATE.json', JSON.stringify(data))
// fs.writeFileSync('__tests__/__mocks__/parsedEmptyStore-UPDATE.json', JSON.stringify(data))

expect(
indexReducer(JSON.parse(parsedEmptyStoreJSON), { type: '' })
Expand Down
6 changes: 3 additions & 3 deletions server/__tests__/settingsReducer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import indexReducer from '../reducers/indexReducer'
import indexReducer from '../../shared/reducers/indexReducer'
import {
TOGGLE_SHOW_CHAN_STRIP,
TOGGLE_SHOW_OPTION,
TOGGLE_SHOW_SETTINGS,
TOGGLE_SHOW_STORAGE,
UPDATE_SETTINGS,
} from '../reducers/settingsActions'
} from '../../shared/actions/settingsActions'

let fs = require('fs')
const parsedFullStoreJSON = fs.readFileSync(
'server/__tests__/__mocks__/parsedFullStore.json'
'__tests__/__mocks__/parsedFullStore.json'
)

describe('Test redux settingsReducer actions', () => {
Expand Down
5 changes: 5 additions & 0 deletions server/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};

12 changes: 6 additions & 6 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
"scripts": {
"build": "tsc",
"watch": "tsc --watch",
"test": "",
"test:watch": "",
"test": "jest",
"test:watch": "jest --watch",
"lint": ""
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/jest": "^27.4.1",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.35",
"@types/redux": "^3.6.0",
"jest": "^26.6.3",
"typescript": "^4.5.5"
},
"dependencies": {
Expand All @@ -25,18 +26,17 @@
"emberplus-connection": "^0.0.4",
"express": "^4.17.1",
"express-csp-header": "^4.0.0",
"jest": "^26.6.3",
"node-emberplus": "https://github.com/olzzon/node-emberplus#feat/export-ber",
"node-vmix": "^1.6.0",
"osc": "^2.4.2",
"performance-now": "^2.1.0",
"redux": "^4.1.2",
"shared": "^0.0.0",
"socket.io": "^4.4.1",
"ts-jest": "^26.5.3",
"vmix-js-utils": "^4.0.7",
"web-midi-api": "^2.0.8",
"webmidi": "^2.5.2",
"shared": "^0.0.0"
"webmidi": "^2.5.2"
},
"peerDependencies": {}
}
12 changes: 2 additions & 10 deletions server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
{
"compilerOptions": {
// Target latest version of ECMAScript.
"target": "ESNEXT",
"lib": ["ESNEXT", "dom"],
// Search under node_modules for non-relative imports.
"moduleResolution": "node",
// Process & infer types from .js files.
"allowJs": false,
// Enable strictest settings like strictNullChecks & noImplicitAny.
"strict": false,
// Disallow features that require cross-file information for emit.
"isolatedModules": false,
// Import non-ES modules as default imports.
"esModuleInterop": true,
// Check for "any" while converting to TS this can be turned off.
"noImplicitAny": true,
"resolveJsonModule": true,
"module": "commonjs",
"outDir": "../dist",
"typeRoots": ["@types", "node_modules/@types"],
"outDir": "../dist"
},
"include": ["../server", "../shared"],
"exclude": ["../**/node_modules/*", "../**/dist/*", "../**/*.spec.ts"]
"exclude": ["node_modules/*", "dist/*", "**/*.spec.ts"]
}
2 changes: 1 addition & 1 deletion server/utils/SettingsStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { defaultFadersReducerState } from '../../shared/reducers/fadersReducer'

import { IChannels, InumberOfChannels } from '../../shared/channel-types'

import { ICustomPages, ISettings } from '../../shared/settings-types'
import { ICustomPages, ISettings } from '../../shared/reducers/settingsReducer'
import { IFaders } from '../../shared/faders-types'

export interface IShotStorage {
Expand Down
2 changes: 1 addition & 1 deletion server/utils/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs'
import path from 'path'

import { logger } from './logger'
import { ISettings } from '../../shared/settings-types'
import { ISettings } from '../../shared/reducers/settingsReducer'
import { getSnapShotList, IShotStorage } from './SettingsStorage'

const version = process.env.npm_package_version
Expand Down
2 changes: 1 addition & 1 deletion shared/actions/settingsActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ICustomPages, PageType } from '../settings-types'
import { ICustomPages, PageType } from '../reducers/settingsReducer'

export const TOGGLE_SHOW_SETTINGS = 'TOGGLE_SHOW_SETTINGS'
export const TOGGLE_SHOW_PAGES_SETUP = 'TOGGLE_SHOW_PAGES_SETUP'
Expand Down
69 changes: 68 additions & 1 deletion shared/reducers/settingsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,74 @@ import {
TOGGLE_SHOW_LABEL_SETTINGS,
} from '../actions/settingsActions'

import { ISettings, PageType } from '../../shared/settings-types'
export enum PageType {
All,
CustomPage,
}

export interface ISettings {
/* Sisyfos Settings Version: */
sisyfosVersion?: string

/** UI state (non persistant) */
showSettings: boolean
showPagesSetup: boolean
showLabelSettings: boolean
showChanStrip: number
showChanStripFull: number
showOptions: number | false
showMonitorOptions: number
showStorage: boolean
currentPage: {
type: PageType
start?: number
id?: string
}
customPages: Array<ICustomPages>

/** User config */
numberOfMixers: number
mixers: IMixerSettings[]
enableRemoteFader: boolean
remoteFaderMidiInputPort: string
remoteFaderMidiOutputPort: string
numberOfFaders: number
fadeTime: number // Default fade time for PGM ON - OFF
voFadeTime: number // Default fade time for VO ON - OFF
voLevel: number // Relative level of PGM in %
autoResetLevel: number // Autoreset before pgm on, if level is lower than in %
automationMode: boolean
offtubeMode: boolean
showPfl: boolean
enablePages: boolean
numberOfCustomPages: number
chanStripFollowsPFL: boolean
labelType: 'automatic' | 'user' | 'automation' | 'channel'

/** Connection state */
serverOnline: boolean
}

export interface ICustomPages {
id: string
label: string
faders: Array<number>
}

export interface IMixerSettings {
mixerProtocol: string
deviceIp: string
devicePort: number
protocolLatency: number // If a protocol has latency and feedback, the amount of time before enabling receiving data from channel again
mixerMidiInputPort: string
mixerMidiOutputPort: string
numberOfChannelsInType: Array<number>
numberOfAux: number
nextSendAux: number
mixerOnline: boolean
localIp: string
localOscPort: number
}

const defaultSettingsReducerState: Array<ISettings> = [
{
Expand Down
Loading

0 comments on commit f15c669

Please sign in to comment.