Skip to content

Conversation

@Q1WP
Copy link
Contributor

@Q1WP Q1WP commented Dec 29, 2025

Source Branch: feature/macros-and-service-tracking
Base Version: 2.0.7

Summary

Two major feature additions: enhanced macro management system with tabbed organization and a comprehensive machine service/maintenance tracking system.

GitHub Issues Addressed

Issue Description
#344 Maintenance minder
#271 Maintenance log and periodic task scheduling

Macro System Enhancements

Tabbed Organization

Macros can be organized into custom tabs for logical grouping:

  • Setup macros (homing, probing)
  • Tool change macros
  • Utility macros

Configuration:

{
  "macro_tabs": [
    {"id": "setup", "name": "Setup"},
    {"id": "tools", "name": "Tools"}
  ],
  "macros": [
    {"name": "Home All", "path": "home.ngc", "tab": "setup"},
    {"name": "Tool 1", "path": "tool1.ngc", "tab": "tools"}
  ]
}

Visibility Control

Individual macros can be hidden from the control page without deletion:

{"name": "Debug", "path": "debug.ngc", "visible": false}

Hidden macros remain configured and can be re-enabled at any time.

Confirmation Dialogs

Macros show confirmation before execution (default: enabled):

{"name": "Probe", "path": "probe.ngc", "confirm": true}

Disable for frequently-used safe macros:

{"name": "Spindle On", "path": "spindle.ngc", "confirm": false}

Skip Reference Check

Homing macros need to run without position reference (since they establish it):

{"name": "Home All", "path": "home.ngc", "skip_reference_check": true}

Color Coding

Custom button colors for visual organization:

{"name": "E-Stop Reset", "path": "reset.ngc", "color": "#ff6666"}

Drag-and-Drop Reordering

Macros can be reordered by dragging in the configuration interface.

Dedicated Configuration Page

New #macros route with three sub-views:

View Purpose
Macros Configure name, file, color, visibility, tab assignment
Tabs Create, rename, delete, reorder macro tabs
Safety Configure confirmation and reference-check bypass per macro

Service Tracking System

Professional CNC machines require scheduled maintenance: spindle bearing lubrication, way oil changes, belt inspections. This system tracks machine hours and reminds operators when service is due.

Automatic Hour Tracking

Metric Description
Power Hours Total time controller is powered on
Motion Hours Time spent actively moving axes

Backend increments counters automatically while the controller runs.

Service Items

Each service item tracks:

  • Name and description
  • Interval (hours or days)
  • Interval type (power_hours, motion_hours, days)
  • Next due threshold
  • Completion history with timestamps

Alert Integration:

  • Due items trigger header banner alert
  • Session-dismissable (reappears when new items come due)
  • Links to Service page for details

Completion Logging

When service is performed:

  • Mark item complete with one click
  • Timestamp recorded automatically
  • Next due date/hours recalculated
  • History preserved for maintenance records

Machine Notes

Free-form notes storage for:

  • Machine specifications and serial numbers
  • Supplier contacts
  • Configuration history
  • Troubleshooting notes and quirks

Files Added

File Purpose
src/py/bbctrl/Service.py Service tracking backend
src/py/bbctrl/ServiceHandler.py Service REST API endpoints
src/resources/service-template.json Default service configuration
src/js/view-macros.js Macro configuration page
src/js/view-service.js Service tracking page
src/pug/templates/view-macros.pug Macro configuration template
src/pug/templates/view-service.pug Service tracking template
src/stylus/view-macros.styl Macro page styling
src/stylus/view-service.styl Service page styling

Files Modified

File Changes
src/py/bbctrl/Config.py Macro configuration schema, tab support
src/py/bbctrl/State.py Hour tracking updates
src/py/bbctrl/Ctrl.py Service initialization
src/py/bbctrl/Web.py Service routes
src/js/view-control.js Tab filtering, visibility, confirmation handling
src/pug/templates/view-control.pug Tab UI, macro buttons
src/pug/index.pug Navigation links, service alert
src/stylus/macros.styl Tab and button styling
src/stylus/style.styl Alert styling
src/resources/config-template.json Macro and service schemas

Q1WP added 27 commits December 3, 2025 14:56
Macro Enhancements:
- Add dedicated Macros page with top-level menu item
- Implement tab system for organizing macros into groups
- Add visibility toggle to show/hide macros on control page
- Add confirmation dialog option before running macros
- Display macro tabs as clickable tab bar on control page
- Settings tab appears in tab bar linking to Macros page

