Newer
Older
* Simulation control buttons with Material-UI - Start, Stop, Reset, Clear Results.
import {
Box,
Button,
Typography,
Divider,
Stack,
Chip,
CircularProgress,
} from '@mui/material';
import {
PlayArrow as PlayArrowIcon,
Stop as StopIcon,
Delete as DeleteIcon,
Refresh as RefreshIcon,
} from '@mui/icons-material';
import { useSimulationStore } from '../../store/simulationStore';
export default function SimulationControl() {
const {
config,
isRunning,
isLoading,
simulationResults,
startSimulation,
stopSimulation,
clearResults,
reset,
} = useSimulationStore();
const canStart = config !== null && !isRunning && !isLoading;
const canStop = isRunning;
const canClear = simulationResults !== null && !isRunning;
return (
<Box>
<Divider sx={{ my: 2 }} />
<Typography variant="subtitle2" fontWeight={600} gutterBottom>
Contrôle de simulation
</Typography>
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{/* Status indicator */}
<Box sx={{ my: 2 }}>
<Chip
label={
isRunning
? 'Simulation en cours...'
: simulationResults
? 'Simulation terminée'
: 'Prêt à simuler'
}
color={
isRunning
? 'warning'
: simulationResults
? 'success'
: 'default'
}
size="small"
sx={{
animation: isRunning ? 'pulse 2s ease-in-out infinite' : 'none',
'@keyframes pulse': {
'0%, 100%': { opacity: 1 },
'50%': { opacity: 0.6 },
},
}}
/>
</Box>
{/* Action buttons */}
<Stack spacing={1.5}>
{/* Start button */}
<Button
onClick={startSimulation}
disabled={!canStart}
variant="contained"
color="primary"
fullWidth
startIcon={
isLoading ? (
<CircularProgress size={16} color="inherit" />
<PlayArrowIcon />
)
}
>
{isLoading ? 'Traitement...' : 'Démarrer la simulation'}
</Button>
{/* Stop button */}
<Button
onClick={stopSimulation}
disabled={!canStop}
variant="contained"
color="error"
fullWidth
startIcon={<StopIcon />}
>
Arrêter la simulation
</Button>
{/* Clear results button */}
<Button
onClick={clearResults}
disabled={!canClear}
variant="contained"
color="warning"
fullWidth
startIcon={<DeleteIcon />}
>
Effacer les résultats
</Button>
{/* Reset button */}
<Button
onClick={reset}
disabled={isRunning}
variant="outlined"
color="primary"
fullWidth
startIcon={<RefreshIcon />}
>
Réinitialiser
</Button>
</Stack>
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
{/* Simulation info */}
{config && (
<Box sx={{ mt: 3, pt: 2, borderTop: 1, borderColor: 'divider' }}>
<Typography
variant="caption"
fontWeight={600}
color="text.secondary"
sx={{ textTransform: 'uppercase', display: 'block', mb: 1.5 }}
>
Paramètres de simulation
</Typography>
<Stack spacing={1}>
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
<Typography variant="body2" color="text.secondary">
Temps de préchauffage:
</Typography>
<Typography variant="body2" fontFamily="monospace" fontWeight={500}>
{config.warmup_time?.toLocaleString()} unités
</Typography>
</Box>
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
<Typography variant="body2" color="text.secondary">
Durée de simulation:
</Typography>
<Typography variant="body2" fontFamily="monospace" fontWeight={500}>
{config.simulation_time?.toLocaleString()} unités
</Typography>
</Box>
{config.random_seed !== undefined && (
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
<Typography variant="body2" color="text.secondary">
Graine aléatoire:
</Typography>
<Typography variant="body2" fontFamily="monospace" fontWeight={500}>
{config.random_seed}
</Typography>
</Box>
)}
</Stack>
</Box>
)}
</Box>