Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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
/**
* Simulation control buttons - Start, Stop, Reset, Clear Results.
*/
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 (
<div className="space-y-4">
<div className="border-t border-gray-200 pt-4">
<h3 className="text-sm font-medium text-gray-700 mb-3">Contrôle de simulation</h3>
{/* Status indicator */}
<div className="mb-4">
<div className="flex items-center space-x-2">
<div
className={`w-3 h-3 rounded-full ${
isRunning
? 'bg-yellow-400 animate-pulse'
: simulationResults
? 'bg-green-400'
: 'bg-gray-300'
}`}
/>
<span className="text-sm text-gray-600">
{isRunning
? 'Simulation en cours...'
: simulationResults
? 'Simulation terminée'
: 'Prêt à simuler'}
</span>
</div>
</div>
{/* Action buttons */}
<div className="space-y-2">
{/* Start button */}
<button
onClick={startSimulation}
disabled={!canStart}
className={`w-full px-4 py-2 rounded-md text-sm font-medium transition-colors ${
canStart
? 'bg-blue-600 text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2'
: 'bg-gray-300 text-gray-500 cursor-not-allowed'
}`}
>
{isLoading ? (
<span className="flex items-center justify-center">
<svg
className="animate-spin -ml-1 mr-2 h-4 w-4 text-white"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
/>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
/>
</svg>
Traitement...
</span>
) : (
'Démarrer la simulation'
)}
</button>
{/* Stop button */}
<button
onClick={stopSimulation}
disabled={!canStop}
className={`w-full px-4 py-2 rounded-md text-sm font-medium transition-colors ${
canStop
? 'bg-red-600 text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2'
: 'bg-gray-300 text-gray-500 cursor-not-allowed'
}`}
>
Arrêter la simulation
</button>
{/* Clear results button */}
<button
onClick={clearResults}
disabled={!canClear}
className={`w-full px-4 py-2 rounded-md text-sm font-medium transition-colors ${
canClear
? 'bg-yellow-600 text-white hover:bg-yellow-700 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2'
: 'bg-gray-300 text-gray-500 cursor-not-allowed'
}`}
>
Effacer les résultats
</button>
{/* Reset button */}
<button
onClick={reset}
disabled={isRunning}
className={`w-full px-4 py-2 rounded-md text-sm font-medium border transition-colors ${
isRunning
? 'border-gray-300 text-gray-500 cursor-not-allowed'
: 'border-gray-300 text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2'
}`}
>
Réinitialiser
</button>
</div>
{/* Simulation info */}
{config && (
<div className="mt-4 pt-4 border-t border-gray-200">
<h4 className="text-xs font-medium text-gray-500 uppercase mb-2">
Paramètres de simulation
</h4>
<div className="space-y-1 text-sm text-gray-600">
<div className="flex justify-between">
<span>Temps de préchauffage:</span>
<span className="font-mono">{config.warmup_time?.toLocaleString()} unités</span>
</div>
<div className="flex justify-between">
<span>Durée de simulation:</span>
<span className="font-mono">{config.simulation_time?.toLocaleString()} unités</span>
</div>
{config.random_seed !== undefined && (
<div className="flex justify-between">
<span>Graine aléatoire:</span>
<span className="font-mono">{config.random_seed}</span>
</div>
)}
</div>
</div>
)}
</div>
</div>
);
}