fix: 机构远程空间配置表单取值/赋值 bug + get 支持 owner_type
根因:bricks.Form.getValue() 返回 FormData 对象(非普通对象),v.remote_host=undefined 传空值报格式非法;setValue 是 InlineForm 方法,Form 无此方法导致加载失败
- 取值 getValue→_getValue(返回 {name:value} 普通对象)
- 加载遍历 name_inputs 逐个 setValue
- work_env.dspy get 加 owner_type 参数,org 页面加载 org 级(原 user 级优先导致看不到 org 配置)
This commit is contained in:
parent
1fd895213c
commit
af178f98ad
@ -32,9 +32,15 @@ except Exception:
|
||||
pass
|
||||
|
||||
if action == 'get':
|
||||
_ot = (params_kw or {}).get('owner_type', '')
|
||||
try:
|
||||
async with get_sor_context(request._run_ns, 'pipeline') as sor:
|
||||
env = await get_work_env(sor, user_id, org_id)
|
||||
if _ot == 'org':
|
||||
env = await get_work_env(sor, '', org_id)
|
||||
elif _ot == 'user':
|
||||
env = await get_work_env(sor, user_id, '')
|
||||
else:
|
||||
env = await get_work_env(sor, user_id, org_id)
|
||||
return json.dumps({'ok': True, 'env': env, 'account_name': account_name_for(username)}, ensure_ascii=False)
|
||||
except Exception as e:
|
||||
return json.dumps({'ok': False, 'error': str(e)}, ensure_ascii=False)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
{
|
||||
"widgettype": "Html",
|
||||
"options": {
|
||||
"html": "<script>setTimeout(function(){fetch('/pipeline-sdlc/api/work_env.dspy?action=get').then(function(r){return r.json()}).then(function(d){if(d.ok&&d.env){var f=bricks.getWidgetById('remote_form',bricks.app);if(f){f.setValue(d.env);}}})},300);</script>",
|
||||
"html": "<script>setTimeout(function(){fetch('/pipeline-sdlc/api/work_env.dspy?action=get&owner_type=org').then(function(r){return r.json()}).then(function(d){if(d.ok&&d.env){var f=bricks.getWidgetById('remote_form',bricks.app);if(f){var env=d.env||{};for(var k in env){if(f.name_inputs&&f.name_inputs[k]){f.name_inputs[k].setValue(env[k]);}}}}})},300);</script>",
|
||||
"height": "0",
|
||||
"width": "0"
|
||||
}
|
||||
@ -85,7 +85,7 @@
|
||||
"options": {"label": "保存配置"},
|
||||
"binds": [{
|
||||
"wid": "self", "event": "click", "actiontype": "script", "target": "self",
|
||||
"script": "var f=bricks.getWidgetById('remote_form',bricks.app);var v=f?f.getValue():{};var body=new URLSearchParams();body.append('action','set');body.append('owner_type','org');body.append('mode',v.mode||'local');body.append('remote_host',v.remote_host||'');body.append('remote_port',v.remote_port||'22');body.append('remote_user',v.remote_user||'');body.append('remote_dir',v.remote_dir||'');fetch('/pipeline-sdlc/api/work_env.dspy',{method:'POST',body:body}).then(function(r){return r.json()}).then(function(d){if(d.ok){bricks.show_message({title:'成功',message:'远程空间配置已保存'});}else{bricks.show_error({title:'失败',message:d.error||'未知错误'});}});"
|
||||
"script": "var f=bricks.getWidgetById('remote_form',bricks.app);var v=f?f._getValue():{};var body=new URLSearchParams();body.append('action','set');body.append('owner_type','org');body.append('mode',v.mode||'local');body.append('remote_host',v.remote_host||'');body.append('remote_port',v.remote_port||'22');body.append('remote_user',v.remote_user||'');body.append('remote_dir',v.remote_dir||'');fetch('/pipeline-sdlc/api/work_env.dspy',{method:'POST',body:body}).then(function(r){return r.json()}).then(function(d){if(d.ok){bricks.show_message({title:'成功',message:'远程空间配置已保存'});}else{bricks.show_error({title:'失败',message:d.error||'未知错误'});}});"
|
||||
}]
|
||||
},
|
||||
{
|
||||
@ -94,7 +94,7 @@
|
||||
"options": {"label": "测试远程连接"},
|
||||
"binds": [{
|
||||
"wid": "self", "event": "click", "actiontype": "script", "target": "self",
|
||||
"script": "var f=bricks.getWidgetById('remote_form',bricks.app);var v=f?f.getValue():{};var body=new URLSearchParams();body.append('action','ensure_remote_bwrap');body.append('remote_host',v.remote_host||'');body.append('remote_port',v.remote_port||'22');body.append('remote_user',v.remote_user||'');fetch('/pipeline-sdlc/api/work_env.dspy',{method:'POST',body:body}).then(function(r){return r.json()}).then(function(d){if(d.ok){bricks.show_message({title:'连接成功',message:'远程 bwrap 位置: '+(d.location||'unknown')});}else{bricks.show_error({title:'连接失败',message:d.error||'未知错误'});}});"
|
||||
"script": "var f=bricks.getWidgetById('remote_form',bricks.app);var v=f?f._getValue():{};var body=new URLSearchParams();body.append('action','ensure_remote_bwrap');body.append('remote_host',v.remote_host||'');body.append('remote_port',v.remote_port||'22');body.append('remote_user',v.remote_user||'');fetch('/pipeline-sdlc/api/work_env.dspy',{method:'POST',body:body}).then(function(r){return r.json()}).then(function(d){if(d.ok){bricks.show_message({title:'连接成功',message:'远程 bwrap 位置: '+(d.location||'unknown')});}else{bricks.show_error({title:'连接失败',message:d.error||'未知错误'});}});"
|
||||
}]
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user