1- import React , { useEffect , useState } from "react" ;
1+ import React , { useEffect , useState , useRef } from "react" ;
22import { CourseViewModel , HomeworkViewModel , StatisticsCourseMatesModel } from "@/api" ;
33import { useNavigate , useParams } from 'react-router-dom' ;
44import { LinearProgress , Table , TableBody , TableCell , TableContainer , TableHead , TableRow } from "@material-ui/core" ;
55import StudentStatsCell from "../Tasks/StudentStatsCell" ;
6- import { Alert , Button , Chip , Typography } from "@mui/material" ;
6+ import { Alert , Button , Chip , IconButton , Typography } from "@mui/material" ;
77import { grey } from "@material-ui/core/colors" ;
88import StudentStatsUtils from "../../services/StudentStatsUtils" ;
99import ShowChartIcon from "@mui/icons-material/ShowChart" ;
1010import { BonusTag , DefaultTags , TestTag } from "../Common/HomeworkTags" ;
1111import Lodash from "lodash"
1212import ApiSingleton from "@/api/ApiSingleton" ;
13+ import FullscreenIcon from '@mui/icons-material/Fullscreen' ;
14+ import FullscreenExitIcon from '@mui/icons-material/FullscreenExit' ;
1315
1416interface IStudentStatsProps {
1517 course : CourseViewModel ;
@@ -35,11 +37,36 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
3537 navigate ( `/statistics/${ courseId } /charts` )
3638 }
3739
40+ const [ isFullscreen , setIsFullscreen ] = useState ( false )
41+
42+ const tableRef = useRef < HTMLDivElement | null > ( null )
43+
44+ const toggleFullscreen = ( ) => {
45+ const target = tableRef . current
46+ if ( ! target ) return
47+ if ( ! document . fullscreenElement ) {
48+ if ( target . requestFullscreen ) {
49+ target . requestFullscreen ( )
50+ }
51+ } else {
52+ if ( document . exitFullscreen ) {
53+ document . exitFullscreen ( )
54+ }
55+ }
56+ }
57+
58+ useEffect ( ( ) => {
59+ const onFsChange = ( ) => setIsFullscreen ( ! ! document . fullscreenElement )
60+ document . addEventListener ( 'fullscreenchange' , onFsChange )
61+ return ( ) => document . removeEventListener ( 'fullscreenchange' , onFsChange )
62+ } , [ ] )
63+
3864 const { searched} = state
3965 const isMentor = ApiSingleton . authService . isMentor ( )
4066
4167 useEffect ( ( ) => {
4268 const keyDownHandler = ( event : KeyboardEvent ) => {
69+ if ( isFullscreen ) return
4370 if ( event . ctrlKey || event . altKey ) return
4471 if ( searched && event . key === "Escape" ) {
4572 setSearched ( { searched : "" } ) ;
@@ -130,13 +157,18 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
130157 < Alert style = { { marginBottom : 5 } } severity = "info" > < b > Поиск: </ b >
131158 { searched . replaceAll ( " " , "·" ) }
132159 </ Alert > }
133- < TableContainer style = { { maxHeight : "93vh" , marginBottom : - 50 } } >
160+ < TableContainer ref = { tableRef } style = { { maxHeight : "93vh" , marginBottom : - 50 } } >
134161 < Table stickyHeader aria-label = "sticky table" >
135162 < TableHead >
136163 < TableRow >
137- < TableCell style = { { zIndex : - 4 , color : "" } } align = "center"
164+ < TableCell style = { { zIndex : 10 } } align = "center"
138165 padding = "none"
139166 component = "td" >
167+ < IconButton size = "medium" color = { "primary" } onClick = { toggleFullscreen } >
168+ { isFullscreen
169+ ? < FullscreenExitIcon fontSize = { "medium" } />
170+ : < FullscreenIcon fontSize = { "medium" } /> }
171+ </ IconButton >
140172 </ TableCell >
141173 { ( hasHomeworks || hasTests ) && < TableCell
142174 padding = "checkbox"
@@ -277,6 +309,7 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
277309 padding = "none"
278310 style = { {
279311 borderLeft : borderStyle ,
312+ backgroundColor : "white"
280313 } }
281314 component = "td"
282315 scope = "row"
@@ -294,6 +327,7 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
294327 padding = "none"
295328 style = { {
296329 borderLeft : borderStyle ,
330+ backgroundColor : "white"
297331 } }
298332 component = "td"
299333 scope = "row"
@@ -309,9 +343,13 @@ const StudentStats: React.FC<IStudentStatsProps> = (props) => {
309343 { showBestSolutions && < TableCell
310344 align = "center"
311345 padding = "none"
312- style = { { borderLeft : borderStyle } } >
313- { bestSolutionsCount > 0
314- ? < Typography variant = { "caption" } color = { "grey" } > { bestSolutionsCount } </ Typography >
346+ style = { {
347+ borderLeft : borderStyle ,
348+ backgroundColor : "white"
349+ } } >
350+ { bestSolutionsCount > 0
351+ ? < Typography variant = { "caption" }
352+ color = { "grey" } > { bestSolutionsCount } </ Typography >
315353 : "" }
316354 </ TableCell > }
317355 { homeworks . map ( ( homework , idx ) =>
0 commit comments