From c1ba9effee85249101258033ac5e75b29c0abe37 Mon Sep 17 00:00:00 2001 From: Jesse Hines Date: Wed, 24 Sep 2025 13:07:43 -0400 Subject: [PATCH 01/19] Skip auth in dev --- .env.development | 4 +++ .gitignore | 2 +- src/App.tsx | 79 +++++++++++++++++++++++++----------------------- vite.config.ts | 4 +-- 4 files changed, 48 insertions(+), 41 deletions(-) create mode 100644 .env.development diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..25f9599 --- /dev/null +++ b/.env.development @@ -0,0 +1,4 @@ +VITE_PORT=9080 +VITE_AUTH_URL= +VITE_BASE_PATH=http://localhost:9080 +VITE_API_PATH=http://localhost:8080 diff --git a/.gitignore b/.gitignore index 5ae8b5a..48f4057 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ dist .env .env.* -!.env.example +!.env.development diff --git a/src/App.tsx b/src/App.tsx index 6cb0e24..c1bb075 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -13,37 +13,8 @@ import "react-tooltip/dist/react-tooltip.css"; const basepath = import.meta.env.VITE_BASE_PATH ? new URL(import.meta.env.VITE_BASE_PATH).pathname : "/"; - -const initOptions: KeycloakConfig = { - url: import.meta.env.VITE_AUTH_URL, - realm: "obsidian", - clientId: "obsidian-public", -}; - -const kc = new Keycloak(initOptions); - axios.defaults.baseURL = import.meta.env.VITE_API_PATH; -kc.init({ - onLoad: "login-required", - redirectUri: window.location.toString(), -}).then( - (auth) => { - if (auth) { - if (kc.token) { - localStorage.setItem("exadigitAuthToken", kc.token); - axios.defaults.headers.common = { - Authorization: `Bearer ${kc.token}`, - }; - axios.defaults.withCredentials = true; - } - } - }, - () => { - console.error("Authenticated Failed"); - }, -); - export { axios }; export interface RouterContext { @@ -64,15 +35,13 @@ declare module "@tanstack/react-router" { } export const AppContext = createContext<{ - AuthToken?: string; theme: string | null; setTheme: (value: "dark" | "light") => void; -}>({ AuthToken: kc.token, theme: null, setTheme: () => {} }); +}>({ theme: null, setTheme: () => {} }); function App() { - const authToken = localStorage.getItem("exadigitAuthToken") || undefined; - const theme = localStorage.getItem("theme"); - const [_theme, setTheme] = useState(theme); + const [apiToken, setApiToken] = useState(); + const [theme, setTheme] = useState(localStorage.getItem("theme")); const onThemeSwitch = (theme: "dark" | "light") => { if (theme === "dark") { @@ -97,14 +66,48 @@ function App() { } }, []); - if (!authToken || axios.defaults.baseURL?.includes("localhost")) { + useEffect(() => { + if (!apiToken && import.meta.env.VITE_AUTH_URL) { + const initOptions: KeycloakConfig = { + url: import.meta.env.VITE_AUTH_URL, + realm: "obsidian", + clientId: "obsidian-public", + }; + + const kc = new Keycloak(initOptions); + + kc.init({ + onLoad: "login-required", + redirectUri: window.location.toString(), + }).then( + (auth) => { + if (auth) { + if (kc.token) { + axios.defaults.headers.common = { + Authorization: `Bearer ${kc.token}`, + }; + axios.defaults.withCredentials = true; + setApiToken(kc.token) + } + } + }, + () => { + console.error("Authenticated Failed"); + }, + ); + + setApiToken(apiToken) + } else { + setApiToken("no-auth") + } + }, [apiToken]) + + if (!apiToken) { return

Please Authenticate

