75 lines
2.6 KiB
Plaintext
75 lines
2.6 KiB
Plaintext
# workspace_popup.dspy - 返回 PopupWindow(纯widget结构,无binds)
|
||
|
||
uid = await get_user()
|
||
if not uid:
|
||
uid = 'user-01'
|
||
|
||
dbname = get_module_dbname('pipeline-sdlc')
|
||
|
||
async with DBPools().sqlorContext(dbname) as sor:
|
||
recs = await sor.sqlExe(
|
||
"SELECT current_project_id FROM pipeline_agent_settings WHERE user_id=${u}$",
|
||
{"u": uid})
|
||
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:
|
||
resp = {
|
||
"widgettype": "PopupWindow",
|
||
"options": {"title": "提示", "cwidth": 30, "cheight": 8, "auto_open": True},
|
||
"subwidgets": [{
|
||
"widgettype": "Text",
|
||
"options": {"text": "请先选择项目", "cfontsize": 1, "color": "#64748b", "padding": "20px"}
|
||
}]
|
||
}
|
||
else:
|
||
resp = {
|
||
"widgettype": "PopupWindow",
|
||
"options": {
|
||
"title": pname + " - 工作空间",
|
||
"width": "85%",
|
||
"height": "80%",
|
||
"auto_open": True
|
||
},
|
||
"subwidgets": [{
|
||
"widgettype": "HBox",
|
||
"options": {"height": "100%"},
|
||
"subwidgets": [
|
||
{
|
||
"widgettype": "VBox",
|
||
"options": {"width": "280px"},
|
||
"subwidgets": [{
|
||
"widgettype": "Tree",
|
||
"id": "ws_tree",
|
||
"options": {
|
||
"dataurl": entire_url("/pipeline-sdlc/api/workspace_tree.dspy"),
|
||
"textField": "label",
|
||
"idField": "id",
|
||
"cfontsize": 1.0,
|
||
"css": "filler",
|
||
"padding": "4px",
|
||
"cheight": "100%"
|
||
}
|
||
}]
|
||
},
|
||
{
|
||
"widgettype": "VScrollPanel",
|
||
"id": "ws_files",
|
||
"options": {
|
||
"dataurl": entire_url("/pipeline-sdlc/api/workspace_files.dspy") + "?id=__root__",
|
||
"css": "filler",
|
||
"padding": "8px",
|
||
"gap": "4px"
|
||
}
|
||
}
|
||
]
|
||
}]
|
||
}
|
||
|
||
return json.dumps(resp, ensure_ascii=False)
|