-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add local modal dialog after MUI example. Remove fi-sci dependency.
- Loading branch information
Showing
10 changed files
with
246 additions
and
165 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -23,10 +23,9 @@ | |
"@emotion/react": "^11.11.4", | ||
"@emotion/styled": "^11.11.5", | ||
"@fi-sci/misc": "^0.0.8", | ||
"@fi-sci/modal-window": "^0.0.2", | ||
"@geoffcox/react-splitter": "^2.1.2", | ||
"@monaco-editor/react": "^4.6.0", | ||
"@mui/icons-material": "^5.15.17", | ||
"@mui/icons-material": "^5.16.5", | ||
"@mui/material": "^5.15.17", | ||
"@octokit/rest": "^21.0.0", | ||
"@vercel/analytics": "^1.3.1", | ||
|
@@ -65,5 +64,6 @@ | |
"vite": "^5.2.12", | ||
"vite-tsconfig-paths": "^4.3.2", | ||
"vitest": "^1.6.0" | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610" | ||
} |
This file contains 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 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
124 changes: 124 additions & 0 deletions
124
gui/src/app/CompilationServerConnectionControl/ConfigureCompilationServerDialog.tsx
This file contains 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,124 @@ | ||
import Button from "@mui/material/Button"; | ||
import Link from "@mui/material/Link"; | ||
import { FunctionComponent, useEffect, useState } from "react"; | ||
import { localUrl, publicUrl } from "./CompilationServerConnectionControl"; | ||
|
||
type ConfigureCompilationServerDialogProps = { | ||
stanWasmServerUrl: string; | ||
setStanWasmServerUrl: (url: string) => void; | ||
isConnected: boolean; | ||
closeDialog: () => void; | ||
onRetry: () => void; | ||
}; | ||
|
||
const ConfigureCompilationServerDialog: FunctionComponent< | ||
ConfigureCompilationServerDialogProps | ||
> = ({ | ||
stanWasmServerUrl, | ||
setStanWasmServerUrl, | ||
isConnected, | ||
closeDialog, | ||
onRetry, | ||
}) => { | ||
const [choice, setChoice] = useState<"public" | "local" | "custom">("custom"); | ||
useEffect(() => { | ||
if (stanWasmServerUrl === publicUrl) setChoice("public"); | ||
else if (stanWasmServerUrl === localUrl) setChoice("local"); | ||
else setChoice("custom"); | ||
}, [stanWasmServerUrl]); | ||
return ( | ||
<div className="dialogWrapper"> | ||
<p> | ||
While the sampling is performed locally in the browser, a compilation | ||
server is required to compile the Stan programs. | ||
</p> | ||
<hr /> | ||
<div> | ||
{isConnected ? ( | ||
<span className="connected">Connected</span> | ||
) : ( | ||
<span className="disconnected">Not connected</span> | ||
)} | ||
| ||
<Link onClick={onRetry} component="button" underline="none"> | ||
retry | ||
</Link> | ||
</div> | ||
<hr /> | ||
<div> | ||
<input | ||
type="radio" | ||
id="public" | ||
name="server" | ||
value="public" | ||
checked={choice === "public"} | ||
onChange={() => { | ||
if (choice === "custom") setChoice("public"); | ||
setStanWasmServerUrl(publicUrl); | ||
}} | ||
/> | ||
<label htmlFor="public">Public server</label> | ||
<br /> | ||
|
||
<input | ||
type="radio" | ||
id="local" | ||
name="server" | ||
value="local" | ||
checked={choice === "local"} | ||
onChange={() => { | ||
if (choice === "custom") setChoice("local"); | ||
setStanWasmServerUrl(localUrl); | ||
}} | ||
/> | ||
<label htmlFor="local">Local server</label> | ||
<br /> | ||
|
||
<input | ||
type="radio" | ||
id="custom" | ||
name="server" | ||
value="custom" | ||
checked={choice === "custom"} | ||
onChange={() => setChoice("custom")} | ||
/> | ||
<label htmlFor="custom">Custom server</label> | ||
<br /> | ||
|
||
<input | ||
// This one isn't honoring a class-based style for some reason | ||
style={{ width: 500 }} | ||
disabled={choice !== "custom"} | ||
type="text" | ||
value={stanWasmServerUrl} | ||
onChange={(e) => setStanWasmServerUrl(e.target.value)} | ||
/> | ||
<br /> | ||
<hr /> | ||
{choice === "local" && ( | ||
<div> | ||
<p>To start a local compilation server:</p> | ||
<div> | ||
<pre> | ||
docker run -p 8083:8080 -it magland/stan-wasm-server:latest | ||
</pre> | ||
</div> | ||
</div> | ||
)} | ||
{choice === "public" && ( | ||
<div> | ||
<p> | ||
The public server is provided for convenience, but may not be as | ||
reliable as a local server, depending on the current load and | ||
availability. | ||
</p> | ||
</div> | ||
)} | ||
<hr /> | ||
<Button onClick={() => closeDialog()}>Close</Button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ConfigureCompilationServerDialog; |
Oops, something went wrong.