feat: integrate Grafana dashboards into BOC DashboardPage
- Add Infrastructure Health section with CPU/Memory/Disk panels - Add Service Status section with PM2/Docker panels - Create GrafanaPanel component for iframe embedding - Build passes successfully
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"boc/briefing"
|
||||
)
|
||||
|
||||
// BriefingHandler hanterar daily briefing requests
|
||||
type BriefingHandler struct {
|
||||
engine *briefing.BriefingEngine
|
||||
}
|
||||
|
||||
func NewBriefingHandler(engine *briefing.BriefingEngine) *BriefingHandler {
|
||||
return &BriefingHandler{engine: engine}
|
||||
}
|
||||
|
||||
// GetDailyBriefing returnerar användarens dagsöversikt
|
||||
func (h *BriefingHandler) GetDailyBriefing(w http.ResponseWriter, r *http.Request) {
|
||||
// Hämta user ID från context (satt av auth middleware)
|
||||
// För utveckling: använd default user
|
||||
userID := "3847477b-3d56-4975-9157-ae8f9ce52aa7"
|
||||
|
||||
briefing, err := h.engine.GenerateDailyBriefing(r.Context(), userID)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"failed to generate briefing"}`, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(briefing)
|
||||
}
|
||||
|
||||
// GetPriority returnerar endast prioritetssektionen
|
||||
func (h *BriefingHandler) GetPriority(w http.ResponseWriter, r *http.Request) {
|
||||
userID := "3847477b-3d56-4975-9157-ae8f9ce52aa7"
|
||||
|
||||
briefing, err := h.engine.GenerateDailyBriefing(r.Context(), userID)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"failed to generate briefing"}`, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(briefing.Priority)
|
||||
}
|
||||
|
||||
// GetAlerts returnerar endast alerts
|
||||
func (h *BriefingHandler) GetAlerts(w http.ResponseWriter, r *http.Request) {
|
||||
userID := "3847477b-3d56-4975-9157-ae8f9ce52aa7"
|
||||
|
||||
briefing, err := h.engine.GenerateDailyBriefing(r.Context(), userID)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"failed to generate briefing"}`, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"alerts": briefing.Alerts,
|
||||
})
|
||||
}
|
||||
|
||||
// GetRecommendations returnerar endast rekommendationer
|
||||
func (h *BriefingHandler) GetRecommendations(w http.ResponseWriter, r *http.Request) {
|
||||
userID := "3847477b-3d56-4975-9157-ae8f9ce52aa7"
|
||||
|
||||
briefing, err := h.engine.GenerateDailyBriefing(r.Context(), userID)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"failed to generate briefing"}`, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"recommendations": briefing.Recommendations,
|
||||
})
|
||||
}
|
||||
|
||||
// GetWorkPlan returnerar endast arbetsplanen
|
||||
func (h *BriefingHandler) GetWorkPlan(w http.ResponseWriter, r *http.Request) {
|
||||
userID := "3847477b-3d56-4975-9157-ae8f9ce52aa7"
|
||||
|
||||
briefing, err := h.engine.GenerateDailyBriefing(r.Context(), userID)
|
||||
if err != nil {
|
||||
http.Error(w, `{"error":"failed to generate briefing"}`, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(briefing.WorkPlan)
|
||||
}
|
||||
Reference in New Issue
Block a user