feat(ui): add message cache management page and dashboard enhancements
Some checks failed
CI / Test (1.23) (push) Failing after -30m37s
CI / Test (1.22) (push) Failing after -30m33s
CI / Build (push) Failing after -30m45s
CI / Lint (push) Failing after -30m39s

- Introduced MessageCachePage for browsing and managing cached webhook events.
- Enhanced DashboardPage to display runtime stats and message cache information.
- Added new API types for message cache events and system stats.
- Integrated SwaggerPage for API documentation and live request testing.
This commit is contained in:
2026-03-05 00:32:57 +02:00
parent 4b44340c58
commit 1490e0b596
47 changed files with 4430 additions and 611 deletions

View File

@@ -25,17 +25,60 @@ func (h *Handlers) GetCachedEvents(w http.ResponseWriter, r *http.Request) {
// Optional event_type filter
eventType := r.URL.Query().Get("event_type")
limit := 0
offset := 0
limitProvided := false
offsetProvided := false
var cachedEvents interface{}
if eventType != "" {
cachedEvents = cache.ListByEventType(events.EventType(eventType))
} else {
cachedEvents = cache.List()
limitParam := r.URL.Query().Get("limit")
if limitParam != "" {
parsedLimit, err := strconv.Atoi(limitParam)
if err != nil {
http.Error(w, "Invalid limit parameter", http.StatusBadRequest)
return
}
if parsedLimit <= 0 {
http.Error(w, "Limit must be greater than 0", http.StatusBadRequest)
return
}
limit = parsedLimit
limitProvided = true
}
offsetParam := r.URL.Query().Get("offset")
if offsetParam != "" {
parsedOffset, err := strconv.Atoi(offsetParam)
if err != nil {
http.Error(w, "Invalid offset parameter", http.StatusBadRequest)
return
}
if parsedOffset < 0 {
http.Error(w, "Offset must be greater than or equal to 0", http.StatusBadRequest)
return
}
offset = parsedOffset
offsetProvided = true
}
// If offset is provided without limit, use a sensible page size.
if offsetProvided && !limitProvided {
limit = 100
}
cachedEvents, filteredCount := cache.ListPaged(events.EventType(eventType), limit, offset)
if !limitProvided && !offsetProvided {
// Backward-compatible response values when pagination is not requested.
limit = len(cachedEvents)
offset = 0
}
writeJSON(w, map[string]interface{}{
"cached_events": cachedEvents,
"count": cache.Count(),
"filtered_count": filteredCount,
"returned_count": len(cachedEvents),
"limit": limit,
"offset": offset,
})
}