63 lines
2.1 KiB
Plaintext
63 lines
2.1 KiB
Plaintext
# workspace_popup.dspy - 返回 PopupWindow,内含 ResourceBrowser 控件
|
||
|
||
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": "ResourceBrowser",
|
||
"options": {
|
||
"tree_options": {
|
||
"widgettype": "Tree",
|
||
"options": {
|
||
"dataurl": entire_url("/pipeline-sdlc/api/workspace_tree.dspy"),
|
||
"textField": "label",
|
||
"idField": "id",
|
||
"cfontsize": 1.0
|
||
}
|
||
},
|
||
"browser_options": {
|
||
"widgettype": "urlwidget",
|
||
"options": {
|
||
"url": entire_url("/pipeline-sdlc/api/workspace_files.dspy")
|
||
}
|
||
},
|
||
"tree_width": "280px"
|
||
}
|
||
}]
|
||
}
|
||
|
||
return json.dumps(resp, ensure_ascii=False)
|