2021-11-10 17:49:53 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-12-28 14:35:21 +00:00
|
|
|
import { makeStyles } from '@material-ui/core/styles';
|
|
|
|
import React, { useCallback, useEffect } from 'react';
|
|
|
|
import { useSelector, useDispatch } from 'react-redux';
|
2021-11-10 17:49:53 +00:00
|
|
|
|
|
|
|
import { Dialog } from '../../../base/dialog';
|
|
|
|
import { escapeRegexp } from '../../../base/util';
|
2021-12-28 14:35:21 +00:00
|
|
|
import { resetSearchCriteria, toggleFacialExpressions, initSearch } from '../../actions';
|
|
|
|
import {
|
|
|
|
DISPLAY_SWITCH_BREAKPOINT,
|
|
|
|
MOBILE_BREAKPOINT,
|
|
|
|
RESIZE_SEARCH_SWITCH_CONTAINER_BREAKPOINT
|
|
|
|
} from '../../constants';
|
|
|
|
|
|
|
|
import FacialExpressionsSwitch from './FacialExpressionsSwitch';
|
2021-11-10 17:49:53 +00:00
|
|
|
import SpeakerStatsLabels from './SpeakerStatsLabels';
|
|
|
|
import SpeakerStatsList from './SpeakerStatsList';
|
|
|
|
import SpeakerStatsSearch from './SpeakerStatsSearch';
|
|
|
|
|
2021-12-28 14:35:21 +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
|
|
|
footer: {
|
|
|
|
display: 'none !important'
|
|
|
|
},
|
|
|
|
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,
|
2021-12-28 14:35:21 +00:00
|
|
|
backgroundColor: theme.palette.border02
|
|
|
|
},
|
|
|
|
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 = () => {
|
|
|
|
const { enableDisplayFacialExpressions } = useSelector(state => state['features/base/config']);
|
|
|
|
const { showFacialExpressions } = useSelector(state => state['features/speaker-stats']);
|
|
|
|
const { clientWidth } = useSelector(state => state['features/base/responsive-ui']);
|
|
|
|
const displaySwitch = enableDisplayFacialExpressions && clientWidth > DISPLAY_SWITCH_BREAKPOINT;
|
|
|
|
const displayLabels = clientWidth > MOBILE_BREAKPOINT;
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const classes = useStyles();
|
|
|
|
|
|
|
|
const onToggleFacialExpressions = useCallback(() =>
|
|
|
|
dispatch(toggleFacialExpressions())
|
|
|
|
, [ dispatch ]);
|
|
|
|
|
|
|
|
const onSearch = useCallback((criteria = '') => {
|
|
|
|
dispatch(initSearch(escapeRegexp(criteria)));
|
|
|
|
}
|
|
|
|
, [ dispatch ]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
showFacialExpressions && !displaySwitch && dispatch(toggleFacialExpressions());
|
|
|
|
}, [ clientWidth ]);
|
|
|
|
useEffect(() => () => dispatch(resetSearchCriteria()), []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog
|
|
|
|
cancelKey = 'dialog.close'
|
2022-02-17 14:55:30 +00:00
|
|
|
classes = {{ footer: classes.footer }}
|
2021-12-28 14:35:21 +00:00
|
|
|
hideCancelButton = { true }
|
|
|
|
submitDisabled = { true }
|
|
|
|
titleKey = 'speakerStats.speakerStats'
|
|
|
|
width = { showFacialExpressions ? '664px' : 'small' }>
|
2022-03-15 11:02:50 +00:00
|
|
|
<div className = { classes.speakerStats }>
|
2021-12-28 14:35:21 +00:00
|
|
|
<div
|
|
|
|
className = {
|
|
|
|
`${classes.searchSwitchContainer}
|
|
|
|
${showFacialExpressions ? classes.searchSwitchContainerExpressionsOn : ''}`
|
|
|
|
}>
|
|
|
|
<div
|
|
|
|
className = {
|
|
|
|
displaySwitch
|
|
|
|
? classes.searchContainer
|
|
|
|
: classes.searchContainerFullWidth }>
|
|
|
|
<SpeakerStatsSearch
|
|
|
|
onSearch = { onSearch } />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{ displaySwitch
|
|
|
|
&& <FacialExpressionsSwitch
|
|
|
|
onChange = { onToggleFacialExpressions }
|
|
|
|
showFacialExpressions = { showFacialExpressions } />
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
{ displayLabels && (
|
2022-02-17 14:55:30 +00:00
|
|
|
<div className = { classes.labelsContainer }>
|
2021-12-28 14:35:21 +00:00
|
|
|
<SpeakerStatsLabels
|
|
|
|
showFacialExpressions = { showFacialExpressions ?? false } />
|
|
|
|
<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;
|