Service Tracking:
- Add dedicated Service page with dashboard, items, and notes views
- Track power-on, spindle, and motion hours automatically
- Support configurable maintenance intervals per hour type
- Display service warning banner on control page when items are due
- Add service completion history and manual hour entry
- Include export functionality for service data

Control Page:
- Macro tab bar now always visible with Settings tab on right
- Service warning banner shows count of due maintenance items
Service Page Navbar:
- Add Login button for unauthenticated users (far right)
- Add Save button that appears when changes are pending
- Add "Saved" status indicator when no pending changes
- Use spacer to push action buttons to far right

Dirty Form Tracking:
- Track modified state for item and note editors
- Show confirmation dialog when navigating away with unsaved changes
- Add Cancel button confirmation to prevent accidental data loss
- Implement markModified(), clearModified(), checkUnsavedChanges() helpers

Service Items Layout:
- Move status badge (duration) next to label instead of far right
- Relocate action buttons to vertical column on right side of card
- Add visual separator between content and actions
- Complete button now always visible (not just when due)

Dashboard Upcoming List:
- Display duration inline with label using pill-style badge
- Keep interval info on right as secondary information
- Improve visual grouping of related information

Form Fixes:
- Fix input overflow in Add Item editor using flexbox rows
- Remove non-functional .small class from button elements
- Apply button sizing via container CSS instead
Macro List Layout:
- Restructure as two-row records for better readability
- Row 1: drag grip, index, visibility, confirm, tab, color, delete
- Row 2: name and file inputs (indented to align with content)
- Move drag handle to far left of each row
- Simplify index display (remove "#", lighter weight)
- Align header text with column centers

Delete Confirmations:
- Add confirmation dialog before deleting macros
- Add confirmation dialog before deleting tabs
- Tab deletion shows count of macros that will be moved

