pipeline-sdlc/wwwroot/api/cockpit_context.dspy
yumoqing 8d158dcc86 feat: cockpit_context端点 + UI context_bar动态化
- 新增 cockpit_context.dspy API(读 pipeline_agent_settings,返回项目/迭代/workspace)
- index_cockpit.ui & index.ui context_bar:
  - 静态'当前项目/迭代:--' → Button(link样式)+datawidget自动加载
  - 点击项目/迭代弹出 PopupWindow 查看详情
2026-08-05 18:10:56 +08:00

36 lines
1.3 KiB
Plaintext

# cockpit_context.dspy — 返回当前上下文(项目/迭代),供前端 context_bar 显示
async with DBPools().sqlorContext(dbname) as sor:
recs = await sor.sqlExe(
"SELECT current_project_id, current_iteration_id FROM pipeline_agent_settings WHERE user_id=${uid}$",
{"uid": uid})
pid = ''
iid = ''
if recs and len(recs) > 0:
pid = getattr(recs[0], 'current_project_id', '') or ''
iid = getattr(recs[0], 'current_iteration_id', '') or ''
# 拿到项目名和迭代名
pname = ''
iname = ''
ws_dir = ''
if pid:
precs = await sor.sqlExe(
"SELECT name, workspace_dir FROM sd_projects WHERE id=${pid}$", {"pid": pid})
if precs and len(precs) > 0:
pname = getattr(precs[0], 'name', '') or ''
ws_dir = getattr(precs[0], 'workspace_dir', '') or ''
if iid:
irecs = await sor.sqlExe(
"SELECT iteration_name FROM sd_iterations WHERE id=${iid}$", {"iid": iid})
if irecs and len(irecs) > 0:
iname = getattr(irecs[0], 'iteration_name', '') or ''
return json.dumps({
"project_name": pname,
"iteration_name": iname,
"project_id": pid,
"iteration_id": iid,
"workspace_dir": ws_dir,
}, ensure_ascii=False)