2021-12-28 14:35:21 +00:00
|
|
|
import React, { useCallback, useEffect } from 'react';
|
2022-11-22 13:56:37 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
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-11-22 13:56:37 +00:00
|
|
|
import Icon from '../../../base/icons/components/Icon';
|
|
|
|
import {
|
|
|
|
IconEmotionsAngry,
|
|
|
|
IconEmotionsDisgusted,
|
|
|
|
IconEmotionsFearful,
|
|
|
|
IconEmotionsHappy,
|
|
|
|
IconEmotionsNeutral,
|
|
|
|
IconEmotionsSad,
|
|
|
|
IconEmotionsSurprised
|
|
|
|
} from '../../../base/icons/svg';
|
|
|
|
// eslint-disable-next-line lines-around-comment
|
|
|
|
// @ts-ignore
|
|
|
|
import { Tooltip } from '../../../base/tooltip';
|
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-11-22 13:56:37 +00:00
|
|
|
import { initSearch, resetSearchCriteria, toggleFaceExpressions } from '../../actions.any';
|
2021-12-28 14:35:21 +00:00
|
|
|
import {
|
|
|
|
DISPLAY_SWITCH_BREAKPOINT,
|
2022-11-22 13:56:37 +00:00
|
|
|
MOBILE_BREAKPOINT
|
2021-12-28 14:35:21 +00:00
|
|
|
} 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: {
|
2022-11-22 13:56:37 +00:00
|
|
|
'& .header': {
|
|
|
|
position: 'fixed',
|
|
|
|
backgroundColor: theme.palette.ui01,
|
|
|
|
paddingLeft: theme.spacing(4),
|
|
|
|
paddingRight: theme.spacing(4),
|
|
|
|
marginLeft: `-${theme.spacing(4)}`,
|
|
|
|
'&.large': {
|
|
|
|
width: '616px'
|
|
|
|
},
|
|
|
|
'&.medium': {
|
|
|
|
width: '352px'
|
|
|
|
},
|
|
|
|
'@media (max-width: 448px)': {
|
|
|
|
width: 'calc(100% - 48px) !important'
|
|
|
|
},
|
|
|
|
'& .upper-header': {
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
alignItems: 'center',
|
|
|
|
width: '100%',
|
|
|
|
'& .search-switch-container': {
|
|
|
|
display: 'flex',
|
|
|
|
width: '100%',
|
|
|
|
'& .search-container': {
|
|
|
|
width: 175,
|
|
|
|
marginRight: theme.spacing(3)
|
|
|
|
},
|
|
|
|
'& .search-container-full-width': {
|
|
|
|
width: '100%'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'& .emotions-icons': {
|
|
|
|
display: 'flex',
|
|
|
|
'& svg': {
|
|
|
|
fill: '#000'
|
|
|
|
},
|
|
|
|
'&>div': {
|
|
|
|
marginRight: theme.spacing(3)
|
|
|
|
},
|
|
|
|
'&>div:last-child': {
|
|
|
|
marginRight: 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-03-15 11:02:50 +00:00
|
|
|
'& .row': {
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
'& .name-time': {
|
|
|
|
width: 'calc(100% - 48px)',
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between',
|
2022-11-22 13:56:37 +00:00
|
|
|
alignItems: 'center',
|
|
|
|
'&.expressions-on': {
|
|
|
|
width: 'calc(47% - 48px)',
|
|
|
|
marginRight: theme.spacing(4)
|
|
|
|
}
|
2022-03-15 11:02:50 +00:00
|
|
|
},
|
2022-11-22 13:56:37 +00:00
|
|
|
'& .timeline-container': {
|
|
|
|
height: '100%',
|
|
|
|
width: `calc(53% - ${theme.spacing(4)})`,
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
borderLeftWidth: 1,
|
|
|
|
borderLeftColor: theme.palette.ui02,
|
|
|
|
borderLeftStyle: 'solid',
|
|
|
|
'& .timeline': {
|
|
|
|
height: theme.spacing(2),
|
|
|
|
display: 'flex',
|
|
|
|
width: '100%',
|
|
|
|
'&>div': {
|
|
|
|
marginRight: theme.spacing(1),
|
|
|
|
borderRadius: 5
|
|
|
|
},
|
|
|
|
'&>div:first-child': {
|
|
|
|
borderRadius: '0 5px 5px 0'
|
|
|
|
},
|
|
|
|
'&>div:last-child': {
|
|
|
|
marginRight: 0,
|
|
|
|
borderRadius: '5px 0 0 5px'
|
|
|
|
}
|
|
|
|
}
|
2022-03-15 11:02:50 +00:00
|
|
|
},
|
2022-11-22 13:56:37 +00:00
|
|
|
'& .axis-container': {
|
|
|
|
height: '100%',
|
|
|
|
width: `calc(53% - ${theme.spacing(6)})`,
|
2022-03-15 11:02:50 +00:00
|
|
|
display: 'flex',
|
2022-11-22 13:56:37 +00:00
|
|
|
alignItems: 'center',
|
|
|
|
marginLeft: theme.spacing(3),
|
|
|
|
'& div': {
|
|
|
|
borderRadius: 5
|
|
|
|
},
|
|
|
|
'& .axis': {
|
|
|
|
height: theme.spacing(1),
|
|
|
|
display: 'flex',
|
|
|
|
width: '100%',
|
|
|
|
backgroundColor: theme.palette.ui03,
|
|
|
|
position: 'relative',
|
|
|
|
'& .left-bound': {
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 10,
|
|
|
|
left: 0
|
|
|
|
},
|
|
|
|
'& .right-bound': {
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 10,
|
|
|
|
right: 0
|
|
|
|
},
|
|
|
|
'& .handler': {
|
|
|
|
position: 'absolute',
|
|
|
|
backgroundColor: theme.palette.ui09,
|
|
|
|
height: 12,
|
|
|
|
marginTop: -4,
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
'& .resize': {
|
|
|
|
height: '100%',
|
|
|
|
width: 5,
|
|
|
|
cursor: 'col-resize'
|
|
|
|
}
|
|
|
|
}
|
2022-03-15 11:02:50 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-22 13:56:37 +00:00
|
|
|
},
|
|
|
|
'& .separator': {
|
|
|
|
width: 'calc(100% + 48px)',
|
|
|
|
height: 1,
|
|
|
|
marginLeft: -24,
|
|
|
|
backgroundColor: theme.palette.ui02
|
2022-03-15 11:02:50 +00:00
|
|
|
}
|
2021-12-28 14:35:21 +00:00
|
|
|
}
|
2021-11-10 17:49:53 +00:00
|
|
|
};
|
2021-12-28 14:35:21 +00:00
|
|
|
});
|
|
|
|
|
2022-11-22 13:56:37 +00:00
|
|
|
const EMOTIONS_LEGEND = [
|
|
|
|
{
|
|
|
|
translationKey: 'speakerStats.neutral',
|
|
|
|
icon: IconEmotionsNeutral
|
|
|
|
},
|
|
|
|
{
|
|
|
|
translationKey: 'speakerStats.happy',
|
|
|
|
icon: IconEmotionsHappy
|
|
|
|
},
|
|
|
|
{
|
|
|
|
translationKey: 'speakerStats.surprised',
|
|
|
|
icon: IconEmotionsSurprised
|
|
|
|
},
|
|
|
|
{
|
|
|
|
translationKey: 'speakerStats.sad',
|
|
|
|
icon: IconEmotionsSad
|
|
|
|
},
|
|
|
|
{
|
|
|
|
translationKey: 'speakerStats.fearful',
|
|
|
|
icon: IconEmotionsFearful
|
|
|
|
},
|
|
|
|
{
|
|
|
|
translationKey: 'speakerStats.angry',
|
|
|
|
icon: IconEmotionsAngry
|
|
|
|
},
|
|
|
|
{
|
|
|
|
translationKey: 'speakerStats.disgusted',
|
|
|
|
icon: IconEmotionsDisgusted
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
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();
|
2022-11-22 13:56:37 +00:00
|
|
|
const { t } = useTranslation();
|
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-11-22 13:56:37 +00:00
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
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 }>
|
2022-11-22 13:56:37 +00:00
|
|
|
<div className = { `header ${showFaceExpressions ? 'large' : 'medium'}` }>
|
|
|
|
<div className = 'upper-header'>
|
|
|
|
<div
|
|
|
|
className = {
|
|
|
|
`search-switch-container
|
|
|
|
${showFaceExpressions ? 'expressions-on' : ''}`
|
|
|
|
}>
|
|
|
|
<div
|
|
|
|
className = {
|
|
|
|
displaySwitch
|
|
|
|
? 'search-container'
|
|
|
|
: 'search-container-full-width' }>
|
|
|
|
<SpeakerStatsSearch
|
|
|
|
onSearch = { onSearch } />
|
|
|
|
</div>
|
2021-12-28 14:35:21 +00:00
|
|
|
|
2022-11-22 13:56:37 +00:00
|
|
|
{ displaySwitch
|
2022-04-06 09:10:31 +00:00
|
|
|
&& <FaceExpressionsSwitch
|
|
|
|
onChange = { onToggleFaceExpressions }
|
|
|
|
showFaceExpressions = { showFaceExpressions } />
|
2022-11-22 13:56:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
{ showFaceExpressions && <div className = 'emotions-icons'>
|
|
|
|
{
|
|
|
|
EMOTIONS_LEGEND.map(emotion => (
|
|
|
|
<Tooltip
|
|
|
|
content = { t(emotion.translationKey) }
|
|
|
|
key = { emotion.translationKey }
|
|
|
|
position = { 'top' }>
|
|
|
|
<Icon
|
|
|
|
size = { 20 }
|
|
|
|
src = { emotion.icon } />
|
|
|
|
</Tooltip>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
</div>}
|
|
|
|
</div>
|
|
|
|
{ displayLabels && (
|
2021-12-28 14:35:21 +00:00
|
|
|
<SpeakerStatsLabels
|
2022-04-06 09:10:31 +00:00
|
|
|
showFaceExpressions = { showFaceExpressions ?? false } />
|
2022-11-22 13:56:37 +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;
|