From 697505fdf26d81dcce42cc0958efd82f999a185a Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Wed, 6 May 2026 16:45:01 +0800 Subject: [PATCH] feat: merge audit records into diagnostics page, remove redundant sections --- internal/web/ui.go | 14 +++- internal/web/ui/templates/diagnostics.html | 79 ++++++++++++++++++---- internal/web/ui_test.go | 2 +- 3 files changed, 78 insertions(+), 17 deletions(-) diff --git a/internal/web/ui.go b/internal/web/ui.go index a20beb6..5c8049f 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -1418,7 +1418,19 @@ func (u *UI) actionModelSync(w http.ResponseWriter, r *http.Request) { } func (u *UI) pageDiagnostics(w http.ResponseWriter, r *http.Request) { - u.render(w, r, "diagnostics", PageData{Title: "日志审计", Devices: u.registry.GetDevices()}) + data := PageData{Title: "日志审计", Devices: u.registry.GetDevices()} + if u.auditRepo != nil { + items, err := u.auditRepo.List() + if err != nil { + data.Error = err.Error() + } else { + data.AuditEntries = items + } + } + if len(data.AuditEntries) == 0 && u.tasks != nil { + data.Tasks = u.tasks.ListTasks() + } + u.render(w, r, "diagnostics", data) } func (u *UI) pageResources(w http.ResponseWriter, r *http.Request) { diff --git a/internal/web/ui/templates/diagnostics.html b/internal/web/ui/templates/diagnostics.html index 6d48b40..997600e 100644 --- a/internal/web/ui/templates/diagnostics.html +++ b/internal/web/ui/templates/diagnostics.html @@ -2,15 +2,74 @@
| 动作 | +目标 | +任务 | +配置 | +结果 | +
|---|---|---|---|---|
| {{auditActionLabel .Action}} | +{{.TargetID}} | +{{if auditField .DetailsJSON "task_id"}}{{auditField .DetailsJSON "task_id"}}{{else}}-{{end}} | +{{if auditField .DetailsJSON "profile"}}{{auditField .DetailsJSON "profile"}}{{else if auditField .DetailsJSON "config_id"}}{{auditField .DetailsJSON "config_id"}}{{else}}-{{end}} | +{{if auditField .DetailsJSON "status"}}{{auditStatusLabel (auditField .DetailsJSON "status")}}{{else}}{{.Actor}}{{end}} | +
| 类型 | +任务 | +目标设备数 | +结果 | +说明 | +
|---|---|---|---|---|
|
+ {{taskGroupLabel .Type}}
+ {{taskActionLabel .Type}}
+ |
+ {{.ID}} |
+ {{len .DeviceIDs}} 台 | +{{taskStatusLabel .Status}} | +{{if .Payload}}已记录任务参数{{else}}无附加参数{{end}} | +
|
+
+
+ 暂无审计记录
+ 当前后台还没有记录到任何任务或设备操作。
+ |
+ ||||
| 暂无设备。请先在“新增设备”页扫描或手动添加。 | |||
| 暂无设备。请先在“设备”页扫描或手动添加。 |