Styling:
- Consistent column widths between header and rows
- Uppercase labels for Name/File fields
- Improved visual hierarchy with row grouping
Navbar Styling:
- Switch both Service and Macros pages to dark navbar (buildbotics#333 background)
- Consistent styling with light text and hover effects

Service Items:
- Move action buttons to single row below item content
- Add text labels to all buttons (Mark Complete, Edit, Delete)
- Change color bar from vertical left to horizontal top

Service Item Editor:
- Label field on full-width row
- Track By, Interval, and Color on second row
- Normalize input heights to 38px

Macros Layout:
- Add spacer column to push Color and Trash to far right
- Widen color picker area for better hex input display
- Move trash icon to far right column

Macros Navbar:
- Add button changes contextually (Add Macro vs Add Tab)
- Remove redundant Add Tab button from Tabs content area
Service Page:
- Move Add Item and Add Note buttons to navbar (context-sensitive)
- Notes card layout matches Items (buttons on bottom row)
- Add text labels to note Edit/Delete buttons
- Remove Add buttons from content areas

Macros Page:
- Column order: Grip, Index, Visible, Confirm, Tab, Color, [spacer], Trash
- Color picker positioned after Tab dropdown (not pushed far right)
- Trash icon pushed to far right via spacer
- Grip icon enlarged (16px, darker color)
- Hex input height/padding/font matches file input exactly

Consistency:
- Both pages use navbar for context-sensitive Add buttons
- Both pages have dark navbar with summary/metrics bar below
- Action button rows have consistent styling across Items and Notes
System Alerts:
- Add alerts section below header for upgrade and service notifications
- Upgrade alert: Shows when new firmware available with link to settings
- Service alert: Shows count of due items with link to service page
- Both alerts are dismissible (X button)
- Dismissals stored in sessionStorage (reset on browser close)
- Dismissal resets when upgrade version changes or new items become due

Camera Visibility:
- Add camera_available to state from Python backend
- Hide camera menu item when camera not available
- Hide camera video preview in header when not available
- Works on all screen sizes (not just mobile)

Files Changed:
- src/pug/index.pug - Add alerts section, conditional camera visibility
- src/js/app.js - Add alert computed properties and dismiss methods
- src/stylus/style.styl - Add alert styling (warning/info colors)
- src/py/bbctrl/State.py - Add camera_available to state snapshot
Macros View Changes:
- Reverted to single row layout (cleaner, less busy)
- All columns on one row: Grip, #, Visible, Confirm, Tab, Color, Name, File, Actions
- Better column spacing and alignment
- Headers centered over column content
- Tab select and Color picker have more spacing between them
- Name and File fields back on same row as other columns
- Folder and Trash icons together in actions column on right
- Hex input styled consistently (28px height, 0.85em font)

Service Tracking - Remove Spindle Hours:
- Removed spindle_hours from Service.py (not all users have machine-controlled spindles)
- Removed spindle tracking from State.py (no more spindle_started/spindle_stopped)
- Updated service-template.json (removed spindle_hours from hours section)
- Updated view-service.pug (removed Spindle from hours bar)
- Updated view-service.js (removed spindleHours computed, hourTypes, labels)
- Service items can now only track: Power-On Hours or Motion Hours

Files Changed:
- src/pug/templates/view-macros.pug - Single row layout
- src/stylus/view-macros.styl - Updated column styles
- src/pug/templates/view-service.pug - Removed spindle hours display
- src/js/view-service.js - Removed spindle computed/methods
- src/py/bbctrl/Service.py - Removed spindle tracking
- src/py/bbctrl/State.py - Removed spindle state tracking
- src/resources/service-template.json - Removed spindle_hours
Macros View Changes:
- Reverted to single row layout (cleaner, less busy)
- All columns on one row: Grip, #, Visible, Confirm, Tab, Color, Name, File, Actions
- Better column spacing and alignment
- Headers centered over column content
- Tab select and Color picker have more spacing between them
- Name and File fields back on same row as other columns
- Folder and Trash icons together in actions column on right
- Hex input styled consistently (28px height, 0.85em font)

Service Tracking - Remove Spindle Hours:
- Removed spindle_hours from Service.py (not all users have machine-controlled spindles)
- Removed spindle tracking from State.py (no more spindle state tracking)
- Updated service-template.json (removed spindle_hours from hours section)
- Updated view-service.pug (removed Spindle from hours bar)
- Updated view-service.js (removed spindleHours computed, hourTypes, labels)
- Service items can now only track: Power-On Hours or Motion Hours

Files Changed:
- src/pug/templates/view-macros.pug - Single row layout
- src/stylus/view-macros.styl - Updated column styles
- src/pug/templates/view-service.pug - Removed spindle hours display
- src/js/view-service.js - Removed spindle computed/methods
- src/py/bbctrl/Service.py - Removed all spindle tracking
- src/py/bbctrl/State.py - Removed spindle state tracking
- src/resources/service-template.json - Removed spindle_hours
Macros View:
- Single row layout with tighter column spacing
- Columns: grip, #, eye, warn, tab, color, name, file, actions
- Proper gaps between tab/color (16px), color/name/file (10px)
- File margin-right 12px prevents folder icon overlap
- Tab dropdown 100px wide to prevent text cutoff
- All inputs use default font size

Service Tracking:
- Removed spindle_hours (not all users have machine-controlled spindles)
- Service items track only: Power-On Hours or Motion Hours
- Updated Service.py, State.py, view-service.js, service-template.json
Motion Timer:
- State.py update() now tracks 'xx' state transitions
- Calls program_started() when entering RUNNING state
- Calls program_stopped() when leaving RUNNING state
- Fixes motion hours not being recorded

Macros Table Spacing:
- Hex input: normal height (28px), no font-size override
- col-color: width 100px, gap 0.35em between swatch and input
- col-name: margin-left 16px (was 10px)
- col-file: margin-left 16px, input has margin-right 8px
- Prevents folder icon overlap with filename input
- Consistent 16px gaps between color/name/file columns
- Hex color input: added font-size inherit for normal text size
- Increased margin-left on col-file from 16px to 20px for name/file separation
- Updated header to match
- Hex input: font-size 14px (explicit, matches other inputs)
- col-name: margin-left 24px (was 16px)
- col-file: margin-left 24px (was 20px)
- Consistent gaps between hex→name and name→file columns
- Updated both header and row sections to match
Adjusted column margins and removed explicit font-size overrides
to achieve consistent visual spacing between input fields.
- Restored font-size declaration for hex color input
- Fine-tuned col-name margin-left for better visual balance
Vue 1.x requires reactive properties to be defined at initialization.
The service_due_count was being sent from backend but Vue couldn't
detect changes because the property wasn't in the initial state object.

- Add service_due_count: 0 to initial state in app.js line 50
Fix service alert not appearing in header

- Add service_due_count: 0 to initial state in app.js (Vue reactivity)
- Push service_due_count via websocket in State.py update_service()

The service_due_count was only in snapshot() for API calls, but never
pushed to websocket clients via set().
Alert fixes:
- Add gap, margin, and rounded corners to system alerts
- Remove duplicate service-warning-banner from control page
- Header alert now handles service notifications site-wide

Dashboard removal:
- Remove Dashboard tab from service navigation
- Make Items the default service view
- Remove dashboard section from view-service.pug
- Remove dashboard-only styling (due-items-section, no-due-items,
  stats-section, upcoming-list)
- Remove unused serviceDueCount computed and warning banner styling

Service now matches Macros pattern: direct content, no landing page.
Service item colors were adding complexity without clear benefit. The due/overdue state is the meaningful visual indicator, and user-selected colors could conflict with the red "due" indicator.

Changes:

* Removed 'color' field from service-template.json schema
* Removed color picker from service item editor in view-service.pug
* Removed item-color-bar element, replaced with simple top border
* Removed color-related code from view-service.js
* Simplified view-service.styl - items now use gray top border (default) that turns red when due
* Removed 'color' parameter from Service.py add_item() and update_item()
* Removed 'color' from _get_item_defaults() in Service.py

UI Behavior:

* All service items now have a consistent gray top border
* When an item is due, the entire border turns red for clear visibility
* This creates better contrast and clearer visual hierarchy

Files Modified:

* src/resources/service-template.json: Removed color field from items template
* src/pug/templates/view-service.pug: Removed color picker and color bar
* src/js/view-service.js: Removed color-related code
* src/stylus/view-service.styl: Simplified item styling
* src/py/bbctrl/Service.py: Removed color handling
Add a dedicated settings page for macro safety options, consolidating
safety-critical settings separate from cosmetic macro configuration.

The page provides a clear table view of all macros with their safety
settings:
- Confirm: whether to show confirmation dialog before running
- Skip Reference Check: whether macro can run without position reference

Navigation updated: Settings → Macros now shows dropdown menu with
"Configuration" (existing page) and "Safety" (new page) options.

This is the UI counterpart to the skip_reference_check backend logic
in bugfixes-complete. Together they allow homing macros to bypass
the position reference safety check while keeping other macros protected.

- Add settings-macros-safety.pug template
- Add settings-macros-safety.js Vue component
- Update view-settings.pug navigation to dropdown
- Register component in view-settings.js
- Add skip_reference_check to config template
- Add safety page styles to macros.styl
- Add Safety tab to Macros page navbar (Macros | Tabs | Safety)
- Remove Macros dropdown from Settings menu entirely
- Safety tab shows checkboxes first (Confirm, Skip Reference Check)
  to match Macros tab layout pattern
- Delete obsolete settings-macros and settings-macros-safety components

Safety settings now accessible at #macros:safety instead of
#settings:macros-safety
- Remove Macros dropdown from Settings navbar entirely
  Macros now managed exclusively from standalone Macros page
- Delete obsolete settings-macros and settings-macros-safety components
- Increase checkbox size to 1.3em on Macros tab (visible/confirm columns)
- Increase checkbox size to 1.3em on Safety tab (confirm/bypass columns)
- Update column widths from 24px to 32px for larger checkboxes

Files to DELETE:
- src/pug/templates/settings-macros.pug
- src/pug/templates/settings-macros-safety.pug
- src/js/settings-macros.js
- src/js/settings-macros-safety.js
Vue prop type warning when macro has no name - the fallback
(macro.originalIndex + 1) returns Number but component expects String.

Wrap in String() to satisfy prop type check.
Macro button text prop expects String. When macro.name is empty, the
fallback (macro.originalIndex + 1) returns Number.

Use '' + concatenation instead of String() - Vue 1.x templates run in
component scope without access to global constructors.
The confirm checkbox was moved to the Safety tab but not removed from the
main Macros tab. This commit removes the duplicate column.

Changes:
- Remove .col-confirm from macro-header in view-macros.pug
- Remove .col-confirm checkbox from macro-row in view-macros.pug
- Remove .col-confirm styling from macro-header in view-macros.styl
- Remove .col-confirm styling from macro-row in view-macros.styl
- Update help text to reference Safety tab for confirmation settings
- Update intro text to remove "confirmation options" mention
- Planner.py: Add hasattr check for get_modal_state()
  - Backwards compatible with old camotics.so
  - Silently skips if method doesn't exist
- Config.py: Fix undefined 'macro_id' variable (was i + 1)
- FileSystem.py: Remove noisy warning for missing macro sources
  - Expected behavior for existing configs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant