Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
public/app.js
public/app.css
npm-debug.log*
32 changes: 32 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# React device dashboard

Minimal manager-facing frontend for the RPi-Monitoring `GET /devices` endpoint.

## Develop and build

From `frontend/` (Node 22 or newer):

```sh
npm install
npm test
npm run build
python -m http.server 8080 --directory public
```

Open http://localhost:8080. API defaults to http://localhost:8000.
Build-time override:

```sh
REACT_APP_API_BASE=https://monitor.example.com npm run build
```

On Windows PowerShell: `$env:REACT_APP_API_BASE="http://localhost:8000"; npm run build`.

**Browser CORS:** A separate frontend origin such as localhost:8080 requires
the FastAPI server to allow that origin or a same-origin reverse proxy.
This frontend does not disable browser security or send credentials.

The application is read-only. It handles initial loading, empty devices,
HTTP errors, manual refresh, responsive layout and online/offline badges.
`npm test` runs 7 isolated API tests with no hardware or backend.
Generated `public/app.js` and `public/app.css` are gitignored.
12 changes: 12 additions & 0 deletions frontend/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { build } from "esbuild";
const apiBase = process.env.REACT_APP_API_BASE || "http://localhost:8000";
await build({
entryPoints: ["src/index.jsx"],
outfile: "public/app.js",
bundle: true,
minify: true,
target: ["es2020"],
define: { "process.env.REACT_APP_API_BASE": JSON.stringify(apiBase) },
logLevel: "info",
});
console.log(`Built dashboard with API: ${apiBase}`);
Loading