feat: v1.3.87 — Grafana Organizations per namespace (StatsProvider + public dashboards + UI button)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// handleStatsDashboard GET /console/api/stats/dashboard-url
|
||||
// Возвращает публичный URL дашборда Grafana для текущего namespace пользователя.
|
||||
// Если аналитика не настроена — возвращает {"url":""}.
|
||||
func (s *Server) handleStatsDashboard(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
writeJSONError(w, http.StatusMethodNotAllowed, "method not allowed")
|
||||
return
|
||||
}
|
||||
|
||||
ns := s.userNS(r)
|
||||
url := s.stats.DashboardURL(r.Context(), ns)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"url": url,
|
||||
"namespace": ns,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user