83 lines
3.2 KiB
Plaintext
83 lines
3.2 KiB
Plaintext
# workspace_popup.dspy - 返回工作空间 PopupWindow
|
|
|
|
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:
|
|
files_url = entire_url("/pipeline-sdlc/api/workspace_files.dspy")
|
|
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%"
|
|
},
|
|
"binds": [{
|
|
"wid": "self",
|
|
"event": "selected",
|
|
"actiontype": "script",
|
|
"target": "self",
|
|
"script": f"var nid=this.selected_node.user_data.id;var fp=bricks.getWidgetById('ws_files',bricks.app);if(fp)fetch('{files_url}?id='+encodeURIComponent(nid)).then(function(r){{return r.json()}}).then(function(d){{fp.dom_element.innerHTML='';bricks.widgetBuild(d,fp);}});"
|
|
}]
|
|
}]
|
|
},
|
|
{
|
|
"widgettype": "VScrollPanel",
|
|
"id": "ws_files",
|
|
"options": {
|
|
"dataurl": files_url + "?id=__root__",
|
|
"css": "filler",
|
|
"padding": "8px",
|
|
"gap": "4px"
|
|
}
|
|
}
|
|
]
|
|
}]
|
|
}
|
|
|
|
return json.dumps(resp, ensure_ascii=False)
|