-
Notifications
You must be signed in to change notification settings - Fork 1
Add presets #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add presets #80
Changes from all commits
ef4ff07
de00f07
13d8e82
7745f75
f673732
09cb218
1076119
914c3da
ee1ac87
090bca1
87b94cc
9c8cc23
a4f7706
825e2ac
f942324
cc791e6
e225a7a
72190f4
18db020
514dc90
e0c4fc0
b71489f
dd67ef0
19e9984
dcc3e37
67e34b8
b285614
5c6ba95
8f4e429
b2cc225
3838927
acd213b
cb3a894
10535e1
a2707a8
361df65
db415e8
ec5d964
59ab045
61d76cb
36f1bab
26df268
333f79f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,10 @@ import { | |
| createUniqueId, | ||
| onCleanup, | ||
| } from "solid-js"; | ||
| import { unwrap } from "solid-js/store"; | ||
| import { Button, buttonVariants } from "~/components/ui/button"; | ||
| import { createArchive, toConfigBlob } from "~/lib/download"; | ||
| import { findPresetByName } from "~/lib/presets"; | ||
| import { | ||
| type Experiment, | ||
| addExperiment, | ||
|
|
@@ -46,15 +48,17 @@ export function AddExperimentDialog(props: { | |
| onClose: () => void; | ||
| open: boolean; | ||
| }) { | ||
| const initialExperiment = () => { | ||
| const defaultPreset = findPresetByName(); | ||
| const initialExperimentConfig = createMemo(() => { | ||
| return { | ||
| name: `My experiment ${props.nextIndex}`, | ||
| description: "", | ||
| reference: { config: {} }, | ||
| preset: "Default", | ||
| reference: { | ||
| ...structuredClone(defaultPreset.config), | ||
| name: `My experiment ${props.nextIndex}`, | ||
| }, | ||
| permutations: [], | ||
| running: false as const, | ||
| }; | ||
| }; | ||
| }); | ||
|
|
||
| function setOpen(value: boolean) { | ||
| if (!value) { | ||
|
|
@@ -66,19 +70,19 @@ export function AddExperimentDialog(props: { | |
| <Dialog open={props.open} onOpenChange={setOpen}> | ||
| <DialogContent class="min-w-[33%]"> | ||
| <DialogHeader> | ||
| <DialogTitle class="mr-10">Experiment</DialogTitle> | ||
| <DialogTitle class="mr-10 flex justify-between gap-1"> | ||
| Experiment | ||
| <span class="text-gray-300 text-sm "> | ||
| Preset: {defaultPreset.config.name} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How hard would it be to make this editable via a dropdown? |
||
| </span> | ||
| </DialogTitle> | ||
| </DialogHeader> | ||
| <ExperimentConfigForm | ||
| id="experiment-form" | ||
| experiment={initialExperiment()} | ||
| experiment={initialExperimentConfig()} | ||
| onSubmit={(newConfig) => { | ||
| props.onClose(); | ||
| const { title, description, ...strippedConfig } = newConfig; | ||
| addExperiment( | ||
| strippedConfig, | ||
| title ?? initialExperiment().name, | ||
| description ?? initialExperiment().description, | ||
| ); | ||
| addExperiment(newConfig); | ||
| }} | ||
| /> | ||
| <DialogFooter> | ||
|
|
@@ -104,20 +108,19 @@ export function ExperimentSettingsDialog(props: { | |
| </DialogTrigger> | ||
| <DialogContent class="min-w-[33%]"> | ||
| <DialogHeader> | ||
| <DialogTitle class="mr-10">Experiment</DialogTitle> | ||
| <DialogTitle class="mr-10 flex justify-between gap-1"> | ||
| Experiment | ||
| <span class="text-gray-300 text-sm "> | ||
| Preset: {props.experiment.config.preset} | ||
| </span> | ||
| </DialogTitle> | ||
|
Comment on lines
+111
to
+116
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should combine "from scratch (default preset)" and "from preset" into one. |
||
| </DialogHeader> | ||
| <ExperimentConfigForm | ||
| id="experiment-form" | ||
| experiment={props.experiment} | ||
| experiment={props.experiment.config} | ||
| onSubmit={(newConfig) => { | ||
| setOpen(false); | ||
| const { title, description, ...strippedConfig } = newConfig; | ||
| modifyExperiment( | ||
| props.experimentIndex, | ||
| strippedConfig, | ||
| title ?? props.experiment.name, | ||
| description ?? props.experiment.description, | ||
| ); | ||
| modifyExperiment(props.experimentIndex, newConfig); | ||
| }} | ||
| /> | ||
| <DialogFooter> | ||
|
|
@@ -164,14 +167,14 @@ function RunningIndicator(props: { progress: number | false }) { | |
|
|
||
| function DownloadExperimentConfiguration(props: { experiment: Experiment }) { | ||
| const downloadUrl = createMemo(() => { | ||
| return URL.createObjectURL(toConfigBlob(props.experiment)); | ||
| return URL.createObjectURL(toConfigBlob(unwrap(props.experiment.config))); | ||
| }); | ||
|
|
||
| onCleanup(() => { | ||
| URL.revokeObjectURL(downloadUrl()); | ||
| }); | ||
|
|
||
| const filename = `class-${props.experiment.name}.json`; | ||
| const filename = `class-${props.experiment.config.reference.name}.json`; | ||
| return ( | ||
| <a href={downloadUrl()} download={filename} type="application/json"> | ||
| Configuration | ||
|
|
@@ -182,7 +185,7 @@ function DownloadExperimentConfiguration(props: { experiment: Experiment }) { | |
| function DownloadExperimentArchive(props: { experiment: Experiment }) { | ||
| const [url, setUrl] = createSignal<string>(""); | ||
| createEffect(async () => { | ||
| const archive = await createArchive(props.experiment); | ||
| const archive = await createArchive(unwrap(props.experiment)); | ||
| if (!archive) { | ||
| return; | ||
| } | ||
|
|
@@ -191,7 +194,7 @@ function DownloadExperimentArchive(props: { experiment: Experiment }) { | |
| onCleanup(() => URL.revokeObjectURL(objectUrl)); | ||
| }); | ||
|
|
||
| const filename = `class-${props.experiment.name}.zip`; | ||
| const filename = `class-${props.experiment.config.reference.name}.zip`; | ||
| return ( | ||
| <a href={url()} download={filename} type="application/zip"> | ||
| Configuration and output | ||
|
|
@@ -236,9 +239,9 @@ export function ExperimentCard(props: { | |
| aria-describedby={descriptionId} | ||
| > | ||
| <CardHeader> | ||
| <CardTitle id={id}>{experiment().name}</CardTitle> | ||
| <CardTitle id={id}>{experiment().config.reference.name}</CardTitle> | ||
| <CardDescription id={descriptionId}> | ||
| {experiment().description} | ||
| {experiment().config.reference.description} | ||
| </CardDescription> | ||
| </CardHeader> | ||
| <CardContent> | ||
|
|
@@ -247,10 +250,10 @@ export function ExperimentCard(props: { | |
| experimentIndex={experimentIndex()} | ||
| /> | ||
| </CardContent> | ||
| <CardFooter> | ||
| <CardFooter class="gap-1"> | ||
| <Show | ||
| when={!experiment().running} | ||
| fallback={<RunningIndicator progress={experiment().running} />} | ||
| when={!experiment().output.running} | ||
| fallback={<RunningIndicator progress={experiment().output.running} />} | ||
| > | ||
| <DownloadExperiment experiment={experiment()} /> | ||
| <ExperimentSettingsDialog | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool! But now we have a share URL that says
/?experiments=...and the preset url that says/?preset=...which defaults to a single experiment. Makes me wonder if we shouldn't provide one consistent way to encode URLs. See #102There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yep lets look at the different search params later