Files
2025-12-02 16:27:21 +00:00

39 lines
1.2 KiB
Python

#!/usr/bin/env python3
import json
with open('/home/mdares/.node-red/flows.json', 'r') as f:
flows = json.load(f)
# selectRange function
select_range_func = '''
// Filter range selection
scope.currentFilter = '24h'; // Default filter
scope.selectRange = function(range) {
scope.currentFilter = range;
scope.refreshGraphData();
};
'''
for node in flows:
if node.get('id') == 'f3a4b5c6d7e8f9a0':
template = node.get('format', '')
if 'scope.selectRange' in template:
print("✓ selectRange function already exists")
else:
# Add before refreshGraphData function (which we added earlier)
if 'scope.refreshGraphData' in template:
insert_pos = template.find('scope.refreshGraphData')
template = template[:insert_pos] + select_range_func + '\n ' + template[insert_pos:]
node['format'] = template
print("✓ Added selectRange function")
else:
print("✗ Could not find refreshGraphData to insert before")
break
with open('/home/mdares/.node-red/flows.json', 'w') as f:
json.dump(flows, f, indent=4)
print("✓ flows.json updated")