feat: add week/month quick links to alarms page, remove subtitle
This commit is contained in:
parent
316a05aec4
commit
e5922ea6c0
@ -88,6 +88,10 @@ type PageData struct {
|
||||
CurrentPage int
|
||||
SelectedFrom string
|
||||
SelectedTo string
|
||||
WeekStart string
|
||||
WeekEnd string
|
||||
MonthStart string
|
||||
MonthEnd string
|
||||
TodayAlarmCount int
|
||||
DeviceMetrics []DeviceMetric
|
||||
ConsoleDevices []ConsoleDeviceData
|
||||
@ -1933,6 +1937,18 @@ func (u *UI) pageAlarms(w http.ResponseWriter, r *http.Request) {
|
||||
data.SelectedTo = to
|
||||
data.CurrentPage = page
|
||||
|
||||
// Compute quick-link ranges.
|
||||
now := time.Now()
|
||||
weekday := int(now.Weekday())
|
||||
if weekday == 0 {
|
||||
weekday = 7
|
||||
}
|
||||
mon := now.AddDate(0, 0, -(weekday - 1))
|
||||
data.WeekStart = mon.Format("2006-01-02")
|
||||
data.WeekEnd = today
|
||||
data.MonthStart = now.Format("2006-01-02")[:8] + "01"
|
||||
data.MonthEnd = today
|
||||
|
||||
if u.alarmCollector != nil {
|
||||
data.AlarmRecords, data.TotalAlarmCount = u.alarmCollector.GetFiltered(from, to, perPage, (page-1)*perPage)
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
<div class="section-title">
|
||||
<div>
|
||||
<h2 class="title-with-icon">{{icon "bell"}}<span>告警中心</span></h2>
|
||||
<div class="form-hint">来自所有设备的实时告警记录,按时间倒序排列。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -15,6 +14,8 @@
|
||||
<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>
|
||||
<a href="/ui/alarms?from={{.WeekStart}}&to={{.WeekEnd}}" class="btn ghost" style="font-size:11px">本周</a>
|
||||
<a href="/ui/alarms?from={{.MonthStart}}&to={{.MonthEnd}}" class="btn ghost" style="font-size:11px">本月</a>
|
||||
<a href="/ui/alarms?from=2000-01-01&to=2099-12-31" class="btn ghost" style="font-size:11px">全部</a>
|
||||
</form>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user