feat: merge audit records into diagnostics page, remove redundant sections
This commit is contained in:
parent
e4e4edd31b
commit
697505fdf2
@ -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) {
|
||||
|
||||
@ -2,15 +2,74 @@
|
||||
<div class="card">
|
||||
<div class="section-title">
|
||||
<div>
|
||||
<h2>日志审计</h2>
|
||||
<div class="muted small">按设备查看日志与运行指标,并进入审计记录和高级调试。</div>
|
||||
<h2 class="title-with-icon">{{icon "audit"}}<span>审计记录</span></h2>
|
||||
</div>
|
||||
<a class="btn ghost" href="/ui/api">高级调试</a>
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
{{if .AuditEntries}}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>动作</th>
|
||||
<th>目标</th>
|
||||
<th>任务</th>
|
||||
<th>配置</th>
|
||||
<th>结果</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .AuditEntries}}
|
||||
<tr>
|
||||
<td>{{auditActionLabel .Action}}</td>
|
||||
<td><span class="mono">{{.TargetID}}</span></td>
|
||||
<td class="mono">{{if auditField .DetailsJSON "task_id"}}{{auditField .DetailsJSON "task_id"}}{{else}}-{{end}}</td>
|
||||
<td class="mono">{{if auditField .DetailsJSON "profile"}}{{auditField .DetailsJSON "profile"}}{{else if auditField .DetailsJSON "config_id"}}{{auditField .DetailsJSON "config_id"}}{{else}}-{{end}}</td>
|
||||
<td>{{if auditField .DetailsJSON "status"}}{{auditStatusLabel (auditField .DetailsJSON "status")}}{{else}}{{.Actor}}{{end}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>类型</th>
|
||||
<th>任务</th>
|
||||
<th>目标设备数</th>
|
||||
<th>结果</th>
|
||||
<th>说明</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Tasks}}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="{{taskGroupClass .Type}}">{{taskGroupLabel .Type}}</span>
|
||||
<div class="muted small" style="margin-top:4px">{{taskActionLabel .Type}}</div>
|
||||
</td>
|
||||
<td><div class="mono">{{.ID}}</div></td>
|
||||
<td>{{len .DeviceIDs}} 台</td>
|
||||
<td><span class="{{taskStatusClass .Status}}">{{taskStatusLabel .Status}}</span></td>
|
||||
<td class="muted small">{{if .Payload}}已记录任务参数{{else}}无附加参数{{end}}</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<div class="empty-state">
|
||||
<div class="empty-title">暂无审计记录</div>
|
||||
<div class="muted">当前后台还没有记录到任何任务或设备操作。</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>日志分析</h2>
|
||||
<h2 class="title-with-icon">{{icon "logs"}}<span>日志分析</span></h2>
|
||||
<div class="table-wrap" style="margin-top:10px">
|
||||
<table>
|
||||
<thead>
|
||||
@ -33,20 +92,10 @@
|
||||
</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr><td colspan="4" class="muted">暂无设备。请先在“新增设备”页扫描或手动添加。</td></tr>
|
||||
<tr><td colspan="4" class="muted">暂无设备。请先在“设备”页扫描或手动添加。</td></tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="section-title">
|
||||
<div>
|
||||
<h2>审计记录</h2>
|
||||
</div>
|
||||
<a class="btn ghost" href="/ui/audit">进入审计记录</a>
|
||||
</div>
|
||||
<div class="muted small">查看任务执行、设备操作和配置下发相关的审计记录。</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
@ -2068,7 +2068,7 @@ func TestUI_LogAuditPageRendersLogAndMetricLinks(t *testing.T) {
|
||||
t.Fatalf("expected 200, got %d: %s", rr.Code, rr.Body.String())
|
||||
}
|
||||
body := rr.Body.String()
|
||||
for _, want := range []string{"日志审计", "日志分析", "审计记录", "入口识别节点", "诊断日志", "运行指标", "高级调试"} {
|
||||
for _, want := range []string{"日志分析", "审计记录", "入口识别节点", "诊断日志", "运行指标"} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Fatalf("expected diagnostics HTML to contain %q", want)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user