2021-12-28 14:35:21 +00:00
|
|
|
import React, { useCallback, useEffect } from 'react';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2022-09-13 07:36:00 +00:00
|
|
|
import { makeStyles } from 'tss-react/mui';
|
2021-11-10 17:49:53 +00:00
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../../../app/types';
|
2022-10-10 09:12:02 +00:00
|
|
|
import Dialog from '../../../base/ui/components/web/Dialog';
|
2022-08-25 11:35:19 +00:00
|
|
|
import { escapeRegexp } from '../../../base/util/helpers';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { initSearch, resetSearchCriteria, toggleFaceExpressions } from '../../actions';
|
2021-12-28 14:35:21 +00:00
|
|
|
import {
|
|
|
|
DISPLAY_SWITCH_BREAKPOINT,
|
|
|
|
MOBILE_BREAKPOINT,
|
|
|
|
RESIZE_SEARCH_SWITCH_CONTAINER_BREAKPOINT
|
|
|
|
} from '../../constants';
|
|
|
|
|
2022-04-06 09:10:31 +00:00
|
|
|
import FaceExpressionsSwitch from './FaceExpressionsSwitch';
|
2021-11-10 17:49:53 +00:00
|
|
|
import SpeakerStatsLabels from './SpeakerStatsLabels';
|
|
|
|
import SpeakerStatsList from './SpeakerStatsList';
|
|
|
|
import SpeakerStatsSearch from './SpeakerStatsSearch';
|
|
|
|
|
2022-11-15 07:50:22 +00:00
|
|
|
const useStyles = makeStyles()(theme => {
|
2021-11-10 17:49:53 +00:00
|
|
|
return {
|
2022-03-15 11:02:50 +00:00
|
|
|
speakerStats: {
|
|
|
|
'& .row': {
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
|
|
'& .avatar': {
|
|
|
|
width: '32px',
|
|
|
|
marginRight: theme.spacing(3)
|
|
|
|
},
|
|
|
|
|
|
|
|
'& .name-time': {
|
|
|
|
width: 'calc(100% - 48px)',
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
alignItems: 'center'
|
|
|
|
},
|
|
|
|
|
|
|
|
'& .name-time_expressions-on': {
|
|
|
|
width: 'calc(47% - 48px)'
|
|
|
|
},
|
|
|
|
|
|
|
|
'& .expressions': {
|
|
|
|
width: 'calc(53% - 29px)',
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
|
|
|
'& .expression': {
|
|
|
|
width: '30px',
|
|
|
|
textAlign: 'center'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-02-17 14:55:30 +00:00
|
|
|
labelsContainer: {
|
|
|
|
position: 'relative'
|
|
|
|
},
|
2021-12-28 14:35:21 +00:00
|
|
|
separator: {
|
|
|
|
position: 'absolute',
|
2022-02-17 14:55:30 +00:00
|
|
|
width: 'calc(100% + 48px)',
|
2021-12-28 14:35:21 +00:00
|
|
|
height: 1,
|
2022-02-17 14:55:30 +00:00
|
|
|
left: -24,
|
2022-07-12 12:28:20 +00:00
|
|
|
backgroundColor: theme.palette.ui05
|
2021-12-28 14:35:21 +00:00
|
|
|
},
|
|
|
|
searchSwitchContainer: {
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
alignItems: 'center',
|
|
|
|
width: '100%'
|
|
|
|
},
|
|
|
|
searchSwitchContainerExpressionsOn: {
|
|
|
|
width: '58.5%',
|
|
|
|
[theme.breakpoints.down(RESIZE_SEARCH_SWITCH_CONTAINER_BREAKPOINT)]: {
|
|
|
|
width: '100%'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
searchContainer: {
|
|
|
|
width: '50%'
|
|
|
|
},
|
|
|
|
searchContainerFullWidth: {
|
|
|
|
width: '100%'
|
|
|
|
}
|
2021-11-10 17:49:53 +00:00
|
|
|
};
|
2021-12-28 14:35:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const SpeakerStats = () => {
|
2022-10-20 09:11:27 +00:00
|
|
|
const { faceLandmarks } = useSelector((state: IReduxState) => state['features/base/config']);
|
|
|
|
const { showFaceExpressions } = useSelector((state: IReduxState) => state['features/speaker-stats']);
|
|
|
|
const { clientWidth } = useSelector((state: IReduxState) => state['features/base/responsive-ui']);
|
2022-04-06 09:10:31 +00:00
|
|
|
const displaySwitch = faceLandmarks?.enableDisplayFaceExpressions && clientWidth > DISPLAY_SWITCH_BREAKPOINT;
|
2021-12-28 14:35:21 +00:00
|
|
|
const displayLabels = clientWidth > MOBILE_BREAKPOINT;
|
|
|
|
const dispatch = useDispatch();
|
2022-09-13 07:36:00 +00:00
|
|
|
const { classes } = useStyles();
|
2021-12-28 14:35:21 +00:00
|
|
|
|
2022-04-06 09:10:31 +00:00
|
|
|
const onToggleFaceExpressions = useCallback(() =>
|
|
|
|
dispatch(toggleFaceExpressions())
|
2021-12-28 14:35:21 +00:00
|
|
|
, [ dispatch ]);
|
|
|
|
|
|
|
|
const onSearch = useCallback((criteria = '') => {
|
|
|
|
dispatch(initSearch(escapeRegexp(criteria)));
|
|
|
|
}
|
|
|
|
, [ dispatch ]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
2022-04-06 09:10:31 +00:00
|
|
|
showFaceExpressions && !displaySwitch && dispatch(toggleFaceExpressions());
|
2021-12-28 14:35:21 +00:00
|
|
|
}, [ clientWidth ]);
|
2022-10-26 06:59:21 +00:00
|
|
|
useEffect(() => () => {
|
|
|
|
dispatch(resetSearchCriteria());
|
|
|
|
}, []);
|
2021-12-28 14:35:21 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog
|
2022-10-10 09:12:02 +00:00
|
|
|
cancel = {{ hidden: true }}
|
|
|
|
ok = {{ hidden: true }}
|
|
|
|
size = { showFaceExpressions ? 'large' : 'medium' }
|
|
|
|
titleKey = 'speakerStats.speakerStats'>
|
2022-03-15 11:02:50 +00:00
|
|
|
<div className = { classes.speakerStats }>
|
2021-12-28 14:35:21 +00:00
|
|
|
<div
|
|
|
|
className = {
|
|
|
|
`${classes.searchSwitchContainer}
|
2022-04-06 09:10:31 +00:00
|
|
|
${showFaceExpressions ? classes.searchSwitchContainerExpressionsOn : ''}`
|
2021-12-28 14:35:21 +00:00
|
|
|
}>
|
|
|
|
<div
|
|
|
|
className = {
|
|
|
|
displaySwitch
|
|
|
|
? classes.searchContainer
|
|
|
|
: classes.searchContainerFullWidth }>
|
|
|
|
<SpeakerStatsSearch
|
|
|
|
onSearch = { onSearch } />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{ displaySwitch
|
2022-04-06 09:10:31 +00:00
|
|
|
&& <FaceExpressionsSwitch
|
|
|
|
onChange = { onToggleFaceExpressions }
|
|
|
|
showFaceExpressions = { showFaceExpressions } />
|
2021-12-28 14:35:21 +00:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
{ displayLabels && (
|
2022-02-17 14:55:30 +00:00
|
|
|
<div className = { classes.labelsContainer }>
|
2021-12-28 14:35:21 +00:00
|
|
|
<SpeakerStatsLabels
|
2022-04-06 09:10:31 +00:00
|
|
|
showFaceExpressions = { showFaceExpressions ?? false } />
|
2021-12-28 14:35:21 +00:00
|
|
|
<div className = { classes.separator } />
|
2022-02-17 14:55:30 +00:00
|
|
|
</div>
|
2021-12-28 14:35:21 +00:00
|
|
|
)}
|
|
|
|
<SpeakerStatsList />
|
|
|
|
</div>
|
|
|
|
</Dialog>
|
|
|
|
|
|
|
|
);
|
|
|
|
};
|
2021-11-10 17:49:53 +00:00
|
|
|
|
2021-12-28 14:35:21 +00:00
|
|
|
export default SpeakerStats;
|