From 04ad3e2dd845734acf61e3c48cbac3de582cd4c3 Mon Sep 17 00:00:00 2001 From: Jan Svabenik Date: Wed, 18 Mar 2026 10:21:11 +0100 Subject: [PATCH] Expose decoder list API and populate UI --- cmd/sdrd/main.go | 16 ++++++++++++++++ web/app.js | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/cmd/sdrd/main.go b/cmd/sdrd/main.go index 20b6e9d..95309da 100644 --- a/cmd/sdrd/main.go +++ b/cmd/sdrd/main.go @@ -9,6 +9,7 @@ import ( "os" "os/signal" "path/filepath" + "sort" "strconv" "strings" "sync" @@ -516,6 +517,11 @@ func main() { _ = json.NewEncoder(w).Encode(sigSnap.get()) }) + http.HandleFunc("/api/decoders", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + _ = json.NewEncoder(w).Encode(decoderKeys(cfgManager.Snapshot())) + }) + http.HandleFunc("/api/recordings", func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) @@ -825,6 +831,16 @@ func buildDecoderMap(cfg config.Config) map[string]string { return out } +func decoderKeys(cfg config.Config) []string { + m := buildDecoderMap(cfg) + keys := make([]string, 0, len(m)) + for k := range m { + keys = append(keys, k) + } + sort.Strings(keys) + return keys +} + func parseSince(raw string) (time.Time, error) { if raw == "" { return time.Time{}, nil diff --git a/web/app.js b/web/app.js index 3dcc747..b90cd99 100644 --- a/web/app.js +++ b/web/app.js @@ -1276,6 +1276,29 @@ window.addEventListener('keydown', (ev) => { } }); +loadConfig(); +loadStats(); +loadGPU(); +fetchEvents(true); +fetchRecordings(); +loadDecoders(); +connect(); +requestAnimationFrame(renderLoop); +setInterval(loadStats, 1000); +setInterval(loadGPU, 1000); +setInterval(() => fetchEvents(false), 2000); +setInterval(fetchRecordings, 5000); +setInterval(loadSignals, 1500); +setInterval(loadDecoders, 10000); +lse if (ev.key === 'ArrowLeft') { + pan = Math.max(-0.5, pan - 0.04); + followLive = false; + } else if (ev.key === 'ArrowRight') { + pan = Math.min(0.5, pan + 0.04); + followLive = false; + } +}); + loadConfig(); loadStats(); loadGPU();