-
Notifications
You must be signed in to change notification settings - Fork 1
Persist analyses #191
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
Merged
Merged
Persist analyses #191
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8cae570
See if ?preset works to load experiment remotely
sverhoeven e7cd062
Only hide toast on success + allow toast of failure to be closed manu…
sverhoeven 8aaa7f8
Load experiment from remote URL via `?e=<remote-url>`
sverhoeven 9e02c29
Embed json file into README
sverhoeven c2dfb76
Do not try to parse non-200 responses
sverhoeven 50b3064
Plot pressure, temperature and relative humidity from observations
sverhoeven edd84c2
If shareable link is too large give hosting state file as alternative
sverhoeven 36be474
Always clear adress bar from `?s=...`
sverhoeven 9d0c94d
more e to s replacements + spelling
sverhoeven 43671f0
Merge remote-tracking branch 'origin/remote-exp' into persist-analyis…
sverhoeven 4a9392e
Use union type for Analysis + setAnalysis on loading state
sverhoeven a543202
Encode/decode analyses array using a JSON schema validator + move Ana…
sverhoeven 640d833
Make oneOfs the same
sverhoeven f0d6538
Merge remote-tracking branch 'origin/main' into persist-analyis-189
sverhoeven File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { ajv } from "@classmodel/class/validate"; | ||
| import { type DefinedError, type JSONSchemaType, ValidationError } from "ajv"; | ||
|
|
||
| export interface BaseAnalysis { | ||
| id: string; | ||
| description: string; | ||
| type: string; | ||
| name: string; | ||
| } | ||
|
|
||
| export type TimeseriesAnalysis = BaseAnalysis & { | ||
| xVariable: string; | ||
| yVariable: string; | ||
| }; | ||
|
|
||
| export type ProfilesAnalysis = BaseAnalysis & { | ||
| variable: string; | ||
| time: number; | ||
| }; | ||
|
|
||
| export type SkewTAnalysis = BaseAnalysis & { | ||
| time: number; | ||
| }; | ||
|
|
||
| export type Analysis = TimeseriesAnalysis | ProfilesAnalysis | SkewTAnalysis; | ||
| export const analysisNames = [ | ||
| "Vertical profiles", | ||
| "Timeseries", | ||
| "Thermodynamic diagram", | ||
| ]; | ||
|
|
||
| export function parseAnalysis(raw: unknown): Analysis { | ||
| const schema = { | ||
| oneOf: [ | ||
| { | ||
| type: "object", | ||
| required: [ | ||
| "id", | ||
| "description", | ||
| "type", | ||
| "name", | ||
| "xVariable", | ||
| "yVariable", | ||
| ], | ||
| properties: { | ||
| id: { type: "string" }, | ||
| description: { type: "string" }, | ||
| type: { const: "timeseries" }, | ||
| name: { type: "string" }, | ||
| xVariable: { type: "string" }, | ||
| yVariable: { type: "string" }, | ||
| }, | ||
| additionalProperties: false, | ||
| }, | ||
| { | ||
| type: "object", | ||
| required: ["id", "description", "type", "name", "variable", "time"], | ||
| properties: { | ||
| id: { type: "string" }, | ||
| description: { type: "string" }, | ||
| type: { const: "profiles" }, | ||
| name: { type: "string" }, | ||
| variable: { type: "string" }, | ||
| time: { type: "number" }, | ||
| }, | ||
| additionalProperties: false, | ||
| }, | ||
| { | ||
| type: "object", | ||
| required: ["id", "description", "type", "name", "time"], | ||
| properties: { | ||
| id: { type: "string" }, | ||
| description: { type: "string" }, | ||
| type: { const: "skewT" }, | ||
| name: { type: "string" }, | ||
| time: { type: "number" }, | ||
| }, | ||
| additionalProperties: false, | ||
| }, | ||
| ], | ||
| } as unknown as JSONSchemaType<Analysis>; | ||
| const validate = ajv.compile(schema); | ||
| if (!validate(raw)) { | ||
| throw new ValidationError(validate.errors as DefinedError[]); | ||
| } | ||
| return raw; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.