Skip to content

Commit b4e2fb6

Browse files
committed
WIP: interface for pausing re-execution of simulations
1 parent 254b1d9 commit b4e2fb6

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

packages/frontend/src/stdlib/analyses/mass_action.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createMemo } from "solid-js";
1+
import { createMemo, createSignal, on } from "solid-js";
22

33
import {
44
BlockTitle,
@@ -8,6 +8,7 @@ import {
88
FixedTableEditor,
99
Foldable,
1010
KatexDisplay,
11+
Button,
1112
} from "catcolab-ui-components";
1213
import type { MassActionProblemData, MorType, ObType, QualifiedName } from "catlog-wasm";
1314
import type { ModelAnalysisProps } from "../../analysis";
@@ -101,7 +102,13 @@ export default function MassAction(
101102
(model) => props.simulate(model, props.content),
102103
);
103104

104-
const plotResult = () => result()?.plotData;
105+
const [autoUpdate, setAutoUpdate] = createSignal(true);
106+
const [shouldUpdate, trigger] = createSignal(false);
107+
const plotResult = createMemo(
108+
on(
109+
() => autoUpdate() ? result()?.plotData : shouldUpdate(),
110+
() => result()?.plotData
111+
));
105112
const latexEquations = () => result()?.latexEquations ?? [];
106113

107114
return (
@@ -125,6 +132,24 @@ export default function MassAction(
125132
]}
126133
/>
127134
</Foldable>
135+
<div>
136+
<Button
137+
type="button"
138+
variant="utility"
139+
onClick={() => trigger(val => !val)}
140+
disabled={autoUpdate()}
141+
>
142+
Execute
143+
</Button>
144+
<Button
145+
type="button"
146+
variant="utility"
147+
onClick={() => setAutoUpdate(val => !val)}
148+
disabled={false}
149+
>
150+
{autoUpdate() ? "Turn off autoupdate" : "Turn on autoupdate"}
151+
</Button>
152+
</div>
128153
<ODEResultPlot result={plotResult()} />
129154
</div>
130155
);

0 commit comments

Comments
 (0)