-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
633 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
import Discover from './Discover'; | ||
import List from './List'; | ||
import RootLayout from './RootLayout'; | ||
import createTheme from './theme'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import Typography from '@mui/material/Typography'; | ||
import {ThemeProvider} from '@mui/material/styles'; | ||
import React from 'react'; | ||
|
||
export function App() { | ||
return ( | ||
<div> | ||
<h1>IP Web Cams Recorder</h1> | ||
<List /> | ||
<Discover /> | ||
</div> | ||
<ThemeProvider theme={createTheme()}> | ||
<CssBaseline /> | ||
<RootLayout> | ||
<Typography variant="h1">IP Web Cams Recorder</Typography> | ||
<List /> | ||
<Discover /> | ||
</RootLayout> | ||
</ThemeProvider> | ||
); | ||
} |
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,55 @@ | ||
import {callMethod} from '../../api/methods'; | ||
import {CAMERA_STATE} from '../../constants'; | ||
import METHODS from '../../methods'; | ||
import {logError} from '../../utils/logger'; | ||
import RecordIcon from '@mui/icons-material/FiberManualRecord'; | ||
import StopIcon from '@mui/icons-material/Stop'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import Tooltip from '@mui/material/Tooltip'; | ||
import PropTypes from 'prop-types'; | ||
import React, {useMemo, useCallback, useState, useRef, useEffect} from 'react'; | ||
|
||
export default function RecordButton({_id, state}) { | ||
const [loading, setLoading] = useState(false); | ||
const prevState = useRef(state); | ||
|
||
const label = useMemo(() => { | ||
return state === CAMERA_STATE.rec ? 'Stop recording' : 'Start recording'; | ||
}, [state]); | ||
|
||
const StateIcon = useMemo(() => { | ||
return state === CAMERA_STATE.rec ? StopIcon : RecordIcon; | ||
}, [state]); | ||
|
||
const onClick = useCallback(async () => { | ||
try { | ||
setLoading(true); | ||
await callMethod(METHODS.CAMERA_TOGGLE, _id); | ||
} | ||
catch (err) { | ||
logError('Failed to toggle state of camera.')(err); | ||
} | ||
}, [_id]); | ||
|
||
useEffect(() => { | ||
if (prevState.current !== state) { | ||
setLoading(false); | ||
prevState.current = state; | ||
} | ||
}, [state]); | ||
|
||
return ( | ||
<Tooltip title={label}> | ||
<span> | ||
<IconButton onClick={onClick} aria-label={label} disabled={loading}> | ||
<StateIcon /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
RecordButton.propTypes = { | ||
_id: PropTypes.string.isRequired, | ||
state: PropTypes.string.isRequired, | ||
}; |
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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import Collection from '../../api/camera'; | ||
import Item from './Item'; | ||
import MuiList from '@mui/material/List'; | ||
import {useTracker} from 'meteor/react-meteor-data'; | ||
import React from 'react'; | ||
|
||
export default function List() { | ||
const list = useTracker(() => Collection.find().fetch()); | ||
|
||
return ( | ||
<ul> | ||
{list.map((cam) => <li key={cam._id}><Item {...cam} /></li>)} | ||
</ul> | ||
<MuiList> | ||
{list.map((cam) => <Item key={cam._id} {...cam} />)} | ||
</MuiList> | ||
); | ||
} |
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,27 @@ | ||
import styled from '@emotion/styled'; | ||
import Grid from '@mui/material/Grid'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
const Container = styled(Grid)` | ||
padding: ${({theme}) => theme.spacing(3)}; | ||
height: 100%; | ||
`; | ||
|
||
export default function RootLayout({children, ...props}) { | ||
return ( | ||
<Container | ||
container | ||
direction="column" | ||
rowGap={3} | ||
component="main" | ||
{...props} | ||
> | ||
{children} | ||
</Container> | ||
); | ||
} | ||
|
||
RootLayout.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
}; |
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,27 @@ | ||
export default () => ({ | ||
MuiCssBaseline: { | ||
styleOverrides: { | ||
'html, body, #root': { | ||
padding: 0, | ||
margin: 0, | ||
height: '100%', | ||
}, | ||
}, | ||
}, | ||
MuiButton: { | ||
defaultProps: { | ||
variant: 'contained', | ||
}, | ||
}, | ||
MuiIconButton: { | ||
defaultProps: { | ||
color: 'primary', | ||
}, | ||
}, | ||
MuiTextField: { | ||
defaultProps: { | ||
fullWidth: true, | ||
margin: 'none', | ||
}, | ||
}, | ||
}); |
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,10 @@ | ||
import createComponents from './components'; | ||
import createPalette from './palette'; | ||
import createTypography from './typography'; | ||
import {createTheme} from '@mui/material'; | ||
|
||
export default (...args) => createTheme({ | ||
palette: createPalette(...args), | ||
typography: createTypography(...args), | ||
components: createComponents(...args), | ||
}); |
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,17 @@ | ||
export default () => ({ | ||
mode: 'dark', | ||
primary: { | ||
main: '#7cb342', | ||
}, | ||
secondary: { | ||
main: '#ff6e40', | ||
}, | ||
text: { | ||
primary: '#aab4be', | ||
secondary: '#fdfeff', | ||
}, | ||
background: { | ||
default: '#072111', | ||
paper: '#0d290a', | ||
}, | ||
}); |
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,29 @@ | ||
export default () => ({ | ||
fontFamily: "'Fira Sans Extra Condensed', sans-serif", | ||
htmlFontSize: 16, | ||
fontSize: 16, | ||
h1: { | ||
fontSize: '3rem', | ||
fontWeight: 'bold', | ||
}, | ||
h2: { | ||
fontSize: '2rem', | ||
fontWeight: 'bold', | ||
}, | ||
h3: { | ||
fontSize: '1.5rem', | ||
fontWeight: 'bold', | ||
}, | ||
h4: { | ||
fontSize: '1.25rem', | ||
fontWeight: 'bold', | ||
}, | ||
h5: { | ||
fontSize: '1.1rem', | ||
fontWeight: 'bold', | ||
}, | ||
h6: { | ||
fontSize: '1rem', | ||
fontWeight: 'bold', | ||
}, | ||
}); |
Oops, something went wrong.