Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,23 @@ export const DatasetsAndNotebooksProvider = ({ children }) => {
removeNotebooksByDatasetId,
} = useNotebooks({ t });

const [step, setStep] = useState(0);
const [selectedOption, setSelectedOption] = useState(OptionsEnum.NEW); // "datasets" or "notebooks"
// Derived once from the URL present at mount so a direct navigation to
// .../datasets/new (or .../notebooks/new) renders the right step on the
// very first paint, instead of flashing the default "new" landing menu
// for a frame while DatasetsContent's location-sync effect catches up.
const initialPath =
typeof window !== "undefined" ? window.location.pathname : "";
const initialSelectedOption = initialPath.startsWith(
"/app/data/notebooks/new",
)
? OptionsEnum.NOTEBOOK
: initialPath.startsWith("/app/data/datasets/new")
? OptionsEnum.DATASET
: OptionsEnum.NEW;
const initialStep = initialSelectedOption === OptionsEnum.NEW ? 0 : 1;

const [step, setStep] = useState(initialStep);
const [selectedOption, setSelectedOption] = useState(initialSelectedOption); // "datasets" or "notebooks"

const [rightBarContent, setRightBarContent] = useState(null);
const [availableConverters, setAvailableConverters] = useState([]);
Expand Down
22 changes: 20 additions & 2 deletions DashAI/front/src/components/models/DatasetPredictionPanel.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useEffect, useRef, useState } from "react";
import PropTypes from "prop-types";
import { Box, CircularProgress } from "@mui/material";
import { Box, Button, CircularProgress } from "@mui/material";
import { ArrowForward } from "@mui/icons-material";
import { useNavigate } from "react-router-dom";
import { useSnackbar } from "notistack";
import { useTranslation } from "react-i18next";
import DatasetSelector from "../predictions/DatasetSelector";
Expand Down Expand Up @@ -32,7 +34,13 @@ export default function DatasetPredictionPanel({
const [isSubmitting, setIsSubmitting] = useState(false);

const { enqueueSnackbar } = useSnackbar();
const { t } = useTranslation(["prediction", "common"]);
const { t } = useTranslation(["prediction", "common", "models"]);
const navigate = useNavigate();

const handleUploadNewDataset = () => {
onClose();
navigate("/app/data/datasets/new");
};

const handleRunRef = useRef(null);
useEffect(() => {
Expand Down Expand Up @@ -182,6 +190,16 @@ export default function DatasetPredictionPanel({
datasets={datasets}
selectedDataset={selectedDataset}
setSelectedDataset={setSelectedDataset}
actionSlot={
<Button
variant="outlined"
endIcon={<ArrowForward />}
onClick={handleUploadNewDataset}
sx={{ textTransform: "none", fontWeight: 500, flexShrink: 0 }}
>
{t("models:button.uploadNewDataset")}
</Button>
}
/>
</Box>
);
Expand Down
89 changes: 47 additions & 42 deletions DashAI/front/src/components/predictions/DatasetSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function DatasetSelector({
datasets,
selectedDataset,
setSelectedDataset,
actionSlot = null,
}) {
const { t } = useTranslation(["prediction", "common", "datasets"]);
const [columnTypes, setColumnTypes] = useState({});
Expand Down Expand Up @@ -53,49 +54,53 @@ function DatasetSelector({

return (
<Box sx={{ mb: 6 }}>
<Autocomplete
options={datasets}
getOptionLabel={(option) => option.name}
isOptionEqualToValue={(opt, val) => opt.id === val.id}
value={selectedDataset}
onChange={(_, newValue) => setSelectedDataset(newValue)}
renderInput={(params) => (
<TextField
{...params}
label={t("prediction:label.selectDataset")}
variant="outlined"
placeholder={t("datasets:label.typeToSearchDatasets")}
/>
)}
renderOption={(props, option) => {
const { key, ...rootProps } = props;
return (
<Box component="li" key={key} {...rootProps}>
<Box
sx={{
display: "flex",
flexDirection: "column",
width: "100%",
gap: 0.25,
}}
>
<Typography variant="body1" fontWeight="medium">
{option.name}
</Typography>
<Typography variant="body2" color="text.secondary">
{t("common:created")}: {formatDate(option.created)}
</Typography>
<Typography variant="caption" color="text.secondary">
{t("datasets:label.rowsColumnsInfo", {
totalRows: option.total_rows ?? "...",
totalColumns: option.total_columns ?? "...",
})}
</Typography>
<Box sx={{ display: "flex", alignItems: "stretch", gap: 2 }}>
<Autocomplete
sx={{ flex: 1 }}
options={datasets}
getOptionLabel={(option) => option.name}
isOptionEqualToValue={(opt, val) => opt.id === val.id}
value={selectedDataset}
onChange={(_, newValue) => setSelectedDataset(newValue)}
renderInput={(params) => (
<TextField
{...params}
label={t("prediction:label.selectDataset")}
variant="outlined"
placeholder={t("datasets:label.typeToSearchDatasets")}
/>
)}
renderOption={(props, option) => {
const { key, ...rootProps } = props;
return (
<Box component="li" key={key} {...rootProps}>
<Box
sx={{
display: "flex",
flexDirection: "column",
width: "100%",
gap: 0.25,
}}
>
<Typography variant="body1" fontWeight="medium">
{option.name}
</Typography>
<Typography variant="body2" color="text.secondary">
{t("common:created")}: {formatDate(option.created)}
</Typography>
<Typography variant="caption" color="text.secondary">
{t("datasets:label.rowsColumnsInfo", {
totalRows: option.total_rows ?? "...",
totalColumns: option.total_columns ?? "...",
})}
</Typography>
</Box>
</Box>
</Box>
);
}}
/>
);
}}
/>
{actionSlot}
</Box>
{selectedDataset && (
<>
<Alert severity="info" sx={{ mt: 4 }}>
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/de/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"createLocalExplainer": "Neues lokales Erklärungsmodell",
"createPrediction": "Vorhersage erstellen",
"addNewPrediction": "Neue Vorhersage hinzufügen",
"uploadNewDataset": "Neuen Datensatz hochladen",
"createSession": "Sitzung erstellen",
"deleteAndRetrain": "Löschen und neu trainieren",
"deleteRun": "Durchlauf löschen",
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/en/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"createLocalExplainer": "New Local Explainer",
"createPrediction": "Create Prediction",
"addNewPrediction": "Add New Prediction",
"uploadNewDataset": "Upload new dataset",
"createSession": "Create Session",
"deleteAndRetrain": "Delete & Re-train",
"deleteRun": "Delete Run",
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/es/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"createLocalExplainer": "Nuevo Explicador Local",
"createPrediction": "Crear Predicción",
"addNewPrediction": "Agregar Nueva Predicción",
"uploadNewDataset": "Subir nuevo dataset",
"createSession": "Crear Sesión",
"deleteAndRetrain": "Eliminar y Re-entrenar",
"deleteRun": "Eliminar Ejecución",
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/pt/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"createLocalExplainer": "Novo Explicador Local",
"createPrediction": "Criar Previsão",
"addNewPrediction": "Adicionar Nova Previsão",
"uploadNewDataset": "Enviar Novo Conjunto de Dados",
"createSession": "Criar Sessão",
"deleteAndRetrain": "Excluir e Retreinar",
"deleteRun": "Excluir Execução",
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/zh/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"createLocalExplainer": "新建局部解释器",
"createPrediction": "创建预测",
"addNewPrediction": "添加新预测",
"uploadNewDataset": "上传新数据集",
"createSession": "创建会话",
"deleteAndRetrain": "删除并重新训练",
"deleteRun": "删除运行",
Expand Down
Loading