Compare commits

...

2 Commits

Author SHA1 Message Date
af196529f8 chore: remove hooks 2026-02-02 14:39:20 +01:00
901159ae2d feat: stop experiment button 2026-02-02 14:39:07 +01:00
5 changed files with 81 additions and 79 deletions

17
package-lock.json generated
View File

@@ -31,7 +31,6 @@
"eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20", "eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.4.0", "globals": "^16.4.0",
"husky": "^9.1.7",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"jest": "^30.2.0", "jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0", "jest-environment-jsdom": "^30.2.0",
@@ -5544,22 +5543,6 @@
"node": ">=10.17.0" "node": ">=10.17.0"
} }
}, },
"node_modules/husky": {
"version": "9.1.7",
"resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
"integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==",
"dev": true,
"license": "MIT",
"bin": {
"husky": "bin.js"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/iconv-lite": { "node_modules/iconv-lite": {
"version": "0.6.3", "version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",

View File

@@ -8,8 +8,7 @@
"build": "tsc -b && vite build", "build": "tsc -b && vite build",
"lint": "eslint src test", "lint": "eslint src test",
"preview": "vite preview", "preview": "vite preview",
"test": "jest", "test": "jest"
"prepare": "husky"
}, },
"dependencies": { "dependencies": {
"@neodrag/react": "^2.3.1", "@neodrag/react": "^2.3.1",
@@ -35,7 +34,6 @@
"eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20", "eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.4.0", "globals": "^16.4.0",
"husky": "^9.1.7",
"identity-obj-proxy": "^3.0.0", "identity-obj-proxy": "^3.0.0",
"jest": "^30.2.0", "jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0", "jest-environment-jsdom": "^30.2.0",

View File

@@ -98,6 +98,11 @@ University within the Software Project course.
color: white; color: white;
} }
.stop {
background-color: red;
color: white;
}
.restartExperiment{ .restartExperiment{
background-color: red; background-color: red;
color: white; color: white;

View File

@@ -8,6 +8,7 @@ import styles from './MonitoringPage.module.css';
import useProgramStore from "../../utils/programStore"; import useProgramStore from "../../utils/programStore";
import { import {
nextPhase, nextPhase,
stopExperiment,
useExperimentLogger, useExperimentLogger,
useStatusLogger, useStatusLogger,
pauseExperiment, pauseExperiment,
@@ -144,7 +145,7 @@ function useExperimentLogic() {
} }
}, [setProgramState]); }, [setProgramState]);
const handleControlAction = async (action: "pause" | "play" | "nextPhase") => { const handleControlAction = async (action: "pause" | "play" | "nextPhase" | "stop") => {
try { try {
setLoading(true); setLoading(true);
switch (action) { switch (action) {
@@ -159,6 +160,9 @@ function useExperimentLogic() {
case "nextPhase": case "nextPhase":
await nextPhase(); await nextPhase();
break; break;
case "stop":
await stopExperiment();
break;
} }
} catch (err) { } catch (err) {
console.error(err); console.error(err);
@@ -226,7 +230,7 @@ function ControlPanel({
}: { }: {
loading: boolean, loading: boolean,
isPlaying: boolean, isPlaying: boolean,
onAction: (a: "pause" | "play" | "nextPhase") => void, onAction: (a: "pause" | "play" | "nextPhase" | "stop") => void,
onReset: () => void onReset: () => void
}) { }) {
return ( return (
@@ -256,6 +260,12 @@ function ControlPanel({
onClick={onReset} onClick={onReset}
disabled={loading} disabled={loading}
></button> ></button>
<button
className={styles.stop}
onClick={() => onAction("stop")}
disabled={loading}
></button>
</div> </div>
</div> </div>
); );

View File

@@ -32,6 +32,12 @@ export async function nextPhase(): Promise<void> {
sendAPICall(type, context) 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 * Sends an API call to the CB for going to pause experiment