88 IconButton ,
99 TextField ,
1010 Stack ,
11+ Slider ,
1112} from "@mui/material" ;
1213import { DataGrid } from "@mui/x-data-grid" ;
1314import OpenInNewIcon from "@mui/icons-material/OpenInNew" ;
@@ -85,20 +86,79 @@ const AutograderSpam = () => {
8586 } ) ;
8687 } , [ routeParams , numBackupsThreshold , timeThreshold ] ) ;
8788
89+ const getMarks = ( totalBackups ) => {
90+ return [
91+ {
92+ value : 0 ,
93+ label : "0" ,
94+ } ,
95+ {
96+ value : Math . round ( totalBackups * 0.25 ) ,
97+ label : `${ Math . round ( totalBackups * 0.25 ) } ` ,
98+ } ,
99+ {
100+ value : Math . round ( totalBackups * 0.5 ) ,
101+ label : `${ Math . round ( totalBackups * 0.5 ) } ` ,
102+ } ,
103+ {
104+ value : Math . round ( totalBackups * 0.75 ) ,
105+ label : `${ Math . round ( totalBackups * 0.75 ) } ` ,
106+ } ,
107+ {
108+ value : totalBackups ,
109+ label : `${ totalBackups } ` ,
110+ } ,
111+ ] ;
112+ } ;
113+
88114 const columns = [
89115 {
90- field : "startTimestamp" ,
91- headerName : "Start Timestamp" ,
92- flex : 1 ,
93- valueGetter : ( value ) => value ,
94- valueFormatter : ( value ) => formatTimestamp ( value ) ,
95- } ,
96- {
97- field : "endTimestamp" ,
98- headerName : "End Timestamp" ,
99- flex : 1 ,
100- valueGetter : ( value ) => value ,
101- valueFormatter : ( value ) => formatTimestamp ( value ) ,
116+ field : "worksession" ,
117+ headerName : "Worksession" ,
118+ flex : 2 ,
119+ valueGetter : ( value , row ) => new Date ( row . startTimestamp ) ,
120+ sortComparator : ( v1 , v2 ) => v1 - v2 ,
121+ // TODO fix popper being hidden by DataGrid on the far left side when hovering over the slider thumbs
122+ renderCell : ( params ) => {
123+ const getSliderValueText = ( value ) => {
124+ if ( value === params . row . startIndex ) {
125+ return `Backup #${ value } (${ formatTimestamp ( params . row . startTimestamp ) } )` ;
126+ } else {
127+ return `Backup #${ value } (${ formatTimestamp ( params . row . endTimestamp ) } )` ;
128+ }
129+ } ;
130+
131+ return (
132+ < div
133+ style = { { display : "flex" , alignItems : "center" , height : "100%" } }
134+ >
135+ < Slider
136+ aria-label = "Worksession"
137+ value = { [ params . row . startIndex , params . row . endIndex ] }
138+ valueLabelDisplay = "auto"
139+ min = { 0 }
140+ max = { params . row . totalBackups }
141+ marks = { getMarks ( params . row . totalBackups ) }
142+ valueLabelFormat = { getSliderValueText }
143+ getAriaValueText = { getSliderValueText }
144+ sx = { {
145+ // Reduce the size of the circles (thumbs)
146+ "& .MuiSlider-thumb" : {
147+ height : 12 ,
148+ width : 12 ,
149+ } ,
150+ // Adjust the track and rail thickness to match smaller thumbs
151+ "& .MuiSlider-track" : {
152+ height : 4 ,
153+ } ,
154+ "& .MuiSlider-rail" : {
155+ height : 4 ,
156+ } ,
157+ } }
158+ />
159+ </ div >
160+ ) ;
161+ } ,
102162 } ,
103163 {
104164 field : "duration" ,
@@ -113,9 +173,9 @@ const AutograderSpam = () => {
113173 } ,
114174 {
115175 field : "numBackups" ,
116- headerName : "Number of Backups" ,
176+ headerName : "# of Backups" ,
117177 type : "number" ,
118- width : 150 ,
178+ width : 100 ,
119179 align : "right" ,
120180 headerAlign : "right" ,
121181 } ,
@@ -134,19 +194,21 @@ const AutograderSpam = () => {
134194 align : "center" ,
135195 headerAlign : "center" ,
136196 renderCell : ( params ) => (
137- < Tooltip title = "Jump to start of session in Timeline" >
138- < IconButton
139- color = "primary"
140- size = "small"
141- onClick = { ( ) => {
142- navigate (
143- `/courses/${ routeParams . courseId } /assignments/${ routeParams . assignmentId } /students/${ routeParams . studentId } /submission/timeline/${ params . id } ` ,
144- ) ;
145- } }
146- >
147- < OpenInNewIcon fontSize = "small" />
148- </ IconButton >
149- </ Tooltip >
197+ < div style = { { display : "flex" , alignItems : "center" , height : "100%" } } >
198+ < Tooltip title = "Jump to start of session in Timeline" >
199+ < IconButton
200+ color = "primary"
201+ size = "small"
202+ onClick = { ( ) => {
203+ navigate (
204+ `/courses/${ routeParams . courseId } /assignments/${ routeParams . assignmentId } /students/${ routeParams . studentId } /submission/timeline/${ params . id } ` ,
205+ ) ;
206+ } }
207+ >
208+ < OpenInNewIcon fontSize = "small" />
209+ </ IconButton >
210+ </ Tooltip >
211+ </ div >
150212 ) ,
151213 } ,
152214 ] ;
@@ -228,6 +290,7 @@ const AutograderSpam = () => {
228290 } }
229291 pageSizeOptions = { [ 5 , 10 , 25 ] }
230292 disableRowSelectionOnClick
293+ rowHeight = { 100 }
231294 />
232295 </ Paper >
233296 </ Box >
0 commit comments