52 lines
1.9 KiB
Python
52 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
import json
|
|
|
|
# Read flows.json
|
|
with open('/home/mdares/.node-red/flows.json', 'r') as f:
|
|
flows = json.load(f)
|
|
|
|
# Find Stop Reason UI and Work Order buttons nodes
|
|
stop_reason_ui_node = None
|
|
work_order_buttons_id = '9bbd4fade968036d'
|
|
|
|
for node in flows:
|
|
if node.get('id') == '94afa68639264697':
|
|
stop_reason_ui_node = node
|
|
break
|
|
|
|
if stop_reason_ui_node:
|
|
print(f"Found Stop Reason UI node: {stop_reason_ui_node['id']}")
|
|
print(f"Current output wiring: {stop_reason_ui_node.get('wires', [])}")
|
|
|
|
# Wire output to Work Order buttons
|
|
stop_reason_ui_node['wires'] = [[work_order_buttons_id]]
|
|
|
|
print(f"\n✅ Fixed Stop Reason UI output wiring:")
|
|
print(f" - Now wired to: Work Order buttons ({work_order_buttons_id})")
|
|
print(f" - This completes the loop: STOP → Switch → Stop Reason UI → Work Order buttons")
|
|
else:
|
|
print("❌ ERROR: Could not find Stop Reason UI node")
|
|
exit(1)
|
|
|
|
# Write updated flows
|
|
with open('/home/mdares/.node-red/flows.json', 'w') as f:
|
|
json.dump(flows, f, indent=4)
|
|
|
|
print("\n" + "="*60)
|
|
print("✅ PRIORITY 1 COMPLETE: Stop Prompt Wiring Fixed")
|
|
print("="*60)
|
|
print("\n📋 Complete Flow:")
|
|
print(" 1. User clicks STOP → Work Order buttons (action: 'stop')")
|
|
print(" 2. Work Order buttons sets _mode='stop-prompt' → output 2")
|
|
print(" 3. Switch node routes to Stop Reason UI")
|
|
print(" 4. User selects reason → Stop Reason UI")
|
|
print(" 5. Stop Reason UI sends action='stop-reason' → Work Order buttons")
|
|
print(" 6. Work Order buttons processes and disables tracking")
|
|
print("\n🧪 Ready to test:")
|
|
print(" 1. Restart Node-RED: sudo systemctl restart nodered")
|
|
print(" 2. Start a work order")
|
|
print(" 3. Click STOP button")
|
|
print(" 4. Modal should appear with stop reason options")
|
|
print(" 5. Select a reason and submit")
|
|
print(" 6. Tracking should be disabled")
|