mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-12 12:40:33 +08:00
Fix action.ts and DataGrid.tsx
This commit is contained in:
@@ -34,6 +34,7 @@ type LocalStorageReloadInterval = {
|
||||
reloadInterval?: number
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export const actionCreator = () => {
|
||||
const { enqueueSnackbar } = useSnackbar()
|
||||
const [studySummaries, setStudySummaries] =
|
||||
@@ -432,8 +433,13 @@ export const actionCreator = () => {
|
||||
const reader = new FileReader()
|
||||
setUploading(true)
|
||||
reader.readAsDataURL(file)
|
||||
reader.onload = (upload: any) => {
|
||||
uploadArtifactAPI(studyId, trialId, file.name, upload.target.result)
|
||||
reader.onload = (upload: ProgressEvent<FileReader>) => {
|
||||
uploadArtifactAPI(
|
||||
studyId,
|
||||
trialId,
|
||||
file.name,
|
||||
upload.target?.result as string
|
||||
)
|
||||
.then((res) => {
|
||||
setUploading(false)
|
||||
const index = studyDetails[studyId].trials.findIndex(
|
||||
|
||||
@@ -19,6 +19,9 @@ import { Clear } from "@mui/icons-material"
|
||||
|
||||
type Order = "asc" | "desc"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type Value = any
|
||||
|
||||
const defaultRowsPerPageOption = [10, 50, 100, { label: "All", value: -1 }]
|
||||
|
||||
interface DataGridColumn<T> {
|
||||
@@ -33,7 +36,7 @@ interface DataGridColumn<T> {
|
||||
|
||||
interface RowFilter {
|
||||
columnIdx: number
|
||||
value: any
|
||||
value: Value
|
||||
}
|
||||
|
||||
function DataGrid<T>(props: {
|
||||
@@ -45,7 +48,7 @@ function DataGrid<T>(props: {
|
||||
initialRowsPerPage?: number
|
||||
rowsPerPageOption?: Array<number | { value: number; label: string }>
|
||||
defaultFilter?: (row: T) => boolean
|
||||
}) {
|
||||
}): React.ReactElement {
|
||||
const { columns, rows, keyField, dense, collapseBody, defaultFilter } = props
|
||||
let { initialRowsPerPage, rowsPerPageOption } = props
|
||||
const [order, setOrder] = React.useState<Order>("asc")
|
||||
@@ -81,7 +84,7 @@ function DataGrid<T>(props: {
|
||||
const fieldAlreadyFiltered = (columnIdx: number): boolean =>
|
||||
filters.some((f) => f.columnIdx === columnIdx)
|
||||
|
||||
const handleClickFilterCell = (columnIdx: number, value: any) => {
|
||||
const handleClickFilterCell = (columnIdx: number, value: Value) => {
|
||||
if (fieldAlreadyFiltered(columnIdx)) {
|
||||
return
|
||||
}
|
||||
@@ -242,7 +245,7 @@ function DataGridRow<T>(props: {
|
||||
row: T
|
||||
keyField: keyof T
|
||||
collapseBody?: (rowIndex: number) => React.ReactNode
|
||||
handleClickFilterCell: (columnIdx: number, value: any) => void
|
||||
handleClickFilterCell: (columnIdx: number, value: Value) => void
|
||||
}) {
|
||||
const {
|
||||
columns,
|
||||
|
||||
Reference in New Issue
Block a user