Commit Graph
549 Commits
Author SHA1 Message Date
maziggy 4ea7f7c4aa Add GitHub profile backup feature
New feature to automatically backup K-profiles, cloud profiles, and app
settings to a GitHub repository with scheduled or on-demand execution.

Features:
- Configure GitHub repo URL and Personal Access Token
- Schedule backups hourly, daily, or weekly (background scheduler)
- Manual backup trigger with real-time progress tracking
- Skip unchanged commits (only creates commit when data changes)
- Backup history log with status and commit links
- Requires Bambu Cloud login for full profile access
- New Settings → Backup & Restore tab consolidating all backup options
- GitHub backup config included in local backup/restore (except PAT)

Backend:
- New models: GitHubBackupConfig, GitHubBackupLog
- New service: GitHubBackupService with scheduler and GitHub API client
- New routes: /github-backup/* for config, status, logs, and triggers
- Updated settings.py to include github_backup in backup/restore

Frontend:
- New GitHubBackupSettings.tsx component with auto-save
- Updated SettingsPage with Backup tab and status indicator
- Added API types and methods to client.ts

Tests:
- Backend integration tests for all GitHub backup API endpoints
- Frontend API type and endpoint tests
2026-01-27 15:01:06 +01:00
maziggy ea737c4719 Updated CHANGELOG 2026-01-27 13:02:17 +01:00
maziggy 5c0b5500fb Fix backup/restore 2026-01-27 12:52:24 +01:00
maziggy b28b829bd8 Fix backup/restore 2026-01-27 12:47:43 +01:00
maziggy 945121b799 Fix plate calibration backup/restore with printer ID remapping
- Add "Plate Detection" option to backup modal
- Store printer_id_to_serial mapping in backup for calibration files
- Remap printer IDs during restore based on serial numbers so files
  like printer_3_ref_0.jpg get correctly renamed if printer 3 becomes
  printer 2 on the new system
- Add parents=True to mkdir calls in config.py to fix startup crash
- Labels/metadata are now correctly restored via the metadata.json files
2026-01-27 12:39:02 +01:00
maziggy 30f7d41ec3 Add plate calibration to backup and fix directory creation
- Add "Plate Detection" option to backup modal for exporting empty plate
  reference images (requires Printers to be selected)
- Add parents=True to mkdir calls in config.py to create full directory
  tree on first run (fixes startup crash when data dir doesn't exist)
- Update BackupModal test to use exact match for "Printers" text
2026-01-27 12:30:15 +01:00
maziggy 8f30f08559 Fix startup crash when data directory doesn't exist
Add parents=True to mkdir calls for archive_dir and plate_calibration_dir
in config.py to create the full directory tree on first run.
2026-01-27 12:12:04 +01:00
maziggy c52c505ad8 Added explicit permissions: issues: write 2026-01-27 11:24:49 +01:00
maziggy d6dcc7656d Fix auth mock in tests
Add missing /api/v1/auth/status mock to MSW handlers to prevent
network errors during frontend tests
2026-01-27 11:23:23 +01:00
maziggy cdf52a6a28 Added stale issues workflow 2026-01-27 11:14:48 +01:00
maziggy c196ae017a Fix plate detection calibration persistence
- Check cv2.imwrite() return value to catch silent failures
- Verify reference image file exists after save
- Validate file size is reasonable (>1KB) to detect corruption
- Add logging for save, rotate, and delete operations
- Use temp directory for plate calibration during tests to avoid
  deleting real user calibration files

Previously, calibration could report success even if the image file
failed to save. Additionally, running tests would delete real
calibration files because tests shared the same plate_calibration_dir.
2026-01-27 10:38:44 +01:00
maziggy db236f0aa7 Improved cv2.imwrite for build plate empty detection 2026-01-27 10:14:39 +01:00
maziggy e57fb87a52 Add queue bulk editing and fix milestone time display
New Features:
- Queue bulk edit: Select multiple pending items and edit printer
  assignment, print options, or cancel them at once (Issue #159)
- Tri-state toggles (unchanged/on/off) for selective field updates

Fixes:
- Progress milestone notifications showed wrong time (e.g., "17m" instead
  of "17h 47m") - fixed by converting remaining_time from minutes to
  seconds (Issue #157)
- File Manager folder names now show full name on hover tooltip (Issue #160)

Backend:
- Added PATCH /queue/bulk endpoint for bulk updates
- Route ordering fixed to prevent /bulk matching as /{item_id}

Frontend:
- Added checkbox selection to pending queue items
- Added bulk action toolbar with Select All, Edit Selected, Cancel Selected
- Created BulkEditModal with tri-state toggles for each setting

Tests:
- Added 7 integration tests for bulk update endpoint

Closes #159
2026-01-27 09:35:28 +01:00
maziggy 60d9505c0d Add tooltip for truncated folder names in File Manager
Long folder names are truncated to prevent layout issues. Added title
attribute so users can hover to see the full folder name.

Fixes #160
2026-01-27 09:07:18 +01:00
maziggy d0cc282d3e Allow folder names to wrap in File Manager navigation
Long folder names were truncated with ellipsis. Now they wrap onto
multiple lines and show full name on hover tooltip.

Closes #160
2026-01-27 09:04:20 +01:00
maziggy 2e03fca2df Fix progress milestone notification showing wrong time unit
The remaining_time from printer state is in minutes (from mc_remaining_time),
but _format_duration() expects seconds. This caused "17h 47m" to display as
"17m" in milestone notifications.

Closes #157
2026-01-27 08:53:48 +01:00
maziggy b9495877fc Add HMS error notifications with translations and plate detection fixes
New Features:
- HMS error notifications with human-readable messages (853 error codes)
- Plate not empty notification category (separate toggle in settings)
- Module-friendly names: Print/Task, AMS/Filament, Nozzle/Extruder, etc.
- Backup/restore now includes plate calibration reference images

Fixes:
- Plate calibration images now persist after restart in Docker
- Telegram notifications no longer fail on error codes with underscores
- Plate detection combo button: main toggles detection, chevron opens modal

Tests:
- Added HMS error code tests (10 tests)
- Implemented Dashboard, FileManagerModal, UploadModal tests (previously skipped)
- Added notification service tests for HMS errors and plate detection
- Fixed AuthContext unmount memory leak in tests
2026-01-27 08:48:57 +01:00
maziggy 9d6164ab1c Add USB camera support (V4L2)
- Add USB camera type to external camera service
- Auto-detect available V4L2 devices on Linux
- New API endpoint: GET /api/v1/printers/usb-cameras
- Use ffmpeg for USB camera capture and streaming
- Add "USB Camera (V4L2)" option in Settings UI
- Debounce camera URL input to avoid saving on every keystroke

Closes #143
2026-01-27 06:40:14 +01:00
maziggy 82be877843 Fixed CI 2026-01-26 15:52:23 +01:00
maziggy c9b3263381 Updated .gitignore 2026-01-26 15:04:15 +01:00
maziggy 274a398bbf Added missing dependency test and warning on app startup 2026-01-26 14:54:26 +01:00
maziggy afe7ddeb72 Added missing dependency test and warning on app startup 2026-01-26 14:52:46 +01:00
maziggy 2d3437f68e Added missing dependency test and warning on app startup 2026-01-26 14:49:52 +01:00
maziggy d575e060fa Added missing dependency test and warning on app startup 2026-01-26 14:46:20 +01:00
MartinNYHC 4ff9378a6b Merge pull request #158 from maziggy/feature/empty_plate_detection
Add build plate empty detection feature
2026-01-26 14:38:19 +01:00
maziggy 6b0e3e7964 Replace python-jose with PyJWT to eliminate ecdsa vulnerability 2026-01-26 13:24:15 +01:00
maziggy 4b2d8b51e0 Add security scanning to CI pipeline
- Add pip-audit check to PR workflow (non-blocking warning)
- Add npm audit check to PR workflow (non-blocking, high severity only)
- Create scheduled weekly security audit workflow that:
  - Runs strict pip-audit and npm audit
  - Creates/updates GitHub issues when vulnerabilities found
  - Uploads audit results as artifacts
  - Supports manual trigger via workflow_dispatch
2026-01-26 13:20:33 +01:00
maziggy c7458fc73f Add security scanning to CI pipeline
- Add pip-audit check to PR workflow (non-blocking warning)
- Add npm audit check to PR workflow (non-blocking warning)
- Create scheduled weekly security audit workflow that:
  - Runs strict pip-audit and npm audit
  - Creates/updates GitHub issues when vulnerabilities found
  - Uploads audit results as artifacts
  - Supports manual trigger via workflow_dispatch
2026-01-26 13:17:43 +01:00
maziggy 888891fdc6 Add build plate empty detection feature
Automatically detect if objects are on the build plate before printing
and pause the print immediately if detected.

Features:
- Per-printer toggle to enable/disable plate detection
- Multi-reference calibration: store up to 5 reference images per printer
  for different plate types (textured, smooth, high-temp, etc.)
- Automatic print pause when objects detected at print start
- Push notification and WebSocket alert when print is paused
- ROI (Region of Interest) calibration UI with sliders to adjust
  detection area
- Reference management: view thumbnails, add labels, delete references
- Works with both built-in and external cameras
- Uses buffered camera frames when stream is active (no blocking)
- Split button UI: main button opens modal, chevron toggles on/off
- Green visual indicator when plate detection is enabled
- Included in backup/restore
2026-01-26 13:04:29 +01:00
maziggy d34816e2c7 Fix progress milestone notifications not triggering (Issue #157)
The on_print_progress notification method existed but was never called.
Added milestone tracking in on_printer_status_change that:
- Tracks last notified milestone per printer
- Detects when progress crosses 25%, 50%, 75% thresholds
- Sends notification via notification_service.on_print_progress()
- Resets tracking when progress drops below 5% (new print)

Closes #157
2026-01-26 10:08:03 +01:00
maziggy bb7e8398bc Completely removed telemetry 2026-01-26 09:34:04 +01:00
maziggy d3ebbe503c Minor frontend test fixes 2026-01-26 09:22:06 +01:00
maziggy 97238644a0 Added missing database migrations 2026-01-26 09:19:28 +01:00
maziggy caf3f3ae0a Minor frontend fixes 2026-01-26 09:11:15 +01:00
maziggy 93e2f0af82 Minor frontend fixes 2026-01-26 09:09:58 +01:00
maziggy 3a3f6a1845 Settings API PATCH Method
- Added PATCH support to `/api/settings` for Home Assistant rest_command compatibility

Closes #152
2026-01-25 13:43:47 +01:00
maziggy ec3c47f048 Fix P2S empty archive tiles - add root folder to FTP search paths (Issue #146)
Printers without an SD card store files in the root folder `/` instead of
`/cache`. Added root folder to search paths in both main.py and bambu_ftp.py
so 3MF files can be found regardless of storage configuration.

Closes #146
2026-01-25 13:33:51 +01:00
maziggy 30537cfa54 Add project import/export with ZIP file support
Features:
- Export single project as ZIP containing project.json and all files
  from linked library folders
- Export all projects as JSON (metadata only) for bulk backup
- Import from ZIP (creates folders and extracts files) or JSON
- New /api/v1/projects/import/file endpoint for file uploads
- Frontend buttons on Projects page and Project Detail page
- BOM items are now fully editable (not just checkbox toggle)
2026-01-25 13:17:15 +01:00
maziggy 9034121bd5 Added scripts/update_archive_date.py 2026-01-25 11:58:09 +01:00
maziggy 4266049e0c Fix empty AMS slot not recognized (Issue #147)
When spools were removed from AMS slots, Bambuddy continued showing them
as loaded. Fixed for both old and new AMS models:

- Old AMS: Allow empty values to overwrite slot data during merge
  (tray_type, tray_color, tag_uid, etc. were being skipped)
- New AMS (AMS 2 Pro): Parse tray_exist_bits bitmask to detect empty
  slots and clear their data accordingly

Added 3 unit tests for AMS data merging behavior.

Closes #147
2026-01-25 07:07:36 +01:00
maziggy 6bc1ce8693 Add external link field for archives (Issue #151)
Allow users to manually set external URLs for archives from Printables,
Thingiverse, or other sources. The Globe button now opens the external
link when set, falling back to auto-detected MakerWorld URL.

- Add external_url field to PrintArchive model with migration
- Add input field to archive edit modal
- Update Globe button: external_url > makerworld_url > disabled
- Include external_url in backup/restore
- Add API test for external_url update
- Update docs (changelog, wiki, website)

Closes #151
2026-01-25 06:47:55 +01:00
maziggy 2669eabe2b Fixed bug where file manager's upload dialog only allowed zip files for selection 2026-01-24 11:21:56 +01:00
maziggy 691fb133b7 Add external network camera support for printers
Add support for external network cameras (MJPEG, RTSP, HTTP snapshot)
that replace a printer's built-in camera when configured.

Features:
- Live streaming on printers page (replaces built-in camera)
- Finish photo capture from external camera on print complete
- Layer-based timelapse: captures frame on each layer change,
  stitches to MP4 video on print completion

Backend changes:
- Add external_camera_url, external_camera_type, external_camera_enabled
  fields to Printer model with database migration
- New external_camera.py service: MJPEG/RTSP/snapshot frame capture,
  connection testing, MJPEG stream generation
- New layer_timelapse.py service: TimelapseSession management,
  layer-by-layer frame capture, ffmpeg video stitching
- Add on_layer_change callback to MQTT client and printer manager
- Update camera routes with external camera streaming and tracking
- Update print lifecycle hooks for timelapse start/stitch/cancel
- Add external camera fields to backup/restore
- Rate limiting for external camera streams (prevents browser freeze)

Frontend changes:
- Add external camera configuration UI in Settings > Camera
- Per-printer enable toggle, URL input, type selector, test button
- Toast notification on save

Closes #143
2026-01-24 09:58:45 +01:00
maziggy e0e53cb680 Add multi-file selection and bulk download to printer file browser
- Add checkbox selection for individual files
- Add Select All / Deselect All buttons
- Download single file directly, multiple files as ZIP archive
- Add POST /printers/{id}/files/download-zip endpoint
- Clear selection after successful download
- Support bulk delete for multiple files
- Update docs (changelog, wiki, website)

Closes #144
2026-01-24 08:28:03 +01:00
maziggy 8ba04dfa89 Add ZIP folder creation option and improve camera zoom/pan (#121, #132)
File Manager improvements (#121):
- New option to create folder from ZIP filename (e.g., MyProject.zip → MyProject/)
- Upload modal now accepts all file types, not just ZIP files
- Updated drop zone text to clarify all files are supported
- Both options can be combined: create folder + preserve internal structure

Camera zoom/pan improvements (#132):
- Pan range now based on actual container size instead of fixed pixels
- Users can pan across the entire zoomed image at any zoom level
- Added pinch-to-zoom gesture for mobile (two fingers)
- Added single finger pan when zoomed in on touch devices
- Pan while pinching to reposition zoom focus
- Both EmbeddedCameraViewer and standalone CameraPage updated
2026-01-24 08:13:20 +01:00
maziggy 721eab1f67 Fix HA energy sensors not detected due to case-sensitive unit matching
Home Assistant integrations may report units in different cases (e.g., "w"
instead of "W", "kwh" instead of "kWh"). The sensor entity filter was using
case-sensitive comparison, causing valid energy sensors to not appear in
the Energy Monitoring dropdown.

Changed unit comparison to case-insensitive matching in list_sensor_entities().

Closes #119
2026-01-24 07:39:48 +01:00
maziggy d56206cbac Fix empty archive tiles on P2S printer
P2S printer creates fallback archives without thumbnails/metadata because
FTP couldn't find 3MF files. The P2S uses different directory structure
(/data/Metadata/) and doesn't have a /cache directory.

Changes:
- Add P2S to SKIP_SESSION_REUSE_MODELS for SSL compatibility
- Add /data/ and /data/Metadata/ to 3MF download paths
- Update fallback search to try multiple directories instead of just /cache
- Add /data paths to FTP storage scan directories

Closes #146
2026-01-24 07:33:01 +01:00
maziggy bda659e11d Fix status indicators using accent color instead of semantic colors
Status badges (Connected/Offline, HMS errors, maintenance, success/failed)
were using bambu-green which follows the user's accent color theme. This
caused confusing UX - e.g., "Connected" appearing red with a red accent.

Added fixed semantic status colors that never change with theme:
- status-ok: #22c55e (green) - success, online, OK states
- status-error: #ef4444 (red) - failed, offline, error states
- status-warning: #f59e0b (amber) - warnings, pending states

Updated components:
- PrintersPage: connection badge, HMS errors, maintenance, WiFi signal
- SmartPlugCard/SwitchbarPopover: plug connectivity status
- StatsPage: success/failed counts, failure rate, time accuracy
- QueuePage: queue item statuses (pending, completed, failed)
- ArchivesPage: failed/aborted archive badge
- ProjectDetailPage: child status, timeline events, BOM checklist
- CompareArchivesModal: archive completion status
- NotificationProviderCard: last success/error status

Closes #136
2026-01-24 07:25:35 +01:00
maziggy 5672d7965a Add recalculate costs button and reprint cost tracking
- Add "Recalculate Costs" button to Dashboard that updates all archive
  costs using current filament prices (Issue #120)
- Track reprints and add cost to existing archive total on completion,
  so statistics accurately reflect total filament expenditure

Closes #120
2026-01-24 07:05:15 +01:00
maziggy 40c672b1b9 Changed version 2026-01-23 17:57:07 +01:00