Add adjustable probe area for OpenSky test connection

Let the OpenSky health probe run over a chosen bounding box without
touching the saved default, so its credit cost (which scales with area)
can be checked cheaply.

- Backend: the plugin health endpoint (panel Check) and the OpenSky
  health endpoint (Web App Test connection) accept an optional ?bbox=,
  validated with validBBox and applied to a transient probe instance;
  both BFF and API forward it. Saved config is untouched.
- API panel: a "Probe area" picker beside each bbox-capable plugin's
  Check button — saved default, all countries (grouped by continent),
  or Custom. Adds a compact pv-input-sm style.
- Web App: a "Test area" picker beside Test connection, using the full
  country list (new countryGroups() helper) plus Custom. This is where
  the probe is authenticated and the credit cost is shown.

Builds pass across both Go modules and both frontends. Panel picker
verified live (186 options, defaults to saved default).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
tajniak81
2026-07-14 10:25:59 +02:00
co-authored by Claude Opus 4.8
parent 763cc67081
commit 15bff7f517
17 changed files with 233 additions and 53 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0F1E3D" />
<title>PilotVault · API Server</title>
<script type="module" crossorigin src="/assets/index-B8Dqe_UO.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CVh8EDzq.css">
<script type="module" crossorigin src="/assets/index-Dh-j3HLZ.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-4CKxSIBg.css">
</head>
<body>
<div id="app"></div>
+7 -1
View File
@@ -536,11 +536,17 @@ func (s *Server) handleOpenSkyHealth(w http.ResponseWriter, r *http.Request) {
"status": "down", "detail": "OpenSky is disabled for your organization"}})
return
}
// A ?bbox= override lets the Settings "Test connection" probe a specific area
// (to check its credit cost) without changing the saved default.
bbox := res.eff.Bbox
if q := strings.TrimSpace(r.URL.Query().Get("bbox")); q != "" && validBBox(q) {
bbox = q
}
cfg := map[string]string{
"clientId": res.eff.ClientID,
"clientSecret": res.eff.ClientSecret,
"plan": res.eff.Plan,
"bbox": res.eff.Bbox,
"bbox": bbox,
"allowAnonymous": boolStr(res.allowAnon),
}
h, err := s.plugins.HealthCheckWith(r.Context(), openSkyPlugin, cfg)
+34 -2
View File
@@ -93,9 +93,41 @@ func (s *Server) handleDeletePlugin(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, map[string]any{"ok": true})
}
// POST /api/admin/plugins/{name}/health — run a health check now.
// POST /api/admin/plugins/{name}/health — run a health check now. An optional
// ?bbox= overrides the plugin's stored bounding box for this probe only (used by
// the panel to test-probe OpenSky over a smaller, cheaper area without changing
// the saved default). Ignored by plugins that don't use a bbox.
func (s *Server) handlePluginHealth(w http.ResponseWriter, r *http.Request) {
h, err := s.plugins.HealthCheck(r.Context(), r.PathValue("name"))
name := r.PathValue("name")
if bbox := strings.TrimSpace(r.URL.Query().Get("bbox")); bbox != "" {
if !validBBox(bbox) {
writeError(w, http.StatusBadRequest, "invalid bbox")
return
}
cfg, _, ok := s.plugins.RawConfig(name)
if !ok {
writeError(w, http.StatusNotFound, "unknown plugin")
return
}
if cfg == nil {
cfg = map[string]string{}
}
cfg["bbox"] = bbox
h, err := s.plugins.HealthCheckWith(r.Context(), name, cfg)
if err != nil {
if plugins.IsUnknown(err) {
writeError(w, http.StatusNotFound, "unknown plugin")
return
}
writeJSON(w, http.StatusBadGateway, map[string]any{"error": err.Error()})
return
}
writeJSON(w, http.StatusOK, map[string]any{"health": h})
return
}
h, err := s.plugins.HealthCheck(r.Context(), name)
if err != nil {
if plugins.IsUnknown(err) {
writeError(w, http.StatusNotFound, "unknown plugin")