From 2f487ab00dcfa0eefef646f0b324682ed2973e4d Mon Sep 17 00:00:00 2001 From: c-bata Date: Sat, 12 Mar 2022 17:10:52 +0900 Subject: [PATCH] Put reload interval select on AppBar --- .../static/components/StudyDetail.tsx | 127 ++++++++++++++---- 1 file changed, 102 insertions(+), 25 deletions(-) diff --git a/optuna_dashboard/static/components/StudyDetail.tsx b/optuna_dashboard/static/components/StudyDetail.tsx index 4fc9f114..41c367ed 100644 --- a/optuna_dashboard/static/components/StudyDetail.tsx +++ b/optuna_dashboard/static/components/StudyDetail.tsx @@ -13,14 +13,15 @@ import { Toolbar, Box, IconButton, - Select, MenuItem, FormGroup, useTheme, FormLabel, - FormControl, + TextField, + alpha, } from "@mui/material" -import { Home, Settings } from "@mui/icons-material" +import { styled } from "@mui/system" +import { Cached, Home, Settings } from "@mui/icons-material" import FormControlLabel from "@mui/material/FormControlLabel" import MuiDialogTitle from "@mui/material/DialogTitle" import MuiDialogContent from "@mui/material/DialogContent" @@ -52,6 +53,17 @@ export const useStudyDetailValue = (studyId: number): StudyDetail | null => { return studyDetails[studyId] || null } +interface Preference { + graphHistoryChecked: boolean + graphParetoFrontChecked: boolean + graphParallelCoordinateChecked: boolean + graphIntermediateValuesChecked: boolean + edfChecked: boolean + graphHyperparameterImportancesChecked: boolean + graphSliceChecked: boolean + reloadInterval: number +} + export const StudyDetail: FC<{ toggleColorMode: () => void }> = ({ toggleColorMode }) => { @@ -61,7 +73,7 @@ export const StudyDetail: FC<{ const studyIdNumber = parseInt(studyId, 10) const studyDetail = useStudyDetailValue(studyIdNumber) - const [preferences, setPreferences] = useState({ + const [preferences, setPreferences] = useState({ graphHistoryChecked: true, graphParetoFrontChecked: true, graphParallelCoordinateChecked: true, @@ -220,27 +232,6 @@ export const StudyDetail: FC<{ label="Slice" /> - - Reload Interval - - - - ) @@ -260,6 +251,10 @@ export const StudyDetail: FC<{ {APP_BAR_TITLE} + { toggleColorMode() @@ -390,6 +385,88 @@ export const StudyDetail: FC<{ ) } +const ReloadIntervalSelect: FC<{ + preferences: Preference + setPreferences: (Preference) => void +}> = ({ preferences, setPreferences }) => { + const Wrapper = styled("div")(({ theme }) => ({ + position: "relative", + borderRadius: theme.shape.borderRadius, + backgroundColor: alpha(theme.palette.common.white, 0.15), + "&:hover": { + backgroundColor: alpha(theme.palette.common.white, 0.25), + }, + marginLeft: 0, + width: "100%", + [theme.breakpoints.up("sm")]: { + marginLeft: theme.spacing(1), + width: "auto", + }, + })) + + const IconWrapper = styled("div")(({ theme }) => ({ + padding: theme.spacing(0, 2), + height: "100%", + position: "absolute", + pointerEvents: "none", + display: "flex", + alignItems: "center", + justifyContent: "center", + })) + + const Select = styled(TextField)(({ theme }) => ({ + color: "inherit", + width: "14ch", + "& .MuiInput-underline:after": { + borderColor: "rgb(256,256,256,.1)", + }, + "& .MuiOutlinedInput-root": { + color: "inherit", + "& fieldset": { + borderColor: "rgb(256,256,256,.1)", + }, + "& .MuiSelect-icon": { + color: "white", + }, + "&:hover fieldset": { + borderColor: "rgb(256,256,256,.1)", + }, + "&.Mui-focused fieldset": { + borderColor: "rgb(256,256,256,.1)", + }, + }, + "& .MuiInputBase-input": { + // vertical padding + font size from searchIcon + paddingLeft: `calc(1em + ${theme.spacing(4)})`, + width: "100%", + }, + })) + + return ( + + + + + + + ) +} + export const TrialTable: FC<{ studyDetail: StudyDetail | null }> = ({ studyDetail, }) => {