1
0
Fork 0
mirror of https://github.com/maziggy/bambuddy.git synced 2026-05-09 08:25:54 +02:00

[PR #570] [MERGED] Feature AMS Info Card #1073

Closed
opened 2026-05-07 00:15:50 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/570
Author: @cadtoolbox
Created: 3/2/2026
Status: Merged
Merged: 3/5/2026
Merged by: @maziggy

Base: 0.2.2b2Head: dev_amsinfocard


📝 Commits (10+)

📊 Changes

20 files changed (+786 additions, -36 deletions)

View changed files

📝 backend/app/api/routes/inventory.py (+52 -1)
📝 backend/app/api/routes/printers.py (+124 -0)
📝 backend/app/api/routes/settings.py (+6 -3)
📝 backend/app/core/database.py (+40 -0)
📝 backend/app/models/__init__.py (+2 -0)
backend/app/models/ams_label.py (+30 -0)
📝 backend/app/schemas/printer.py (+7 -0)
📝 backend/app/schemas/spool.py (+1 -0)
📝 backend/app/services/bambu_mqtt.py (+143 -3)
📝 backend/app/services/printer_manager.py (+4 -0)
📝 frontend/src/api/client.ts (+20 -0)
frontend/src/components/FilamentSlotCircle.tsx (+47 -0)
📝 frontend/src/i18n/locales/de.ts (+10 -0)
📝 frontend/src/i18n/locales/en.ts (+10 -0)
📝 frontend/src/i18n/locales/fr.ts (+10 -0)
📝 frontend/src/i18n/locales/it.ts (+10 -0)
📝 frontend/src/i18n/locales/ja.ts (+10 -0)
📝 frontend/src/i18n/locales/pt-BR.ts (+10 -0)
📝 frontend/src/pages/InventoryPage.tsx (+3 -2)
📝 frontend/src/pages/PrintersPage.tsx (+247 -27)

📄 Description

Description

Adds two UX improvements to the AMS display on the Printers page: a hover popup on each AMS label exposing hardware details and a user-editable friendly name, and 1-based slot numbers centered inside each filament color circle with auto-inverted contrast.

AMS name hover popup
Hovering the AMS label (e.g. AMS-A) opens a popover showing:

  • Serial number – sourced from the MQTT sn field on the AMS unit object
  • Firmware version – parsed from info.module[name="ams/"].sw_ver in the get_version MQTT response
  • Friendly name – editable text field, stored in a new ams_labels DB table; gated by printers:update permission
  • Filament location will reflect this new AMS friendly name as a suffix (friendly_name)

Fixes #464

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition or update

Changes Made

Backend

  • New AmsLabel model (printer_id, ams_id, label); table auto-created via create_all.
  • AMSUnit schema gains serial_number and sw_ver fields; both populated in the status route from raw MQTT data.
    _handle_version_info in bambu_mqtt.py extended to parse ams/ modules and write sw_ver/sn back onto the stored AMS unit dict.

Frontend

  • New AmsNameHoverCard component in PrintersPage.tsx using the same hover-card pattern as NozzleSlotHoverCard.
  • AMSUnit interface extended with serial_number and sw_ver; three new API client functions added.
  • Slot numbers in color circles
  • Each filament circle now renders its 1-based slot number centered inside it. Font color is computed via the existing isLightFilamentColor helper—black text on light filament, white on dark. Applied consistently to regular 4-tray AMS, HT AMS, and external spool slots.

Bug Fixes

  • backend/app/api/routes/settings.py: After copying the backup database file, call reinitialize_database() to point the engine at the restored file, then init_db() to create missing tables (CREATE TABLE IF NOT EXISTS) and apply column migrations — eliminating the need for a manual restart to recover a usable schema.
# After shutil.copy2(backup_db, db_path)
await reinitialize_database()
await init_db()

Screenshots

2026-02-26_08-41-29

Testing

  • I have tested this on my local machine
  • I have tested with my printer model: X1E

Checklist

  • My code follows the project's coding style
  • I have commented my code where necessary
  • I have updated the documentation (if needed)
  • My changes generate no new warnings
  • I have tested my changes thoroughly

Additional Notes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/maziggy/bambuddy/pull/570 **Author:** [@cadtoolbox](https://github.com/cadtoolbox) **Created:** 3/2/2026 **Status:** ✅ Merged **Merged:** 3/5/2026 **Merged by:** [@maziggy](https://github.com/maziggy) **Base:** `0.2.2b2` ← **Head:** `dev_amsinfocard` --- ### 📝 Commits (10+) - [`d657219`](https://github.com/maziggy/bambuddy/commit/d657219fcdfabf25413cc29dfb90920cf97f1d95) AMS Labels addition to PrintersPage - [`71bf670`](https://github.com/maziggy/bambuddy/commit/71bf670b5edcde8be4bede22ff2c9dbf71b32839) Added database reinitialization for schema migrations on database restore - [`e5fa745`](https://github.com/maziggy/bambuddy/commit/e5fa745e7e6a125fbdb5af54f6e72d4a06f785d8) Bug fixes and AMS Label persistence updates - [`e591d04`](https://github.com/maziggy/bambuddy/commit/e591d04be08c6edd29b7b39b2c43aa468c01f1d2) Update database.py to resolve PR conflicts - [`a6148fb`](https://github.com/maziggy/bambuddy/commit/a6148fb5a2428187cf1080ff8fc2864d94bc6f1c) Merge branch '0.2.2b1' into dev_amsinfocard - [`bfe4325`](https://github.com/maziggy/bambuddy/commit/bfe43256d50c9fc9df4de336b5c501bf9b7ed180) PR Comment Resolution - [`ec0d64f`](https://github.com/maziggy/bambuddy/commit/ec0d64faa2c0befa06ffcc06fbf811a9d12de391) Merge branch 'dev_amsinfocard' of https://github.com/cadtoolbox/bambuddy into dev_amsinfocard - [`81c618b`](https://github.com/maziggy/bambuddy/commit/81c618b497947ba792f3149be4f1b4a842e6e9c9) Merge branch '0.2.2b1' into dev_amsinfocard - [`4062291`](https://github.com/maziggy/bambuddy/commit/4062291c3a7e4ca23df010d39f00bbfd300e2c70) Resolve conflicts in database.py for PR#570 - [`c126cd5`](https://github.com/maziggy/bambuddy/commit/c126cd523c21e1ae635fdf1c3c99f54a0ec6bbd7) Merge branch 'dev_amsinfocard' of https://github.com/cadtoolbox/bambuddy into dev_amsinfocard ### 📊 Changes **20 files changed** (+786 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/api/routes/inventory.py` (+52 -1) 📝 `backend/app/api/routes/printers.py` (+124 -0) 📝 `backend/app/api/routes/settings.py` (+6 -3) 📝 `backend/app/core/database.py` (+40 -0) 📝 `backend/app/models/__init__.py` (+2 -0) ➕ `backend/app/models/ams_label.py` (+30 -0) 📝 `backend/app/schemas/printer.py` (+7 -0) 📝 `backend/app/schemas/spool.py` (+1 -0) 📝 `backend/app/services/bambu_mqtt.py` (+143 -3) 📝 `backend/app/services/printer_manager.py` (+4 -0) 📝 `frontend/src/api/client.ts` (+20 -0) ➕ `frontend/src/components/FilamentSlotCircle.tsx` (+47 -0) 📝 `frontend/src/i18n/locales/de.ts` (+10 -0) 📝 `frontend/src/i18n/locales/en.ts` (+10 -0) 📝 `frontend/src/i18n/locales/fr.ts` (+10 -0) 📝 `frontend/src/i18n/locales/it.ts` (+10 -0) 📝 `frontend/src/i18n/locales/ja.ts` (+10 -0) 📝 `frontend/src/i18n/locales/pt-BR.ts` (+10 -0) 📝 `frontend/src/pages/InventoryPage.tsx` (+3 -2) 📝 `frontend/src/pages/PrintersPage.tsx` (+247 -27) </details> ### 📄 Description ## Description Adds two UX improvements to the AMS display on the Printers page: a hover popup on each AMS label exposing hardware details and a user-editable friendly name, and 1-based slot numbers centered inside each filament color circle with auto-inverted contrast. **AMS name hover popup** Hovering the AMS label (e.g. AMS-A) opens a popover showing: - Serial number – sourced from the MQTT sn field on the AMS unit object - Firmware version – parsed from info.module[name="ams/<id>"].sw_ver in the get_version MQTT response - Friendly name – editable text field, stored in a new ams_labels DB table; gated by printers:update permission - Filament location will reflect this new AMS friendly name as a suffix (friendly_name) ## Related Issue <!-- Link to the issue this PR addresses (if applicable) --> Fixes #464 ## Type of Change <!-- Mark the relevant option with an "x" --> - [ ] Bug fix (non-breaking change that fixes an issue) - [X] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Test addition or update ## Changes Made Backend - New AmsLabel model (printer_id, ams_id, label); table auto-created via create_all. - AMSUnit schema gains serial_number and sw_ver fields; both populated in the status route from raw MQTT data. _handle_version_info in bambu_mqtt.py extended to parse ams/<id> modules and write sw_ver/sn back onto the stored AMS unit dict. Frontend - New AmsNameHoverCard component in PrintersPage.tsx using the same hover-card pattern as NozzleSlotHoverCard. - AMSUnit interface extended with serial_number and sw_ver; three new API client functions added. - Slot numbers in color circles - Each filament circle now renders its 1-based slot number centered inside it. Font color is computed via the existing isLightFilamentColor helper—black text on light filament, white on dark. Applied consistently to regular 4-tray AMS, HT AMS, and external spool slots. Bug Fixes - backend/app/api/routes/settings.py: After copying the backup database file, call reinitialize_database() to point the engine at the restored file, then init_db() to create missing tables (CREATE TABLE IF NOT EXISTS) and apply column migrations — eliminating the need for a manual restart to recover a usable schema. ``` # After shutil.copy2(backup_db, db_path) await reinitialize_database() await init_db() ``` ## Screenshots <!-- If applicable, add screenshots to demonstrate your changes --> ![2026-02-26_08-41-29](https://github.com/user-attachments/assets/8de3a152-40ce-40a6-9d0d-70b63616e38b) ## Testing <!-- Describe how you tested your changes --> - [X] I have tested this on my local machine - [X] I have tested with my printer model: X1E ## Checklist - [X] My code follows the project's coding style - [X] I have commented my code where necessary - [ ] I have updated the documentation (if needed) - [X] My changes generate no new warnings - [X] I have tested my changes thoroughly ## Additional Notes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 00:15:50 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy-maziggy-1#1073
No description provided.