diff --git a/app/models.py b/app/models.py index 261832f..591f2e6 100644 --- a/app/models.py +++ b/app/models.py @@ -27,6 +27,7 @@ class Project(SQLModel, table=True): repo_url: Optional[str] = Field(default=None) local_path: Optional[str] = Field(default=None) description: Optional[str] = Field(default=None) + repair_enabled: bool = Field(default=True) created_at: datetime = Field(default_factory=datetime.utcnow) updated_at: datetime = Field(default_factory=datetime.utcnow) @@ -36,6 +37,7 @@ class ProjectUpdate(SQLModel): repo_url: Optional[str] = None local_path: Optional[str] = None description: Optional[str] = None + repair_enabled: Optional[bool] = None class ErrorLog(SQLModel, table=True): id: Optional[int] = Field(default=None, primary_key=True) diff --git a/repair_agent/agent/scheduler.py b/repair_agent/agent/scheduler.py index f1b3ddb..bc05a41 100644 --- a/repair_agent/agent/scheduler.py +++ b/repair_agent/agent/scheduler.py @@ -41,13 +41,18 @@ class RepairScheduler: @staticmethod def _fetch_projects_from_api() -> list[str]: - """从 Log Center API 动态获取所有已注册项目""" + """从 Log Center API 动态获取所有已启用修复的项目""" try: resp = httpx.get(f"{settings.log_center_url}/api/v1/projects", timeout=10) resp.raise_for_status() projects = resp.json().get("projects", []) - project_ids = [p["project_id"] for p in projects] - logger.info(f"从 API 获取到 {len(project_ids)} 个项目: {', '.join(project_ids)}") + # 只返回 repair_enabled=True 的项目 + enabled = [p for p in projects if p.get("repair_enabled", True)] + disabled = [p["project_id"] for p in projects if not p.get("repair_enabled", True)] + project_ids = [p["project_id"] for p in enabled] + logger.info(f"从 API 获取到 {len(project_ids)} 个已启用项目: {', '.join(project_ids)}") + if disabled: + logger.info(f" 已禁用修复的项目: {', '.join(disabled)}") return project_ids except Exception as e: logger.warning(f"从 API 获取项目列表失败: {e},回退到本地配置") diff --git a/web/index.html b/web/index.html index af88f03..59646d0 100644 --- a/web/index.html +++ b/web/index.html @@ -1,10 +1,13 @@ - +
-错误追踪系统概览
+错误追踪与自动修复系统概览
| 状态 | -数量 | -
|---|---|
| - - {STATUS_LABELS[status] || status} - - | -{count} | -
| 来源 | -数量 | -
|---|---|
| - - {SOURCE_LABELS[source] || source} - - | -{count} | -
管理项目的仓库地址和本地路径,供 Repair Agent 使用
+管理项目配置,控制 Repair Agent 的自动修复范围
+| 项目 ID | -名称 | -仓库地址 | -本地路径 | -描述 | -更新时间 | -操作 | -|||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {p.project_id} | -- setEditForm({ ...editForm, name: e.target.value })} - placeholder="项目名称" - className="edit-input" - /> - | -- setEditForm({ ...editForm, repo_url: e.target.value })} - placeholder="https://gitea.example.com/..." - className="edit-input" - /> - | -- setEditForm({ ...editForm, local_path: e.target.value })} - placeholder="/home/user/projects/..." - className="edit-input" - /> - | -- setEditForm({ ...editForm, description: e.target.value })} - placeholder="项目描述" - className="edit-input" - /> - | -- {new Date(p.updated_at).toLocaleString()} - | -
-
-
-
-
- |
- >
- ) : (
- <>
- {p.project_id} | -{p.name || -} | -{p.description || '-'} | -- {new Date(p.updated_at).toLocaleString()} - | -
-
-
-
-
- |
- >
- )}
-
{p.description}
+ )} + ++
此操作不可撤销。请输入项目 ID {deleteTarget.project_id} 以确认删除。
-