91 lines
2.9 KiB
Plaintext
91 lines
2.9 KiB
Plaintext
# workspace_popup.dspy - 返回工作空间 PopupWindow widget 定义
|
|
|
|
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 + " - 工作空间",
|
|
"cwidth": 80,
|
|
"cheight": 36,
|
|
"auto_open": True
|
|
},
|
|
"subwidgets": [{
|
|
"widgettype": "Splitter",
|
|
"options": {
|
|
"direction": "horizontal",
|
|
"split": "30%"
|
|
},
|
|
"subwidgets": [
|
|
{
|
|
"widgettype": "Tree",
|
|
"id": "ws_tree",
|
|
"options": {
|
|
"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"
|
|
}
|
|
}]
|
|
},
|
|
{
|
|
"widgettype": "VScrollPanel",
|
|
"id": "ws_files",
|
|
"options": {
|
|
"css": "filler",
|
|
"padding": "8px",
|
|
"gap": "4px"
|
|
}
|
|
}
|
|
]
|
|
}]
|
|
}
|
|
|
|
return json.dumps(resp, ensure_ascii=False)
|