- Added ReactJS App Rebuild Script (For Rapid Development of WebUI).

- Added Basic Menu Bar and Graphing Surface
This commit is contained in:
Nicole Rappe 2025-03-20 19:06:46 -06:00
parent 936eda8cd8
commit 5af92778e9
3 changed files with 167 additions and 22 deletions

View File

@ -1,17 +1,70 @@
import logo from './logo.svg'; import React from "react";
import './App.css'; import FlowEditor from "./components/FlowEditor";
import { AppBar, Toolbar, Typography, Box, Menu, MenuItem, Button, CssBaseline, ThemeProvider, createTheme } from "@mui/material";
const darkTheme = createTheme({
palette: {
mode: "dark",
background: {
default: "#121212",
paper: "#1e1e1e"
},
text: {
primary: "#ffffff"
}
}
});
export default function App() {
const [anchorEl, setAnchorEl] = React.useState(null);
const handleMenuOpen = (event) => {
setAnchorEl(event.currentTarget);
};
const handleMenuClose = () => {
setAnchorEl(null);
};
function App() {
return ( return (
<div className="App"> <ThemeProvider theme={darkTheme}>
<header className="App-header"> <CssBaseline />
<img src={logo} className="App-logo" alt="logo" /> <Box display="flex" flexDirection="column" height="100vh" bgcolor="#121212">
<p> {/* Top Menu Bar */}
Borealis Workflow Automation Tool <AppBar position="static" sx={{ bgcolor: "#092c44" }}>
</p> <Toolbar>
</header> <Typography variant="h6" sx={{ flexGrow: 1 }}>
</div> Borealis - Workflow Automation Tool
</Typography>
<Button color="inherit" onClick={handleMenuOpen}>Workflows</Button>
<Menu
anchorEl={anchorEl}
open={Boolean(anchorEl)}
onClose={handleMenuClose}
>
<MenuItem onClick={handleMenuClose}>Save Workflow</MenuItem>
<MenuItem onClick={handleMenuClose}>Load Workflow</MenuItem>
<MenuItem onClick={handleMenuClose}>Close Workflow</MenuItem>
</Menu>
</Toolbar>
</AppBar>
{/* Main Content - React Flow */}
<Box flexGrow={1}>
<FlowEditor updateNodeCount={(count) => {
document.getElementById("nodeCount").innerText = count;
}} />
</Box>
{/* Status Bar */}
<Box
component="footer"
sx={{ bgcolor: "#1e1e1e", color: "white", padding: "5px 10px", textAlign: "center" }}
>
Nodes: <span id="nodeCount">0</span> | Update Rate: 500ms | Flask API Server:
<a href="http://127.0.0.1:5000/data" style={{ color: "#3c78b4" }}> http://127.0.0.1:5000/data</a>
</Box>
</Box>
</ThemeProvider>
); );
} }
export default App;

View File

