From ecb5a08d2d242fb68c877a9942588b62b833ed5c Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Fri, 8 May 2026 19:32:14 +0800 Subject: [PATCH] feat: today alarm count on dashboard --- internal/web/ui.go | 8 ++++++++ internal/web/ui/templates/dashboard.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/web/ui.go b/internal/web/ui.go index 63e13ec..841c1a0 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -82,6 +82,7 @@ type PageData struct { StandardResources []storage.StandardResourceRecord ResourceStatusBoard *service.ResourceStatusBoard AlarmRecords []service.AlarmRecord + TodayAlarmCount int FaceGalleryPersons []storage.PersonRecord Templates []service.Template Template *service.Template @@ -762,6 +763,13 @@ func (u *UI) pageDashboard(w http.ResponseWriter, r *http.Request) { data.Title = "总览" if u.alarmCollector != nil { data.AlarmRecords = u.alarmCollector.GetRecent(5) + all := u.alarmCollector.GetRecent(9999) + today := time.Now().Format("2006-01-02") + for _, a := range all { + if strings.HasPrefix(a.Timestamp, today) { + data.TodayAlarmCount++ + } + } } data.Tasks = nil if u.tasks != nil { diff --git a/internal/web/ui/templates/dashboard.html b/internal/web/ui/templates/dashboard.html index e2f5930..fd37790 100644 --- a/internal/web/ui/templates/dashboard.html +++ b/internal/web/ui/templates/dashboard.html @@ -19,7 +19,7 @@
设备总数
{{.DeviceCount}}
已纳管的边缘设备
在线率
{{.OnlineCount}} / {{.DeviceCount}}
在线设备占比
-
离线节点
{{.OfflineCount}}
需要检查网络或设备服务
+
离线节点
{{.TodayAlarmCount}}
今日告警总数
执行中任务
{{.RunningTaskCount}}
正在下发或控制节点