show version in UI
This commit is contained in:
@@ -21,12 +21,14 @@ type webServer struct {
|
||||
db *db.DB
|
||||
site providers.Site
|
||||
model string
|
||||
build binaryBuildInfo
|
||||
}
|
||||
|
||||
type dashboardResponse struct {
|
||||
GeneratedAt time.Time `json:"generated_at"`
|
||||
Site string `json:"site"`
|
||||
Model string `json:"model"`
|
||||
Build binaryBuildInfo `json:"build"`
|
||||
RangeStart time.Time `json:"range_start"`
|
||||
RangeEnd time.Time `json:"range_end"`
|
||||
Observations []db.ObservationPoint `json:"observations"`
|
||||
@@ -46,6 +48,7 @@ func runWebServer(ctx context.Context, d *db.DB, site providers.Site, model, add
|
||||
db: d,
|
||||
site: site,
|
||||
model: model,
|
||||
build: currentBuildInfo(),
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
@@ -53,7 +56,10 @@ func runWebServer(ctx context.Context, d *db.DB, site providers.Site, model, add
|
||||
mux.HandleFunc("/api/dashboard", ws.handleDashboard)
|
||||
mux.HandleFunc("/api/health", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"ok":true}`))
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"ok": true,
|
||||
"build": ws.build,
|
||||
})
|
||||
})
|
||||
mux.HandleFunc("/chart", func(w http.ResponseWriter, r *http.Request) {
|
||||
serveIndex(w, sub)
|
||||
@@ -193,6 +199,7 @@ func (s *webServer) handleDashboard(w http.ResponseWriter, r *http.Request) {
|
||||
GeneratedAt: time.Now().UTC(),
|
||||
Site: s.site.Name,
|
||||
Model: s.model,
|
||||
Build: s.build,
|
||||
RangeStart: start,
|
||||
RangeEnd: end,
|
||||
Observations: observations,
|
||||
|
||||
Reference in New Issue
Block a user