workspace: urlwidget action loading PopupWindow from DSPY

This commit is contained in:
p 2026-08-12 14:34:49 +08:00
parent 35261b8b84
commit 90af3f67a1
2 changed files with 65 additions and 39 deletions

View File

@ -1,4 +1,4 @@
# workspace_popup.dspy - 返回工作空间内容 widget(Splitter+Tree),非 PopupWindow # workspace_popup.dspy - 返回工作空间 PopupWindow widget 定义
uid = await get_user() uid = await get_user()
if not uid: if not uid:
@ -12,53 +12,79 @@ async with DBPools().sqlorContext(dbname) as sor:
{"u": uid}) {"u": uid})
pid = getattr(recs[0], 'current_project_id', '') if recs else '' pid = getattr(recs[0], 'current_project_id', '') if recs else ''
pname = ''
if pid:
proj = await sor.sqlExe(
"SELECT name FROM sd_projects WHERE id=${p}$",
{"p": pid})
if proj:
pname = getattr(proj[0], 'name', '')
if not pid: if not pid:
resp = { resp = {
"widgettype": "Text", "widgettype": "PopupWindow",
"options": { "options": {
"text": "请先选择项目", "title": "提示",
"cfontsize": 1, "cwidth": 30,
"color": "#64748b", "cheight": 8,
"padding": "20px" "auto_open": True
} },
"subwidgets": [{
"widgettype": "Text",
"options": {
"text": "请先选择项目",
"cfontsize": 1,
"color": "#64748b",
"padding": "20px"
}
}]
} }
else: else:
resp = { resp = {
"widgettype": "Splitter", "widgettype": "PopupWindow",
"options": { "options": {
"direction": "horizontal", "title": pname + " - 工作空间",
"split": "30%" "cwidth": 80,
"cheight": 36,
"auto_open": True
}, },
"subwidgets": [ "subwidgets": [{
{ "widgettype": "Splitter",
"widgettype": "Tree", "options": {
"id": "ws_tree", "direction": "horizontal",
"options": { "split": "30%"
"dataurl": "/pipeline-sdlc/api/workspace_tree.dspy",
"css": "filler",
"padding": "4px",
"cheight": "100%"
},
"binds": [{
"wid": "self",
"event": "selected",
"actiontype": "urlwidget",
"target": "ws_files",
"options": {
"url": "/pipeline-sdlc/api/workspace_files.dspy"
}
}]
}, },
{ "subwidgets": [
"widgettype": "VScrollPanel", {
"id": "ws_files", "widgettype": "Tree",
"options": { "id": "ws_tree",
"css": "filler", "options": {
"padding": "8px", "dataurl": "/pipeline-sdlc/api/workspace_tree.dspy",
"gap": "4px" "css": "filler",
"padding": "4px",
"cheight": "100%"
},
"binds": [{
"wid": "self",
"event": "selected",
"actiontype": "urlwidget",
"target": "ws_files",
"options": {
"url": "/pipeline-sdlc/api/workspace_files.dspy"
}
}]
},
{
"widgettype": "VScrollPanel",
"id": "ws_files",
"options": {
"css": "filler",
"padding": "8px",
"gap": "4px"
}
} }
} ]
] }]
} }
return json.dumps(resp, ensure_ascii=False) return json.dumps(resp, ensure_ascii=False)

File diff suppressed because one or more lines are too long