feat: stop experiment button
This commit is contained in:
@@ -98,6 +98,11 @@ University within the Software Project course.
|
||||
color: white;
|
||||
}
|
||||
|
||||
.stop {
|
||||
background-color: red;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.restartExperiment{
|
||||
background-color: red;
|
||||
color: white;
|
||||
|
||||
@@ -8,6 +8,7 @@ import styles from './MonitoringPage.module.css';
|
||||
import useProgramStore from "../../utils/programStore";
|
||||
import {
|
||||
nextPhase,
|
||||
stopExperiment,
|
||||
useExperimentLogger,
|
||||
useStatusLogger,
|
||||
pauseExperiment,
|
||||
@@ -144,7 +145,7 @@ function useExperimentLogic() {
|
||||
}
|
||||
}, [setProgramState]);
|
||||
|
||||
const handleControlAction = async (action: "pause" | "play" | "nextPhase") => {
|
||||
const handleControlAction = async (action: "pause" | "play" | "nextPhase" | "stop") => {
|
||||
try {
|
||||
setLoading(true);
|
||||
switch (action) {
|
||||
@@ -159,6 +160,9 @@ function useExperimentLogic() {
|
||||
case "nextPhase":
|
||||
await nextPhase();
|
||||
break;
|
||||
case "stop":
|
||||
await stopExperiment();
|
||||
break;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@@ -226,7 +230,7 @@ function ControlPanel({
|
||||
}: {
|
||||
loading: boolean,
|
||||
isPlaying: boolean,
|
||||
onAction: (a: "pause" | "play" | "nextPhase") => void,
|
||||
onAction: (a: "pause" | "play" | "nextPhase" | "stop") => void,
|
||||
onReset: () => void
|
||||
}) {
|
||||
return (
|
||||
@@ -256,6 +260,12 @@ function ControlPanel({
|
||||
onClick={onReset}
|
||||
disabled={loading}
|
||||
>⟲</button>
|
||||
|
||||
<button
|
||||
className={styles.stop}
|
||||
onClick={() => onAction("stop")}
|
||||
disabled={loading}
|
||||
>⏹</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -32,6 +32,12 @@ export async function nextPhase(): Promise<void> {
|
||||
sendAPICall(type, context)
|
||||
}
|
||||
|
||||
export async function stopExperiment(): Promise<void> {
|
||||
const type = "stop"
|
||||
const context = ""
|
||||
sendAPICall(type, context)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends an API call to the CB for going to pause experiment
|
||||
|
||||
Reference in New Issue
Block a user