@@ -14,15 +14,7 @@ import {
1414 amber ,
1515} from "@mui/material/colors" ;
1616
17- import {
18- lighten ,
19- darken ,
20- useTheme ,
21- Box ,
22- ToggleButtonGroup ,
23- ToggleButton ,
24- Tooltip ,
25- } from "@mui/material" ;
17+ import { lighten , darken , useTheme , Box } from "@mui/material" ;
2618
2719import { TableChart , DonutSmall } from "@mui/icons-material" ;
2820
@@ -37,7 +29,12 @@ import {
3729
3830import { useApplicationId } from "../../hooks/application" ;
3931import { Filter } from "../../types/Filter" ;
40- import { Job , SearchBody , CategoryType } from "../../types" ;
32+ import {
33+ Job ,
34+ SearchBody ,
35+ CategoryType ,
36+ JobMonitorChartType ,
37+ } from "../../types" ;
4138import { JobDataTable } from "./JobDataTable" ;
4239import { JobSearchBar } from "./JobSearchBar" ;
4340import { JobSunburst } from "./JobSunburst" ;
@@ -109,7 +106,7 @@ export default function JobMonitor() {
109106 } ,
110107 ) ;
111108
112- const [ chartType , setChartType ] = useState ( "CHART_TYPE_TABLE" ) ;
109+ const [ chartType , setChartType ] = useState ( JobMonitorChartType . TABLE ) ;
113110
114111 // Save the state of the app in local storage
115112 useEffect ( ( ) => {
@@ -320,11 +317,24 @@ export default function JobMonitor() {
320317 searchBody = { searchBody }
321318 handleApplyFilters = { handleApplyFilters }
322319 columns = { columns }
320+ plotTypeSelectorProps = { {
321+ plotType : chartType ,
322+ setPlotType : setChartType ,
323+ buttonList : [
324+ {
325+ plotName : JobMonitorChartType . TABLE ,
326+ icon : < TableChart fontSize = "large" /> ,
327+ } ,
328+ {
329+ plotName : JobMonitorChartType . SUNBURST ,
330+ icon : < DonutSmall fontSize = "large" /> ,
331+ } ,
332+ ] ,
333+ } }
323334 />
324- < PlotTypeSelector plotType = { chartType } setPlotType = { setChartType } />
325335 </ Box >
326336
327- { chartType === "CHART_TYPE_TABLE" && (
337+ { chartType === JobMonitorChartType . TABLE && (
328338 < JobDataTable
329339 searchBody = { searchBody }
330340 setSearchBody = { setSearchBody }
@@ -340,7 +350,7 @@ export default function JobMonitor() {
340350 statusColors = { statusColors }
341351 />
342352 ) }
343- { chartType === "CHART_TYPE_SUNBURST" && (
353+ { chartType === JobMonitorChartType . SUNBURST && (
344354 < JobSunburst
345355 searchBody = { searchBody }
346356 statusColors = { statusColors }
@@ -414,42 +424,3 @@ export function fromHumanReadableText(
414424 }
415425 return name ;
416426}
417-
418- /**
419- * Component to select the type of plot
420- *
421- * @param plotType The type of the plot
422- * @param setPlotType The setter for the plot type
423- * @returns A list of buttons to select the type of plot
424- */
425- export function PlotTypeSelector ( {
426- plotType,
427- setPlotType,
428- } : {
429- plotType : string ;
430- setPlotType : React . Dispatch < React . SetStateAction < string > > ;
431- } ) {
432- return (
433- < >
434- < ToggleButtonGroup
435- value = { plotType }
436- exclusive
437- onChange = { ( _event : React . MouseEvent , val : string ) => {
438- if ( val !== null ) setPlotType ( val ) ;
439- } }
440- aria-label = "text alignment"
441- >
442- < Tooltip title = "Table view" >
443- < ToggleButton value = "CHART_TYPE_TABLE" aria-label = "left aligned" >
444- < TableChart fontSize = "large" />
445- </ ToggleButton >
446- </ Tooltip >
447- < Tooltip title = "Sunburst view" >
448- < ToggleButton value = "CHART_TYPE_SUNBURST" aria-label = "centered" >
449- < DonutSmall fontSize = "large" />
450- </ ToggleButton >
451- </ Tooltip >
452- </ ToggleButtonGroup >
453- </ >
454- ) ;
455- }
0 commit comments