@ -2,6 +2,10 @@
# Run this script with: # Run this script with:
# Set-ExecutionPolicy Unrestricted -Scope Process; .\Start_Windows -WebServer.ps1 # Set-ExecutionPolicy Unrestricted -Scope Process; .\Start_Windows -WebServer.ps1
Write-Output " =============================== "
Write-Output " Deploying Borealis "
Write-Output " =============================== "
# --- Check for Node.js --- # --- Check for Node.js ---
if (-not (Get-Command node -ErrorAction SilentlyContinue)) { if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Write-Error "Node.js is not installed. Please install Node.js and try again." Write-Error "Node.js is not installed. Please install Node.js and try again."
@ -17,26 +21,26 @@ $webUIDestination = "$venvFolder\web-interface" # Destination f
# --- Create virtual environment if needed --- # --- Create virtual environment if needed ---
if (!(Test-Path "$venvFolder\Scripts\Activate")) { if (!(Test-Path "$venvFolder\Scripts\Activate")) {
Write-Output "Creating virtual environment in '$venvFolder'..." Write-Output "Creating Virtual Python Environment in '$venvFolder'..."
python -m venv $venvFolder python -m venv $venvFolder
} }
# --- Copy Data folder (includes server.py) --- # --- Copy Data folder (includes server.py) ---
if (Test-Path $dataSource) { if (Test-Path $dataSource) {
Write-Output "Copying Data folder into virtual environment..." Write-Output "Copying Borealis Server Data into Virtual Environment..."
if (Test-Path $dataDestination) { if (Test-Path $dataDestination) {
Remove-Item -Recurse -Force $dataDestination Remove-Item -Recurse -Force $dataDestination
} }
New-Item -Path $dataDestination -ItemType Directory -Force | Out-Null New-Item -Path $dataDestination -ItemType Directory -Force | Out-Null
Copy-Item -Path "$dataSource\*" -Destination $dataDestination -Recurse Copy-Item -Path "$dataSource\*" -Destination $dataDestination -Recurse
} else { } else {
Write-Output "Warning: Data folder not found, skipping copy." Write-Output "Warning: Data folder not found, skipping copy. Fix whatever you broke."
} }
# --- React UI Deployment --- # --- React UI Deployment ---
# Check if the React UI folder exists in the virtual environment root. # Check if the React UI folder exists in the virtual environment root.
if (-not (Test-Path $webUIDestination)) { if (-not (Test-Path $webUIDestination)) {
Write-Output "React UI folder '$webUIDestination' not found. Generating default ReactJS app there..." Write-Output "ReactJS App Not Found. Generating Default ReactJS App..."
npx create-react-app $webUIDestination npx create-react-app $webUIDestination
} else { } else {
Write-Output "React UI folder '$webUIDestination' already exists." Write-Output "React UI folder '$webUIDestination' already exists."
@ -44,19 +48,19 @@ if (-not (Test-Path $webUIDestination)) {
# If a custom UI folder exists at <ProjectRoot>\Data\WebUI, copy its contents over (overwrite defaults). # If a custom UI folder exists at <ProjectRoot>\Data\WebUI, copy its contents over (overwrite defaults).
if (Test-Path $customUIPath) { if (Test-Path $customUIPath) {
Write-Output "Custom UI folder found at '$customUIPath'. Overwriting default React app with Borealis-related files..." Write-Output "Borealis ReactJS Data Found at '$customUIPath'. Overwriting ReactJS App Files..."
Copy-Item -Path "$customUIPath\*" -Destination $webUIDestination -Recurse -Force Copy-Item -Path "$customUIPath\*" -Destination $webUIDestination -Recurse -Force
} else { } else {
Write-Output "No custom UI folder found at '$customUIPath'. Using default ReactJS app." Write-Output "No custom UI folder found at '$customUIPath'. Using default ReactJS app."
} }
# --- Activate virtual environment --- # --- Activate virtual environment ---
Write-Output "Activating virtual environment..." Write-Output "Activating Virtual Python Environment..."
. "$venvFolder\Scripts\Activate" . "$venvFolder\Scripts\Activate"
# --- Install Python dependencies --- # --- Install Python dependencies ---
if (Test-Path "requirements.txt") { if (Test-Path "requirements.txt") {
Write-Output "Installing Python dependencies..." Write-Output "Installing Python Dependencies..."
pip install -q -r requirements.txt pip install -q -r requirements.txt
} else { } else {
Write-Output "No requirements.txt found, skipping Python dependency installation." Write-Output "No requirements.txt found, skipping Python dependency installation."
@ -69,12 +73,19 @@ if (-not (Test-Path $buildFolder)) {
if (Test-Path $packageJsonPath) { if (Test-Path $packageJsonPath) {
Write-Output "React UI build not found in '$webUIDestination'. Installing dependencies and building the React app..." Write-Output "React UI build not found in '$webUIDestination'. Installing dependencies and building the React app..."
Push-Location $webUIDestination Push-Location $webUIDestination
Write-Output " =============================== "
Write-Output " Installing NPM Packages "
Write-Output " =============================== "
npm install --no-fund --audit=false npm install --no-fund --audit=false
# Ensure react-flow-renderer is installed # Ensure react-flow-renderer is installed
Write-Output "Installing React Flow..." Write-Output "Installing React Flow..."
npm install reactflow --no-fund --audit=false npm install reactflow --no-fund --audit=false
# Install Material UI Library
Write-Output "Installing Material UI Library..."
npm install @mui/material @emotion/react @emotion/styled --no-fund --audit=false
npm run build npm run build
Pop-Location Pop-Location
} }
@ -92,6 +103,9 @@ $expectedBuildPath = Join-Path (Get-Location) "web-interface\build"
Write-Output "Looking for build folder at: $expectedBuildPath" Write-Output "Looking for build folder at: $expectedBuildPath"
# --- Start the Flask server (server.py is inside Borealis folder) --- # --- Start the Flask server (server.py is inside Borealis folder) ---
Write-Output " =============================== "
Write-Output " Launching Borealis "
Write-Output " =============================== "
Write-Output "Starting the Flask server..." Write-Output "Starting the Flask server..."
python "Borealis\server.py" python "Borealis\server.py"

78
Rebuild_ReactJS_App.ps1 Normal file
View File

@ -0,0 +1,78 @@
# Start_Windows - WebServer.ps1
# Run this script with:
# Set-ExecutionPolicy Unrestricted -Scope Process; .\Start_Windows -WebServer.ps1
Write-Output " =============================== "
Write-Output " Re-Building ReactJS App "
Write-Output " =============================== "
# --- Define paths ---
$venvFolder = "Borealis-Workflow-Automation-Tool" # Virtual environment root.
$dataSource = "Data" # Contains server.py and optionally WebUI.
$dataDestination = "$venvFolder\Borealis" # Data folder copy destination in the venv.
$customUIPath = "$dataSource\WebUI" # Custom UI folder source in the project root.
$webUIDestination = "$venvFolder\web-interface" # Destination for the React UI in the venv.
# If a custom UI folder exists at <ProjectRoot>\Data\WebUI, copy its contents over (overwrite defaults).
if (Test-Path $customUIPath) {
Write-Output "Borealis ReactJS Data Found at '$customUIPath'. Overwriting ReactJS App Files..."
Copy-Item -Path "$customUIPath\*" -Destination $webUIDestination -Recurse -Force
} else {
Write-Output "No custom UI folder found at '$customUIPath'. Using default ReactJS app."
}
# --- Activate virtual environment ---
Write-Output "Activating Virtual Python Environment..."
. "$venvFolder\Scripts\Activate"
# --- Remove Existing / Previous ReactJS App Build folder ---
if (Test-Path $dataDestination) {
Remove-Item -Recurse -Force $venvFolder\web-interface\build
}
# --- Build the React (UI) app in the web-interface folder if needed ---
$packageJsonPath = Join-Path $webUIDestination "package.json"
$buildFolder = Join-Path $webUIDestination "build"
if (-not (Test-Path $buildFolder)) {
if (Test-Path $packageJsonPath) {
Write-Output "React UI build not found in '$webUIDestination'. Installing dependencies and building the React app..."
Push-Location $webUIDestination
Write-Output " =============================== "
Write-Output " Installing NPM Packages "
Write-Output " =============================== "
npm install --no-fund --audit=false
# Ensure react-flow-renderer is installed
Write-Output "Installing React Flow..."
npm install reactflow --no-fund --audit=false
# Install Material UI Library
Write-Output "Installing Material UI Library..."
npm install @mui/material @emotion/react @emotion/styled --no-fund --audit=false
npm run build
Pop-Location
}
else {
Write-Output "No package.json found in '$webUIDestination'; skipping npm install/build."
}
} else {
Write-Output "React UI build found. Skipping npm install/build."
}
# --- Change directory to the virtual environment root ---
Push-Location $venvFolder
Write-Output "Current working directory: $(Get-Location)"
$expectedBuildPath = Join-Path (Get-Location) "web-interface\build"
Write-Output "Looking for build folder at: $expectedBuildPath"
# --- Start the Flask server (server.py is inside Borealis folder) ---
Write-Output " =============================== "
Write-Output " Launching Borealis "
Write-Output " =============================== "
Write-Output "Starting the Flask server..."
python "Borealis\server.py"
# --- Return to original directory and deactivate virtual environment ---
Pop-Location
deactivate