; } return ( - + diff --git a/vite.config.ts b/vite.config.ts index b0d195d..2576acc 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,11 +5,11 @@ import { TanStackRouterVite } from "@tanstack/router-vite-plugin"; // https://vitejs.dev/config/ export default defineConfig(({ mode }) => { const env = {...process.env, ...loadEnv(mode, process.cwd())}; - // console.log(env) + return { base: env.VITE_BASE_PATH, plugins: [react(), TanStackRouterVite()], server: { - port: 8080, + port: Number(env.VITE_PORT ?? 9080), }, }}); -- GitLab From 0856fc2c231e65517be813b62b65b3f52612d371 Mon Sep 17 00:00:00 2001 From: Jesse Hines Date: Wed, 24 Sep 2025 13:31:13 -0400 Subject: [PATCH 02/19] Update README --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 04c7ff9..b174b04 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,16 @@ User Interface for the ExaDigiT project that allows for running simulations and [Tanstack](https://tanstack.com/) -## Getting Started +## Running Locally -To get the project up and running locally, you will want to start by cloning the project and running `npm install` in the projects directory. Then run `npm run dev`. +To get the project up and running locally, first clone and deploy the SimulationServer from [GitHub](https://github.com/ExaDigiT/SimulationServer) +or [GitLab](https://code.ornl.gov/exadigit/simulationserver) and follow the instructions to launch a local instance of the server. + +Then in the SimulationDashboard run: +```bash +npm install +npm run dev +``` + +After doing so you can navigate to `localhost:9080` to use the application. -After doing so you can navigate to `localhost:8080` to login to the application. -- GitLab From 6daae4b8120ee76933ed4d80ddbb209264e8029b Mon Sep 17 00:00:00 2001 From: Jesse Hines Date: Wed, 24 Sep 2025 13:31:54 -0400 Subject: [PATCH 03/19] Remove example env This is in .env.develop now --- .env.example | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index f82ce1f..0000000 --- a/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -VITE_AUTH_URL= -VITE_BASE_PATH= -VITE_API_PATH= -DOCKER_REGISTRY= -K8S_NAMESPACE= -- GitLab From 0b10c1043bc8fe3b292b8153d79ab8acbfe92970 Mon Sep 17 00:00:00 2001 From: Jesse Hines Date: Wed, 1 Oct 2025 13:28:36 -0400 Subject: [PATCH 04/19] Install js-yaml --- package-lock.json | 14 +++++++++++--- package.json | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6f1232d..b0b6b4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "axios": "^1.6.7", "date-fns": "^3.3.1", "framer-motion": "^11.0.20", + "js-yaml": "^4.1.0", "keycloak-js": "^23.0.7", "lodash": "^4.17.21", "plotly.js": "^2.29.1", @@ -36,6 +37,7 @@ "@tanstack/eslint-plugin-query": "^5.20.1", "@tanstack/router-cli": "^1.69.1", "@tanstack/router-vite-plugin": "^1.16.3", + "@types/js-yaml": "^4.0.9", "@types/lodash": "^4.14.202", "@types/react": "^18.2.55", "@types/react-datepicker": "^6.0.3", @@ -2251,6 +2253,13 @@ "@types/geojson": "*" } }, + "node_modules/@types/js-yaml": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", + "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -3101,8 +3110,7 @@ "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/array-bounds": { "version": "1.0.1", @@ -7489,7 +7497,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, + "license": "MIT", "dependencies": { "argparse": "^2.0.1" }, diff --git a/package.json b/package.json index 6cb8883..58ca342 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "axios": "^1.6.7", "date-fns": "^3.3.1", "framer-motion": "^11.0.20", + "js-yaml": "^4.1.0", "keycloak-js": "^23.0.7", "lodash": "^4.17.21", "plotly.js": "^2.29.1", @@ -39,6 +40,7 @@ "@tanstack/eslint-plugin-query": "^5.20.1", "@tanstack/router-cli": "^1.69.1", "@tanstack/router-vite-plugin": "^1.16.3", + "@types/js-yaml": "^4.0.9", "@types/lodash": "^4.14.202", "@types/react": "^18.2.55", "@types/react-datepicker": "^6.0.3", -- GitLab From 7459291f362b5ae8835f2869fbfee01bdfa027d5 Mon Sep 17 00:00:00 2001 From: Jesse Hines Date: Thu, 2 Oct 2025 09:09:12 -0400 Subject: [PATCH 05/19] Update forms to use new RAPS config --- src/components/shared/dropdown.tsx | 8 +- src/components/shared/textArea.tsx | 30 +++++ .../simulations/basicSettings.form.tsx | 23 ++-- src/components/simulations/cooling.form.tsx | 20 ++- .../list/SimulationsDataGridRow.tsx | 2 +- .../list/SimulationsGridColumns.ts | 4 +- src/components/simulations/raps.form.tsx | 116 +++++++---------- src/models/CustomJob.model.ts | 35 ------ src/models/Scheduler.model.ts | 36 ------ src/models/Simulation.model.ts | 4 +- src/models/SimulationConfig.model.ts | 117 ++++++++++++++++++ src/models/SimulationRequest.model.ts | 32 ----- src/models/SystemInfo.model.ts | 6 + ...imulations.$simulationId.configuration.tsx | 39 +++--- src/routes/simulations.new.tsx | 28 ++++- src/util/misc.ts | 18 +++ src/util/queryOptions.ts | 19 ++- 17 files changed, 314 insertions(+), 223 deletions(-) create mode 100644 src/components/shared/textArea.tsx delete mode 100644 src/models/CustomJob.model.ts delete mode 100644 src/models/Scheduler.model.ts create mode 100644 src/models/SimulationConfig.model.ts delete mode 100644 src/models/SimulationRequest.model.ts create mode 100644 src/models/SystemInfo.model.ts create mode 100644 src/util/misc.ts diff --git a/src/components/shared/dropdown.tsx b/src/components/shared/dropdown.tsx index f9a9e1d..5b82a5c 100644 --- a/src/components/shared/dropdown.tsx +++ b/src/components/shared/dropdown.tsx @@ -7,7 +7,7 @@ export interface SelectProps extends HTMLProps { onChange: (e: ChangeEvent) => void; } -export function Select(props: SelectProps) { +export function Select({onChange, value, choices, ...props}: SelectProps) { return (
{props.label && ( @@ -15,8 +15,8 @@ export function Select(props: SelectProps) { )}