aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/editor
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2023-09-14 03:05:28 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2023-09-14 03:43:26 +0200
commit13b464db253566290be6a1063ad8e296288d3339 (patch)
tree29e0a9a346f66974d6c0be0482f511e9becab51c /subprojects/frontend/src/editor
parentfix(frontend): keep live while model generation (diff)
downloadrefinery-13b464db253566290be6a1063ad8e296288d3339.tar.gz
refinery-13b464db253566290be6a1063ad8e296288d3339.tar.zst
refinery-13b464db253566290be6a1063ad8e296288d3339.zip
feat: specify random seed for generation
Diffstat (limited to 'subprojects/frontend/src/editor')
-rw-r--r--subprojects/frontend/src/editor/AnimatedButton.tsx2
-rw-r--r--subprojects/frontend/src/editor/EditorStore.ts8
-rw-r--r--subprojects/frontend/src/editor/GenerateButton.tsx8
-rw-r--r--subprojects/frontend/src/editor/GeneratedModelStore.ts4
4 files changed, 14 insertions, 8 deletions
diff --git a/subprojects/frontend/src/editor/AnimatedButton.tsx b/subprojects/frontend/src/editor/AnimatedButton.tsx
index 24ec69be..606aabea 100644
--- a/subprojects/frontend/src/editor/AnimatedButton.tsx
+++ b/subprojects/frontend/src/editor/AnimatedButton.tsx
@@ -45,7 +45,7 @@ export default function AnimatedButton({
45 children, 45 children,
46}: { 46}: {
47 'aria-label'?: string; 47 'aria-label'?: string;
48 onClick?: () => void; 48 onClick?: React.MouseEventHandler<HTMLElement>;
49 color: 'error' | 'warning' | 'primary' | 'inherit'; 49 color: 'error' | 'warning' | 'primary' | 'inherit';
50 disabled?: boolean; 50 disabled?: boolean;
51 startIcon?: JSX.Element; 51 startIcon?: JSX.Element;
diff --git a/subprojects/frontend/src/editor/EditorStore.ts b/subprojects/frontend/src/editor/EditorStore.ts
index f9a9a7da..9508858d 100644
--- a/subprojects/frontend/src/editor/EditorStore.ts
+++ b/subprojects/frontend/src/editor/EditorStore.ts
@@ -313,14 +313,14 @@ export default class EditorStore {
313 this.disposed = true; 313 this.disposed = true;
314 } 314 }
315 315
316 startModelGeneration(): void { 316 startModelGeneration(randomSeed?: number): void {
317 this.client 317 this.client
318 ?.startModelGeneration() 318 ?.startModelGeneration(randomSeed)
319 ?.catch((error) => log.error('Could not start model generation', error)); 319 ?.catch((error) => log.error('Could not start model generation', error));
320 } 320 }
321 321
322 addGeneratedModel(uuid: string): void { 322 addGeneratedModel(uuid: string, randomSeed: number): void {
323 this.generatedModels.set(uuid, new GeneratedModelStore()); 323 this.generatedModels.set(uuid, new GeneratedModelStore(randomSeed));
324 this.selectGeneratedModel(uuid); 324 this.selectGeneratedModel(uuid);
325 } 325 }
326 326
diff --git a/subprojects/frontend/src/editor/GenerateButton.tsx b/subprojects/frontend/src/editor/GenerateButton.tsx
index b8dcd531..b6b1655a 100644
--- a/subprojects/frontend/src/editor/GenerateButton.tsx
+++ b/subprojects/frontend/src/editor/GenerateButton.tsx
@@ -98,7 +98,13 @@ const GenerateButton = observer(function GenerateButton({
98 disabled={!editorStore.opened} 98 disabled={!editorStore.opened}
99 color={warningCount > 0 ? 'warning' : 'primary'} 99 color={warningCount > 0 ? 'warning' : 'primary'}
100 startIcon={<PlayArrowIcon />} 100 startIcon={<PlayArrowIcon />}
101 onClick={() => editorStore.startModelGeneration()} 101 onClick={(event) => {
102 if (event.shiftKey) {
103 editorStore.startModelGeneration(1);
104 } else {
105 editorStore.startModelGeneration();
106 }
107 }}
102 > 108 >
103 {summary === '' ? GENERATE_LABEL : `${GENERATE_LABEL} (${summary})`} 109 {summary === '' ? GENERATE_LABEL : `${GENERATE_LABEL} (${summary})`}
104 </AnimatedButton> 110 </AnimatedButton>
diff --git a/subprojects/frontend/src/editor/GeneratedModelStore.ts b/subprojects/frontend/src/editor/GeneratedModelStore.ts
index d0181eed..5088d603 100644
--- a/subprojects/frontend/src/editor/GeneratedModelStore.ts
+++ b/subprojects/frontend/src/editor/GeneratedModelStore.ts
@@ -18,9 +18,9 @@ export default class GeneratedModelStore {
18 18
19 graph: GraphStore | undefined; 19 graph: GraphStore | undefined;
20 20
21 constructor() { 21 constructor(randomSeed: number) {
22 const time = new Date().toLocaleTimeString(undefined, { hour12: false }); 22 const time = new Date().toLocaleTimeString(undefined, { hour12: false });
23 this.title = `Generated at ${time}`; 23 this.title = `Generated at ${time} (${randomSeed})`;
24 makeAutoObservable(this); 24 makeAutoObservable(this);
25 } 25 }
26 26