From 0a400e30390145455ea93e3eca5717de73848159 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Thu, 9 Jul 2026 20:03:41 -0500 Subject: [PATCH] Various improvements for usability and consistency and inclusion of PWA handling. --- README.md | 46 ++++---- data/www/admin.html | 27 ++++- data/www/components/uptime-card.js | 35 +++--- data/www/css/app.css | 3 +- data/www/icons/icon-192.png | Bin 0 -> 1471 bytes data/www/icons/icon-512.png | Bin 0 -> 7081 bytes data/www/icons/icon.svg | 21 ++++ data/www/js/app.js | 154 +++++++++++++++++++++----- data/www/js/pwa.js | 9 ++ data/www/js/setup.js | 11 ++ data/www/manifest.webmanifest | 32 ++++++ data/www/service-worker.js | 55 +++++++++ data/www/setup.html | 4 +- include/app.h | 3 + include/custom_api.h | 1 + src/config/api_definitions.cpp | 49 ++++---- src/config/api_definitions_custom.cpp | 1 + src/core/auth.cpp | 22 ++-- src/handlers/handlers_admin.cpp | 53 ++++++--- src/handlers/handlers_custom_api.cpp | 6 +- src/handlers/handlers_setup.cpp | 2 +- src/web/routes.cpp | 35 +++--- src/web/ui.cpp | 3 +- 23 files changed, 439 insertions(+), 133 deletions(-) create mode 100644 data/www/icons/icon-192.png create mode 100644 data/www/icons/icon-512.png create mode 100644 data/www/icons/icon.svg create mode 100644 data/www/js/pwa.js create mode 100644 data/www/manifest.webmanifest create mode 100644 data/www/service-worker.js diff --git a/README.md b/README.md index 7a24b9c..cf020f6 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,9 @@ It provides basic "infrastructure" and "Framework" for specific developments. - Eases updates by providing OTA update mechanism using update-server URL - Role based User Management - Standard Roles - - Sysadmin (Can administer the system, update, change settings) - - UserAdmin (Can administer user accounts) + - SystemAdmin (Can administer the system, update, change settings) + - AccessAdmin (Can administer user accounts, roles, and API access) + - NetworkAdmin (Can administer network settings) - WebUIConnect (Allows logging in to the Web UI) - Debugger (Allowed to use API Test UI in the Web UI) - Secure, Role based Rest API for all functions @@ -33,7 +34,7 @@ It provides basic "infrastructure" and "Framework" for specific developments. - Users can be assigned zero or more roles - Allows to interactively calling of the Rest APIs via the web UI - The corresponding user token is preset with the current user's token by decfault, but it can be overwritten - - This functionality is only accessible when the user has the role Debugger + - This functionality is only accessible when the user has the role AccessAdmin - Enables secrity configuration of the exposed API functions - Configuration of logging - log level @@ -116,7 +117,7 @@ The firmware in `src/main.cpp` implements the boilerplate as a compact Arduino E - Configurable API access control where each route can be `PUBLIC` or require one role. - Public boilerplate APIs: ping, add, and LED brightness. - LED brightness is persisted in non-volatile memory, applied on boot, and loaded into the Admin UI slider. -- User management with the standard roles `Sysadmin`, `UserAdmin`, `WebUIConnect`, and `Debugger`. +- User management with the standard roles `SystemAdmin`, `AccessAdmin`, `NetworkAdmin`, `WebUIConnect`, and `Debugger`. - Custom role management. System roles are protected and cannot be deleted. - Active/inactive user accounts with role checkboxes in the Admin UI. - API security management through a list/detail UI with a role dropdown per API. @@ -224,7 +225,7 @@ The Admin UI stores HTTPS certificate material so applications built on this boi To configure the stored certificate material: -1. Log in as a user with the `Sysadmin` role. +1. Log in as a user with the `NetworkAdmin` role. 2. Open `Networking` -> `HTTPS Certificate`. 3. Select a certificate file and click `Save certificate`. 4. Use `Load current` to verify what is currently stored. @@ -305,23 +306,26 @@ Protected APIs and their default roles: | --- | --- | | `POST /api/logout` | `WebUIConnect` | | `GET /api/me` | `WebUIConnect` | -| `GET /api/apis` | `Sysadmin` | -| `POST /api/apis` | `Sysadmin` | -| `GET /api/users` | `UserAdmin` | -| `POST /api/users` | `UserAdmin` | +| `GET /api/apis` | `AccessAdmin` | +| `POST /api/apis` | `AccessAdmin` | +| `GET /api/users` | `AccessAdmin` | +| `POST /api/users` | `AccessAdmin` | | `POST /api/password` | `WebUIConnect` | -| `GET /api/settings` | `Sysadmin` | -| `POST /api/settings` | `Sysadmin` | -| `GET /api/logs` | `Debugger` | -| `POST /api/logs/clear` | `Debugger` | -| `GET /api/files` | `Debugger` | -| `GET /api/files/download` | `Debugger` | -| `POST /api/factory-reset` | `Sysadmin` | -| `POST /api/ota/check` | `Sysadmin` | -| `POST /api/ota/run` | `Sysadmin` | -| `POST /api/update` | `Sysadmin` | -| `GET /api/cert` | `Sysadmin` | -| `POST /api/cert` | `Sysadmin` | +| `GET /api/settings` | `SystemAdmin` | +| `POST /api/settings` | `SystemAdmin` | +| `GET /api/network` | `NetworkAdmin` | +| `POST /api/network` | `NetworkAdmin` | +| `GET /api/logs` | `SystemAdmin` | +| `POST /api/logs/clear` | `SystemAdmin` | +| `GET /api/files` | `SystemAdmin` | +| `GET /api/files/download` | `SystemAdmin` | +| `POST /api/restart` | `SystemAdmin` | +| `POST /api/factory-reset` | `SystemAdmin` | +| `POST /api/ota/check` | `SystemAdmin` | +| `POST /api/ota/run` | `SystemAdmin` | +| `POST /api/update` | `SystemAdmin` | +| `GET /api/cert` | `NetworkAdmin` | +| `POST /api/cert` | `NetworkAdmin` | Change API security: diff --git a/data/www/admin.html b/data/www/admin.html index 94eb290..05cfa82 100644 --- a/data/www/admin.html +++ b/data/www/admin.html @@ -2,8 +2,17 @@ - ESP32-C3 Admin + + + + + + + + + + @@ -11,8 +20,14 @@ -
ESP32-C3 Admin
- +
+
+
+ + +
+ +

Login

@@ -43,7 +58,7 @@
-

User Overview

+

User Overview