diff --git a/gui/src/app/CompilationServerConnectionControl/CompilationServerConnectionControl.tsx b/gui/src/app/CompilationServerConnectionControl/CompilationServerConnectionControl.tsx index 175878a..42fd646 100644 --- a/gui/src/app/CompilationServerConnectionControl/CompilationServerConnectionControl.tsx +++ b/gui/src/app/CompilationServerConnectionControl/CompilationServerConnectionControl.tsx @@ -1,12 +1,12 @@ -import { SmallIconButton } from "@fi-sci/misc"; import { Cancel, Check } from "@mui/icons-material"; -import Link from "@mui/material/Link"; import CloseableDialog, { useDialogControls, } from "@SpComponents/CloseableDialog"; import { FunctionComponent, useCallback, useEffect, useState } from "react"; import ConfigureCompilationServerDialog from "./ConfigureCompilationServerDialog"; +import IconButton from "@mui/material/IconButton"; +import Typography from "@mui/material/Typography"; export const publicUrl = "https://trom-stan-wasm-server.magland.org"; export const localUrl = "http://localhost:8083"; @@ -43,26 +43,19 @@ const CompilationServerConnectionControl: FunctionComponent< ? "local" : "custom"; return ( - - - - : } - onClick={openDialog} - /> - + <> + + {isConnected ? ( + + ) : ( + + )}   - + {isConnected ? "connected to " : "not connected to "} {serverLabel} - -    - + + - + ); }; diff --git a/gui/src/app/CompilationServerConnectionControl/ConfigureCompilationServerDialog.tsx b/gui/src/app/CompilationServerConnectionControl/ConfigureCompilationServerDialog.tsx index b953c5a..781f7b7 100644 --- a/gui/src/app/CompilationServerConnectionControl/ConfigureCompilationServerDialog.tsx +++ b/gui/src/app/CompilationServerConnectionControl/ConfigureCompilationServerDialog.tsx @@ -1,7 +1,18 @@ import Button from "@mui/material/Button"; import Link from "@mui/material/Link"; -import { FunctionComponent, useEffect, useState } from "react"; +import { FunctionComponent, useCallback, useState } from "react"; import { localUrl, publicUrl } from "./CompilationServerConnectionControl"; +import FormControl from "@mui/material/FormControl"; +import { + Divider, + FormControlLabel, + FormLabel, + Radio, + RadioGroup, + TextField, +} from "@mui/material"; + +type ServerType = "public" | "local" | "custom"; type ConfigureCompilationServerDialogProps = { stanWasmServerUrl: string; @@ -20,103 +31,103 @@ const ConfigureCompilationServerDialog: FunctionComponent< 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]); + const [choice, setChoice] = useState("custom"); + + const makeChoice = useCallback( + (_: unknown, choice: string) => { + if (choice === "public") { + setStanWasmServerUrl(publicUrl); + } else if (choice === "local") { + setStanWasmServerUrl(localUrl); + } else if (choice !== "custom") { + return; + } + setChoice(choice); + }, + [setStanWasmServerUrl], + ); + return (

While the sampling is performed locally in the browser, a compilation server is required to compile the Stan programs.

-
+
- {isConnected ? ( - Connected - ) : ( - Not connected - )} -   - - retry - +

+ {isConnected ? ( + Connected + ) : ( + Not connected + )} +   + + retry + +

-
-
- { - if (choice === "custom") setChoice("public"); - setStanWasmServerUrl(publicUrl); - }} - /> - -
+ - { - if (choice === "custom") setChoice("local"); - setStanWasmServerUrl(localUrl); - }} - /> - -
+ + + Compilation server + + + } + label="Public server" + /> + } + label="Local server" + /> + } + label="Custom server" + /> + - setChoice("custom")} - /> - -
- - setStanWasmServerUrl(e.target.value)} - /> -
-
- {choice === "local" && ( -
-

To start a local compilation server:

-
-
-                docker run -p 8083:8080 -it magland/stan-wasm-server:latest
-              
-
-
- )} - {choice === "public" && ( + {choice === "custom" && (

- The public server is provided for convenience, but may not be as - reliable as a local server, depending on the current load and - availability. + setStanWasmServerUrl(e.target.value)} + />

)} -
- -
+ + + {choice === "local" && ( +
+

To start a local compilation server:

+
+
+              docker run -p 8083:8080 -it magland/stan-wasm-server:latest
+            
+
+
+ )} + {choice === "public" && ( +
+

+ The public server is provided for convenience, but may not be as + reliable as a local server, depending on the current load and + availability. +

+
+ )} + + +
); }; diff --git a/gui/src/app/pages/HomePage/TopBar.tsx b/gui/src/app/pages/HomePage/TopBar.tsx index 918bd37..7936c32 100644 --- a/gui/src/app/pages/HomePage/TopBar.tsx +++ b/gui/src/app/pages/HomePage/TopBar.tsx @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import CompilationServerConnectionControl from "@SpStanc/CompilationServerConnectionControl"; -import { SmallIconButton } from "@fi-sci/misc"; import { Menu, QuestionMark } from "@mui/icons-material"; import AppBar from "@mui/material/AppBar"; import IconButton from "@mui/material/IconButton"; @@ -35,18 +34,18 @@ const TopBar: FunctionComponent = ({ title, onSetCollapsed }) => { Stan Playground - {title} - - } - onClick={() => { - window.open( - "https://github.com/flatironinstitute/stan-playground", - "_blank", - ); - }} - title={`About Stan Playground`} - /> - + + window.open( + "https://github.com/flatironinstitute/stan-playground", + "_blank", + ) + } + > + + ); diff --git a/gui/src/localStyles.css b/gui/src/localStyles.css index 435a10b..509689e 100644 --- a/gui/src/localStyles.css +++ b/gui/src/localStyles.css @@ -17,18 +17,6 @@ padding: 10px; } -.CompilationServerConnectionPane { - font-size: 12px; -} - -.CompilationServerConnectionPane .connected { - color: lightgreen; -} - -.CompilationServerConnectionPane .disconnected { - color: pink; -} - /* Compilation Results (StanCompileResultWindow) */ .ErrorsWindow { height: 100%;