diff --git a/src/nenuscanner/routes/camera.py b/src/nenuscanner/routes/camera.py index c9c0f19..152527b 100644 --- a/src/nenuscanner/routes/camera.py +++ b/src/nenuscanner/routes/camera.py @@ -14,40 +14,11 @@ def get(): Returns the page showing camera configuration for all parameters in capturesettings and imgsettings, grouped by section. """ - # Load configCamera.json - with open('configCamera.json', 'r') as f: - config = json.load(f) + - grouped_params = [] - for section in ['capturesettings', 'imgsettings']: - section_params = [] - settings = config['main'].get(section, {}) - for param_name, param in settings.items(): - if 'Choices' in param and isinstance(param['Choices'], list) and param['Choices']: - choices = [ - {'value': c.get('id', idx), 'label': c['label']} - for idx, c in enumerate(param['Choices']) - ] - if len(choices) > 1: - section_params.append({ - 'name': param_name, - 'label': param.get('Label', param_name.capitalize()), - 'choices': choices, - 'current': param.get('Current', '') - }) - if section_params: - grouped_params.append({ - 'section': section, - 'params': section_params - }) - - import pprint - pprint.pprint(grouped_params) - + return render_template( - 'camera.html', - grouped_params=grouped_params - ) + 'camera.html') @blueprint.route('/set', methods=['POST']) @@ -68,6 +39,8 @@ def camera_feed(): return send_file('static/feed.jpg', mimetype='image/jpeg') + + @blueprint.route('/config', methods=['GET']) def get_camera_config(): """ @@ -77,27 +50,30 @@ def get_camera_config(): config = json.load(f) grouped_params = [] - for section in ['capturesettings', 'imgsettings']: + # Iterate over all sections in config['main'] + for section, settings in config['main'].items(): section_params = [] - settings = config['main'].get(section, {}) - for param_name, param in settings.items(): - if 'Choices' in param and isinstance(param['Choices'], list) and param['Choices']: - choices = [ - {'value': c.get('id', idx), 'label': c['label']} - for idx, c in enumerate(param['Choices']) - ] - if len(choices) > 1: + if isinstance(settings, dict): + for param_name, param in settings.items(): + if 'Choices' in param and isinstance(param['Choices'], list) and param['Choices']: + choices = [ + {'value': c.get('id', idx), 'label': c['label']} + for idx, c in enumerate(param['Choices']) + ] + section_params.append({ - 'name': param_name, - 'label': param.get('Label', param_name.capitalize()), - 'choices': choices, - 'current': param.get('Current', '') + 'name': param_name, + 'label': param.get('Label', param_name.capitalize()), + 'choices': choices, + 'current': param.get('Current', ''), + 'Type': param.get('Type', 'Text'), + 'Readonly': param.get('Readonly', 0) }) + if section_params: grouped_params.append({ 'section': section, 'params': section_params }) - return jsonify(grouped_params) - + return jsonify(grouped_params) \ No newline at end of file diff --git a/src/nenuscanner/templates/camera.html b/src/nenuscanner/templates/camera.html index 898e8c4..5d3b6f6 100644 --- a/src/nenuscanner/templates/camera.html +++ b/src/nenuscanner/templates/camera.html @@ -10,12 +10,29 @@
+ {#
Camera Preview
+ #} + + +