- 告警页增加日期范围筛选(默认今天),50 条/页分页 - AlarmCollector.GetFiltered 支持 from/to/limit/offset - alarm_retention_days 配置项(默认 30 天),超期自动清理
78 lines
2.7 KiB
HTML
78 lines
2.7 KiB
HTML
{{define "alarms"}}
|
|
<div class="card">
|
|
<div class="section-title">
|
|
<div>
|
|
<h2 class="title-with-icon">{{icon "bell"}}<span>告警中心</span></h2>
|
|
<div class="form-hint">来自所有设备的实时告警记录,按时间倒序排列。</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<form method="get" action="/ui/alarms" style="display:flex;gap:8px;align-items:center;margin-bottom:12px;flex-wrap:wrap">
|
|
<input type="date" name="from" value="{{.SelectedFrom}}" style="width:150px;font-size:12px">
|
|
<span class="muted small">至</span>
|
|
<input type="date" name="to" value="{{.SelectedTo}}" style="width:150px;font-size:12px">
|
|
<button class="btn" style="font-size:12px;padding:4px 12px">筛选</button>
|
|
<a href="/ui/alarms" class="btn ghost" style="font-size:11px">今天</a>
|
|
</form>
|
|
|
|
<div class="table-wrap">
|
|
{{if .AlarmRecords}}
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>时间</th>
|
|
<th>设备</th>
|
|
<th>通道</th>
|
|
<th>规则</th>
|
|
<th>目标</th>
|
|
<th>置信度</th>
|
|
<th>截图</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range .AlarmRecords}}
|
|
<tr>
|
|
<td class="mono small">{{.Timestamp}}</td>
|
|
<td>
|
|
<a href="/ui/devices/{{.DeviceID}}">{{shortID .DeviceID}}</a>
|
|
</td>
|
|
<td>{{.Channel}}</td>
|
|
<td>
|
|
<span class="pill warn">{{.RuleName}}</span>
|
|
</td>
|
|
<td>{{if .ObjectLabel}}{{.ObjectLabel}}{{else}}-{{end}}</td>
|
|
<td>{{if .Confidence}}{{printf "%.2f" .Confidence}}{{else}}-{{end}}</td>
|
|
<td>
|
|
{{if .SnapshotURL}}
|
|
<a href="{{.SnapshotURL}}" target="_blank" class="btn ghost">查看截图</a>
|
|
{{else}}-{{end}}
|
|
{{if .ClipURL}}
|
|
<a href="{{.ClipURL}}" target="_blank" class="btn ghost">视频片段</a>
|
|
{{end}}
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
{{if gt .TotalAlarmPages 1}}
|
|
<div style="margin-top:12px;display:flex;gap:6px;align-items:center">
|
|
<span class="muted small">{{.TotalAlarmCount}} 条记录,{{.TotalAlarmPages}} 页</span>
|
|
{{$from := $.SelectedFrom}}{{$to := $.SelectedTo}}
|
|
{{range $p := loop .TotalAlarmPages}}
|
|
{{$pn := add $p 1}}
|
|
<a href="/ui/alarms?from={{$from}}&to={{$to}}&page={{$pn}}" class="btn {{if eq $pn $.CurrentPage}}primary{{else}}ghost{{end}}" style="font-size:11px;padding:2px 8px">{{$pn}}</a>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
{{else}}
|
|
<div class="empty-state">
|
|
<div class="empty-title">暂无告警记录</div>
|
|
<div class="muted">所选日期范围内没有告警,或设备尚未上报。</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
{{end}}
|