mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-19 07:50:43 +01:00
This commit adds enterprise-grade reporting and audit capabilities: Reporting: - Refactored metrics store from internal/ to pkg/ for enterprise access - Added pkg/reporting with shared interfaces for report generation - Created API endpoint: GET /api/admin/reports/generate - New ReportingPanel.tsx for PDF/CSV report configuration Audit Webhooks: - Extended pkg/audit with webhook URL management interface - Added API endpoint: GET/POST /api/admin/webhooks/audit - New AuditWebhookPanel.tsx for webhook configuration - Updated Settings.tsx with Reporting and Webhooks tabs Server Hardening: - Enterprise hooks now execute outside mutex with panic recovery - Removed dbPath from metrics Stats API to prevent path disclosure - Added storage metrics persistence to polling loop Documentation: - Updated README.md feature table - Updated docs/API.md with new endpoints - Updated docs/PULSE_PRO.md with feature descriptions - Updated docs/WEBHOOKS.md with audit webhooks section
45 lines
984 B
Go
45 lines
984 B
Go
package reporting
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// ReportFormat represents the output format of a report
|
|
type ReportFormat string
|
|
|
|
const (
|
|
FormatCSV ReportFormat = "csv"
|
|
FormatPDF ReportFormat = "pdf"
|
|
)
|
|
|
|
// MetricReportRequest defines the parameters for generating a report
|
|
type MetricReportRequest struct {
|
|
ResourceType string
|
|
ResourceID string
|
|
MetricType string // Optional, if empty all metrics for the resource are included
|
|
Start time.Time
|
|
End time.Time
|
|
Format ReportFormat
|
|
Title string
|
|
}
|
|
|
|
// Engine defines the interface for report generation.
|
|
// This allows the enterprise version to provide PDF/CSV generation.
|
|
type Engine interface {
|
|
Generate(req MetricReportRequest) (data []byte, contentType string, err error)
|
|
}
|
|
|
|
var (
|
|
globalEngine Engine
|
|
)
|
|
|
|
// SetEngine sets the global report engine.
|
|
func SetEngine(e Engine) {
|
|
globalEngine = e
|
|
}
|
|
|
|
// GetEngine returns the current global report engine.
|
|
func GetEngine() Engine {
|
|
return globalEngine
|
|
}
|