refactor: 数据源弹框交互重构 + test-connection API
1. 类型选择前置: 4个数据源类型卡片(MySQL/PG/Redis/Mongo)放最前面 2. 根据类型动态渲染: Redis隐藏用户名/数据库, 显示数据库编号 3. 环境支持自定义输入: 预设开发/预发/生产/测试/UAT + 自定义... 4. 去掉流程配置: 不再需要配置审批流程 5. 测试连接优先: 底部左侧「测试连接」按钮, 连接成功后才能「添加数据源」 6. 后端新增 POST /test-connection: 不保存实例直接测试连接参数 7. 类型切换自动填充默认端口: mysql:3306, pg:5432, redis:6379, mongo:27017 8. 连接测试结果展示: 成功(绿色+版本号) / 失败(红色+错误信息) 9. 修改连接参数时自动清除测试结果, 需重新测试 前端构建零错误, 后端202测试通过
This commit is contained in:
1 parent
f8ae3b92e5
commit
e0cb505d43
3 files changed
+205
-122
No files matched your search
@@ -90,6 +90,20 @@ async def create_instance(
|
||||
return _serialize_json_fields(instance)
|
||||
|
||||
|
||||
@router.post("/test-connection", response_model=ConnectionTestResult)
|
||||
async def test_new_connection(
|
||||
data: InstanceCreate,
|
||||
current_user: User = Depends(require_role("admin", "dba")),
|
||||
):
|
||||
"""测试连接参数(不保存实例)"""
|
||||
fake = Instance(
|
||||
name=data.name, db_type=data.db_type, host=data.host, port=data.port,
|
||||
username=data.username, password=data.password, database=data.database,
|
||||
env=data.env, access_mode=data.access_mode,
|
||||
)
|
||||
return await InstanceService.test_connection(fake)
|
||||
|
||||
|
||||
@router.get("/{instance_id}", response_model=InstanceResponse)
|
||||
async def get_instance(
|
||||
instance_id: int,
|
||||
|
||||
Reference in new issue
Block a user