Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41dbb6297c | ||
|
|
1ac9b08233 | ||
|
|
1827c6de6c | ||
|
|
4f4bdf8d72 | ||
|
|
3b44048250 | ||
|
|
fe267b8766 | ||
|
|
ea23f3f35d | ||
|
|
30ed0bb79b | ||
|
|
c2e4f64d82 | ||
|
|
7a27fb85c4 | ||
|
|
4670666421 | ||
|
|
dcca3fa042 | ||
|
|
8f64760add | ||
|
|
ffa34815cd | ||
|
|
ac6840c759 |
@@ -32,3 +32,6 @@ node_modules/
|
||||
# Backup files
|
||||
*.bak
|
||||
*.backup
|
||||
|
||||
# runtime-generated files
|
||||
access_log.json
|
||||
|
||||
@@ -31,11 +31,11 @@ Primary files:
|
||||
|
||||
## Planned Direction
|
||||
|
||||
- The existing admin UI/API in RollCalc is planned for removal.
|
||||
- Do not expand or repair the admin area unless explicitly requested as a temporary measure.
|
||||
- The previous admin UI/API has been removed from RollCalc.
|
||||
- Do not reintroduce admin screens or admin APIs unless explicitly requested as a temporary measure.
|
||||
- Keep login/access logging in RollCalc.
|
||||
- Administration and maintenance of `article-data.json` should move to a separate application.
|
||||
- Treat `templates/admin.html` and `/api/admin/*` expectations as legacy/transitional, not as target architecture.
|
||||
- Treat article-data administration as out of scope for RollCalc.
|
||||
|
||||
## Code Style
|
||||
|
||||
@@ -73,7 +73,7 @@ These credentials are hardcoded and are a known risk; do not introduce more secr
|
||||
- Access logging writes to `access_log.json` by reading and rewriting the whole file.
|
||||
- The active UI logic is largely inline in `templates/roll_calculator.html`.
|
||||
- Several `static/*.js` files appear to be older, alternative, or integration modules. Confirm script inclusion before modifying them.
|
||||
- The admin template and backend admin routes are inconsistent and scheduled for removal rather than expansion.
|
||||
- The previous admin template and backend admin route have been removed; do not rebuild them by default.
|
||||
- The disclaimer confirmation is client-side only.
|
||||
|
||||
## Safety Notes
|
||||
|
||||
+45
-18
@@ -14,13 +14,13 @@ Backend:
|
||||
|
||||
- `app.py` creates the Flask app.
|
||||
- HTTP Basic Auth is implemented with `Flask-HTTPAuth`.
|
||||
- Users are currently hardcoded in `BETA_USERS` and `ADMIN_USERS`.
|
||||
- Users are currently configured in `BETA_USERS` with Werkzeug password hashes.
|
||||
- `/` renders the active calculator template.
|
||||
- `/static/<path:filename>` is intended to serve static files behind Basic Auth.
|
||||
- `/api/health` returns health/version information.
|
||||
- `/api/user` returns the authenticated user and admin flag.
|
||||
- `/admin/logs` returns access logs for admin users.
|
||||
- `/api/user` returns the authenticated user.
|
||||
- Access events are appended to `access_log.json`.
|
||||
- `build_info.json` is loaded at startup and exposed to all templates as `build_info`.
|
||||
|
||||
Frontend:
|
||||
|
||||
@@ -29,6 +29,44 @@ Frontend:
|
||||
- `window.ARTICLE_DATA` is loaded from `/static/article-data.json`.
|
||||
- `window.APP_CONFIG` is currently defined inline for forklift rules.
|
||||
- A disclaimer modal blocks use until the user checks the confirmation checkbox.
|
||||
- The footer displays build metadata: version, branch, commit, and timestamp.
|
||||
|
||||
## Build Info
|
||||
|
||||
Build/deployment metadata is read from:
|
||||
|
||||
```text
|
||||
build_info.json
|
||||
```
|
||||
|
||||
Expected fields:
|
||||
|
||||
- `version`
|
||||
- `branch`
|
||||
- `commit`
|
||||
- `timestamp`
|
||||
|
||||
If `build_info.json` is missing, malformed, or does not contain a usable value, RollCalc falls back to `unknown` for that value and continues serving the site.
|
||||
|
||||
The data is loaded centrally in `app.py` and made available to every template as `build_info`.
|
||||
|
||||
## Authentication
|
||||
|
||||
RollCalc uses HTTP Basic Auth. User entries in `BETA_USERS` have this shape:
|
||||
|
||||
```python
|
||||
"username": {
|
||||
"password_hash": "..."
|
||||
}
|
||||
```
|
||||
|
||||
Password verification uses `werkzeug.security.check_password_hash`. New hashes or config snippets can be generated with:
|
||||
|
||||
```bash
|
||||
python scripts/manage_users.py username
|
||||
```
|
||||
|
||||
Passwords and hashes must not be logged.
|
||||
|
||||
## Roll Geometry
|
||||
|
||||
@@ -184,25 +222,14 @@ This is client-side only. It is not persisted, logged, or enforced server-side.
|
||||
|
||||
## Admin Area State
|
||||
|
||||
Current backend route:
|
||||
RollCalc no longer contains an admin UI or admin API. The previous `/admin/logs` route and `templates/admin.html` have been removed.
|
||||
|
||||
```text
|
||||
/admin/logs
|
||||
```
|
||||
|
||||
Current `templates/admin.html` expects:
|
||||
|
||||
```text
|
||||
/api/admin/stats
|
||||
/api/admin/logs
|
||||
```
|
||||
|
||||
Those `/api/admin/*` endpoints are not currently implemented in `app.py`, and there is no route rendering `templates/admin.html`.
|
||||
Login/access logging remains part of RollCalc, but log viewing and article-data administration should not be implemented inside this app. Maintenance of `article-data.json` is planned for a separate application.
|
||||
|
||||
## Known Technical Risks
|
||||
|
||||
- Hardcoded plaintext credentials in `app.py`.
|
||||
- Basic Auth only; no sessions or role framework beyond user dictionaries.
|
||||
- Password hashes are currently configured in `app.py`; this should eventually move to a protected external configuration or secrets mechanism.
|
||||
- Basic Auth only; no sessions or role framework beyond the user dictionary.
|
||||
- `access_log.json` is rewritten on every logged request and is not concurrency-safe.
|
||||
- No log rotation or retention policy is implemented.
|
||||
- Flask's default static route may conflict with the intended authenticated `/static/<path:filename>` behavior; verify effective routing before relying on protected static files.
|
||||
|
||||
@@ -42,7 +42,7 @@ If port `5000` is already occupied, start through Flask's CLI without changing f
|
||||
flask --app app run --host 127.0.0.1 --port 5001
|
||||
```
|
||||
|
||||
The app uses HTTP Basic Auth. Current credentials are defined in `BETA_USERS` and `ADMIN_USERS` in `app.py`.
|
||||
The app uses HTTP Basic Auth. Current users are defined in `BETA_USERS` in `app.py` with Werkzeug password hashes.
|
||||
|
||||
## Project Layout
|
||||
|
||||
@@ -51,14 +51,14 @@ The app uses HTTP Basic Auth. Current credentials are defined in `BETA_USERS` an
|
||||
├── app.py
|
||||
├── requirements.txt
|
||||
├── README.md
|
||||
├── build_info.json
|
||||
├── access_log.json
|
||||
├── config.json
|
||||
├── article-data_.json
|
||||
├── fix_article_data.py
|
||||
├── service-worker.js
|
||||
├── templates/
|
||||
│ ├── roll_calculator.html
|
||||
│ └── admin.html
|
||||
│ └── roll_calculator.html
|
||||
├── static/
|
||||
│ ├── article-data.json
|
||||
│ ├── config.json
|
||||
@@ -88,10 +88,24 @@ Implemented routes:
|
||||
| `/` | `GET` | Basic Auth | Renders `templates/roll_calculator.html`. |
|
||||
| `/static/<path:filename>` | `GET` | Basic Auth | Intended protected static-file serving from `static/`. |
|
||||
| `/api/health` | `GET` | Basic Auth | Returns app health and version. |
|
||||
| `/api/user` | `GET` | Basic Auth | Returns current authenticated user and admin flag. |
|
||||
| `/admin/logs` | `GET` | Basic Auth plus admin check | Returns `access_log.json` contents. |
|
||||
| `/api/user` | `GET` | Basic Auth | Returns current authenticated user info. |
|
||||
|
||||
Authentication is implemented with `Flask-HTTPAuth`. The current code merges `BETA_USERS` and `ADMIN_USERS` and performs direct plaintext string comparison.
|
||||
Authentication is implemented with `Flask-HTTPAuth`. The current code checks `BETA_USERS` with `werkzeug.security.check_password_hash`; plaintext passwords are not stored in the application.
|
||||
|
||||
Generate a password hash or user entry with:
|
||||
|
||||
```bash
|
||||
python scripts/manage_users.py username
|
||||
python scripts/manage_users.py username --json
|
||||
```
|
||||
|
||||
For non-interactive local maintenance only:
|
||||
|
||||
```bash
|
||||
python scripts/manage_users.py username --password 'new-password'
|
||||
```
|
||||
|
||||
Do not commit real passwords or print them in logs.
|
||||
|
||||
Access logging is handled by `log_access()`, which reads `access_log.json`, appends a record, and writes the whole file back.
|
||||
|
||||
@@ -103,6 +117,7 @@ The template contains:
|
||||
|
||||
- Page layout and all main CSS.
|
||||
- A disclaimer modal shown after Basic Auth login and before calculator use.
|
||||
- Footer build metadata from `build_info`.
|
||||
- Global state:
|
||||
- `window.ARTICLE_DATA`
|
||||
- `window.APP_CONFIG`
|
||||
@@ -243,20 +258,9 @@ These provide or describe range calculations for material thickness, area weight
|
||||
|
||||
### Admin UI
|
||||
|
||||
There are admin-oriented HTML files:
|
||||
RollCalc no longer contains an admin UI or admin API. Login/access logging remains in the backend, but logs are not exposed through a RollCalc admin screen.
|
||||
|
||||
- `templates/admin.html`
|
||||
- `admin.html`
|
||||
- `admin_simple.html`
|
||||
|
||||
The backend currently exposes `/admin/logs`, but `templates/admin.html` expects:
|
||||
|
||||
```text
|
||||
/api/admin/stats
|
||||
/api/admin/logs
|
||||
```
|
||||
|
||||
Those `/api/admin/*` routes are not implemented in `app.py` at the time this README was written. There is also no route currently rendering `templates/admin.html`.
|
||||
Administration and maintenance of `article-data.json` is planned for a separate application. RollCalc should continue to consume `static/article-data.json` read-only.
|
||||
|
||||
## Static Assets and Data Files
|
||||
|
||||
@@ -274,6 +278,19 @@ JSON audit log written by `app.py`.
|
||||
|
||||
Important implementation detail: each logged access reads and rewrites the entire JSON file. This is simple but not concurrency-safe and can become inefficient as the file grows.
|
||||
|
||||
### `build_info.json`
|
||||
|
||||
Deployment/build metadata displayed in the site footer.
|
||||
|
||||
Expected fields:
|
||||
|
||||
- `version`
|
||||
- `branch`
|
||||
- `commit`
|
||||
- `timestamp`
|
||||
|
||||
`app.py` loads this file centrally at startup and exposes it to all templates as `build_info`. If the file is missing, invalid, or a field is empty, the affected values fall back to `unknown` and the website continues to work.
|
||||
|
||||
### `fix_article_data.py`
|
||||
|
||||
Utility script that updates relative frontend fetch/register paths to Flask-style `/static/...` paths and checks that key static files exist.
|
||||
@@ -285,15 +302,15 @@ Utility script that updates relative frontend fetch/register paths to Flask-styl
|
||||
- There are duplicated or legacy-looking files with similar names. Before editing JavaScript under `static/`, confirm it is actually referenced by the active template.
|
||||
- The documentation under `docs/` contains deployment and feature notes, but some filenames and route assumptions may not match the current app exactly.
|
||||
- The Flask dev server is used for local development only. Production should use a WSGI server.
|
||||
- Use `scripts/manage_users.py` to create password hashes when adding or rotating Basic Auth users.
|
||||
|
||||
## Known Risks and Maintenance Items
|
||||
|
||||
- Credentials are hardcoded in `app.py` and should be moved to environment variables or a secrets manager.
|
||||
- Passwords are stored in plaintext and compared directly.
|
||||
- Password hashes are currently configured in `app.py`; user configuration should eventually move to environment variables, a protected config file, or a secrets manager.
|
||||
- `access_log.json` is not safe for concurrent writes.
|
||||
- `access_log.json` grows without rotation or retention limits.
|
||||
- The custom `/static/<path:filename>` route is intended to protect static files, but Flask also creates a default static route unless disabled. Verify effective route behavior before relying on static-file protection.
|
||||
- Admin frontend and backend routes are currently inconsistent.
|
||||
- RollCalc no longer includes an admin UI/API; article data administration belongs in a separate application.
|
||||
- There is no visible automated test suite.
|
||||
- The main template is large and mixes layout, styling, data loading, calculations, and UI behavior.
|
||||
- The disclaimer confirmation is client-side only and is not persisted or audited server-side.
|
||||
|
||||
-604
@@ -1,604 +0,0 @@
|
||||
[
|
||||
{
|
||||
"timestamp": "2026-05-28T13:06:19.854940",
|
||||
"username": "beta",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:06:58.223722",
|
||||
"username": "beta",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:07:05.902636",
|
||||
"username": "beta",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:07:51.345366",
|
||||
"username": "beta",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:09:37.481260",
|
||||
"username": "beta",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:14:02.867188",
|
||||
"username": "beta",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:28:08.386403",
|
||||
"username": "beta",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:29:06.541184",
|
||||
"username": "beta",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:30:47.979071",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:46:05.447815",
|
||||
"username": "beta",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T13:46:19.317688",
|
||||
"username": "beta",
|
||||
"endpoint": "/admin",
|
||||
"method": "GET",
|
||||
"status": 403
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T14:42:29.477028",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T14:43:31.374462",
|
||||
"username": "admin",
|
||||
"endpoint": "/admin",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T14:43:31.411860",
|
||||
"username": "admin",
|
||||
"endpoint": "/api/admin/stats",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T14:43:31.562482",
|
||||
"username": "admin",
|
||||
"endpoint": "/api/admin/logs",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T14:44:01.420524",
|
||||
"username": "admin",
|
||||
"endpoint": "/api/admin/stats",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T14:44:01.438789",
|
||||
"username": "admin",
|
||||
"endpoint": "/api/admin/logs",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T14:44:13.773466",
|
||||
"username": "admin",
|
||||
"endpoint": "/admin",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T14:44:13.817782",
|
||||
"username": "admin",
|
||||
"endpoint": "/api/admin/stats",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-05-28T14:44:13.894128",
|
||||
"username": "admin",
|
||||
"endpoint": "/api/admin/logs",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-06-03T05:20:48.808775",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T07:31:48.451519",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T07:31:48.676701",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T07:31:54.481445",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T07:31:58.011356",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T07:32:48.747837",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T07:33:07.753648",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T07:42:11.820817",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T07:43:37.598978",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T07:47:39.689201",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T08:25:47.585793",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T09:32:59.419063",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T09:35:05.236655",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T09:40:47.890997",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T09:41:02.461403",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T09:42:11.914989",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T09:42:57.125161",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T09:54:34.067541",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T10:02:39.927663",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:00:50.808697",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:09:28.615255",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:09:40.011779",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:09:53.681061",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:10:06.334747",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:17:18.862106",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:44:00.451943",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:44:20.277301",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:49:56.333142",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:50:11.692907",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:56:07.569410",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:59:03.417506",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T12:59:21.102453",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:04:52.131022",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:05:09.915771",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:09:55.899370",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:10:20.387853",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:10:20.736005",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:12:48.924277",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:15:13.236624",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:17:32.470202",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:23:23.613251",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:23:24.369105",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:26:48.783516",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:47:07.888072",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:52:38.653855",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:53:02.662397",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T13:57:19.316896",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T14:05:28.671663",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T14:06:26.413418",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T14:06:42.715163",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T14:12:15.337499",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T14:12:19.510992",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-01T14:13:17.018760",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-02T11:28:30.320494",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-02T11:28:46.119436",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-02T11:36:55.439798",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-02T11:41:31.868950",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-02T16:07:56.334163",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-02T16:08:38.097844",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-03T08:39:44.284544",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-03T08:41:57.673023",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-03T08:42:19.877155",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-06T10:34:02.710459",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-06T13:14:58.113794",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-06T13:15:20.071507",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
},
|
||||
{
|
||||
"timestamp": "2026-07-06T13:15:32.538576",
|
||||
"username": "mtazl",
|
||||
"endpoint": "/",
|
||||
"method": "GET",
|
||||
"status": 200
|
||||
}
|
||||
]
|
||||
@@ -5,6 +5,7 @@ Flask app with HTTP Basic Authentication
|
||||
|
||||
from flask import Flask, render_template, request, send_file, send_from_directory, jsonify
|
||||
from flask_httpauth import HTTPBasicAuth
|
||||
from werkzeug.security import check_password_hash
|
||||
from functools import wraps
|
||||
import os
|
||||
from datetime import datetime
|
||||
@@ -19,21 +20,65 @@ auth = HTTPBasicAuth()
|
||||
|
||||
# Benutzer für Beta-Phase (in Produktion aus env-Variablen laden!)
|
||||
BETA_USERS = {
|
||||
"beta": "rollcalc_beta_2026", # ⚠️ ÄNDERN!
|
||||
"naue": "naue_access_2026", # ⚠️ ÄNDERN!
|
||||
"cniehues": "beta_test_2026", # ⚠️ ÄNDERN!
|
||||
"lvollmert": "Geheim!", # ⚠️ ÄNDERN!
|
||||
"mtazl": "rollcalc", # ⚠️ ÄNDERN!
|
||||
"controlling": "beta2026" # ⚠️ ÄNDERN!
|
||||
}
|
||||
|
||||
# Optional: Admin-Features (z.B. Logs, Stats)
|
||||
ADMIN_USERS = {
|
||||
"admin": "admin_secure_pwd_2026" # ⚠️ ÄNDERN!
|
||||
"beta": {
|
||||
"password_hash": "pbkdf2:sha256:600000$HNtF3VdZKdmtg8Vw$8f976a99a457c5e924916dc6f735dd631042c8c126af8d4bda9abcd7532d904f"
|
||||
},
|
||||
"naue": {
|
||||
"password_hash": "pbkdf2:sha256:600000$RVPiW2mYXJJIp3d7$0f838b8619d386e2da57e60ae8ccb944bb0f9f63d81ce3d174ec3034b0abcd19"
|
||||
},
|
||||
"cniehues": {
|
||||
"password_hash": "pbkdf2:sha256:600000$iNmhakf34xk26xrz$ae78846461370c52b7f56fad5ac0ae8e33860d6f00075ac78e3a5b8c31d51a3d"
|
||||
},
|
||||
"lvollmert": {
|
||||
"password_hash": "pbkdf2:sha256:600000$8FGop5ymmHpuIqfK$8ba223e20c514cf6bc1297435a2e7e2be81668951297f0e01ad6a931718ad7de"
|
||||
},
|
||||
"mtazl": {
|
||||
"password_hash": "pbkdf2:sha256:600000$H19skoalhWxlLnY5$d30bfeae38470b19900648fd110978b3677607c3a161d663a7e5d5c2167a3710"
|
||||
},
|
||||
"controlling": {
|
||||
"password_hash": "pbkdf2:sha256:600000$ksj86lrKz6nnSpXz$5161e0b5c76bd72d6b2cd04866ef49e69f463f474d7e47075171894bf3366f29"
|
||||
}
|
||||
}
|
||||
|
||||
# Logging für Auditing
|
||||
LOG_FILE = "access_log.json"
|
||||
BUILD_INFO_FILE = "build_info.json"
|
||||
UNKNOWN_BUILD_INFO = {
|
||||
"version": "unknown",
|
||||
"branch": "unknown",
|
||||
"commit": "unknown",
|
||||
"timestamp": "unknown"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# BUILD INFO
|
||||
# ============================================================================
|
||||
|
||||
def load_build_info():
|
||||
"""Load deployment/build metadata for templates."""
|
||||
try:
|
||||
with open(BUILD_INFO_FILE, "r") as f:
|
||||
data = json.load(f)
|
||||
except Exception as e:
|
||||
print(f"[Build Info Error] {e}")
|
||||
return UNKNOWN_BUILD_INFO.copy()
|
||||
|
||||
if not isinstance(data, dict):
|
||||
return UNKNOWN_BUILD_INFO.copy()
|
||||
|
||||
build_info = UNKNOWN_BUILD_INFO.copy()
|
||||
for key in build_info:
|
||||
value = data.get(key)
|
||||
if isinstance(value, str) and value.strip():
|
||||
build_info[key] = value.strip()
|
||||
return build_info
|
||||
|
||||
BUILD_INFO = load_build_info()
|
||||
|
||||
@app.context_processor
|
||||
def inject_build_info():
|
||||
"""Make build metadata available in all templates."""
|
||||
return {"build_info": BUILD_INFO}
|
||||
|
||||
# ============================================================================
|
||||
# AUTHENTICATION
|
||||
@@ -42,8 +87,12 @@ LOG_FILE = "access_log.json"
|
||||
@auth.verify_password
|
||||
def verify_password(username, password):
|
||||
"""Verify HTTP Basic Auth credentials"""
|
||||
all_users = {**BETA_USERS, **ADMIN_USERS}
|
||||
if username in all_users and all_users[username] == password:
|
||||
user_config = BETA_USERS.get(username)
|
||||
if not user_config:
|
||||
return None
|
||||
|
||||
password_hash = user_config.get("password_hash")
|
||||
if password_hash and check_password_hash(password_hash, password):
|
||||
return username
|
||||
return None
|
||||
|
||||
@@ -96,30 +145,12 @@ def health_check():
|
||||
def get_user():
|
||||
"""Get current authenticated user info"""
|
||||
user = auth.current_user()
|
||||
is_admin = user in ADMIN_USERS
|
||||
return jsonify({
|
||||
"username": user,
|
||||
"authenticated": True,
|
||||
"is_admin": is_admin,
|
||||
"timestamp": datetime.now().isoformat()
|
||||
}), 200
|
||||
|
||||
@app.route("/admin/logs", methods=["GET"])
|
||||
@auth.login_required
|
||||
def get_logs():
|
||||
"""View access logs - admin only"""
|
||||
user = auth.current_user()
|
||||
if user not in ADMIN_USERS:
|
||||
log_access(user, "/admin/logs", "GET", 403)
|
||||
return jsonify({"error": "Unauthorized"}), 403
|
||||
|
||||
log_access(user, "/admin/logs", "GET")
|
||||
logs = []
|
||||
if os.path.exists(LOG_FILE):
|
||||
with open(LOG_FILE, "r") as f:
|
||||
logs = json.load(f)
|
||||
return jsonify({"logs": logs}), 200
|
||||
|
||||
# ============================================================================
|
||||
# ERROR HANDLERS
|
||||
# ============================================================================
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "v0.4",
|
||||
"branch": "main",
|
||||
"commit": "fe267b8",
|
||||
"timestamp": "2026-07-27T11:08:47+02:00"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
# Documentation Guidelines
|
||||
|
||||
## Language
|
||||
|
||||
The primary documentation language is German.
|
||||
|
||||
An English version will be maintained as a translation of the German master document.
|
||||
|
||||
## UI terminology
|
||||
|
||||
All user interface terms remain in English.
|
||||
|
||||
Examples:
|
||||
|
||||
- Direct Calculation
|
||||
- Extrapolation
|
||||
- Roll Diameter
|
||||
- Product Length
|
||||
- Capacity Summary
|
||||
- Capacity Analysis
|
||||
- Governing Constraint
|
||||
|
||||
Do not translate UI labels.
|
||||
|
||||
## Style
|
||||
|
||||
- Technical user manual
|
||||
- Workflow-oriented
|
||||
- Explain why, not only how
|
||||
- Engineering language
|
||||
- No marketing language
|
||||
|
||||
## Workflow
|
||||
|
||||
1. Write German chapter.
|
||||
2. Technical review.
|
||||
3. Add screenshots.
|
||||
4. Approve.
|
||||
5. Translate to English.
|
||||
+1744
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Create password hashes or user config snippets for RollCalc Basic Auth users.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import getpass
|
||||
import json
|
||||
|
||||
from werkzeug.security import generate_password_hash
|
||||
|
||||
|
||||
def build_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Generate RollCalc password hashes or user config entries."
|
||||
)
|
||||
parser.add_argument(
|
||||
"username",
|
||||
nargs="?",
|
||||
help="Optional username for a generated user config snippet.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--password",
|
||||
help="Password to hash. Omit to enter it securely via prompt.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--json",
|
||||
action="store_true",
|
||||
help="Output a JSON object for the user entry.",
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
def main():
|
||||
args = build_parser().parse_args()
|
||||
password = args.password
|
||||
|
||||
if password is None:
|
||||
password = getpass.getpass("Password: ")
|
||||
|
||||
password_hash = generate_password_hash(password)
|
||||
|
||||
if args.username:
|
||||
entry = {args.username: {"password_hash": password_hash}}
|
||||
if args.json:
|
||||
print(json.dumps(entry, indent=2))
|
||||
else:
|
||||
print(f'"{args.username}": {{')
|
||||
print(f' "password_hash": "{password_hash}"')
|
||||
print("}")
|
||||
else:
|
||||
print(password_hash)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
VERSION="${1:-v0.4-dev}"
|
||||
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
cat > build_info.json <<EOF
|
||||
{
|
||||
"version": "$VERSION",
|
||||
"branch": "$(git branch --show-current)",
|
||||
"commit": "$(git rev-parse --short HEAD)",
|
||||
"timestamp": "$(date -Iseconds)"
|
||||
}
|
||||
EOF
|
||||
@@ -1,568 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="theme-color" content="#0066cc">
|
||||
<title>Admin Panel – Roll Calculator</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Arial, sans-serif;
|
||||
background: #f4f6f9;
|
||||
color: #333;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* ---- HEADER ---- */
|
||||
.admin-header {
|
||||
background: linear-gradient(135deg, #003366 0%, #0066cc 100%);
|
||||
color: white;
|
||||
padding: 20px 32px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.admin-header h1 {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.admin-header .subtitle {
|
||||
font-size: 12px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.admin-header .user-info {
|
||||
font-size: 12px;
|
||||
opacity: 0.9;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.admin-header .user-info strong {
|
||||
opacity: 1;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ---- CONTAINER ---- */
|
||||
.admin-container {
|
||||
max-width: 1300px;
|
||||
margin: 30px auto;
|
||||
padding: 0 20px 60px;
|
||||
}
|
||||
|
||||
/* ---- STATS GRID ---- */
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.07);
|
||||
border-left: 4px solid #0066cc;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.stat-card.warning {
|
||||
border-left-color: #f0b429;
|
||||
}
|
||||
|
||||
.stat-card.danger {
|
||||
border-left-color: #dc3545;
|
||||
}
|
||||
|
||||
.stat-card .label {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.4px;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.stat-card .value {
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
color: #0066cc;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.stat-card.warning .value {
|
||||
color: #f0b429;
|
||||
}
|
||||
|
||||
.stat-card.danger .value {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.stat-card .sublabel {
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
/* ---- LOGS SECTION ---- */
|
||||
.logs-section {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 24px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.07);
|
||||
}
|
||||
|
||||
.logs-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.logs-header h2 {
|
||||
font-size: 18px;
|
||||
color: #003366;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background: #0066cc;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
transition: background 0.2s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: #0052a3;
|
||||
}
|
||||
|
||||
.btn.secondary {
|
||||
background: #e0e0e0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.btn.secondary:hover {
|
||||
background: #d0d0d0;
|
||||
}
|
||||
|
||||
.btn-refresh {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
.btn-refresh.spinning {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* ---- TABLE ---- */
|
||||
.logs-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.logs-table thead {
|
||||
background: #f0f4fa;
|
||||
border-bottom: 2px solid #0066cc;
|
||||
}
|
||||
|
||||
.logs-table th {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.logs-table td {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #e8ecf0;
|
||||
}
|
||||
|
||||
.logs-table tbody tr {
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.logs-table tbody tr:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.status-200 {
|
||||
color: #28a745;
|
||||
font-weight: 600;
|
||||
background: #f0f9f6;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.status-401 {
|
||||
color: #dc3545;
|
||||
font-weight: 600;
|
||||
background: #fff0f0;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.status-403 {
|
||||
color: #f0b429;
|
||||
font-weight: 600;
|
||||
background: #fffbea;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* ---- LOADING / EMPTY ---- */
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.error {
|
||||
background: #fff0f0;
|
||||
color: #dc3545;
|
||||
padding: 12px;
|
||||
border-radius: 5px;
|
||||
border-left: 4px solid #dc3545;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
/* ---- FILTERS ---- */
|
||||
.filters {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.filter-input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.filter-input:focus {
|
||||
outline: none;
|
||||
border-color: #0066cc;
|
||||
box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
|
||||
}
|
||||
|
||||
/* ---- FOOTER ---- */
|
||||
.admin-footer {
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
color: #aaa;
|
||||
margin-top: 40px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #e8ecf0;
|
||||
}
|
||||
|
||||
/* ---- RESPONSIVE ---- */
|
||||
@media (max-width: 768px) {
|
||||
.admin-header {
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.admin-header .user-info {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.logs-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.controls {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.logs-table {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.logs-table th, .logs-table td {
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- HEADER -->
|
||||
<div class="admin-header">
|
||||
<div>
|
||||
<h1>🔐 Admin Panel</h1>
|
||||
<div class="subtitle">Roll Calculator – Naue GmbH & Co. KG</div>
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<span>Angemeldet als:</span>
|
||||
<strong id="authUser">admin</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MAIN CONTAINER -->
|
||||
<div class="admin-container">
|
||||
|
||||
<!-- STATISTICS -->
|
||||
<div class="stats-grid" id="statsGrid">
|
||||
<div style="grid-column: 1 / -1; text-align: center; padding: 40px; color: #999;">
|
||||
⏳ Statistiken werden geladen...
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- LOGS SECTION -->
|
||||
<div class="logs-section">
|
||||
|
||||
<!-- HEADER -->
|
||||
<div class="logs-header">
|
||||
<h2>📋 Access Logs</h2>
|
||||
<div class="controls">
|
||||
<button class="btn" id="refreshBtn" onclick="refreshData()">
|
||||
<span id="refreshIcon">🔄</span> Aktualisieren
|
||||
</button>
|
||||
<button class="btn secondary" onclick="downloadLogs()">
|
||||
⬇️ Download
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- FILTERS -->
|
||||
<div class="filters">
|
||||
<input
|
||||
type="text"
|
||||
class="filter-input"
|
||||
placeholder="Nach Benutzer filtern..."
|
||||
id="filterUser"
|
||||
onkeyup="filterLogs()"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
class="filter-input"
|
||||
placeholder="Nach Endpoint filtern..."
|
||||
id="filterEndpoint"
|
||||
onkeyup="filterLogs()"
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- TABLE -->
|
||||
<div id="errorContainer"></div>
|
||||
|
||||
<table class="logs-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zeitstempel</th>
|
||||
<th>Benutzer</th>
|
||||
<th>Endpoint</th>
|
||||
<th>Methode</th>
|
||||
<th style="width: 80px;">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="logsList">
|
||||
<tr>
|
||||
<td colspan="5" class="loading">Logs werden geladen...</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- FOOTER -->
|
||||
<div class="admin-footer">
|
||||
ℹ️ Logs werden automatisch alle 30 Sekunden aktualisiert |
|
||||
Letztes Update: <span id="lastUpdate">-</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- SCRIPTS -->
|
||||
<script>
|
||||
let allLogs = [];
|
||||
|
||||
// Get authenticated user from API
|
||||
async function getAuthUser() {
|
||||
try {
|
||||
const res = await fetch('/api/user');
|
||||
const data = await res.json();
|
||||
document.getElementById('authUser').textContent = data.username || 'admin';
|
||||
} catch (e) {
|
||||
console.warn('Konnte Benutzerinformation nicht laden');
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh Data (Statistiken + Logs)
|
||||
async function refreshData() {
|
||||
const btn = document.getElementById('refreshBtn');
|
||||
const icon = document.getElementById('refreshIcon');
|
||||
|
||||
try {
|
||||
icon.style.animation = 'spin 1s linear infinite';
|
||||
|
||||
// Load Statistics
|
||||
const statsRes = await fetch('/api/admin/stats');
|
||||
if (!statsRes.ok) throw new Error('Statistiken konnten nicht geladen werden');
|
||||
const stats = await statsRes.json();
|
||||
|
||||
// Load Logs
|
||||
const logsRes = await fetch('/api/admin/logs');
|
||||
if (!logsRes.ok) throw new Error('Logs konnten nicht geladen werden');
|
||||
const logsData = await logsRes.json();
|
||||
|
||||
allLogs = logsData.logs || [];
|
||||
|
||||
// Render Statistics
|
||||
renderStats(stats);
|
||||
|
||||
// Render Logs
|
||||
renderLogs(allLogs);
|
||||
|
||||
// Update timestamp
|
||||
document.getElementById('lastUpdate').textContent = new Date().toLocaleTimeString('de-DE');
|
||||
|
||||
// Clear error
|
||||
document.getElementById('errorContainer').innerHTML = '';
|
||||
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Laden der Daten:', error);
|
||||
document.getElementById('errorContainer').innerHTML =
|
||||
'<div class="error">❌ ' + error.message + '</div>';
|
||||
} finally {
|
||||
icon.style.animation = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Render Statistics
|
||||
function renderStats(stats) {
|
||||
const html = `
|
||||
<div class="stat-card">
|
||||
<div class="label">📊 Gesamte Anfragen</div>
|
||||
<div class="value">${stats.total_requests || 0}</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="label">👥 Eindeutige Benutzer</div>
|
||||
<div class="value">${stats.unique_users || 0}</div>
|
||||
</div>
|
||||
<div class="stat-card danger">
|
||||
<div class="label">⛔ Fehlgeschlagene Logins</div>
|
||||
<div class="value">${stats.failed_logins || 0}</div>
|
||||
</div>
|
||||
`;
|
||||
document.getElementById('statsGrid').innerHTML = html;
|
||||
}
|
||||
|
||||
// Render Logs
|
||||
function renderLogs(logs) {
|
||||
if (!logs || logs.length === 0) {
|
||||
document.getElementById('logsList').innerHTML =
|
||||
'<tr><td colspan="5" class="empty">Keine Logs verfügbar</td></tr>';
|
||||
return;
|
||||
}
|
||||
|
||||
const html = logs.reverse().map(log => {
|
||||
const time = new Date(log.timestamp).toLocaleString('de-DE');
|
||||
const statusClass = `status-${log.status}`;
|
||||
return `
|
||||
<tr>
|
||||
<td>${time}</td>
|
||||
<td><strong>${log.username}</strong></td>
|
||||
<td><code>${log.endpoint}</code></td>
|
||||
<td>${log.method}</td>
|
||||
<td><span class="${statusClass}">${log.status}</span></td>
|
||||
</tr>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
document.getElementById('logsList').innerHTML = html;
|
||||
}
|
||||
|
||||
// Filter Logs
|
||||
function filterLogs() {
|
||||
const userFilter = document.getElementById('filterUser').value.toLowerCase();
|
||||
const endpointFilter = document.getElementById('filterEndpoint').value.toLowerCase();
|
||||
|
||||
const filtered = allLogs.filter(log =>
|
||||
log.username.toLowerCase().includes(userFilter) &&
|
||||
log.endpoint.toLowerCase().includes(endpointFilter)
|
||||
);
|
||||
|
||||
renderLogs(filtered);
|
||||
}
|
||||
|
||||
// Download Logs as JSON
|
||||
function downloadLogs() {
|
||||
const data = JSON.stringify(allLogs, null, 2);
|
||||
const blob = new Blob([data], { type: 'application/json' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `access-logs-${new Date().toISOString()}.json`;
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
// Initialize
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
getAuthUser();
|
||||
refreshData();
|
||||
|
||||
// Auto-refresh every 30 seconds
|
||||
setInterval(refreshData, 30000);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+176
-25
@@ -48,6 +48,9 @@
|
||||
.result-label { font-size: 12px; color: #1F5438; font-weight: 600; text-transform: uppercase; }
|
||||
.result-value { font-size: 28px; font-weight: 700; color: #1F5438; line-height: 1.2; }
|
||||
.result-range { font-size: 12px; color: #1F5438; margin-top: 4px; font-weight: 500; }
|
||||
.result-range div { margin-top: 2px; }
|
||||
.result-range .range-warning { color: #9a6700; font-weight: 700; }
|
||||
.result-range .range-ok { color: #1F5438; font-weight: 700; }
|
||||
.forklift-check { border-radius: 7px; padding: 14px 16px; margin-top: 14px; font-size: 13px; line-height: 1.6; display: none; }
|
||||
.forklift-check.show { display: block; }
|
||||
.forklift-check.fc-ok { background: #eafaf1; border: 1.5px solid #28a745; }
|
||||
@@ -60,6 +63,7 @@
|
||||
.fc-req-nok { color: #dc3545; font-weight: 600; }
|
||||
.formula-box { background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 6px; padding: 10px 14px; font-size: 12px; color: #666; margin-top: 18px; font-family: 'Courier New', monospace; }
|
||||
.footer { text-align: center; font-size: 11px; color: #aaa; padding: 18px; margin-top: 30px; }
|
||||
.footer-build-info { margin-top: 6px; color: #bbb; }
|
||||
.disclaimer-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
@@ -285,6 +289,23 @@
|
||||
border-left: 4px solid #2BAC70;
|
||||
}
|
||||
.lo-results-summary h4 { margin-top: 0; color: #333; font-size: 14px; margin-bottom: 12px; }
|
||||
.lo-summary-section {
|
||||
padding-top: 12px;
|
||||
margin-top: 12px;
|
||||
border-top: 1px solid #e6ece9;
|
||||
}
|
||||
.lo-summary-section:first-of-type {
|
||||
padding-top: 0;
|
||||
margin-top: 0;
|
||||
border-top: 0;
|
||||
}
|
||||
.lo-summary-section-title {
|
||||
margin-bottom: 8px;
|
||||
color: #1F5438;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.lo-summary-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -293,9 +314,23 @@
|
||||
font-size: 13px;
|
||||
}
|
||||
.lo-summary-item:last-child { margin-bottom: 0; }
|
||||
.lo-summary-item.lo-governing-summary {
|
||||
background: #eef8f2;
|
||||
border-left: 3px solid #2BAC70;
|
||||
padding: 8px 10px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.lo-value-highlight { color: #2BAC70; font-weight: bold; font-size: 16px; }
|
||||
.lo-value-number { color: #1F5438; font-weight: bold; }
|
||||
.lo-util-group { display: flex; flex-direction: column; gap: 4px; text-align: right; }
|
||||
.lo-reserve-note {
|
||||
margin-top: 4px;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
line-height: 1.35;
|
||||
text-align: right;
|
||||
max-width: 300px;
|
||||
}
|
||||
.lo-results-table {
|
||||
background: white;
|
||||
padding: 16px;
|
||||
@@ -311,10 +346,15 @@
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
border-bottom: 2px solid #2BAC70;
|
||||
white-space: normal;
|
||||
}
|
||||
.lo-results-table td { padding: 8px; border-bottom: 1px solid #e0e0e0; }
|
||||
.lo-results-table tbody tr:hover { background: #f9f9f9; }
|
||||
.lo-results-table tbody tr.lo-recommended { background: #fffacd; font-weight: bold; }
|
||||
.lo-results-table tbody tr.lo-governing {
|
||||
background: #eef8f2;
|
||||
font-weight: 600;
|
||||
border-left: 3px solid #2BAC70;
|
||||
}
|
||||
.lo-warning {
|
||||
background: #fff8e1;
|
||||
border: 1px solid #f0b429;
|
||||
@@ -392,6 +432,11 @@
|
||||
}
|
||||
.lo-sideview-section.show { display: block; }
|
||||
.lo-sideview-section h4 { margin: 0 0 12px 0; font-size: 14px; color: #333; }
|
||||
.lo-sideview-context {
|
||||
margin: -6px 0 12px;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
.lo-sideview-wrap {
|
||||
background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 4px; overflow: hidden;
|
||||
}
|
||||
@@ -571,6 +616,27 @@
|
||||
<span class="unit-label">kg</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Max. Roll Diameter</label>
|
||||
<div class="input-with-unit">
|
||||
<input type="number" id="d-target-di" placeholder="mm" min="0" step="1">
|
||||
<span class="unit-label">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Max. Roll Weight</label>
|
||||
<div class="input-with-unit">
|
||||
<input type="number" id="d-max-weight" placeholder="kg" min="0" step="1">
|
||||
<span class="unit-label">kg</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Minimum Product Length</label>
|
||||
<div class="input-with-unit">
|
||||
<input type="number" id="d-min-le" placeholder="m" min="0" step="0.1">
|
||||
<span class="unit-label">m</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -782,11 +848,17 @@
|
||||
<div class="lo-results" id="resultsContainer">
|
||||
|
||||
<div class="lo-results-summary">
|
||||
<h4>Results:</h4>
|
||||
<div class="lo-summary-item">
|
||||
<span><strong>Limiting Factor:</strong></span>
|
||||
<h4>Capacity Summary:</h4>
|
||||
<div class="lo-summary-section">
|
||||
<div class="lo-summary-section-title">Governing Constraint</div>
|
||||
<div class="lo-summary-item lo-governing-summary">
|
||||
<span><strong>Constraint:</strong></span>
|
||||
<span id="limitingFactorValue" class="lo-value-highlight">–</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lo-summary-section">
|
||||
<div class="lo-summary-section-title">Transport Result</div>
|
||||
<div class="lo-summary-item">
|
||||
<span><strong>Total Rolls:</strong></span>
|
||||
<div style="text-align:right;">
|
||||
@@ -797,23 +869,37 @@
|
||||
<div class="lo-summary-item">
|
||||
<span><strong>Utilization:</strong></span>
|
||||
<div class="lo-util-group">
|
||||
<div>Weight: <span id="weightUtilValue" class="lo-value-number">–</span> %</div>
|
||||
<div>Volume: <span id="volumeUtilValue" class="lo-value-number">–</span> %</div>
|
||||
<div>Product: <span id="productM2Value" class="lo-value-number">–</span> m²</div>
|
||||
<div>Weight Utilization: <span id="weightUtilValue" class="lo-value-number">–</span> %</div>
|
||||
<div>Volume Utilization: <span id="volumeUtilValue" class="lo-value-number">–</span> %</div>
|
||||
<div>Transported Product Area: <span id="productM2Value" class="lo-value-number">–</span> m²</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lo-summary-section">
|
||||
<div class="lo-summary-section-title">Remaining Capacity</div>
|
||||
<div class="lo-summary-item">
|
||||
<span><strong>Remaining Capacity:</strong></span>
|
||||
<div class="lo-util-group">
|
||||
<div>Remaining Payload: <span id="remainingPayloadValue" class="lo-value-number">–</span> kg</div>
|
||||
<div>Unused Payload: <span id="unusedPayloadValue" class="lo-value-number">–</span> %</div>
|
||||
<div>Unused Volume: <span id="unusedVolumeValue" class="lo-value-number">–</span> %</div>
|
||||
<div id="capacityInterpretationValue" class="lo-reserve-note"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lo-results-table">
|
||||
<h4>Comparison Table:</h4>
|
||||
<h4>Capacity Analysis:</h4>
|
||||
<table id="comparisonTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Scenario</th>
|
||||
<th>Rolls</th>
|
||||
<th>kg</th>
|
||||
<th>m²</th>
|
||||
<th>Util. %</th>
|
||||
<th>Constraint</th>
|
||||
<th>Max Rolls</th>
|
||||
<th>Total Weight</th>
|
||||
<th>Transported Area [m²]</th>
|
||||
<th>Payload Util. %</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
@@ -822,6 +908,7 @@
|
||||
|
||||
<div class="lo-sideview-section" id="sideViewSection">
|
||||
<h4>🔍 Front View – Cross-Section</h4>
|
||||
<p class="lo-sideview-context">Cross-section of the actual loading configuration.</p>
|
||||
<div class="lo-sideview-wrap">
|
||||
<svg id="sideViewSVG" width="100%" viewBox="0 0 800 300" xmlns="http://www.w3.org/2000/svg">
|
||||
<text x="400" y="130" text-anchor="middle" fill="#aaa" font-size="14">Run a calculation to see the side view.</text>
|
||||
@@ -844,6 +931,9 @@
|
||||
|
||||
<div class="footer">
|
||||
Naue GmbH & Co. KG · Roll Diameter Calculator · Internal Application
|
||||
<div class="footer-build-info">
|
||||
Version {{ build_info.version }} · Branch {{ build_info.branch }} · Commit {{ build_info.commit }} · Built {{ build_info.timestamp }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@@ -989,21 +1079,69 @@ document.getElementById('d-calc').addEventListener('click', () => {
|
||||
resRange.textContent = '';
|
||||
document.getElementById('d-le').value = L_calc.toFixed(2);
|
||||
} else if (mode === 'target') {
|
||||
if (!d || !t) { alert('Please enter d and t.'); return; }
|
||||
const D_target = D || 800;
|
||||
const L_calc = (Math.PI / (4 * t)) * (D_target*D_target - d*d) / 1000;
|
||||
resLabel.textContent = 'Length for Target Diameter ' + D_target + ' mm';
|
||||
resVal.textContent = L_calc.toFixed(2) + ' m';
|
||||
resRange.textContent = '';
|
||||
document.getElementById('d-le').value = L_calc.toFixed(2);
|
||||
const wi = parseFloat(document.getElementById('d-wi').value) || 0;
|
||||
const aw = parseFloat(document.getElementById('d-aw').value) || 0;
|
||||
const maxWeight = parseFloat(document.getElementById('d-max-weight').value) || 0;
|
||||
const minLength = parseFloat(document.getElementById('d-min-le').value) || 0;
|
||||
const D_target = parseFloat(document.getElementById('d-target-di').value) || 0;
|
||||
|
||||
if (!d || !t || !D_target || !wi || !aw || !maxWeight) {
|
||||
alert('Please enter d, t, max. roll diameter, roll width, area weight, and max. roll weight.');
|
||||
return;
|
||||
}
|
||||
if (D_target <= d) {
|
||||
alert('Max. roll diameter must be larger than core diameter.');
|
||||
return;
|
||||
}
|
||||
|
||||
const L_diameter = (Math.PI / (4 * t)) * (D_target*D_target - d*d) / 1000;
|
||||
const L_weight = maxWeight * 1000 / (aw * wi);
|
||||
const L_allowed = Math.min(L_diameter, L_weight);
|
||||
const D_result = Math.sqrt(d*d + (4*L_allowed*1000*t)/Math.PI);
|
||||
const W_result = aw * L_allowed * wi / 1000;
|
||||
const diameterUtil = D_result / D_target * 100;
|
||||
const weightUtil = W_result / maxWeight * 100;
|
||||
const lengthDiff = minLength > 0 ? L_allowed - minLength : null;
|
||||
const epsilon = 0.0001;
|
||||
let limitingFactor = 'Diameter + Weight';
|
||||
|
||||
if (L_diameter < L_weight - epsilon) {
|
||||
limitingFactor = 'Diameter';
|
||||
} else if (L_weight < L_diameter - epsilon) {
|
||||
limitingFactor = 'Weight';
|
||||
}
|
||||
|
||||
resLabel.textContent = 'Maximum Allowed Product Length';
|
||||
resVal.textContent = L_allowed.toFixed(2) + ' m';
|
||||
|
||||
const minLengthText = minLength > 0 ? minLength.toFixed(2) + ' m' : 'not set';
|
||||
const diffText = lengthDiff !== null ? lengthDiff.toFixed(2) + ' m' : 'n/a';
|
||||
let minStatus = '<div>Minimum length not set</div>';
|
||||
if (minLength > 0 && L_allowed < minLength) {
|
||||
minStatus = '<div class="range-warning">Warning: maximum allowed length is below the minimum product length.</div>';
|
||||
} else if (minLength > 0) {
|
||||
minStatus = '<div class="range-ok">Minimum length OK</div>';
|
||||
}
|
||||
|
||||
resRange.innerHTML =
|
||||
'<div>Resulting Roll Diameter: ' + D_result.toFixed(1) + ' mm</div>' +
|
||||
'<div>Resulting weight: ' + W_result.toFixed(1) + ' kg</div>' +
|
||||
'<div>Minimum length: ' + minLengthText + '</div>' +
|
||||
'<div>Difference: ' + diffText + '</div>' +
|
||||
'<div>Limiting factor: ' + limitingFactor + '</div>' +
|
||||
'<div>Utilization: Diameter ' + diameterUtil.toFixed(1) + '% | Weight ' + weightUtil.toFixed(1) + '%</div>' +
|
||||
minStatus;
|
||||
|
||||
document.getElementById('d-le').value = L_allowed.toFixed(2);
|
||||
document.getElementById('d-wo').value = W_result.toFixed(1);
|
||||
}
|
||||
|
||||
const wi = parseFloat(document.getElementById('d-wi').value) || 0;
|
||||
const aw = parseFloat(document.getElementById('d-aw').value) || 0;
|
||||
const L_final = parseFloat(document.getElementById('d-le').value) || 0;
|
||||
if (wi > 0 && aw > 0 && L_final > 0) {
|
||||
const weight = (aw * L_final * wi / 1000).toFixed(1);
|
||||
document.getElementById('d-wo').value = weight;
|
||||
const weight = aw * L_final * wi / 1000;
|
||||
document.getElementById('d-wo').value = weight.toFixed(1);
|
||||
checkForklift(weight, d, category);
|
||||
} else {
|
||||
document.getElementById('forkliftCheck').classList.remove('show');
|
||||
@@ -1013,7 +1151,7 @@ document.getElementById('d-calc').addEventListener('click', () => {
|
||||
});
|
||||
|
||||
document.getElementById('d-reset').addEventListener('click', () => {
|
||||
['d-co', 'd-th', 'd-tol', 'd-le', 'd-di', 'd-wi', 'd-aw', 'd-wo'].forEach(id => {
|
||||
['d-co', 'd-th', 'd-tol', 'd-le', 'd-di', 'd-wi', 'd-aw', 'd-wo', 'd-target-di', 'd-max-weight', 'd-min-le'].forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.value = id === 'd-co' ? '150' : '';
|
||||
});
|
||||
@@ -1274,6 +1412,14 @@ class LoadOptimizerUI {
|
||||
|
||||
showResults(res, maxW) {
|
||||
const m2PerRoll = this.optimizer.state.m2PerRoll || 0;
|
||||
const remainingPayload = Math.max(0, maxW - res.finalWeight);
|
||||
const unusedPayload = Math.max(0, 100 - res.utilizationWeight);
|
||||
const unusedVolume = Math.max(0, 100 - res.utilizationVolume);
|
||||
const interpretations = {
|
||||
geometry: 'Geometry prevents loading additional rolls although payload capacity remains available.',
|
||||
weight: 'Payload limit is reached before the available geometry or volume is fully used.',
|
||||
volume: 'Volume capacity is reached before payload or geometric capacity is fully used.'
|
||||
};
|
||||
document.getElementById('limitingFactorValue').textContent = res.limiting.name;
|
||||
document.getElementById('totalRollsValue').textContent = res.finalRolls;
|
||||
document.getElementById('rollsDetailValue').textContent =
|
||||
@@ -1281,16 +1427,21 @@ class LoadOptimizerUI {
|
||||
document.getElementById('weightUtilValue').textContent = this.optimizer.fmt(res.utilizationWeight);
|
||||
document.getElementById('volumeUtilValue').textContent = this.optimizer.fmt(res.utilizationVolume);
|
||||
document.getElementById('productM2Value').textContent = this.optimizer.fmt(res.finalM2, 0);
|
||||
document.getElementById('remainingPayloadValue').textContent = this.optimizer.fmt(remainingPayload, 0);
|
||||
document.getElementById('unusedPayloadValue').textContent = this.optimizer.fmt(unusedPayload);
|
||||
document.getElementById('unusedVolumeValue').textContent = this.optimizer.fmt(unusedVolume);
|
||||
document.getElementById('capacityInterpretationValue').textContent =
|
||||
interpretations[res.limiting.type] || '';
|
||||
const tbody = document.querySelector('#comparisonTable tbody');
|
||||
tbody.innerHTML = '';
|
||||
res.scenarios.forEach(sc => {
|
||||
const tr = document.createElement('tr');
|
||||
const lim = (sc.type === res.limiting.type);
|
||||
if (lim) tr.classList.add('lo-recommended');
|
||||
if (lim) tr.classList.add('lo-governing');
|
||||
const util = maxW > 0 ? (sc.weight / maxW * 100).toFixed(1) : '–';
|
||||
const scM2 = isFinite(sc.rolls) && m2PerRoll > 0 ? Math.round(sc.rolls * m2PerRoll) : '–';
|
||||
tr.innerHTML =
|
||||
'<td>'+ sc.name +(lim?' ★':'')+'</td>'+
|
||||
'<td>'+ sc.name +(lim?' → Governing Constraint':'')+'</td>'+
|
||||
'<td>'+ (sc.rolls === Infinity ? '–' : sc.rolls) +'</td>'+
|
||||
'<td>'+ (isFinite(sc.weight) ? Math.round(sc.weight) : '–') +'</td>'+
|
||||
'<td>'+ scM2 +'</td>'+
|
||||
|
||||
Reference in New Issue
Block a user