fix: resolve Jinja2 template errors and undefined item variables
- Replace JavaScript ternary operator with Jinja2 if-else syntax in services.ui - Change all 'item' references to 'data' in List component templates - Add proper script bindings with data passing for List component actions - Update main.dspy functions to use correct parameter names from form data - Add missing update_model and remove_model functions for AI model management - Ensure all List component interactions properly pass current item data
This commit is contained in:
parent
c158573a39
commit
6c28e4f6a9
@ -35,7 +35,7 @@ def filter_sessions():
|
||||
return {"sessions": filtered_sessions}
|
||||
|
||||
def open_session():
|
||||
session_id = request.form.get('item.id')
|
||||
session_id = request.form.get('session_id')
|
||||
if session_id:
|
||||
session_data = get_session_by_id(session_id)
|
||||
if session_data:
|
||||
@ -62,7 +62,7 @@ def add_service():
|
||||
return {"redirect": "add_service.ui"}
|
||||
|
||||
def edit_service():
|
||||
service_id = request.form.get('item.id')
|
||||
service_id = request.form.get('service_id')
|
||||
if service_id:
|
||||
service_data = get_service_by_id(service_id)
|
||||
if service_data:
|
||||
@ -71,7 +71,7 @@ def edit_service():
|
||||
return {"error": "Service not found"}
|
||||
|
||||
def remove_service():
|
||||
service_id = request.form.get('item.id')
|
||||
service_id = request.form.get('service_id')
|
||||
if service_id:
|
||||
delete_service(service_id)
|
||||
return {"success": True, "message": "Service removed successfully"}
|
||||
@ -79,7 +79,7 @@ def remove_service():
|
||||
return {"error": "Service not found"}
|
||||
|
||||
def test_service_connection():
|
||||
service_id = request.form.get('item.id')
|
||||
service_id = request.form.get('service_id')
|
||||
if service_id:
|
||||
service_data = get_service_by_id(service_id)
|
||||
if service_data:
|
||||
@ -127,6 +127,39 @@ def save_appearance_settings():
|
||||
def add_model():
|
||||
return {"redirect": "add_model.ui"}
|
||||
|
||||
def update_model():
|
||||
model_id = request.form.get('model_id')
|
||||
model_name = request.form.get('model_name')
|
||||
model_provider = request.form.get('model_provider')
|
||||
|
||||
if not model_id or not model_name:
|
||||
return {"error": "Model ID and name are required"}
|
||||
|
||||
model_data = {
|
||||
'id': model_id,
|
||||
'name': model_name,
|
||||
'provider': model_provider
|
||||
}
|
||||
|
||||
update_model_in_storage(model_data)
|
||||
return {"success": True, "message": "Model updated successfully"}
|
||||
|
||||
def remove_model():
|
||||
model_id = request.form.get('model_id')
|
||||
if model_id:
|
||||
delete_model_from_storage(model_id)
|
||||
return {"success": True, "message": "Model removed successfully"}
|
||||
|
||||
return {"error": "Model not found"}
|
||||
|
||||
def update_model_in_storage(model_data):
|
||||
# Framework-provided function
|
||||
pass
|
||||
|
||||
def delete_model_from_storage(model_id):
|
||||
# Framework-provided function
|
||||
pass
|
||||
|
||||
# Helper function stubs - these would be provided by the framework
|
||||
def generate_session_id():
|
||||
# Framework-provided function
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "{{item.name}}",
|
||||
"text": "{{data.name}}",
|
||||
"fontSize": "18px",
|
||||
"fontWeight": "600",
|
||||
"color": "#F8FAFC"
|
||||
@ -112,8 +112,8 @@
|
||||
{
|
||||
"widgettype": "Badge",
|
||||
"options": {
|
||||
"text": "{{item.status}}",
|
||||
"bgcolor": "{{item.status == 'Connected' ? '#22C55E' : '#EF4444'}}",
|
||||
"text": "{{data.status}}",
|
||||
"bgcolor": "{{ '#22C55E' if data.status == 'Connected' else '#EF4444' }}",
|
||||
"color": "#FFFFFF",
|
||||
"borderRadius": "12px",
|
||||
"padding": "4px 12px",
|
||||
@ -125,7 +125,7 @@
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "{{item.endpoint}}",
|
||||
"text": "{{data.endpoint}}",
|
||||
"fontSize": "14px",
|
||||
"color": "#CBD5E1",
|
||||
"marginBottom": "8px"
|
||||
@ -149,15 +149,18 @@
|
||||
"padding": "6px 12px",
|
||||
"fontSize": "12px"
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "app.edit_service",
|
||||
"mode": "call"
|
||||
}
|
||||
]
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "app.edit_service",
|
||||
"options": {
|
||||
"service_id": "{{data.id}}"
|
||||
},
|
||||
"mode": "call"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgettype": "Button",
|
||||
@ -170,15 +173,18 @@
|
||||
"padding": "6px 12px",
|
||||
"fontSize": "12px"
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "app.remove_service",
|
||||
"mode": "call"
|
||||
}
|
||||
]
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "app.remove_service",
|
||||
"options": {
|
||||
"service_id": "{{data.id}}"
|
||||
},
|
||||
"mode": "call"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgettype": "Button",
|
||||
@ -191,15 +197,18 @@
|
||||
"padding": "6px 12px",
|
||||
"fontSize": "12px"
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "app.test_service_connection",
|
||||
"mode": "call"
|
||||
}
|
||||
]
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "app.test_service_connection",
|
||||
"options": {
|
||||
"service_id": "{{data.id}}"
|
||||
},
|
||||
"mode": "call"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "{{item.name}}",
|
||||
"text": "{{data.name}}",
|
||||
"fontSize": "16px",
|
||||
"fontWeight": "600",
|
||||
"color": "#F8FAFC"
|
||||
@ -115,7 +115,7 @@
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "{{item.last_active}}",
|
||||
"text": "{{data.last_active}}",
|
||||
"fontSize": "12px",
|
||||
"color": "#94A3B8"
|
||||
}
|
||||
@ -125,7 +125,7 @@
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "{{item.model}}",
|
||||
"text": "{{data.model}}",
|
||||
"fontSize": "14px",
|
||||
"color": "#CBD5E1",
|
||||
"marginTop": "4px"
|
||||
@ -138,6 +138,9 @@
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "app.open_session",
|
||||
"options": {
|
||||
"session_id": "{{data.id}}"
|
||||
},
|
||||
"mode": "call"
|
||||
}
|
||||
]
|
||||
|
||||
@ -158,7 +158,7 @@
|
||||
"widgettype": "Input",
|
||||
"options": {
|
||||
"label": "Model Name",
|
||||
"value": "{{item.name}}",
|
||||
"value": "{{data.name}}",
|
||||
"width": "100%",
|
||||
"marginBottom": "8px"
|
||||
}
|
||||
@ -167,7 +167,7 @@
|
||||
"widgettype": "Input",
|
||||
"options": {
|
||||
"label": "Provider",
|
||||
"value": "{{item.provider}}",
|
||||
"value": "{{data.provider}}",
|
||||
"width": "100%",
|
||||
"marginBottom": "8px"
|
||||
}
|
||||
@ -189,7 +189,21 @@
|
||||
"borderRadius": "4px",
|
||||
"padding": "6px 12px",
|
||||
"fontSize": "12px"
|
||||
}
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "app.update_model",
|
||||
"options": {
|
||||
"model_id": "{{data.id}}",
|
||||
"model_name": "{{data.name}}",
|
||||
"model_provider": "{{data.provider}}"
|
||||
},
|
||||
"mode": "call"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgettype": "Button",
|
||||
@ -201,7 +215,19 @@
|
||||
"borderRadius": "4px",
|
||||
"padding": "6px 12px",
|
||||
"fontSize": "12px"
|
||||
}
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "click",
|
||||
"actiontype": "script",
|
||||
"target": "app.remove_model",
|
||||
"options": {
|
||||
"model_id": "{{data.id}}"
|
||||
},
|
||||
"mode": "call"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user