upadate
This commit is contained in:
+10
-2
@@ -913,10 +913,18 @@ def getLib():
|
||||
@app.route('/api/component/<component_name>')
|
||||
@login_required_json
|
||||
def getComp(component_name):
|
||||
"""Return component YAML data."""
|
||||
data = readCompYaml(component_name, pdk_root_for_request_project())
|
||||
"""Return component YAML data with injected category."""
|
||||
comps_root = pdk_root_for_request_project()
|
||||
data = readCompYaml(component_name, comps_root)
|
||||
if data is None:
|
||||
return jsonify({"error": "Component not found"}), 404
|
||||
# Derive the category (parent folder name) for icon resolution on the canvas.
|
||||
if isinstance(data, dict) and '__category__' not in data:
|
||||
search_root = comps_root or current_pdk_root()
|
||||
for root, dirs, files in os.walk(search_root):
|
||||
if os.path.basename(root) == component_name:
|
||||
data['__category__'] = os.path.basename(os.path.dirname(root))
|
||||
break
|
||||
return jsonify(data)
|
||||
|
||||
@app.route('/api/component/<component_name>/image')
|
||||
|
||||
Reference in New Issue
Block a user