Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eff19f6e2 | ||
|
|
e0dfa53f54 | ||
|
|
4f87cedc2c | ||
|
|
d273d21f1a | ||
|
|
bde136b98b | ||
|
|
ae7472a67d | ||
|
|
0d48dbfd17 | ||
|
|
d6ed9f03eb | ||
|
|
c95a1137fc | ||
|
|
d41352a3a5 | ||
|
|
9b2115be8f | ||
|
|
0a8c1ac45f | ||
|
|
6497568813 | ||
|
|
9f62808392 | ||
|
|
9d8b69d804 | ||
|
|
6825af135a | ||
|
|
ca42fd90f9 | ||
|
|
18a583901c | ||
|
|
2cb1add3db | ||
|
|
a3815c24a1 | ||
|
|
f6f5235a8b | ||
|
|
86a644863a |
@@ -541,6 +541,8 @@ type StationSettings struct {
|
||||
MyCountry string `json:"my_country"`
|
||||
MySOTARef string `json:"my_sota_ref"`
|
||||
MyPOTARef string `json:"my_pota_ref"`
|
||||
// MyIOTA is the island the station operates FROM (ADIF MY_IOTA), e.g. EU-005.
|
||||
MyIOTA string `json:"my_iota"`
|
||||
}
|
||||
|
||||
// LookupSettings is the JSON shape exchanged with the frontend.
|
||||
@@ -595,6 +597,18 @@ type App struct {
|
||||
// or when a setting that shapes the maps flips.
|
||||
clusterStatusIdx *clusterStatusCache
|
||||
clusterStatusMu sync.Mutex
|
||||
// decodeGrids maps a callsign to the 4-character grid it announced in a CQ
|
||||
// heard over the WSJT-X UDP link. It is the ONLY source of grids we have for
|
||||
// a spot: a DX-cluster line carries the spotter's grid at best, never the
|
||||
// DX's, and a per-callsign QRZ lookup under an RBN firehose is out of the
|
||||
// question. So grids are known for the stations this station's own receiver
|
||||
// decoded — which is exactly the FT8/FT4 watering hole an operator is looking
|
||||
// at when grid chasing.
|
||||
//
|
||||
// In memory only, and bounded: it is a session-local view of who is on the
|
||||
// air now, not a database.
|
||||
decodeGrids map[string]string
|
||||
decodeGridsMu sync.RWMutex
|
||||
// Self-spot throttle: when and on what frequency we last announced ourselves.
|
||||
// Held in memory only — a restart legitimately re-announces the station.
|
||||
selfSpotMu sync.Mutex
|
||||
@@ -687,16 +701,17 @@ type App struct {
|
||||
liveFreqHz int64 // last freq/band/mode the UI reported (fallback when CAT is off)
|
||||
liveBand string
|
||||
liveMode string
|
||||
livePublishTimer *time.Timer // debounced live-status publish on activity change
|
||||
liveLastQSOAt time.Time // when this operator last logged a NEW contact — drives online/offline
|
||||
liveTableMu sync.Mutex // guards liveTableFor
|
||||
liveTableFor *sql.DB // logbook whose live_status DDL has been ensured (once per connection, not per call)
|
||||
awardSnapMu sync.Mutex // guards the award QSO snapshot
|
||||
awardSnap []qso.QSO // light-scanned + enriched logbook snapshot reused across award computations
|
||||
awardSnapRev string // logbook revision the snapshot was built at ("" = none)
|
||||
awardSnapUsed time.Time // last read — the snapshot is dropped once it goes cold (see awardSnapshotJanitor)
|
||||
webpub webPublisher // log-to-website publishing: debounce timer, periodic ticker, last result
|
||||
dataDir string // <exeDir>/data — holds config.json, logs, cty.dat
|
||||
livePublishTimer *time.Timer // debounced live-status publish on activity change
|
||||
liveLastQSOAt time.Time // when this operator last logged a NEW contact — drives online/offline
|
||||
liveTableMu sync.Mutex // guards liveTableFor
|
||||
liveTableFor *sql.DB // logbook whose live_status DDL has been ensured (once per connection, not per call)
|
||||
awardSnapMu sync.Mutex // guards the award QSO snapshot
|
||||
awardSnap []qso.QSO // light-scanned + enriched logbook snapshot reused across award computations
|
||||
awardSnapRev string // logbook revision the snapshot was built at ("" = none)
|
||||
awardSnapUsed time.Time // last read — the snapshot is dropped once it goes cold (see awardSnapshotJanitor)
|
||||
webpub webPublisher // log-to-website publishing: debounce timer, periodic ticker, last result
|
||||
bandOpen bandOpenState // sporadic-E / band-opening detector over the spot stream
|
||||
dataDir string // <exeDir>/data — holds config.json, logs, cty.dat
|
||||
|
||||
// shuttingDown gates beforeClose re-entry: the first user attempt to
|
||||
// close fires shutdown tasks (backup, future LoTW upload, ...) while
|
||||
@@ -949,7 +964,12 @@ func (a *App) startup(ctx context.Context) {
|
||||
// impossible: the copy someone is actually running is not always the one they
|
||||
// think they installed, and the version shown in the UI is the only clue.
|
||||
exe, _ := os.Executable()
|
||||
applog.Printf("startup: OpsLog %s — %s", appVersion, exe)
|
||||
// Everything before this line is outside our control: Windows mapping a 30 MB
|
||||
// binary, an antivirus reading all of it, and Wails creating the WebView2
|
||||
// environment. Logging it separates "OpsLog is slow" from "starting OpsLog is
|
||||
// slow", which are two different problems with two different fixes.
|
||||
applog.Printf("startup: OpsLog %s — %s (%.0f ms before startup: exe load + WebView2)",
|
||||
appVersion, exe, float64(time.Since(processStart).Microseconds())/1000)
|
||||
applog.Printf("startup: data dir = %s", dataDir)
|
||||
// The local SQLite file ALWAYS holds per-operator configuration — settings,
|
||||
// station profiles, rigs/antennas, cluster nodes, UDP, QSL templates, award
|
||||
@@ -1390,6 +1410,10 @@ func (a *App) startup(ctx context.Context) {
|
||||
func (a *App) domReady(ctx context.Context) {
|
||||
a.restoreWindowPosition()
|
||||
wruntime.WindowShow(ctx)
|
||||
// The one number that matches what the operator actually experiences: click
|
||||
// to window. Anything else measures a part of it.
|
||||
applog.Printf("startup: window visible %.0f ms after launch",
|
||||
float64(time.Since(processStart).Microseconds())/1000)
|
||||
}
|
||||
|
||||
// StartupStatus returns a diagnostic snapshot for the frontend.
|
||||
@@ -2471,6 +2495,19 @@ func (a *App) groupDigitalSlots() bool {
|
||||
// Off (default) → a call worked on any band/mode reads as already worked. On →
|
||||
// the WORKED-call flag needs the same band and mode (digital-grouped when that
|
||||
// option is also on).
|
||||
// clusterSlotHighlight reports the "colour the stations I have NOT worked on
|
||||
// this band and mode" preference (Settings -> DX Cluster). It needs the same
|
||||
// per-slot index as clusterWorkedSameSlot, which is why the index is built when
|
||||
// EITHER is on: that map is one entry per worked call+band+mode, so on a large
|
||||
// log it is not something to hold for an operator using neither.
|
||||
func (a *App) clusterSlotHighlight() bool {
|
||||
if a.settings == nil {
|
||||
return false
|
||||
}
|
||||
v, _ := a.settings.Get(a.ctx, "ui.opslog.clusterSlotHighlight")
|
||||
return v == "1"
|
||||
}
|
||||
|
||||
func (a *App) clusterWorkedSameSlot() bool {
|
||||
if a.settings == nil {
|
||||
return false
|
||||
@@ -2646,6 +2683,23 @@ func (a *App) AddQSO(q qso.QSO) (id int64, err error) {
|
||||
// and the audio was discarded (recordings silently stopped working). The
|
||||
// snapshot is an in-memory copy; the heavy file encode still runs async.
|
||||
a.saveQSORecording(&q)
|
||||
// Drop the cluster worked-index snapshot BEFORE announcing, so the refresh
|
||||
// the frontend fires on qso:logged rebuilds it and sees this QSO.
|
||||
//
|
||||
// Without this the spot colours never moved after a contact. Logging emitted
|
||||
// the event, the frontend dutifully re-queried every visible spot two
|
||||
// seconds later, and ClusterSpotStatuses answered out of a snapshot built
|
||||
// before the QSO — the same "new band" as before, for ever. Reported on an
|
||||
// E51 and again on a ZD7 that stayed yellow on the band map with the QSO
|
||||
// plainly in the log.
|
||||
//
|
||||
// Deliberately NOT invalidateAwardStats(): that also drops the award
|
||||
// matrices, which are expensive to rebuild on a large log, and a contest run
|
||||
// would pay for it once per QSO. This index is a handful of DISTINCT scans
|
||||
// and it is what the spot colours actually read.
|
||||
a.clusterStatusMu.Lock()
|
||||
a.clusterStatusIdx = nil
|
||||
a.clusterStatusMu.Unlock()
|
||||
// Announce the log RIGHT AWAY so the grid/UI refresh at once and the entry
|
||||
// form clears immediately — the operator is not made to wait on the DB.
|
||||
wruntime.EventsEmit(a.ctx, "qso:logged", id)
|
||||
@@ -2990,6 +3044,9 @@ func (a *App) applyStationDefaults(q *qso.QSO, includeIdentity bool) {
|
||||
if q.MyPOTARef == "" {
|
||||
q.MyPOTARef = p.MyPOTARef
|
||||
}
|
||||
if q.MyIOTA == "" {
|
||||
q.MyIOTA = p.MyIOTA
|
||||
}
|
||||
// MY_NAME = the operator's personal name (profile OpName, e.g. "Greg") — stamped
|
||||
// like the other My* fields so every QSO carries it, not just those edited by hand.
|
||||
if q.MyName == "" {
|
||||
@@ -7824,6 +7881,10 @@ func (a *App) clusterEventWorker() {
|
||||
if s.Historical {
|
||||
continue
|
||||
}
|
||||
// Band-opening detector. Deliberately AFTER the Historical guard above: a
|
||||
// SH/DX reply replays a hundred past spots in a second, which is exactly
|
||||
// the shape of a burst and would announce an opening that ended hours ago.
|
||||
a.detectBandOpening(s)
|
||||
// Fire any matching alert rules (sound / visual / e-mail).
|
||||
a.evaluateAlerts(s)
|
||||
// Mirror the spot onto the FlexRadio panadapter when enabled. Infer the
|
||||
@@ -11751,6 +11812,19 @@ func (a *App) consumeUDPEvents() {
|
||||
}
|
||||
switch {
|
||||
case ev.DecodeCall != "":
|
||||
// Remember the grid before anything else: a CQ is the one message that
|
||||
// carries it, and the station may never send another.
|
||||
if ev.DecodeGrid != "" {
|
||||
a.decodeGridsMu.Lock()
|
||||
if a.decodeGrids == nil {
|
||||
a.decodeGrids = make(map[string]string, 512)
|
||||
}
|
||||
if len(a.decodeGrids) > 20000 {
|
||||
a.decodeGrids = make(map[string]string, 512) // bound a long session
|
||||
}
|
||||
a.decodeGrids[strings.ToUpper(ev.DecodeCall)] = ev.DecodeGrid
|
||||
a.decodeGridsMu.Unlock()
|
||||
}
|
||||
// A WSJT-X decode (heard station). Render it on the FlexRadio
|
||||
// panadapter when the option is on; green + SNR comment, auto-expiring
|
||||
// after the configured duration. De-duped per call in the Flex backend.
|
||||
@@ -13404,6 +13478,7 @@ func (a *App) GetStationSettings() (StationSettings, error) {
|
||||
MyCountry: p.MyCountry,
|
||||
MySOTARef: p.MySOTARef,
|
||||
MyPOTARef: p.MyPOTARef,
|
||||
MyIOTA: p.MyIOTA,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -13501,6 +13576,10 @@ func (a *App) SaveStationSettings(s StationSettings) error {
|
||||
p.MyCountry = s.MyCountry
|
||||
p.MySOTARef = s.MySOTARef
|
||||
p.MyPOTARef = s.MyPOTARef
|
||||
// Uppercased on the way in: ADIF spells it EU-005, and an operator typing
|
||||
// "eu-005" would otherwise put a reference no award matcher recognises on
|
||||
// every QSO of an activation.
|
||||
p.MyIOTA = strings.ToUpper(strings.TrimSpace(s.MyIOTA))
|
||||
return a.profiles.Save(a.ctx, &p)
|
||||
}
|
||||
|
||||
@@ -16350,6 +16429,10 @@ type SpotQuery struct {
|
||||
Band string `json:"band"`
|
||||
Mode string `json:"mode"`
|
||||
POTARef string `json:"pota_ref,omitempty"` // park id if the spot is a POTA activation
|
||||
// Spotter is the station that sent the spot. Only its continent is wanted, and
|
||||
// resolving it here rather than in the frontend keeps the one DXCC prefix
|
||||
// table as the single authority on what continent a callsign is in.
|
||||
Spotter string `json:"spotter,omitempty"`
|
||||
}
|
||||
|
||||
// SpotStatus is the per-tuple result. Status is one of:
|
||||
@@ -16376,13 +16459,39 @@ type SpotStatus struct {
|
||||
// is resolved from the callsign via the offline ULS store (US only, and only
|
||||
// when that database has been downloaded); POTA from the spot's tagged park.
|
||||
NewCounty bool `json:"new_county"`
|
||||
NewPOTA bool `json:"new_pota"`
|
||||
// County and State are that resolved county, so the cluster can show it as a
|
||||
// column instead of only flagging it. Free: the ULS lookup that decides
|
||||
// NewCounty already has them in hand.
|
||||
County string `json:"county,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
NewPOTA bool `json:"new_pota"`
|
||||
// Grid is the 4-character square this station announced in a CQ on the UDP
|
||||
// link, and NewGrid says that square has never been worked. Both are empty /
|
||||
// false for any station this receiver has not decoded — a DX-cluster line
|
||||
// carries the SPOTTER's grid at best, never the DX's.
|
||||
Grid string `json:"grid,omitempty"`
|
||||
NewGrid bool `json:"new_grid"`
|
||||
// SpotterContinent is the continent of the station that SENT the spot, not of
|
||||
// the DX. It answers a different question — "is anyone near me hearing this?"
|
||||
// — which is what makes it worth filtering on: a JA spot on 20 m tells a
|
||||
// European very little about their own path.
|
||||
SpotterContinent string `json:"spotter_continent,omitempty"`
|
||||
// LoTW is true when the DX callsign appears in ARRL's user-activity list, so
|
||||
// an operator chasing confirmations can skip the stations that will never
|
||||
// upload. Inert until that list has been downloaded.
|
||||
LoTW bool `json:"lotw"`
|
||||
// NewPfx flags a CQ WPX prefix never worked before, and Pfx is that prefix.
|
||||
// Also orthogonal: a common entity on a worked band can still carry a prefix
|
||||
// that has never been in the log, which is exactly what a WPX chaser is
|
||||
// scanning the cluster for.
|
||||
NewPfx bool `json:"new_pfx"`
|
||||
Pfx string `json:"pfx,omitempty"`
|
||||
// WorkedSlot: this exact callsign already worked on THIS band and mode.
|
||||
// Distinct from WorkedCall, which follows the "same slot" preference and so
|
||||
// means different things depending on it. This one is always slot-scoped, so
|
||||
// the UI can highlight what is still to be worked here without the two
|
||||
// options having to agree. Only filled when the slot index is built.
|
||||
WorkedSlot bool `json:"worked_slot"`
|
||||
}
|
||||
|
||||
// clusterStatusCache holds the whole-logbook maps ClusterSpotStatuses colours
|
||||
@@ -16398,9 +16507,11 @@ type clusterStatusCache struct {
|
||||
workedCounties map[string]struct{}
|
||||
workedPOTA map[string]struct{}
|
||||
workedPfx map[string]struct{}
|
||||
workedGrids map[string]struct{} // "GRID|MODE", mode normalised like the rest
|
||||
normMode func(string) string // nil unless digital-mode grouping is on
|
||||
groupDigital bool // settings the maps were built under —
|
||||
sameSlot bool // a change rebuilds the snapshot
|
||||
slotHighlight bool // (same: the slot index is built for either)
|
||||
}
|
||||
|
||||
// clusterStatusMaps returns the cached worked-index snapshot, building it once
|
||||
@@ -16410,12 +16521,13 @@ type clusterStatusCache struct {
|
||||
func (a *App) clusterStatusMaps() *clusterStatusCache {
|
||||
groupDigital := a.groupDigitalSlots()
|
||||
sameSlot := a.clusterWorkedSameSlot()
|
||||
slotHighlight := a.clusterSlotHighlight()
|
||||
a.clusterStatusMu.Lock()
|
||||
defer a.clusterStatusMu.Unlock()
|
||||
if c := a.clusterStatusIdx; c != nil && c.groupDigital == groupDigital && c.sameSlot == sameSlot {
|
||||
if c := a.clusterStatusIdx; c != nil && c.groupDigital == groupDigital && c.sameSlot == sameSlot && c.slotHighlight == slotHighlight {
|
||||
return c
|
||||
}
|
||||
c := &clusterStatusCache{groupDigital: groupDigital, sameSlot: sameSlot}
|
||||
c := &clusterStatusCache{groupDigital: groupDigital, sameSlot: sameSlot, slotHighlight: slotHighlight}
|
||||
if a.qso == nil {
|
||||
a.clusterStatusIdx = c
|
||||
return c
|
||||
@@ -16455,13 +16567,17 @@ func (a *App) clusterStatusMaps() *clusterStatusCache {
|
||||
// "Already worked only on the same slot" option (Settings → DX Cluster): the
|
||||
// WORKED-call flag then needs the SAME band and mode (digital-grouped through
|
||||
// the same normMode when that option is on) rather than the call anywhere.
|
||||
if sameSlot {
|
||||
if sameSlot || slotHighlight {
|
||||
c.workedCallSlots, _ = a.qso.WorkedCallSlotKeys(a.ctx, c.normMode)
|
||||
}
|
||||
// Orthogonal dimensions: worked US counties (for the ULS callsign→county
|
||||
// lookup) and worked POTA parks.
|
||||
c.workedCounties, _ = a.qso.WorkedCountyKeys(a.ctx, award.USCountyKey)
|
||||
c.workedPOTA, _ = a.qso.WorkedPOTARefs(a.ctx)
|
||||
// One more DISTINCT scan when the snapshot is rebuilt, then pure map lookups
|
||||
// per spot — the same shape as the county and POTA sets beside it, which is
|
||||
// why grids cost nothing under an RBN firehose.
|
||||
c.workedGrids, _ = a.qso.WorkedGridKeys(a.ctx, c.normMode)
|
||||
// Worked WPX prefixes, derived from the callsigns we already loaded — no
|
||||
// extra query. Derived rather than read from the stored PFX column: that
|
||||
// column is only filled when an import supplied it, and deriving keeps this
|
||||
@@ -16505,6 +16621,21 @@ func (a *App) ClusterSpotStatuses(spots []SpotQuery) []SpotStatus {
|
||||
Band: strings.ToLower(q.Band),
|
||||
Mode: strings.ToUpper(q.Mode),
|
||||
}
|
||||
// Slot-scoped worked flag, independent of the sameSlot preference: it is
|
||||
// what "highlight what I have NOT worked here" reads, and that must not
|
||||
// change meaning because a different option was toggled.
|
||||
if workedCallSlots != nil {
|
||||
upCall := strings.ToUpper(q.Call)
|
||||
cm := out[i].Mode
|
||||
if normMode != nil && cm != "" {
|
||||
cm = normMode(cm)
|
||||
}
|
||||
if cm == "" {
|
||||
_, out[i].WorkedSlot = workedCallSlots[upCall+"|"+out[i].Band]
|
||||
} else {
|
||||
_, out[i].WorkedSlot = workedCallSlots[upCall+"|"+out[i].Band+"|"+cm]
|
||||
}
|
||||
}
|
||||
if sameSlot {
|
||||
// Already worked ONLY when this exact band+mode slot was worked. With no
|
||||
// inferable mode, fall back to same-band (better than claiming the whole
|
||||
@@ -16535,10 +16666,51 @@ func (a *App) ClusterSpotStatuses(spots []SpotQuery) []SpotStatus {
|
||||
out[i].NewPOTA = true
|
||||
}
|
||||
}
|
||||
// The spotter's continent, and whether the DX uploads to LoTW. Both are
|
||||
// in-memory lookups on tables already loaded, so they add nothing per spot.
|
||||
if a.dxcc != nil && q.Spotter != "" {
|
||||
// Strip the skimmer suffix first. RBN spotters report as "VU2OY-#" and
|
||||
// a cluster node as "DL1ABC-2"; the prefix matcher sees an unknown
|
||||
// callsign and gives up, so EVERY spot came back with no continent and
|
||||
// the filter silently matched nothing. A real callsign never contains a
|
||||
// hyphen, so cutting at the first one is safe.
|
||||
sp := q.Spotter
|
||||
if i := strings.IndexByte(sp, '-'); i > 0 {
|
||||
sp = sp[:i]
|
||||
}
|
||||
if m, ok := a.dxcc.Lookup(sp); ok {
|
||||
out[i].SpotterContinent = m.Continent
|
||||
}
|
||||
}
|
||||
if a.lotwUsers != nil {
|
||||
out[i].LoTW = a.lotwUsers.Lookup(q.Call).IsUser
|
||||
}
|
||||
// NEW GRID: the square this station announced in a CQ we decoded. The mode
|
||||
// is part of the key, so the "group digital modes" option decides whether a
|
||||
// grid worked on FT8 still counts as new on FT4 — one rule, no branch here.
|
||||
{
|
||||
// The length check has to be INSIDE the lock: the decode goroutine
|
||||
// replaces this map wholesale when it grows too large, so reading len()
|
||||
// unguarded is a race on the map header, not a cheap fast path.
|
||||
a.decodeGridsMu.RLock()
|
||||
g := a.decodeGrids[strings.ToUpper(q.Call)]
|
||||
a.decodeGridsMu.RUnlock()
|
||||
if g != "" {
|
||||
out[i].Grid = g
|
||||
cm := out[i].Mode
|
||||
if normMode != nil && cm != "" {
|
||||
cm = normMode(cm)
|
||||
}
|
||||
if _, done := idx.workedGrids[g+"|"+cm]; !done {
|
||||
out[i].NewGrid = true
|
||||
}
|
||||
}
|
||||
}
|
||||
// NEW COUNTY: resolve the callsign's home county from the offline ULS
|
||||
// store (US only; inert until downloaded) and flag if never worked.
|
||||
if a.uls != nil {
|
||||
if loc, ok := a.uls.Resolve(q.Call); ok {
|
||||
out[i].County, out[i].State = loc.County, loc.State
|
||||
if key := award.USCountyKey(loc.State, loc.County); key != "" {
|
||||
if _, done := workedCounties[key]; !done {
|
||||
out[i].NewCounty = true
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package main
|
||||
|
||||
// Band-opening announcements — the app-side glue for internal/bandopen.
|
||||
//
|
||||
// The detector needs nothing OpsLog does not already compute: the cluster event
|
||||
// worker enriches every spot with the great-circle distance and bearing from
|
||||
// the operator's grid before this is called. So watching for sporadic E costs
|
||||
// one function call per spot and no new data source.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"hamlog/internal/applog"
|
||||
"hamlog/internal/bandopen"
|
||||
"hamlog/internal/cluster"
|
||||
|
||||
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
type bandOpenState struct {
|
||||
mu sync.Mutex
|
||||
det *bandopen.Detector
|
||||
last []bandopen.Opening // most recent first, for the UI
|
||||
}
|
||||
|
||||
const maxRememberedOpenings = 20
|
||||
|
||||
// detectBandOpening feeds one spot to the detector and announces a hit.
|
||||
func (a *App) detectBandOpening(s cluster.Spot) {
|
||||
// No operator grid = no distance and no bearing on the spot, and the whole
|
||||
// detection rests on those two. Say nothing rather than guess.
|
||||
if !a.opSet || s.DistanceKm <= 0 || !bandopen.Watched(s.Band) {
|
||||
return
|
||||
}
|
||||
a.bandOpen.mu.Lock()
|
||||
if a.bandOpen.det == nil {
|
||||
a.bandOpen.det = bandopen.New(bandopen.DefaultConfig())
|
||||
}
|
||||
op := a.bandOpen.det.Add(bandopen.Spot{
|
||||
Call: s.DXCall, Band: s.Band, DistKm: s.DistanceKm,
|
||||
Bearing: s.ShortPath, At: s.ReceivedAt,
|
||||
}, a.opLat)
|
||||
if op != nil {
|
||||
a.bandOpen.last = append([]bandopen.Opening{*op}, a.bandOpen.last...)
|
||||
if len(a.bandOpen.last) > maxRememberedOpenings {
|
||||
a.bandOpen.last = a.bandOpen.last[:maxRememberedOpenings]
|
||||
}
|
||||
}
|
||||
a.bandOpen.mu.Unlock()
|
||||
if op == nil {
|
||||
return
|
||||
}
|
||||
|
||||
applog.Printf("bandopen: %s opening — %d stations, ~%d km, %s%s (%s)",
|
||||
op.Band, op.Calls, op.MedianKm, op.Sector(),
|
||||
map[bool]string{true: "", false: " — UNUSUAL for the season"}[op.InSeason],
|
||||
strings.Join(op.Examples, " "))
|
||||
if a.ctx != nil {
|
||||
wruntime.EventsEmit(a.ctx, "bandopen:detected", op)
|
||||
}
|
||||
}
|
||||
|
||||
// GetBandOpenings returns the openings seen this session, newest first. The UI
|
||||
// polls this so a detection is still visible after its toast has gone.
|
||||
func (a *App) GetBandOpenings() []bandopen.Opening {
|
||||
a.bandOpen.mu.Lock()
|
||||
defer a.bandOpen.mu.Unlock()
|
||||
out := make([]bandopen.Opening, len(a.bandOpen.last))
|
||||
copy(out, a.bandOpen.last)
|
||||
return out
|
||||
}
|
||||
|
||||
// BandOpeningSummary is the one-line form used in the toast and the log.
|
||||
func BandOpeningSummary(o bandopen.Opening) string {
|
||||
s := fmt.Sprintf("%s open — %d stations ~%d km, %s", strings.ToUpper(o.Band), o.Calls, o.MedianKm, o.Sector())
|
||||
if !o.InSeason {
|
||||
s += " (unusual for the season)"
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -1,4 +1,42 @@
|
||||
[
|
||||
{
|
||||
"version": "0.24.4",
|
||||
"date": "",
|
||||
"en": [
|
||||
"DX cluster: an L badge next to a callsign marks a station that uploads to LoTW, with a matching LoTW users only filter, and a Spotter continent filter narrows the list by where the spot came FROM — a JA report on 20 m tells a European little about their own path. The filter panel has been tidied along one rule: a switch is a behaviour you turn on or off, chips pick any number from a set. Nothing appears in both shapes any more, the Lock buttons sit in the heading of the section they lock, every section can be cleared the same way, and the whole panel is finally translated.",
|
||||
"DX cluster: the Spotter continent filter now actually matches. RBN skimmers report as VU2OY-# and cluster nodes as DL1ABC-2, and the suffix was passed straight to the prefix lookup, so every spot came back with no continent and the filter silently selected nothing.",
|
||||
"A spot now stops being NEW the moment you log it. Logging announced the QSO but never dropped the cluster worked-index snapshot, so the refresh that follows re-read the answer computed BEFORE the contact — a station stayed yellow on the band map and in the cluster with the QSO plainly in the log, until something else happened to rebuild the index.",
|
||||
"Station information gains an IOTA field (ADIF MY_IOTA, e.g. EU-005), stamped on every QSO like the SOTA and POTA references beside it. The QSO table has carried the field since the first release and both ADIF import and export already handled it — only the station profile could not supply it, so an island activation meant typing the reference on every contact.",
|
||||
"PowerGenius XL: fixed the amplifier link dropping and reconnecting every few seconds, and the stall while transmitting. The amp pushes status frames on the same socket it answers commands on, and it pushes them constantly once in OPERATE; OpsLog read one line per command and took whatever arrived first as its answer, so the stream slipped permanently one reply behind until a command timed out and the connection was dropped. Replies are now matched to the command that asked for them. Only ever visible over a remote link with the amplifier in OPERATE.",
|
||||
"No colour on worked stations now does only that: it removes the blue already-worked mark and leaves everything else alone. It used to blank the spot status as well, and the status is what dims a quiet row — so turning the option on made every grey row bright white, which is the opposite of what it is for.",
|
||||
"Grid squares in the cluster. Every CQ decoded over the WSJT-X UDP link carries the sender grid, and OpsLog now keeps it: a Grid column shows the square and NEW GRID flags one never worked, as a badge, a filled cell and a filter of its own. Whether a grid counts as new follows the group digital modes setting — with it on, a square worked on FT8 is no longer new on FT4; with it off the two are separate. Only stations your own receiver decodes have a grid: a cluster line carries the spotter grid at best, never the DX one. Turn the column on in Columns."
|
||||
],
|
||||
"fr": [
|
||||
"Cluster DX : un badge L à côté de l indicatif signale une station qui utilise LoTW, avec le filtre Utilisateurs LoTW seulement qui va avec, et un filtre Continent du spotter restreint selon l origine du spot — un report JA sur 20 m dit peu de chose à un Européen sur son propre chemin. Le panneau de filtres a été remis d aplomb selon une seule règle : un interrupteur est un comportement qu on active ou non, les pastilles choisissent dans un ensemble. Plus rien n existe sous les deux formes, les boutons de verrouillage sont dans le titre de la section qu ils verrouillent, chaque section s efface de la même façon, et le panneau est enfin traduit.",
|
||||
"Cluster DX : le filtre Continent du spotter fonctionne enfin. Les skimmers RBN s annoncent en VU2OY-# et les nœuds cluster en DL1ABC-2, et ce suffixe partait tel quel dans la recherche de préfixe — tous les spots revenaient sans continent et le filtre ne sélectionnait rien.",
|
||||
"Un spot cesse enfin d être NOUVEAU dès que tu l enregistres. La journalisation annonçait le QSO mais ne vidait jamais l instantané de l index des contacts, donc le rafraîchissement qui suit relisait la réponse calculée AVANT le contact — une station restait jaune sur le bandmap et dans le cluster alors que le QSO était bien au log, jusqu à ce qu autre chose reconstruise l index.",
|
||||
"Les informations station gagnent un champ IOTA (MY_IOTA en ADIF, par exemple EU-005), estampillé sur chaque QSO comme les références SOTA et POTA à côté. La table des QSO portait le champ depuis la première version et l import comme l export ADIF le géraient déjà — seul le profil station ne savait pas le fournir, donc une activation d île obligeait à retaper la référence à chaque contact.",
|
||||
"PowerGenius XL : corrigé le lien avec l ampli qui tombait et se reconnectait toutes les quelques secondes, et le blocage en émission. L ampli pousse des trames d état sur la socket même où il répond aux commandes, et il en pousse en permanence dès qu il est en OPERATE ; OpsLog lisait une ligne par commande et prenait la première arrivée pour sa réponse, donc le flux glissait définitivement d une réponse de retard jusqu à expiration et fermeture du lien. Les réponses sont désormais appariées à la commande qui les a demandées. Visible uniquement en liaison distante avec l ampli en OPERATE.",
|
||||
"Aucune couleur sur les stations déjà contactées ne fait plus que ça : la marque bleue disparaît, le reste ne bouge pas. L option vidait aussi le statut du spot, or c est le statut qui estompe une ligne sans intérêt — l activer rendait donc toutes les lignes grises blanches et éclatantes, soit l inverse du but recherché.",
|
||||
"Les carrés locator dans le cluster. Chaque CQ décodé sur le lien UDP WSJT-X porte le grid de l émetteur, et OpsLog le conserve désormais : une colonne Grid affiche le carré et NOUV GRID signale celui jamais contacté, en badge, en cellule remplie et avec son propre filtre. Ce qui compte comme nouveau suit le réglage de regroupement des modes digitaux — activé, un carré fait en FT8 n est plus neuf en FT4 ; désactivé, les deux sont distincts. Seules les stations décodées par ton propre récepteur ont un grid : une ligne de cluster porte le grid du spotter au mieux, jamais celui du DX. Colonne à activer dans Colonnes."
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.24.3",
|
||||
"date": "",
|
||||
"en": [
|
||||
"Band openings: OpsLog now tells you when 6, 4 or 2 m opens. It watches the spots already arriving from your clusters and RBN — several different stations appearing at single-hop range (500–2400 km) in the same bearing sector within a few minutes is the signature of sporadic E, and nothing else looks like it. You get one message per band per opening, naming the sector and the typical distance. An opening outside the usual season is still announced, and flagged as unusual: those are the ones worth knowing about. Nothing to configure — but the quality depends on having a cluster or RBN feed carrying VHF spots, and 2 m openings are often worked without ever being spotted.",
|
||||
"DX cluster, two display options (Settings › DX cluster). The first drops the colour and the badges on stations you have already worked: they stay in the list, they simply stop competing for your attention. The second colours every callsign you have not worked on this band and this mode, even when the entity itself is long since confirmed — the view for filling slots rather than chasing new ones. Both apply to the cluster list and to the band map, so the two panels always agree.",
|
||||
"DX cluster, clearer at a glance. A novelty now FILLS the cell that carries it — a filled Band cell means new band, a filled Pfx cell means new prefix, a filled County cell means new county — instead of only tinting the text. A US County column joins the list, resolved offline from the ULS database. The station-not-worked-here highlight is its own NEW CALL status with its own filter chip, no longer borrowed from NEW SLOT, which means something narrower. The two display options moved from Preferences into the cluster filter panel, next to Hide worked. The Locator column is now labelled Spotter locator, because that is what a cluster line actually carries.",
|
||||
"Web publishing: the published page sorts properly. The Date column would not sort at all, and neither would callsigns starting with a digit — the script read a number from the front of the text, so every date in the same year counted as equal. A third click on a header now puts the table back in the order it was published in, and an arrow shows which way a column is pointing."
|
||||
],
|
||||
"fr": [
|
||||
"Ouvertures de bande : OpsLog te signale désormais l ouverture du 6, du 4 ou du 2 m. Il surveille les spots qui arrivent déjà de tes clusters et du RBN — plusieurs stations différentes apparaissant à distance de saut simple (500–2400 km) dans le même secteur d azimut en quelques minutes, c est la signature de l Es, et rien d autre n y ressemble. Un message par bande et par ouverture, avec le secteur et la distance typique. Une ouverture hors saison est annoncée quand même, et signalée comme inhabituelle : ce sont celles qu il ne faut surtout pas manquer. Rien à configurer — mais la qualité dépend d avoir un flux cluster ou RBN qui porte des spots VHF, et les ouvertures 2 m sont souvent travaillées sans jamais être spottées.",
|
||||
"Cluster DX, deux options d affichage (Paramètres › Cluster DX). La première enlève la couleur et les badges sur les stations déjà contactées : elles restent dans la liste, elles cessent simplement d attirer l œil. La seconde colore tout indicatif non contacté sur cette bande et ce mode, même si l entité est confirmée depuis longtemps — la vue pour remplir des slots plutôt que pour chasser du nouveau. Les deux s appliquent à la liste cluster et au bandmap, les deux panneaux restent donc cohérents.",
|
||||
"Cluster DX, plus lisible d un coup d œil. Une nouveauté REMPLIT désormais la cellule qui la porte — cellule Bande remplie = nouvelle bande, cellule Préf. remplie = nouveau préfixe, cellule Comté remplie = nouveau comté — au lieu de seulement colorer le texte. Une colonne Comté US rejoint la liste, résolue hors ligne depuis la base ULS. La mise en couleur des stations non contactées ici devient un statut CALL NEUF à part entière, avec sa propre puce de filtre, au lieu d emprunter NOUV SLOT qui veut dire autre chose. Les deux options d affichage passent des Préférences au panneau de filtres du cluster, à côté de Hide worked. La colonne Locator s appelle maintenant Locator du spotter, puisque c est ce qu une ligne de cluster porte réellement.",
|
||||
"Publication web : la page publiée se trie correctement. La colonne Date ne se triait pas du tout, ni les indicatifs commençant par un chiffre — le script lisait un nombre au début du texte, donc toutes les dates d une même année se valaient. Un troisième clic sur un en-tête remet le tableau dans l ordre de publication, et une flèche indique le sens du tri."
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.24.2",
|
||||
"date": "",
|
||||
|
||||
+187
-92
@@ -89,6 +89,7 @@ import { ExportFieldsDialog } from '@/components/ExportFieldsDialog';
|
||||
import { ShutdownProgress } from '@/components/ShutdownProgress';
|
||||
import { ClusterGrid } from '@/components/ClusterGrid';
|
||||
import { cleanSpotter, inferSpotMode, spotModeCategory, spotStatusKey } from '@/lib/spot';
|
||||
import { applySpotDisplay, readSpotDisplayOptions } from '@/lib/spotDisplay';
|
||||
import { WorkedBeforeGrid } from '@/components/WorkedBeforeGrid';
|
||||
import { NetControlPanel } from '@/components/NetControlPanel';
|
||||
import { ContestPanel, CONTEST_DEFAULT, type ContestSession } from '@/components/ContestPanel';
|
||||
@@ -1484,7 +1485,19 @@ export default function App() {
|
||||
// county or a new park is not a DXCC state, it is another dimension of the
|
||||
// same spot — which is why the grid shows them as separate badges. Filtering
|
||||
// is an OR across all of them, as it already was for a worked callsign.
|
||||
type SpotFilterKey = SpotStatusKey | 'new-pota' | 'new-county' | 'new-pfx';
|
||||
// 'new-call' is a DISPLAY status, produced by the slot-highlight option rather
|
||||
// than by the backend, so it is named here and not in SpotStatusKey.
|
||||
type SpotFilterKey = SpotStatusKey | 'new-pota' | 'new-county' | 'new-pfx' | 'new-call' | 'new-grid';
|
||||
// Display options, shared with the band map through lib/spotDisplay. Kept in
|
||||
// localStorage (mirrored to settings by writeUiPref) so both panels and the
|
||||
// filter predicate read one source without prop-drilling through three levels.
|
||||
// LoTW-only, and the spotter's continent. Both narrow the list by a property
|
||||
// of the station rather than by what the spot is worth, which is why they sit
|
||||
// beside Hide worked and not among the status chips.
|
||||
const [clusterLotwOnly, setClusterLotwOnly] = useState(() => localStorage.getItem('opslog.clusterLotwOnly') === '1');
|
||||
const [clusterSpotterConts, setClusterSpotterConts] = useState<Set<string>>(() => lsSet<string>('opslog.clusterSpotterCont'));
|
||||
const [clusterMuteWorked, setClusterMuteWorked] = useState(() => localStorage.getItem('opslog.clusterMuteWorked') === '1');
|
||||
const [clusterSlotHighlight, setClusterSlotHighlight] = useState(() => localStorage.getItem('opslog.clusterSlotHighlight') === '1');
|
||||
const [clusterStatusFilter, setClusterStatusFilter] = useState<Set<SpotFilterKey>>(() => lsSet<SpotFilterKey>('opslog.clusterStatusFilter'));
|
||||
// Mode filter chips. Empty set = show every mode. Categories map the
|
||||
// inferred per-spot mode onto SSB (phone) / CW / DATA (digital).
|
||||
@@ -1503,11 +1516,13 @@ export default function App() {
|
||||
writeUiPref('opslog.clusterLockBand', clusterLockBand ? '1' : '0');
|
||||
writeUiPref('opslog.clusterLockMode', clusterLockMode ? '1' : '0');
|
||||
writeUiPref('opslog.clusterStatusFilter', JSON.stringify([...clusterStatusFilter]));
|
||||
writeUiPref('opslog.clusterSpotterCont', JSON.stringify([...clusterSpotterConts]));
|
||||
writeUiPref('opslog.clusterModeFilter', JSON.stringify([...clusterModeFilter]));
|
||||
writeUiPref('opslog.clusterSearch', clusterSearch);
|
||||
writeUiPref('opslog.clusterHideWorked', clusterHideWorked ? '1' : '0');
|
||||
}, [clusterFilterSource, clusterGroup, clusterBands, clusterLockBand, clusterLockMode,
|
||||
clusterStatusFilter, clusterModeFilter, clusterSearch, clusterHideWorked]);
|
||||
clusterStatusFilter, clusterModeFilter, clusterSearch, clusterHideWorked,
|
||||
clusterLotwOnly, clusterSpotterConts]);
|
||||
// Bands shown side-by-side in the Band Map tab (portable).
|
||||
const [bandMapBands, setBandMapBands] = useState<string[]>(() => {
|
||||
try { const v = JSON.parse(localStorage.getItem('opslog.bandMapBands') || '[]'); return Array.isArray(v) ? v : []; }
|
||||
@@ -1580,7 +1595,10 @@ export default function App() {
|
||||
// Cached per-call slot status: "new" | "new-band" | "new-slot" | "worked".
|
||||
// Keyed by `${call}|${band}|${mode}` so two spots of the same call on
|
||||
// different slots don't share the same colour.
|
||||
const [spotStatus, setSpotStatus] = useState<Record<string, { status: string; country?: string; continent?: string; worked_call?: boolean; new_county?: boolean; new_pota?: boolean; new_pfx?: boolean; pfx?: string }>>({});
|
||||
// worked_slot must be carried explicitly like every other field: this map is
|
||||
// assembled field by field, so a backend flag that nobody copies here simply
|
||||
// never reaches the panels — silently, since the extra key is just dropped.
|
||||
const [spotStatus, setSpotStatus] = useState<Record<string, { status: string; country?: string; continent?: string; worked_call?: boolean; worked_slot?: boolean; new_county?: boolean; county?: string; state?: string; lotw?: boolean; spotter_continent?: string; grid?: string; new_grid?: boolean; new_pota?: boolean; new_pfx?: boolean; pfx?: string }>>({});
|
||||
// Live mirror of spotStatus so the incoming-spot buffer can tell which slots
|
||||
// still need resolving without re-subscribing the cluster:spot listener.
|
||||
const spotStatusRef = useRef(spotStatus);
|
||||
@@ -1613,13 +1631,13 @@ export default function App() {
|
||||
const refreshSpotStatuses = useCallback(async () => {
|
||||
const cur = spotsRef.current;
|
||||
if (!cur.length) return;
|
||||
const queries: { call: string; band: string; mode: string; pota_ref: string }[] = [];
|
||||
const queries: { call: string; band: string; mode: string; pota_ref: string; spotter: string }[] = [];
|
||||
const seen = new Set<string>();
|
||||
for (const s of cur) {
|
||||
const k = spotStatusKey(s.dx_call, s.band ?? '', s.comment ?? '', s.freq_hz);
|
||||
if (seen.has(k)) continue;
|
||||
seen.add(k);
|
||||
queries.push({ call: s.dx_call, band: s.band ?? '', mode: inferSpotMode(s.comment ?? '', s.freq_hz), pota_ref: (s as any).pota_ref ?? '' });
|
||||
queries.push({ call: s.dx_call, band: s.band ?? '', mode: inferSpotMode(s.comment ?? '', s.freq_hz), pota_ref: (s as any).pota_ref ?? '', spotter: s.spotter ?? '' });
|
||||
}
|
||||
if (!queries.length) return;
|
||||
try {
|
||||
@@ -1630,7 +1648,7 @@ export default function App() {
|
||||
const k = `${r.call}|${r.band ?? ''}|${(r.mode ?? '').toUpperCase()}`;
|
||||
next[k] = {
|
||||
status: r.status ?? '', country: r.country, continent: (r as any).continent,
|
||||
worked_call: !!(r as any).worked_call, new_county: !!(r as any).new_county,
|
||||
worked_call: !!(r as any).worked_call, worked_slot: !!(r as any).worked_slot, new_county: !!(r as any).new_county, lotw: !!(r as any).lotw, spotter_continent: (r as any).spotter_continent, grid: (r as any).grid, new_grid: !!(r as any).new_grid, county: (r as any).county, state: (r as any).state,
|
||||
new_pota: !!(r as any).new_pota, new_pfx: !!(r as any).new_pfx, pfx: (r as any).pfx,
|
||||
};
|
||||
}
|
||||
@@ -1915,7 +1933,7 @@ export default function App() {
|
||||
// === Station ===
|
||||
const [station, setStation] = useState<StationSettings>({
|
||||
callsign: '', operator: '',
|
||||
my_grid: '', my_country: '', my_sota_ref: '', my_pota_ref: '',
|
||||
my_grid: '', my_country: '', my_sota_ref: '', my_pota_ref: '', my_iota: '',
|
||||
});
|
||||
const [showFirstRun, setShowFirstRun] = useState(false);
|
||||
myCallRef.current = (station.callsign || '').toUpperCase();
|
||||
@@ -2077,6 +2095,23 @@ export default function App() {
|
||||
return () => { off(); };
|
||||
}, [showToast]);
|
||||
|
||||
// Band openings — sporadic E on 6/4/2 m, detected from the spot stream.
|
||||
//
|
||||
// A toast rather than a rule-based alert: this is not "a station you wanted
|
||||
// appeared", it is "the band itself just changed", and it fires a handful of
|
||||
// times a season. The detector already announces each band once per opening,
|
||||
// so there is nothing to throttle here.
|
||||
useEffect(() => {
|
||||
const off = EventsOn('bandopen:detected', (o: any) => {
|
||||
if (!o?.band) return;
|
||||
const season = o.in_season ? '' : ` — ${t('bmp.openUnusual')}`;
|
||||
showToast(`📡 ${t('bmp.openToast', {
|
||||
band: String(o.band).toUpperCase(), n: o.calls, km: o.median_km,
|
||||
})}${season}`);
|
||||
});
|
||||
return () => { off(); };
|
||||
}, [showToast, t]);
|
||||
|
||||
// DX-cluster spot alerts: a matched rule fires here. Play a beep (WebAudio, no
|
||||
// asset needed — CSP-safe) and/or show a toast, per the rule's chosen actions.
|
||||
useEffect(() => {
|
||||
@@ -2689,7 +2724,7 @@ export default function App() {
|
||||
// Resolve unknown statuses before the rows go in.
|
||||
try {
|
||||
const known = spotStatusRef.current;
|
||||
const unknown: { call: string; band: string; mode: string; pota_ref: string }[] = [];
|
||||
const unknown: { call: string; band: string; mode: string; pota_ref: string; spotter: string }[] = [];
|
||||
const seen = new Set<string>();
|
||||
for (const s of batch) {
|
||||
const k = spotStatusKey(s.dx_call, s.band ?? '', s.comment ?? '', s.freq_hz);
|
||||
@@ -2699,6 +2734,7 @@ export default function App() {
|
||||
call: s.dx_call, band: s.band ?? '',
|
||||
mode: inferSpotMode(s.comment ?? '', s.freq_hz),
|
||||
pota_ref: (s as any).pota_ref ?? '',
|
||||
spotter: s.spotter ?? '',
|
||||
});
|
||||
}
|
||||
if (unknown.length > 0) {
|
||||
@@ -2712,7 +2748,8 @@ export default function App() {
|
||||
country: r.country,
|
||||
continent: (r as any).continent,
|
||||
worked_call: !!(r as any).worked_call,
|
||||
new_county: !!(r as any).new_county,
|
||||
worked_slot: !!(r as any).worked_slot,
|
||||
new_county: !!(r as any).new_county, lotw: !!(r as any).lotw, spotter_continent: (r as any).spotter_continent, grid: (r as any).grid, new_grid: !!(r as any).new_grid, county: (r as any).county, state: (r as any).state,
|
||||
new_pota: !!(r as any).new_pota,
|
||||
new_pfx: !!(r as any).new_pfx,
|
||||
pfx: (r as any).pfx,
|
||||
@@ -3158,14 +3195,14 @@ export default function App() {
|
||||
// "new-slot" because the lookup key carried mode="".
|
||||
useEffect(() => {
|
||||
const t = window.setTimeout(async () => {
|
||||
const unknown: { call: string; band: string; mode: string; pota_ref: string }[] = [];
|
||||
const unknown: { call: string; band: string; mode: string; pota_ref: string; spotter: string }[] = [];
|
||||
const seen = new Set<string>();
|
||||
for (const s of spots) {
|
||||
const mode = inferSpotMode(s.comment ?? '', s.freq_hz);
|
||||
const k = spotStatusKey(s.dx_call, s.band ?? '', s.comment ?? '', s.freq_hz);
|
||||
if (seen.has(k) || spotStatus[k]) continue;
|
||||
seen.add(k);
|
||||
unknown.push({ call: s.dx_call, band: s.band ?? '', mode, pota_ref: (s as any).pota_ref ?? '' });
|
||||
unknown.push({ call: s.dx_call, band: s.band ?? '', mode, pota_ref: (s as any).pota_ref ?? '', spotter: s.spotter ?? '' });
|
||||
}
|
||||
if (unknown.length === 0) return;
|
||||
try {
|
||||
@@ -3179,7 +3216,8 @@ export default function App() {
|
||||
country: r.country,
|
||||
continent: (r as any).continent,
|
||||
worked_call: !!(r as any).worked_call,
|
||||
new_county: !!(r as any).new_county,
|
||||
worked_slot: !!(r as any).worked_slot,
|
||||
new_county: !!(r as any).new_county, lotw: !!(r as any).lotw, spotter_continent: (r as any).spotter_continent, grid: (r as any).grid, new_grid: !!(r as any).new_grid, county: (r as any).county, state: (r as any).state,
|
||||
new_pota: !!(r as any).new_pota,
|
||||
new_pfx: !!(r as any).new_pfx,
|
||||
pfx: (r as any).pfx,
|
||||
@@ -4659,7 +4697,10 @@ export default function App() {
|
||||
}
|
||||
if (clusterStatusFilter.size > 0) {
|
||||
const k = spotStatusKey(s.dx_call, s.band ?? '', s.comment ?? '', s.freq_hz);
|
||||
const e = spotStatus[k];
|
||||
// Filter on what is DISPLAYED, not on the raw backend status: NEW CALL is
|
||||
// produced by the slot-highlight option, so a filter reading the raw
|
||||
// entry would offer a chip that never matches a single row.
|
||||
const e = applySpotDisplay(spotStatus[k], readSpotDisplayOptions());
|
||||
const st = (e?.status || '') as SpotStatusKey;
|
||||
// WORKED means "I've worked THIS callsign" — the blue WKD-CALL flag —
|
||||
// NOT the entity status 'worked' (entity/band/mode already worked, which
|
||||
@@ -4672,9 +4713,23 @@ export default function App() {
|
||||
|| (!!e?.worked_call && clusterStatusFilter.has('worked'))
|
||||
|| (!!e?.new_pota && clusterStatusFilter.has('new-pota'))
|
||||
|| (!!e?.new_county && clusterStatusFilter.has('new-county'))
|
||||
|| (!!e?.new_pfx && clusterStatusFilter.has('new-pfx'));
|
||||
|| (!!e?.new_pfx && clusterStatusFilter.has('new-pfx'))
|
||||
|| (!!e?.new_grid && clusterStatusFilter.has('new-grid'));
|
||||
if (!matches) return false;
|
||||
}
|
||||
// LoTW only, and the spotter's continent. Both are properties of the
|
||||
// station rather than judgements about the spot, so they AND with the
|
||||
// status chips instead of joining that OR: "a new band, and from Europe".
|
||||
if (clusterLotwOnly || clusterSpotterConts.size > 0) {
|
||||
const k = spotStatusKey(s.dx_call, s.band ?? '', s.comment ?? '', s.freq_hz);
|
||||
const e = spotStatus[k];
|
||||
// An unresolved spot is not filtered out. The status arrives a moment
|
||||
// after the row does, and dropping it meanwhile made the list flicker.
|
||||
if (e) {
|
||||
if (clusterLotwOnly && !e.lotw) return false;
|
||||
if (clusterSpotterConts.size > 0 && e.spotter_continent && !clusterSpotterConts.has(e.spotter_continent)) return false;
|
||||
}
|
||||
}
|
||||
if (clusterHideWorked) {
|
||||
const k = spotStatusKey(s.dx_call, s.band ?? '', s.comment ?? '', s.freq_hz);
|
||||
const e = spotStatus[k];
|
||||
@@ -4701,11 +4756,46 @@ export default function App() {
|
||||
// The Log4OM-style cluster filter sidebar (callsign search, hide-worked,
|
||||
// group, band/mode/status/source). Rendered both in the Cluster tab and the
|
||||
// Main-view cluster pane; toggled by clusterShowFilters.
|
||||
// One rule for the whole panel, because two shapes for the same kind of choice
|
||||
// is what made it unreadable:
|
||||
//
|
||||
// SWITCH — a behaviour that is on or off (hide worked, group duplicates).
|
||||
// CHIPS — pick any number from a set; none picked means all (status, mode,
|
||||
// continent). Selected is solid, unselected is the same chip faded,
|
||||
// so the palette teaches the colour code even while switched off.
|
||||
//
|
||||
// Nothing appears in both shapes. A control that exists twice is not more
|
||||
// discoverable, it is one control the operator has to recognise twice.
|
||||
const fSection = (label: string, children: any, right?: any) => (
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-1 min-h-[16px]">
|
||||
<span className="text-[10px] uppercase tracking-wider text-muted-foreground">{label}</span>
|
||||
{right}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
const fSwitch = (label: string, on: boolean, set: (v: boolean) => void) => (
|
||||
<label className="flex items-center gap-2 cursor-pointer rounded px-1 py-1 -mx-1 hover:bg-accent/40">
|
||||
<Checkbox checked={on} onCheckedChange={(c) => set(!!c)} />
|
||||
<span className="leading-none">{label}</span>
|
||||
</label>
|
||||
);
|
||||
|
||||
const F_CHIP = 'px-1.5 py-[3px] rounded-md border text-[10px] font-bold tracking-wider transition-opacity';
|
||||
const fChip = (key: string, label: string, cls: string, on: boolean, toggle: () => void) => (
|
||||
<button key={key} type="button" onClick={toggle}
|
||||
className={cn(F_CHIP, on ? cls : `${cls} opacity-40 hover:opacity-80`)}>
|
||||
{label}
|
||||
</button>
|
||||
);
|
||||
|
||||
const renderClusterFilters = () => (
|
||||
<div className="w-56 shrink-0 border-l border-border/60 flex flex-col min-h-0 bg-muted/10">
|
||||
<div className="px-2.5 py-2 border-b border-border/60 flex items-center justify-between">
|
||||
<span className="text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">Filters</span>
|
||||
<button type="button" onClick={toggleClusterFilters} title="Hide filters"
|
||||
<span className="text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">{t('clu.filters')}</span>
|
||||
<button type="button" onClick={toggleClusterFilters} title={t('clu.hideFilters')}
|
||||
className="text-muted-foreground hover:text-foreground">
|
||||
<X className="size-3.5" />
|
||||
</button>
|
||||
@@ -4714,42 +4804,48 @@ export default function App() {
|
||||
{/* Callsign search */}
|
||||
<Input
|
||||
className="h-7 text-xs font-mono uppercase"
|
||||
placeholder="Search call…"
|
||||
placeholder={t('clu.searchCall')}
|
||||
value={clusterSearch}
|
||||
onChange={(e) => setClusterSearch(e.target.value.toUpperCase())}
|
||||
/>
|
||||
|
||||
{/* Toggles */}
|
||||
<div className="space-y-1.5">
|
||||
<label className="flex items-center gap-1.5 cursor-pointer">
|
||||
<Checkbox checked={clusterHideWorked} onCheckedChange={(c) => setClusterHideWorked(!!c)} />
|
||||
Hide worked
|
||||
</label>
|
||||
<label className="flex items-center gap-1.5 cursor-pointer">
|
||||
<Checkbox checked={clusterGroup} onCheckedChange={(c) => setClusterGroup(!!c)} />
|
||||
Group duplicates
|
||||
</label>
|
||||
{/* Behaviours: each is on or off, and none of them narrows by a property
|
||||
of the station. The last two also drive the band map, via
|
||||
lib/spotDisplay — they live here rather than in Preferences because
|
||||
they are changed while working a run. */}
|
||||
<div className="space-y-0.5">
|
||||
{fSwitch(t('clu.hideWorked'), clusterHideWorked, setClusterHideWorked)}
|
||||
{fSwitch(t('clu.groupDup'), clusterGroup, setClusterGroup)}
|
||||
{fSwitch(t('clu.muteWorkedShort'), clusterMuteWorked, (v) => { setClusterMuteWorked(v); writeUiPref('opslog.clusterMuteWorked', v ? '1' : '0'); })}
|
||||
{fSwitch(t('clu.slotHighlightShort'), clusterSlotHighlight, (v) => { setClusterSlotHighlight(v); writeUiPref('opslog.clusterSlotHighlight', v ? '1' : '0'); })}
|
||||
{fSwitch(t('clu.lotwOnly'), clusterLotwOnly, (v) => { setClusterLotwOnly(v); writeUiPref('opslog.clusterLotwOnly', v ? '1' : '0'); })}
|
||||
</div>
|
||||
|
||||
{/* The SPOTTER's continent, not the DX's: this asks whether anyone near
|
||||
you is hearing the band at all. Chips rather than a dropdown — seven
|
||||
two-letter codes fit on two lines, they read as a set the way Status
|
||||
and Mode do, and several can be picked at once, which "EU or NA" needs
|
||||
and a dropdown cannot express. */}
|
||||
{fSection(t('clu.spotterCont'),
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{['AF', 'AN', 'AS', 'EU', 'NA', 'OC', 'SA'].map((c) => fChip(
|
||||
c, c, 'bg-muted text-foreground border-border',
|
||||
clusterSpotterConts.has(c),
|
||||
() => setClusterSpotterConts((cur) => {
|
||||
const n = new Set(cur);
|
||||
if (n.has(c)) n.delete(c); else n.add(c);
|
||||
return n;
|
||||
}),
|
||||
))}
|
||||
</div>,
|
||||
clusterSpotterConts.size > 0 ? (
|
||||
<button type="button" onClick={() => setClusterSpotterConts(new Set())}
|
||||
className="text-[10px] text-muted-foreground hover:text-foreground underline">{t('clu.clear')}</button>
|
||||
) : undefined,
|
||||
)}
|
||||
|
||||
{/* Band filter — multi-select listbox */}
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-1">
|
||||
<span className="text-[10px] uppercase tracking-wider text-muted-foreground">Bands</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setClusterLockBand((v) => !v)}
|
||||
className={cn('inline-flex items-center gap-0.5 text-[10px] px-1 py-0.5 rounded border',
|
||||
clusterLockBand ? 'bg-warning-muted text-warning-muted-foreground border-warning-border' : 'text-muted-foreground border-border hover:bg-muted')}
|
||||
title="Lock to the entry strip's current band"
|
||||
>
|
||||
{clusterLockBand ? <Lock className="size-2.5" /> : <Unlock className="size-2.5" />} {band}
|
||||
</button>
|
||||
{clusterBands.size > 0 && (
|
||||
<button type="button" onClick={() => setClusterBands(new Set())} className="text-[10px] text-muted-foreground hover:text-foreground underline">clear</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{fSection(t('clu.bands'),
|
||||
<div className={cn('rounded border border-border max-h-36 overflow-auto bg-background', clusterLockBand && 'opacity-40 pointer-events-none')}>
|
||||
{bands.map((b) => {
|
||||
const on = clusterBands.has(b);
|
||||
@@ -4765,83 +4861,82 @@ export default function App() {
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Mode lock */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setClusterLockMode((v) => !v)}
|
||||
className={cn('inline-flex items-center gap-1 px-1.5 py-0.5 rounded border text-[10px]',
|
||||
clusterLockMode ? 'bg-warning-muted text-warning-muted-foreground border-warning-border' : 'text-muted-foreground border-border hover:bg-muted')}
|
||||
title="Only show spots whose mode matches the entry strip"
|
||||
>
|
||||
{clusterLockMode ? <Lock className="size-2.5" /> : <Unlock className="size-2.5" />} Lock mode ({mode})
|
||||
</button>
|
||||
</div>,
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setClusterLockBand((v) => !v)}
|
||||
className={cn('inline-flex items-center gap-0.5 text-[10px] px-1 py-0.5 rounded border',
|
||||
clusterLockBand ? 'bg-warning-muted text-warning-muted-foreground border-warning-border' : 'text-muted-foreground border-border hover:bg-muted')}
|
||||
title={t('clu.lockBandTitle')}
|
||||
>
|
||||
{clusterLockBand ? <Lock className="size-2.5" /> : <Unlock className="size-2.5" />} {band}
|
||||
</button>
|
||||
{clusterBands.size > 0 && (
|
||||
<button type="button" onClick={() => setClusterBands(new Set())} className="text-[10px] text-muted-foreground hover:text-foreground underline">{t('clu.clear')}</button>
|
||||
)}
|
||||
</div>,
|
||||
)}
|
||||
|
||||
{/* Status filter */}
|
||||
<div>
|
||||
<div className="text-[10px] uppercase tracking-wider text-muted-foreground mb-1">Status</div>
|
||||
{fSection(t('clu.status'),
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{([
|
||||
{ k: 'new' as SpotFilterKey, label: 'NEW', cls: 'bg-danger-muted text-danger-muted-foreground border-danger-border' },
|
||||
{ k: 'new-band' as SpotFilterKey, label: 'NEW BAND', cls: 'bg-warning-muted text-warning-muted-foreground border-warning-border' },
|
||||
{ k: 'new-mode' as SpotFilterKey, label: 'NEW MODE', cls: 'bg-caution-muted text-caution-muted-foreground border-caution-border' },
|
||||
{ k: 'new-slot' as SpotFilterKey, label: 'NEW SLOT', cls: 'bg-caution-muted text-caution-muted-foreground border-caution-border' },
|
||||
// NEW CALL is about the CALLSIGN, not the entity: never worked on this
|
||||
// band and mode. Only appears when the slot-highlight option is on.
|
||||
{ k: 'new-call' as SpotFilterKey, label: 'NEW CALL', cls: 'bg-caution-muted text-caution-muted-foreground border-caution-border' },
|
||||
// Same colours as the badges in the grid — a filter that does not
|
||||
// look like what it selects has to be learned twice.
|
||||
{ k: 'new-pota' as SpotFilterKey, label: 'NEW POTA', cls: 'bg-success-muted text-success-muted-foreground border-success-border' },
|
||||
{ k: 'new-county' as SpotFilterKey, label: 'NEW COUNTY', cls: 'bg-success-muted text-success-muted-foreground border-success-border' },
|
||||
{ k: 'new-pfx' as SpotFilterKey, label: 'NEW PFX', cls: 'bg-caution-muted text-caution-muted-foreground border-caution-border' },
|
||||
// Only ever set for a station this receiver decoded over the UDP link.
|
||||
{ k: 'new-grid' as SpotFilterKey, label: 'NEW GRID', cls: 'bg-muted text-foreground border-border' },
|
||||
// Blue, like the already-worked call in the grid. Selecting it keeps
|
||||
// worked spots; the separate "Hide worked" checkbox drops them — they
|
||||
// are opposite controls, so don't use both at once.
|
||||
{ k: 'worked' as SpotFilterKey, label: 'WORKED', cls: 'bg-info-muted text-info-muted-foreground border-info-border' },
|
||||
]).map((s) => {
|
||||
const on = clusterStatusFilter.has(s.k);
|
||||
return (
|
||||
<button key={s.k} type="button"
|
||||
onClick={() => setClusterStatusFilter((cur) => { const n = new Set(cur); if (n.has(s.k)) n.delete(s.k); else n.add(s.k); return n; })}
|
||||
className={cn('px-1.5 py-0.5 rounded border text-[10px] font-bold tracking-wider transition-opacity', on ? s.cls : `${s.cls} opacity-40 hover:opacity-100`)}>
|
||||
{s.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
]).map((s) => fChip(s.k, s.label, s.cls, clusterStatusFilter.has(s.k),
|
||||
() => setClusterStatusFilter((cur) => { const n = new Set(cur); if (n.has(s.k)) n.delete(s.k); else n.add(s.k); return n; })))}
|
||||
</div>,
|
||||
clusterStatusFilter.size > 0 ? (
|
||||
<button type="button" onClick={() => setClusterStatusFilter(new Set())}
|
||||
className="text-[10px] text-muted-foreground hover:text-foreground underline">{t('clu.clear')}</button>
|
||||
) : undefined,
|
||||
)}
|
||||
|
||||
{/* Mode filter */}
|
||||
<div>
|
||||
<div className="text-[10px] uppercase tracking-wider text-muted-foreground mb-1">Mode</div>
|
||||
{fSection(t('clu.mode'),
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{([
|
||||
{ k: 'SSB' as SpotModeCat, label: 'SSB', cls: 'bg-info-muted text-info-muted-foreground border-info-border' },
|
||||
{ k: 'CW' as SpotModeCat, label: 'CW', cls: 'bg-info-muted text-info-muted-foreground border-info-border' },
|
||||
{ k: 'DATA' as SpotModeCat, label: 'DATA', cls: 'bg-success-muted text-success-muted-foreground border-success-border' },
|
||||
]).map((s) => {
|
||||
const on = clusterModeFilter.has(s.k);
|
||||
return (
|
||||
<button key={s.k} type="button"
|
||||
onClick={() => setClusterModeFilter((cur) => { const n = new Set(cur); if (n.has(s.k)) n.delete(s.k); else n.add(s.k); return n; })}
|
||||
className={cn('px-1.5 py-0.5 rounded border text-[10px] font-bold tracking-wider transition-opacity', on ? s.cls : `${s.cls} opacity-40 hover:opacity-100`)}>
|
||||
{s.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
]).map((s) => fChip(s.k, s.label, s.cls, clusterModeFilter.has(s.k),
|
||||
() => setClusterModeFilter((cur) => { const n = new Set(cur); if (n.has(s.k)) n.delete(s.k); else n.add(s.k); return n; })))}
|
||||
</div>,
|
||||
<button type="button" onClick={() => setClusterLockMode((v) => !v)}
|
||||
className={cn('inline-flex items-center gap-0.5 text-[10px] px-1 py-0.5 rounded border',
|
||||
clusterLockMode ? 'bg-warning-muted text-warning-muted-foreground border-warning-border' : 'text-muted-foreground border-border hover:bg-muted')}
|
||||
title={t('clu.lockModeTitle')}>
|
||||
{clusterLockMode ? <Lock className="size-2.5" /> : <Unlock className="size-2.5" />} {mode}
|
||||
</button>,
|
||||
)}
|
||||
|
||||
{/* Source */}
|
||||
<div>
|
||||
<div className="text-[10px] uppercase tracking-wider text-muted-foreground mb-1">Source</div>
|
||||
{fSection(t('clu.source'),
|
||||
<Select value={String(clusterFilterSource || '_')} onValueChange={(v) => setClusterFilterSource(v === '_' ? '' : parseInt(v, 10))}>
|
||||
<SelectTrigger className="w-full h-7 text-xs"><SelectValue placeholder="All sources" /></SelectTrigger>
|
||||
<SelectTrigger className="w-full h-7 text-xs"><SelectValue placeholder={t('clu.allSources')} /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="_">All sources</SelectItem>
|
||||
<SelectItem value="_">{t('clu.allSources')}</SelectItem>
|
||||
{clusterServers.map((s) => <SelectItem key={s.id} value={String(s.id)}>{s.name}</SelectItem>)}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</Select>,
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { cn } from '@/lib/utils';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
import { spotStatusKey, inferSpotMode, spotModeCategory } from '@/lib/spot';
|
||||
import { SPOT_MARKERS, activeMarkers } from '@/lib/spotMarkers';
|
||||
import { applySpotDisplay, readSpotDisplayOptions } from '@/lib/spotDisplay';
|
||||
|
||||
// BandMap — vertical spectrum panel inspired by Log4OM.
|
||||
// - Full band is always visible; zoom changes pixels-per-kHz, scroll
|
||||
@@ -32,6 +33,8 @@ type SpotStatusEntry = {
|
||||
status?: string;
|
||||
country?: string;
|
||||
worked_call?: boolean;
|
||||
// worked_slot: this exact callsign already worked on THIS band and mode.
|
||||
worked_slot?: boolean;
|
||||
new_county?: boolean;
|
||||
new_pota?: boolean;
|
||||
new_pfx?: boolean;
|
||||
@@ -45,12 +48,13 @@ type SpotStatusEntry = {
|
||||
//
|
||||
// Their colours come from lib/spotMarkers, shared with the cluster list: the
|
||||
// same fact must not be violet in one panel and green in the next.
|
||||
// The map shows three of the four. A new PREFIX is left to the cluster list: the
|
||||
// The map shows three of the five. A new PREFIX and a new GRID are left to the
|
||||
// cluster list, which has the width to name them: the
|
||||
// pill is 22 px tall, and a fourth segment turns the strip into a colour code
|
||||
// nobody can read at a glance. Add it here the day the strip earns more room.
|
||||
const BMP_MARKERS = SPOT_MARKERS.filter((m) => m.key !== 'new_pfx');
|
||||
const BMP_MARKERS = SPOT_MARKERS.filter((m) => m.key !== 'new_pfx' && m.key !== 'new_grid');
|
||||
const markersFor = (e: SpotStatusEntry | undefined) =>
|
||||
activeMarkers(e).filter((m) => m.key !== 'new_pfx');
|
||||
activeMarkers(e).filter((m) => m.key !== 'new_pfx' && m.key !== 'new_grid');
|
||||
|
||||
// The legend spells the markers out; the cluster list's badges are abbreviated
|
||||
// ("NEW CTY") because they sit in a narrow cell, and there is room here.
|
||||
@@ -150,12 +154,26 @@ function statusLabel(s: string, t: (k: string) => string): string {
|
||||
switch (s) {
|
||||
case 'new': return t('bmp.statusNew');
|
||||
case 'new-band': return t('bmp.statusNewBand');
|
||||
case 'new-mode': return t('bmp.statusNewMode');
|
||||
case 'new-slot': return t('bmp.statusNewSlot');
|
||||
case 'new-call': return t('bmp.statusNewCall');
|
||||
case 'worked': return t('bmp.statusWorked');
|
||||
// An empty status means the entity could not be resolved. Nothing else
|
||||
// empties it: the mute option leaves the status alone and takes only the
|
||||
// already-worked-callsign mark.
|
||||
default: return t('bmp.statusUnresolved');
|
||||
}
|
||||
}
|
||||
|
||||
// QUIET: no status colour at all. The pill keeps the card background and the
|
||||
// accent drops to a plain border grey, so the spot is present but says nothing.
|
||||
const QUIET_STYLE = {
|
||||
pill: 'bg-card text-muted-foreground border-border/60 hover:bg-muted/50',
|
||||
bar: 'bg-muted-foreground/30',
|
||||
line: 'stroke-border',
|
||||
dot: 'fill-border',
|
||||
};
|
||||
|
||||
function statusStyle(s: string): { pill: string; bar: string; line: string; dot: string } {
|
||||
// pill = full pill background+text+border
|
||||
// bar = thick left accent inside the pill
|
||||
@@ -174,18 +192,14 @@ function statusStyle(s: string): { pill: string; bar: string; line: string; dot:
|
||||
line: 'stroke-warning',
|
||||
dot: 'fill-warning',
|
||||
};
|
||||
case 'new-call':
|
||||
case 'new-slot': return {
|
||||
pill: 'bg-caution-muted text-caution-muted-foreground border-caution-border hover:bg-caution-muted',
|
||||
bar: 'bg-caution',
|
||||
line: 'stroke-caution',
|
||||
dot: 'fill-caution',
|
||||
};
|
||||
case 'worked': return {
|
||||
pill: 'bg-card text-muted-foreground border-border/60 hover:bg-muted/50',
|
||||
bar: 'bg-muted-foreground/30',
|
||||
line: 'stroke-border',
|
||||
dot: 'fill-border',
|
||||
};
|
||||
case 'worked': return QUIET_STYLE;
|
||||
default: return {
|
||||
pill: 'bg-card text-foreground border-border hover:bg-accent/40',
|
||||
bar: 'bg-primary/60',
|
||||
@@ -213,8 +227,24 @@ const BOT_PAD = 14; // the top-most freq label isn't clipped at y=0
|
||||
// last; ties broken by closeness to the rig freq).
|
||||
const MAX_VISIBLE_SPOTS = 30;
|
||||
|
||||
export function BandMap({ band, spots, spotStatus, currentFreqHz, onSpotClick, onClose, side = 'right', onToggleSide, hideDigital = false, fitToBand = false, keyNav = false }: Props) {
|
||||
export function BandMap({ band, spots, spotStatus: spotStatusRaw, currentFreqHz, onSpotClick, onClose, side = 'right', onToggleSide, hideDigital = false, fitToBand = false, keyNav = false }: Props) {
|
||||
const { t } = useI18n();
|
||||
|
||||
// The two display options are applied ONCE here, on the whole map, so the
|
||||
// leader lines, the dots, the pills and the badges can never disagree — and so
|
||||
// the map and the cluster list share the single rule set in lib/spotDisplay.
|
||||
// Re-derived whenever the poll delivers a new status map, which is also when a
|
||||
// just-changed option takes effect.
|
||||
// Read at render time, not inside the memo: the options must be part of the
|
||||
// dependencies. Keyed only on spotStatusRaw, toggling an option changed
|
||||
// nothing until the next poll happened to hand over a fresh object.
|
||||
const dispOpts = readSpotDisplayOptions();
|
||||
const spotStatus = useMemo(() => {
|
||||
if (!dispOpts.muteWorked && !dispOpts.slotHighlight) return spotStatusRaw;
|
||||
const out: Record<string, SpotStatusEntry> = {};
|
||||
for (const k of Object.keys(spotStatusRaw)) out[k] = applySpotDisplay(spotStatusRaw[k], dispOpts) as SpotStatusEntry;
|
||||
return out;
|
||||
}, [spotStatusRaw, dispOpts.muteWorked, dispOpts.slotHighlight]);
|
||||
const range = BAND_RANGES[band];
|
||||
const segments = SEGMENT_COLORS[band] ?? [];
|
||||
const [zoomIdx, setZoomIdx] = useState(2); // default 32 px/kHz
|
||||
@@ -282,6 +312,7 @@ export function BandMap({ band, spots, spotStatus, currentFreqHz, onSpotClick, o
|
||||
case 'new': return 0;
|
||||
case 'new-band': return 1;
|
||||
case 'new-slot': return 2;
|
||||
case 'new-call': return 2;
|
||||
case 'worked': return 4;
|
||||
default: return 3;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { cleanSpotter, inferSpotMode, spotStatusKey } from '@/lib/spot';
|
||||
import { markerColour } from '@/lib/spotMarkers';
|
||||
import { applySpotDisplay, readSpotDisplayOptions } from '@/lib/spotDisplay';
|
||||
import { loadLocal, loadRemote, saveState, seedLocal, whenGridPrefsReady } from '@/lib/gridPrefs';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
|
||||
@@ -52,10 +53,22 @@ export type SpotStatusEntry = {
|
||||
country?: string;
|
||||
continent?: string;
|
||||
worked_call?: boolean;
|
||||
// worked_slot: this exact callsign already worked on THIS band and mode.
|
||||
// Always slot-scoped, unlike worked_call which follows the "same slot" option.
|
||||
worked_slot?: boolean;
|
||||
new_county?: boolean;
|
||||
// The resolved US county and state, so the grid can SHOW them and not merely
|
||||
// flag them. Filled from the offline ULS store, US callsigns only.
|
||||
county?: string;
|
||||
state?: string;
|
||||
new_pota?: boolean;
|
||||
new_pfx?: boolean;
|
||||
pfx?: string;
|
||||
// lotw: the DX uploads to LoTW, per ARRL user list. Inert until downloaded.
|
||||
lotw?: boolean;
|
||||
spotter_continent?: string;
|
||||
grid?: string;
|
||||
new_grid?: boolean;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
@@ -97,26 +110,54 @@ type ColEntry = ColDef<ClusterSpot> & { group: string; label: string; defaultVis
|
||||
// statusFor resolves the precomputed spot status (new / new-band / new-slot /
|
||||
// worked-call) for an ag-Grid cell's row.
|
||||
function statusFor(p: any): SpotStatusEntry | undefined {
|
||||
return p?.context?.spotStatus?.[
|
||||
const s = p?.context?.spotStatus?.[
|
||||
spotStatusKey(p.data?.dx_call, p.data?.band ?? '', p.data?.comment ?? '', p.data?.freq_hz)
|
||||
];
|
||||
// One chokepoint: the colour, the badges and the Status text all read through
|
||||
// here, so the two display options are applied once rather than in each
|
||||
// renderer — and the band map applies the very same function.
|
||||
return applySpotDisplay(s, readSpotDisplayOptions());
|
||||
}
|
||||
|
||||
// Spot status is shown by COLOURING THE TEXT, never by a pill or a badge.
|
||||
// Spot status is shown on the CELL that carries the fact — filled background for
|
||||
// a novelty, tinted text otherwise — never by a pill or a badge.
|
||||
//
|
||||
// The pills were dropped: a rounded box has its own height and padding, so it
|
||||
// sat off the row's baseline and the callsign inside it no longer lined up with
|
||||
// the plain callsigns above and below. A whole column of them read as chrome
|
||||
// rather than as data. Same reasoning — and the same semantic tokens — as the
|
||||
// Y/N/R QSL columns in lib/qslStatus.ts.
|
||||
// The pills were dropped and stay dropped: a rounded box has its own height and
|
||||
// padding, so it sat off the row's baseline and the callsign inside it no longer
|
||||
// lined up with the plain callsigns above and below. A whole column of them read
|
||||
// as chrome rather than as data. Same reasoning — and the same semantic tokens —
|
||||
// as the Y/N/R QSL columns in lib/qslStatus.ts.
|
||||
//
|
||||
// Which cell is coloured IS the message, so one colour is enough for all three:
|
||||
// Which cell is marked IS the message:
|
||||
//
|
||||
// yellow call → new DXCC yellow band → new band yellow mode → new mode
|
||||
// blue call → already worked
|
||||
// filled call → new DXCC filled band → new band filled mode → new mode
|
||||
// filled pfx → new prefix filled POTA → new park filled county → new county
|
||||
// blue call → already worked (not a novelty, so text only)
|
||||
const NEW = 'var(--warning)'; // yellow: something here is new
|
||||
const WKD = 'var(--info)'; // blue: this callsign is already in the log
|
||||
|
||||
// FILLING the cell that carries the fact, rather than only tinting its text.
|
||||
//
|
||||
// This is not a return to the pills that were dropped. A pill is a box INSIDE
|
||||
// the cell: it has its own height and padding, so it sat off the row baseline
|
||||
// and the callsign inside it stopped lining up with the plain callsigns above
|
||||
// and below. A cell background has no geometry of its own — the text does not
|
||||
// move by a single pixel — and it reads from across the room, which a tinted
|
||||
// glyph does not.
|
||||
//
|
||||
// Which cell is filled is still the whole message: filled Band means new band,
|
||||
// filled Pfx means new prefix, filled County means new county.
|
||||
//
|
||||
// The colours come from the same places they already came from — the semantic
|
||||
// status tokens and lib/spotMarkers — so a fact keeps one colour across the
|
||||
// grid, the band map and the filter chips. 22 % is the wash that survived both
|
||||
// themes: enough to see at a glance, not enough to fight the text on it.
|
||||
const fillStyle = (colour: string) => ({
|
||||
background: `color-mix(in srgb, ${colour} 22%, transparent)`,
|
||||
color: colour,
|
||||
fontWeight: 700,
|
||||
});
|
||||
|
||||
// cellText renders a cell value in an optional colour. An empty value keeps the
|
||||
// muted dash the grid used before, so blank cells still read as "nothing here"
|
||||
// rather than as a gap.
|
||||
@@ -135,6 +176,7 @@ function statusColor(s: SpotStatusEntry | undefined): string | null {
|
||||
case 'new-band':
|
||||
case 'new-mode':
|
||||
case 'new-slot':
|
||||
case 'new-call':
|
||||
return NEW;
|
||||
default:
|
||||
return s?.worked_call ? WKD : null;
|
||||
@@ -150,8 +192,8 @@ function statusColor(s: SpotStatusEntry | undefined): string | null {
|
||||
// (still loading, or entity unknown) are NOT dimmed — that would flicker.
|
||||
function isDull(s: SpotStatusEntry | undefined): boolean {
|
||||
if (!s || !s.status) return false;
|
||||
if (s.status === 'new' || s.status === 'new-band' || s.status === 'new-mode' || s.status === 'new-slot') return false;
|
||||
return !(s.worked_call || s.new_pota || s.new_county || s.new_pfx);
|
||||
if (s.status === 'new' || s.status === 'new-band' || s.status === 'new-mode' || s.status === 'new-slot' || s.status === 'new-call') return false;
|
||||
return !(s.worked_call || s.new_pota || s.new_county || s.new_pfx || s.new_grid);
|
||||
}
|
||||
|
||||
const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
@@ -177,12 +219,27 @@ const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
headerName: t('clg2.c.call'), field: 'dx_call' as any, width: 120,
|
||||
defaultVisible: true,
|
||||
cellClass: 'font-mono',
|
||||
// NEW DXCC → yellow call. Already worked → blue call. Anything else keeps
|
||||
// the theme's normal ink so ordinary callsigns don't shout.
|
||||
// NEW DXCC fills the call cell. Already worked only tints the text blue:
|
||||
// 'worked' is not a novelty, and filling it would wash most of the rows.
|
||||
cellStyle: (p: any) => (statusFor(p)?.status === 'new' ? fillStyle('var(--danger)') : null) as any,
|
||||
cellRenderer: (p: any) => {
|
||||
const s = statusFor(p);
|
||||
const color = s?.status === 'new' ? NEW : s?.worked_call ? WKD : null;
|
||||
return <span style={{ color: color ?? undefined, fontWeight: 700 }}>{p.value ?? ''}</span>;
|
||||
const color = s?.status === 'new' ? null : s?.worked_call ? WKD : null;
|
||||
return (
|
||||
<span style={{ color: color ?? undefined, fontWeight: 700 }}>
|
||||
{p.value ?? ''}
|
||||
{/* A single letter rather than a word: the column is 120 px and holds a
|
||||
callsign. It stays the muted-blue of a confirmation, never a status
|
||||
colour — whether a station uploads to LoTW says nothing about
|
||||
whether the spot is worth chasing. */}
|
||||
{s?.lotw ? (
|
||||
<span title={t('clu.lotwBadge')} style={{
|
||||
marginLeft: 4, padding: '0 3px', borderRadius: 3, fontSize: 9, verticalAlign: 'middle',
|
||||
background: 'color-mix(in srgb, var(--info) 22%, transparent)', color: 'var(--info)',
|
||||
}}>L</span>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
tooltipValueGetter: (p: any) => {
|
||||
const s = statusFor(p);
|
||||
@@ -204,10 +261,12 @@ const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
else if (s?.status === 'new-band') parts.push(t('clg2.newBand'));
|
||||
else if (s?.status === 'new-mode') parts.push(t('clg2.newMode'));
|
||||
else if (s?.status === 'new-slot') parts.push(t('clg2.newSlot'));
|
||||
else if (s?.status === 'new-call') parts.push(t('clg2.newCall'));
|
||||
else if (s?.worked_call) parts.push(t('clg2.wkdCall'));
|
||||
if (s?.new_county) parts.push(t('clg2.newCounty'));
|
||||
if (s?.new_pota) parts.push(t('clg2.newPota'));
|
||||
if (s?.new_pfx) parts.push(t('clg2.newPfx'));
|
||||
if (s?.new_grid) parts.push(t('clg2.newGrid'));
|
||||
return parts.join(' ');
|
||||
},
|
||||
cellRenderer: (p: any) => {
|
||||
@@ -219,6 +278,7 @@ const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
: s?.status === 'new-band' ? t('clg2.newBand')
|
||||
: s?.status === 'new-mode' ? t('clg2.newMode')
|
||||
: s?.status === 'new-slot' ? t('clg2.newSlot')
|
||||
: s?.status === 'new-call' ? t('clg2.newCall')
|
||||
: t('clg2.wkdCall');
|
||||
parts.push({ text: label, color: main });
|
||||
}
|
||||
@@ -227,6 +287,7 @@ const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
if (s?.new_county) parts.push({ text: t('clg2.newCounty'), color: markerColour('new_county') });
|
||||
if (s?.new_pota) parts.push({ text: t('clg2.newPota'), color: markerColour('new_pota') });
|
||||
if (s?.new_pfx) parts.push({ text: t('clg2.newPfx'), color: markerColour('new_pfx') });
|
||||
if (s?.new_grid) parts.push({ text: t('clg2.newGrid'), color: markerColour('new_grid') });
|
||||
if (parts.length === 0) return <span style={{ color: 'var(--muted-foreground)', fontSize: 10 }}>—</span>;
|
||||
return (
|
||||
<span style={{ whiteSpace: 'nowrap' }}>
|
||||
@@ -243,6 +304,7 @@ const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
if (s?.status === 'new') return t('clg2.tipNewDxcc', { country: s?.country ?? '' });
|
||||
if (s?.status === 'new-band') return t('clg2.tipNewBand');
|
||||
if (s?.status === 'new-slot') return t('clg2.tipNewSlotBand');
|
||||
if (s?.status === 'new-call') return t('clg2.tipNewCall');
|
||||
if (s?.worked_call) return t('clg2.tipWorkedCall');
|
||||
return undefined;
|
||||
},
|
||||
@@ -251,7 +313,9 @@ const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
group: 'Spot', label: t('clg2.c.pota'), colId: 'pota',
|
||||
headerName: t('clg2.c.pota'), field: 'pota_ref' as any, width: 92, cellClass: 'font-mono',
|
||||
defaultVisible: true,
|
||||
cellStyle: { color: 'var(--success)' },
|
||||
cellStyle: (p: any) => (statusFor(p)?.new_pota
|
||||
? fillStyle(markerColour('new_pota'))
|
||||
: { color: 'var(--success)' }) as any,
|
||||
tooltipValueGetter: (p: any) => (p.data?.pota_name ? t('clg2.tipPota', { name: p.data.pota_name }) : undefined),
|
||||
},
|
||||
{
|
||||
@@ -266,8 +330,9 @@ const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
headerName: t('clg2.c.band'), field: 'band' as any, width: 75,
|
||||
defaultVisible: true,
|
||||
cellClass: 'font-mono',
|
||||
// NEW BAND for this entity → the band text turns yellow.
|
||||
cellRenderer: (p: any) => cellText(p.value, statusFor(p)?.status === 'new-band' ? NEW : null),
|
||||
// NEW BAND for this entity → the band cell is filled.
|
||||
cellStyle: (p: any) => (statusFor(p)?.status === 'new-band' ? fillStyle(NEW) : null) as any,
|
||||
cellRenderer: (p: any) => cellText(p.value, null),
|
||||
tooltipValueGetter: (p: any) => (statusFor(p)?.status === 'new-band' ? t('clg2.tipNewBand') : undefined),
|
||||
},
|
||||
{
|
||||
@@ -280,7 +345,8 @@ const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
// for the entity. NEW SLOT means band AND mode were each worked before (just
|
||||
// not together), so highlighting the mode cell would wrongly imply "CW is new";
|
||||
// that case is signalled by the Status badge alone.
|
||||
cellRenderer: (p: any) => cellText(p.value, statusFor(p)?.status === 'new-mode' ? NEW : null),
|
||||
cellStyle: (p: any) => (statusFor(p)?.status === 'new-mode' ? fillStyle('var(--caution)') : null) as any,
|
||||
cellRenderer: (p: any) => cellText(p.value, null),
|
||||
tooltipValueGetter: (p: any) => {
|
||||
const st = statusFor(p)?.status;
|
||||
if (st === 'new-mode') return t('clg2.tipNewMode');
|
||||
@@ -292,7 +358,37 @@ const makeColCatalog = (t: TFn): ColEntry[] => [
|
||||
group: 'Spot', label: t('clg2.c.pfx'), colId: 'pfx',
|
||||
headerName: t('clg2.c.pfx'), width: 60, cellClass: 'font-mono',
|
||||
valueGetter: (p: any) => fmtPfx(p.data?.dx_call ?? ''),
|
||||
cellStyle: { color: 'var(--muted-foreground)' },
|
||||
// NEW PFX fills the prefix cell, in the prefix marker's own colour.
|
||||
cellStyle: (p: any) => (statusFor(p)?.new_pfx
|
||||
? fillStyle(markerColour('new_pfx'))
|
||||
: { color: 'var(--muted-foreground)' }) as any,
|
||||
tooltipValueGetter: (p: any) => (statusFor(p)?.new_pfx ? t('clg2.tipNewPfx') : undefined),
|
||||
},
|
||||
{
|
||||
group: 'Geo', label: t('clg2.c.grid'), colId: 'grid',
|
||||
headerName: t('clg2.c.grid'), width: 70, cellClass: 'font-mono',
|
||||
// Not on the spot: the square a station announced in a CQ that THIS receiver
|
||||
// decoded over the WSJT-X link, so it is filled for the digital watering
|
||||
// hole being monitored and empty everywhere else. A cluster line carries the
|
||||
// spotter's grid at best, never the DX's.
|
||||
valueGetter: (p: any) => statusFor(p)?.grid ?? '',
|
||||
cellStyle: (p: any) => (statusFor(p)?.new_grid ? fillStyle(markerColour('new_grid')) : null) as any,
|
||||
cellRenderer: (p: any) => cellText(p.value, null),
|
||||
tooltipValueGetter: (p: any) => (statusFor(p)?.new_grid ? t('clg2.tipNewGrid') : undefined),
|
||||
},
|
||||
{
|
||||
group: 'Geo', label: t('clg2.c.county'), colId: 'county',
|
||||
headerName: t('clg2.c.county'), width: 130, cellClass: 'font-mono',
|
||||
// Not on the spot: resolved per callsign from the offline ULS store, so it
|
||||
// stays empty for non-US calls and until that database is downloaded.
|
||||
valueGetter: (p: any) => {
|
||||
const s = statusFor(p);
|
||||
if (!s?.county) return '';
|
||||
return s.state ? s.county + ', ' + s.state : s.county;
|
||||
},
|
||||
cellStyle: (p: any) => (statusFor(p)?.new_county ? fillStyle(markerColour('new_county')) : null) as any,
|
||||
cellRenderer: (p: any) => cellText(p.value, null),
|
||||
tooltipValueGetter: (p: any) => (statusFor(p)?.new_county ? t('clg2.tipNewCounty') : undefined),
|
||||
},
|
||||
{
|
||||
group: 'Geo', label: t('clg2.c.cqz'), colId: 'cqz',
|
||||
|
||||
@@ -144,7 +144,7 @@ const emptyProfile = (): Profile => ({
|
||||
my_grid: '', my_country: '',
|
||||
my_state: '', my_cnty: '',
|
||||
my_street: '', my_city: '', my_postal_code: '',
|
||||
my_sota_ref: '', my_pota_ref: '',
|
||||
my_sota_ref: '', my_pota_ref: '', my_iota: '',
|
||||
my_rig: '', my_antenna: '',
|
||||
tx_pwr: undefined,
|
||||
is_active: false,
|
||||
@@ -1854,6 +1854,7 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan
|
||||
my_grid: (activeProfile.my_grid ?? '').trim().toUpperCase(),
|
||||
my_sota_ref: (activeProfile.my_sota_ref ?? '').trim().toUpperCase(),
|
||||
my_pota_ref: (activeProfile.my_pota_ref ?? '').trim().toUpperCase(),
|
||||
my_iota: (activeProfile.my_iota ?? '').trim().toUpperCase(),
|
||||
} as any);
|
||||
}
|
||||
await SaveLookupSettings(lookup as any);
|
||||
@@ -2013,6 +2014,10 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan
|
||||
<Label>{t('station.pota')}</Label>
|
||||
<Input className="font-mono uppercase" value={p.my_pota_ref ?? ''} onChange={(e) => updateActive({ my_pota_ref: e.target.value })} placeholder="FF-1234" />
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label>{t('station.iota')}</Label>
|
||||
<Input className="font-mono uppercase" value={p.my_iota ?? ''} onChange={(e) => updateActive({ my_iota: e.target.value })} placeholder="EU-005" />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
@@ -4137,6 +4142,11 @@ export function SettingsModal({ onClose, onSaved, initialSection, onMainPaneChan
|
||||
onCheckedChange={(c) => { const v = !!c; setClusterWorkedSameSlot(v); writeUiPref('opslog.clusterWorkedSameSlot', v ? '1' : '0'); }} />
|
||||
<span>{t('clu.workedSameSlot')} <span className="text-xs text-muted-foreground">{t('clu.workedSameSlotHint')}</span></span>
|
||||
</label>
|
||||
{/* "No colour on worked" and "colour what is unworked here" used to live
|
||||
here. They moved to the Cluster tab's filter panel, next to Hide
|
||||
worked: they are things an operator changes while working a run, not
|
||||
things set up once. A preferences dialog you reopen every ten minutes
|
||||
is a filter in the wrong place. */}
|
||||
|
||||
{/* Self-spot. The interval only shows once it's on — an interval for
|
||||
something switched off is just a question the operator can't act on. */}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,66 @@
|
||||
// Two operator options that change how a spot LOOKS, shared by the DX-cluster
|
||||
// list and the band map so the two panels can never disagree about the same
|
||||
// spot — the lesson already learnt with the marker colours.
|
||||
//
|
||||
// muteWorked — a station already worked gets no colour and no badge. It
|
||||
// stays in the list, it simply stops competing for attention.
|
||||
// slotHighlight — a callsign not yet worked on THIS band and mode is coloured,
|
||||
// whatever the entity says. For an operator filling slots, a
|
||||
// common entity on a new band+mode is the whole point, and the
|
||||
// entity-level status calls it "worked".
|
||||
//
|
||||
// They compose deliberately: mute what is done, light up what is not.
|
||||
|
||||
export type SpotDisplayOptions = { muteWorked: boolean; slotHighlight: boolean };
|
||||
|
||||
export function readSpotDisplayOptions(): SpotDisplayOptions {
|
||||
try {
|
||||
return {
|
||||
muteWorked: localStorage.getItem('opslog.clusterMuteWorked') === '1',
|
||||
slotHighlight: localStorage.getItem('opslog.clusterSlotHighlight') === '1',
|
||||
};
|
||||
} catch {
|
||||
return { muteWorked: false, slotHighlight: false };
|
||||
}
|
||||
}
|
||||
|
||||
type Entry = {
|
||||
status?: string;
|
||||
worked_call?: boolean;
|
||||
worked_slot?: boolean;
|
||||
new_county?: boolean;
|
||||
new_pota?: boolean;
|
||||
new_pfx?: boolean;
|
||||
new_grid?: boolean;
|
||||
} | undefined;
|
||||
|
||||
// applySpotDisplay rewrites a status entry per the options, so every consumer —
|
||||
// colour, badge, status text — follows from one decision instead of each panel
|
||||
// re-deriving it.
|
||||
export function applySpotDisplay<T extends Entry>(s: T, o: SpotDisplayOptions): T {
|
||||
if (!s) return s;
|
||||
let e = s;
|
||||
|
||||
// Slot promotion runs first: a callsign not yet worked on this band and mode
|
||||
// is not done, whatever the entity says, so it earns a status before the mute
|
||||
// below can take its colour away.
|
||||
if (o.slotHighlight && e.worked_slot === false && (!e.status || e.status === 'worked')) {
|
||||
e = { ...e, status: 'new-call' } as NonNullable<T>;
|
||||
}
|
||||
|
||||
// Mute drops the blue already-worked-callsign mark, and NOTHING else.
|
||||
//
|
||||
// It used to blank the status as well, on the theory that a spot bringing no
|
||||
// novelty should stop painting entirely. That was wrong twice over. The status
|
||||
// is what the cluster list reads to DIM a row, so blanking it turned every
|
||||
// quiet grey row bright white — the option made the list louder, not quieter.
|
||||
// And an empty status means "entity not resolved" everywhere else, so muted
|
||||
// spots had to carry a flag saying they did not really mean that.
|
||||
//
|
||||
// Leaving the status alone costs nothing: a worked entity already renders with
|
||||
// no colour and gets dimmed, so removing the blue is the entire job.
|
||||
if (o.muteWorked) {
|
||||
e = { ...e, worked_call: false } as NonNullable<T>;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
@@ -15,7 +15,10 @@
|
||||
// statuses, blue is "callsign worked", green is POTA
|
||||
// worked blue — matches the WKD-CALL badge the cluster list has always used
|
||||
// prefix yellow — unchanged
|
||||
export type SpotMarkerKey = 'new_pota' | 'new_county' | 'new_pfx' | 'worked_call';
|
||||
// grid magenta — the last hue in the categorical set that is not already
|
||||
// spoken for here and does not read as a status; a grid is
|
||||
// never urgent the way a new entity is
|
||||
export type SpotMarkerKey = 'new_pota' | 'new_county' | 'new_pfx' | 'worked_call' | 'new_grid';
|
||||
|
||||
export type SpotMarker = {
|
||||
key: SpotMarkerKey;
|
||||
@@ -28,6 +31,7 @@ export const SPOT_MARKERS: SpotMarker[] = [
|
||||
{ key: 'new_pota', colour: 'var(--success)', labelKey: 'clg2.newPota' },
|
||||
{ key: 'new_county', colour: 'var(--chart-5)', labelKey: 'clg2.newCounty' },
|
||||
{ key: 'new_pfx', colour: 'var(--caution)', labelKey: 'clg2.newPfx' },
|
||||
{ key: 'new_grid', colour: 'var(--chart-7)', labelKey: 'clg2.newGrid' },
|
||||
{ key: 'worked_call', colour: 'var(--info)', labelKey: 'clg2.wkdCall' },
|
||||
];
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ const PORTABLE_KEYS = [
|
||||
'opslog.clusterModeFilter', 'opslog.clusterSearch', 'opslog.clusterHideWorked',
|
||||
'opslog.activeTab', // last selected tab
|
||||
'opslog.mainSplit', // Main tab: width share of the left pane (percent)
|
||||
'opslog.clusterMuteWorked', // cluster/band map: no colour or badge on worked spots
|
||||
'opslog.clusterSlotHighlight', // cluster/band map: colour calls not worked on this band+mode
|
||||
'opslog.bandMapWidth', // docked band map: column width (px)
|
||||
'opslog.bandMapTabWidth', // Band map tab: shared card width (px)
|
||||
// NOTE: 'hamlog.awardColsShown' and the grid column layouts are NOT listed here.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Single source of truth for the app version shown in the UI (header + About).
|
||||
// Bump this on a release (the release script updates it alongside telemetry.go).
|
||||
export const APP_VERSION = '0.24.2';
|
||||
export const APP_VERSION = '0.24.4';
|
||||
|
||||
// Author / credits, shown in Help -> About.
|
||||
export const APP_AUTHOR = 'F4BPO';
|
||||
|
||||
Vendored
+3
@@ -10,6 +10,7 @@ import {catemu} from '../models';
|
||||
import {antgenius} from '../models';
|
||||
import {award} from '../models';
|
||||
import {awardref} from '../models';
|
||||
import {bandopen} from '../models';
|
||||
import {cluster} from '../models';
|
||||
import {extsvc} from '../models';
|
||||
import {powergenius} from '../models';
|
||||
@@ -386,6 +387,8 @@ export function GetAwards():Promise<Array<award.Result>>;
|
||||
|
||||
export function GetBackupSettings():Promise<main.BackupSettings>;
|
||||
|
||||
export function GetBandOpenings():Promise<Array<bandopen.Opening>>;
|
||||
|
||||
export function GetCATSettings():Promise<main.CATSettings>;
|
||||
|
||||
export function GetCATState():Promise<cat.RigState>;
|
||||
|
||||
@@ -718,6 +718,10 @@ export function GetBackupSettings() {
|
||||
return window['go']['main']['App']['GetBackupSettings']();
|
||||
}
|
||||
|
||||
export function GetBandOpenings() {
|
||||
return window['go']['main']['App']['GetBandOpenings']();
|
||||
}
|
||||
|
||||
export function GetCATSettings() {
|
||||
return window['go']['main']['App']['GetCATSettings']();
|
||||
}
|
||||
|
||||
@@ -677,6 +677,56 @@ export namespace awardref {
|
||||
|
||||
}
|
||||
|
||||
export namespace bandopen {
|
||||
|
||||
export class Opening {
|
||||
band: string;
|
||||
calls: number;
|
||||
median_km: number;
|
||||
bearing_min: number;
|
||||
bearing_max: number;
|
||||
in_season: boolean;
|
||||
// Go type: time
|
||||
at: any;
|
||||
examples: string[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new Opening(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.band = source["band"];
|
||||
this.calls = source["calls"];
|
||||
this.median_km = source["median_km"];
|
||||
this.bearing_min = source["bearing_min"];
|
||||
this.bearing_max = source["bearing_max"];
|
||||
this.in_season = source["in_season"];
|
||||
this.at = this.convertValues(source["at"], null);
|
||||
this.examples = source["examples"];
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export namespace cat {
|
||||
|
||||
export class FlexMeter {
|
||||
@@ -2937,6 +2987,7 @@ export namespace main {
|
||||
band: string;
|
||||
mode: string;
|
||||
pota_ref?: string;
|
||||
spotter?: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new SpotQuery(source);
|
||||
@@ -2948,6 +2999,7 @@ export namespace main {
|
||||
this.band = source["band"];
|
||||
this.mode = source["mode"];
|
||||
this.pota_ref = source["pota_ref"];
|
||||
this.spotter = source["spotter"];
|
||||
}
|
||||
}
|
||||
export class SpotStatus {
|
||||
@@ -2959,9 +3011,16 @@ export namespace main {
|
||||
status: string;
|
||||
worked_call: boolean;
|
||||
new_county: boolean;
|
||||
county?: string;
|
||||
state?: string;
|
||||
new_pota: boolean;
|
||||
grid?: string;
|
||||
new_grid: boolean;
|
||||
spotter_continent?: string;
|
||||
lotw: boolean;
|
||||
new_pfx: boolean;
|
||||
pfx?: string;
|
||||
worked_slot: boolean;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new SpotStatus(source);
|
||||
@@ -2977,9 +3036,16 @@ export namespace main {
|
||||
this.status = source["status"];
|
||||
this.worked_call = source["worked_call"];
|
||||
this.new_county = source["new_county"];
|
||||
this.county = source["county"];
|
||||
this.state = source["state"];
|
||||
this.new_pota = source["new_pota"];
|
||||
this.grid = source["grid"];
|
||||
this.new_grid = source["new_grid"];
|
||||
this.spotter_continent = source["spotter_continent"];
|
||||
this.lotw = source["lotw"];
|
||||
this.new_pfx = source["new_pfx"];
|
||||
this.pfx = source["pfx"];
|
||||
this.worked_slot = source["worked_slot"];
|
||||
}
|
||||
}
|
||||
export class StartupStatus {
|
||||
@@ -3110,6 +3176,7 @@ export namespace main {
|
||||
my_country: string;
|
||||
my_sota_ref: string;
|
||||
my_pota_ref: string;
|
||||
my_iota: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new StationSettings(source);
|
||||
@@ -3123,6 +3190,7 @@ export namespace main {
|
||||
this.my_country = source["my_country"];
|
||||
this.my_sota_ref = source["my_sota_ref"];
|
||||
this.my_pota_ref = source["my_pota_ref"];
|
||||
this.my_iota = source["my_iota"];
|
||||
}
|
||||
}
|
||||
export class StationTestResult {
|
||||
@@ -3647,6 +3715,7 @@ export namespace profile {
|
||||
my_city: string;
|
||||
my_postal_code: string;
|
||||
my_sota_ref: string;
|
||||
my_iota: string;
|
||||
my_pota_ref: string;
|
||||
my_rig: string;
|
||||
my_antenna: string;
|
||||
@@ -3684,6 +3753,7 @@ export namespace profile {
|
||||
this.my_city = source["my_city"];
|
||||
this.my_postal_code = source["my_postal_code"];
|
||||
this.my_sota_ref = source["my_sota_ref"];
|
||||
this.my_iota = source["my_iota"];
|
||||
this.my_pota_ref = source["my_pota_ref"];
|
||||
this.my_rig = source["my_rig"];
|
||||
this.my_antenna = source["my_antenna"];
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
// Package bandopen spots a band OPENING in the cluster stream — sporadic-E on
|
||||
// 6 m, 4 m and 2 m above all.
|
||||
//
|
||||
// This is observation, not prediction. Every spot OpsLog receives is already
|
||||
// enriched with the great-circle distance and bearing from the operator's own
|
||||
// grid, so the signature of a single-hop Es opening is directly measurable:
|
||||
// several distinct stations appearing on a VHF band, all at single-hop range,
|
||||
// all in the same bearing sector, within a few minutes. That combination does
|
||||
// not happen by chance — scattered spots at random distances and bearings are
|
||||
// just a busy band.
|
||||
//
|
||||
// The season is REPORTED, never used to suppress. Es peaks in late spring and
|
||||
// summer, so an opening in November is unusual — and an unusual opening is
|
||||
// precisely the one an operator must not be told about last. InSeason only
|
||||
// labels the announcement.
|
||||
package bandopen
|
||||
|
||||
import (
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Spot is the little a detection needs, taken from an enriched cluster spot.
|
||||
type Spot struct {
|
||||
Call string
|
||||
Band string
|
||||
DistKm int
|
||||
Bearing int // degrees from the operator, short path
|
||||
At time.Time
|
||||
}
|
||||
|
||||
// Config tunes the detector. The defaults describe single-hop sporadic E.
|
||||
type Config struct {
|
||||
Window time.Duration // how far back a burst may span
|
||||
MinCalls int // distinct DX calls before it counts as an opening
|
||||
MinKm, MaxKm int // single-hop Es range
|
||||
BearingSpread int // widest arc (degrees) the spots may cover
|
||||
Requiet time.Duration // silence after announcing a band, so it is announced once
|
||||
}
|
||||
|
||||
// DefaultConfig is the single-hop Es envelope.
|
||||
//
|
||||
// 500–2400 km: below ~500 km a 6 m contact is ordinary tropo or ground wave and
|
||||
// says nothing about the ionosphere; beyond ~2400 km it is no longer one hop, so
|
||||
// the bearing test stops meaning anything. 90° of spread because a genuine Es
|
||||
// cloud illuminates a sector, not the whole horizon — the constraint that
|
||||
// separates an opening from a merely busy evening.
|
||||
func DefaultConfig() Config {
|
||||
return Config{
|
||||
Window: 12 * time.Minute,
|
||||
MinCalls: 4,
|
||||
MinKm: 500,
|
||||
MaxKm: 2400,
|
||||
BearingSpread: 90,
|
||||
Requiet: 45 * time.Minute,
|
||||
}
|
||||
}
|
||||
|
||||
// Bands watched. HF is deliberately absent: an "opening" on 20 m is the normal
|
||||
// state of the band and announcing it would be noise.
|
||||
var watched = map[string]bool{"6m": true, "4m": true, "2m": true}
|
||||
|
||||
// Watched reports whether a band is one the detector looks at.
|
||||
func Watched(band string) bool { return watched[strings.ToLower(strings.TrimSpace(band))] }
|
||||
|
||||
// Opening is a detected opening, ready to be announced.
|
||||
type Opening struct {
|
||||
Band string `json:"band"`
|
||||
Calls int `json:"calls"` // distinct DX stations seen
|
||||
MedianKm int `json:"median_km"` // typical hop length
|
||||
BearingMin int `json:"bearing_min"` // sector, degrees
|
||||
BearingMax int `json:"bearing_max"`
|
||||
InSeason bool `json:"in_season"` // false = unusual for the time of year
|
||||
At time.Time `json:"at"`
|
||||
Examples []string `json:"examples"` // a few callsigns, for the announcement
|
||||
}
|
||||
|
||||
// Detector keeps the rolling window and the per-band quiet period.
|
||||
type Detector struct {
|
||||
cfg Config
|
||||
recent []Spot
|
||||
lastFire map[string]time.Time
|
||||
}
|
||||
|
||||
func New(cfg Config) *Detector {
|
||||
if cfg.Window <= 0 {
|
||||
cfg = DefaultConfig()
|
||||
}
|
||||
return &Detector{cfg: cfg, lastFire: map[string]time.Time{}}
|
||||
}
|
||||
|
||||
// Add records a spot and returns an Opening when this spot completes one.
|
||||
//
|
||||
// Returns nil far more often than not; that is the point. lat is the operator's
|
||||
// latitude, for the hemisphere the season depends on.
|
||||
func (d *Detector) Add(s Spot, lat float64) *Opening {
|
||||
if !Watched(s.Band) {
|
||||
return nil
|
||||
}
|
||||
band := strings.ToLower(strings.TrimSpace(s.Band))
|
||||
s.Band = band
|
||||
if s.At.IsZero() {
|
||||
s.At = time.Now()
|
||||
}
|
||||
// Out-of-range spots are dropped rather than stored: they can never be part
|
||||
// of a single-hop detection, and keeping them only grows the window.
|
||||
if s.DistKm < d.cfg.MinKm || s.DistKm > d.cfg.MaxKm {
|
||||
return nil
|
||||
}
|
||||
d.recent = append(d.recent, s)
|
||||
d.prune(s.At)
|
||||
|
||||
if last, ok := d.lastFire[band]; ok && s.At.Sub(last) < d.cfg.Requiet {
|
||||
return nil // already announced this band recently
|
||||
}
|
||||
|
||||
inBand := make([]Spot, 0, len(d.recent))
|
||||
for _, r := range d.recent {
|
||||
if r.Band == band {
|
||||
inBand = append(inBand, r)
|
||||
}
|
||||
}
|
||||
op := evaluate(band, inBand, d.cfg)
|
||||
if op == nil {
|
||||
return nil
|
||||
}
|
||||
op.At = s.At
|
||||
op.InSeason = InSeason(band, s.At, lat)
|
||||
d.lastFire[band] = s.At
|
||||
return op
|
||||
}
|
||||
|
||||
func (d *Detector) prune(now time.Time) {
|
||||
cut := now.Add(-d.cfg.Window)
|
||||
keep := d.recent[:0]
|
||||
for _, r := range d.recent {
|
||||
if r.At.After(cut) {
|
||||
keep = append(keep, r)
|
||||
}
|
||||
}
|
||||
d.recent = keep
|
||||
}
|
||||
|
||||
// evaluate decides whether a band's recent spots look like one opening.
|
||||
func evaluate(band string, spots []Spot, cfg Config) *Opening {
|
||||
// Distinct callsigns, not spot count: one station spotted by six skimmers is
|
||||
// six spots and one station, and it is not an opening.
|
||||
seen := map[string]Spot{}
|
||||
for _, s := range spots {
|
||||
c := strings.ToUpper(strings.TrimSpace(s.Call))
|
||||
if c == "" {
|
||||
continue
|
||||
}
|
||||
if _, dup := seen[c]; !dup {
|
||||
seen[c] = s
|
||||
}
|
||||
}
|
||||
if len(seen) < cfg.MinCalls {
|
||||
return nil
|
||||
}
|
||||
bearings := make([]int, 0, len(seen))
|
||||
dists := make([]int, 0, len(seen))
|
||||
calls := make([]string, 0, len(seen))
|
||||
for c, s := range seen {
|
||||
bearings = append(bearings, ((s.Bearing%360)+360)%360)
|
||||
dists = append(dists, s.DistKm)
|
||||
calls = append(calls, c)
|
||||
}
|
||||
lo, hi, spread := arc(bearings)
|
||||
if spread > cfg.BearingSpread {
|
||||
return nil // spots all round the compass — a busy band, not an opening
|
||||
}
|
||||
sort.Ints(dists)
|
||||
sort.Strings(calls)
|
||||
if len(calls) > 5 {
|
||||
calls = calls[:5]
|
||||
}
|
||||
return &Opening{
|
||||
Band: band, Calls: len(seen), MedianKm: dists[len(dists)/2],
|
||||
BearingMin: lo, BearingMax: hi, Examples: calls,
|
||||
}
|
||||
}
|
||||
|
||||
// arc returns the smallest compass sector containing every bearing, coping with
|
||||
// the wrap at north: 350° and 10° are 20° apart, not 340°.
|
||||
func arc(b []int) (lo, hi, spread int) {
|
||||
if len(b) == 0 {
|
||||
return 0, 0, 0
|
||||
}
|
||||
s := append([]int(nil), b...)
|
||||
sort.Ints(s)
|
||||
// The widest GAP between consecutive bearings (round the circle) is the part
|
||||
// NOT covered; the sector is everything else.
|
||||
worst, at := -1, 0
|
||||
for i := range s {
|
||||
next := s[(i+1)%len(s)]
|
||||
gap := next - s[i]
|
||||
if i == len(s)-1 {
|
||||
gap = next + 360 - s[i]
|
||||
}
|
||||
if gap > worst {
|
||||
worst, at = gap, i
|
||||
}
|
||||
}
|
||||
lo = s[(at+1)%len(s)]
|
||||
hi = s[at]
|
||||
spread = 360 - worst
|
||||
return lo, hi, spread
|
||||
}
|
||||
|
||||
// InSeason reports whether the time of year is one where sporadic E is common
|
||||
// at the operator's latitude.
|
||||
//
|
||||
// Each hemisphere has a strong summer peak AND a smaller winter one, and both
|
||||
// count as expected: a December opening in Europe surprises nobody. What the
|
||||
// label marks is the genuinely odd month — an equinox opening.
|
||||
//
|
||||
// This LABELS a detection, it never gates one. Out-of-season Es exists, and it
|
||||
// is precisely the opening an operator must not be told about last.
|
||||
func InSeason(band string, t time.Time, lat float64) bool {
|
||||
m := t.UTC().Month()
|
||||
var months map[time.Month]bool
|
||||
if lat >= 0 {
|
||||
months = map[time.Month]bool{
|
||||
time.May: true, time.June: true, time.July: true, time.August: true, // main
|
||||
time.December: true, time.January: true, // lesser winter peak
|
||||
}
|
||||
} else {
|
||||
months = map[time.Month]bool{
|
||||
time.November: true, time.December: true, time.January: true, time.February: true,
|
||||
time.June: true, time.July: true,
|
||||
}
|
||||
}
|
||||
return months[m]
|
||||
}
|
||||
|
||||
// Sector renders the bearing range for a human, e.g. "NE (35–75°)".
|
||||
func (o *Opening) Sector() string {
|
||||
return compass(float64(o.BearingMin+o.BearingMax)/2) +
|
||||
" (" + strconv.Itoa(o.BearingMin) + "–" + strconv.Itoa(o.BearingMax) + "°)"
|
||||
}
|
||||
|
||||
func compass(deg float64) string {
|
||||
names := []string{"N", "NE", "E", "SE", "S", "SW", "W", "NW"}
|
||||
i := int(math.Round(deg/45)) % 8
|
||||
if i < 0 {
|
||||
i += 8
|
||||
}
|
||||
return names[i]
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package bandopen
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func at(min int) time.Time {
|
||||
return time.Date(2026, time.June, 15, 12, min, 0, 0, time.UTC)
|
||||
}
|
||||
|
||||
// feed pushes spots and returns the last Opening produced, if any.
|
||||
func feed(d *Detector, lat float64, spots ...Spot) *Opening {
|
||||
var last *Opening
|
||||
for _, s := range spots {
|
||||
if o := d.Add(s, lat); o != nil {
|
||||
last = o
|
||||
}
|
||||
}
|
||||
return last
|
||||
}
|
||||
|
||||
// The signature that must fire: several distinct stations, single-hop range,
|
||||
// one bearing sector, within the window.
|
||||
func TestDetectsSingleHopEs(t *testing.T) {
|
||||
d := New(DefaultConfig())
|
||||
o := feed(d, 46,
|
||||
Spot{Call: "I0ABC", Band: "6m", DistKm: 1100, Bearing: 140, At: at(0)},
|
||||
Spot{Call: "IK1DEF", Band: "6m", DistKm: 900, Bearing: 150, At: at(1)},
|
||||
Spot{Call: "9A2GHI", Band: "6m", DistKm: 1200, Bearing: 120, At: at(2)},
|
||||
Spot{Call: "S51JKL", Band: "6m", DistKm: 1000, Bearing: 130, At: at(3)},
|
||||
)
|
||||
if o == nil {
|
||||
t.Fatal("four stations at single-hop range in one sector must read as an opening")
|
||||
}
|
||||
if o.Band != "6m" || o.Calls != 4 {
|
||||
t.Errorf("got band=%s calls=%d, want 6m/4", o.Band, o.Calls)
|
||||
}
|
||||
if o.MedianKm < 900 || o.MedianKm > 1200 {
|
||||
t.Errorf("median %d km outside the fed range", o.MedianKm)
|
||||
}
|
||||
if !o.InSeason {
|
||||
t.Error("June in the northern hemisphere is Es season")
|
||||
}
|
||||
}
|
||||
|
||||
// Spots all round the compass are a busy band, not an opening — the bearing
|
||||
// test is what separates the two.
|
||||
func TestScatteredBearingsAreNotAnOpening(t *testing.T) {
|
||||
d := New(DefaultConfig())
|
||||
if o := feed(d, 46,
|
||||
Spot{Call: "A", Band: "6m", DistKm: 1100, Bearing: 10, At: at(0)},
|
||||
Spot{Call: "B", Band: "6m", DistKm: 900, Bearing: 110, At: at(1)},
|
||||
Spot{Call: "C", Band: "6m", DistKm: 1200, Bearing: 210, At: at(2)},
|
||||
Spot{Call: "D", Band: "6m", DistKm: 1000, Bearing: 300, At: at(3)},
|
||||
); o != nil {
|
||||
t.Errorf("bearings spread round the compass must not fire (got %+v)", o)
|
||||
}
|
||||
}
|
||||
|
||||
// One station spotted by six skimmers is six spots and one station.
|
||||
func TestRepeatedSpotsOfOneStationDoNotFire(t *testing.T) {
|
||||
d := New(DefaultConfig())
|
||||
var spots []Spot
|
||||
for i := 0; i < 6; i++ {
|
||||
spots = append(spots, Spot{Call: "I0ABC", Band: "6m", DistKm: 1100, Bearing: 140, At: at(i)})
|
||||
}
|
||||
if o := feed(d, 46, spots...); o != nil {
|
||||
t.Error("one distinct callsign is not an opening however often it is spotted")
|
||||
}
|
||||
}
|
||||
|
||||
// Out of the single-hop window there is nothing to conclude: under ~500 km a
|
||||
// 6 m contact is ordinary tropo.
|
||||
func TestTropoRangeIsIgnored(t *testing.T) {
|
||||
d := New(DefaultConfig())
|
||||
if o := feed(d, 46,
|
||||
Spot{Call: "A", Band: "6m", DistKm: 120, Bearing: 140, At: at(0)},
|
||||
Spot{Call: "B", Band: "6m", DistKm: 200, Bearing: 145, At: at(1)},
|
||||
Spot{Call: "C", Band: "6m", DistKm: 90, Bearing: 150, At: at(2)},
|
||||
Spot{Call: "D", Band: "6m", DistKm: 150, Bearing: 135, At: at(3)},
|
||||
); o != nil {
|
||||
t.Error("short-range spots must not read as sporadic E")
|
||||
}
|
||||
}
|
||||
|
||||
// Spread over more than the window is not one burst.
|
||||
func TestSpotsOutsideTheWindowDoNotAccumulate(t *testing.T) {
|
||||
d := New(DefaultConfig())
|
||||
if o := feed(d, 46,
|
||||
Spot{Call: "A", Band: "6m", DistKm: 1100, Bearing: 140, At: at(0)},
|
||||
Spot{Call: "B", Band: "6m", DistKm: 900, Bearing: 150, At: at(20)},
|
||||
Spot{Call: "C", Band: "6m", DistKm: 1200, Bearing: 120, At: at(40)},
|
||||
Spot{Call: "D", Band: "6m", DistKm: 1000, Bearing: 130, At: at(60)},
|
||||
); o != nil {
|
||||
t.Error("spots an hour apart are not one opening")
|
||||
}
|
||||
}
|
||||
|
||||
// HF is never announced: an "opening" on 20 m is the band's normal state.
|
||||
func TestHFIsNotWatched(t *testing.T) {
|
||||
if Watched("20m") || Watched("40m") {
|
||||
t.Error("HF must not be watched")
|
||||
}
|
||||
if !Watched("6m") || !Watched("2m") || !Watched("4m") {
|
||||
t.Error("6/4/2 m must be watched")
|
||||
}
|
||||
}
|
||||
|
||||
// Announced once, then quiet — an opening lasts hours and produces hundreds of
|
||||
// spots; one alert is information, forty is noise.
|
||||
func TestOneAnnouncementPerOpening(t *testing.T) {
|
||||
d := New(DefaultConfig())
|
||||
base := []Spot{
|
||||
{Call: "A", Band: "6m", DistKm: 1100, Bearing: 140, At: at(0)},
|
||||
{Call: "B", Band: "6m", DistKm: 900, Bearing: 150, At: at(1)},
|
||||
{Call: "C", Band: "6m", DistKm: 1200, Bearing: 120, At: at(2)},
|
||||
{Call: "D", Band: "6m", DistKm: 1000, Bearing: 130, At: at(3)},
|
||||
}
|
||||
if o := feed(d, 46, base...); o == nil {
|
||||
t.Fatal("expected the first opening")
|
||||
}
|
||||
if o := d.Add(Spot{Call: "E", Band: "6m", DistKm: 1050, Bearing: 135, At: at(4)}, 46); o != nil {
|
||||
t.Error("a second alert inside the quiet period is noise")
|
||||
}
|
||||
}
|
||||
|
||||
// Out-of-season openings still fire — they are the ones worth knowing about —
|
||||
// and are simply labelled as unusual.
|
||||
func TestOutOfSeasonStillFiresButIsLabelled(t *testing.T) {
|
||||
d := New(DefaultConfig())
|
||||
nov := func(m int) time.Time { return time.Date(2026, time.November, 3, 9, m, 0, 0, time.UTC) }
|
||||
o := feed(d, 46,
|
||||
Spot{Call: "A", Band: "6m", DistKm: 1100, Bearing: 140, At: nov(0)},
|
||||
Spot{Call: "B", Band: "6m", DistKm: 900, Bearing: 150, At: nov(1)},
|
||||
Spot{Call: "C", Band: "6m", DistKm: 1200, Bearing: 120, At: nov(2)},
|
||||
Spot{Call: "D", Band: "6m", DistKm: 1000, Bearing: 130, At: nov(3)},
|
||||
)
|
||||
if o == nil {
|
||||
t.Fatal("an out-of-season opening must still be announced")
|
||||
}
|
||||
if o.InSeason {
|
||||
t.Error("November in the north is not Es season — it must be flagged unusual")
|
||||
}
|
||||
}
|
||||
|
||||
// Both hemispheres have a summer peak and a lesser winter one, and both read as
|
||||
// expected. What must come out as UNUSUAL is an equinox month.
|
||||
func TestSeasonFollowsTheHemisphere(t *testing.T) {
|
||||
on := func(m time.Month) time.Time { return time.Date(2026, m, 15, 0, 0, 0, 0, time.UTC) }
|
||||
const north, south = 46.0, -33.0
|
||||
|
||||
if !InSeason("6m", on(time.June), north) {
|
||||
t.Error("June is the northern main season")
|
||||
}
|
||||
if !InSeason("6m", on(time.December), north) {
|
||||
t.Error("December is the northern winter peak — not a surprise")
|
||||
}
|
||||
if !InSeason("6m", on(time.December), south) {
|
||||
t.Error("December is the southern main season")
|
||||
}
|
||||
if !InSeason("6m", on(time.June), south) {
|
||||
t.Error("June is the southern winter peak")
|
||||
}
|
||||
// The equinoxes are the quiet months in both hemispheres.
|
||||
for _, lat := range []float64{north, south} {
|
||||
for _, m := range []time.Month{time.March, time.April, time.September, time.October} {
|
||||
if InSeason("6m", on(m), lat) {
|
||||
t.Errorf("%v at lat %.0f should read as unusual", m, lat)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The sector must cope with the wrap at north: 350° and 10° are 20° apart.
|
||||
func TestBearingArcWrapsAtNorth(t *testing.T) {
|
||||
lo, hi, spread := arc([]int{350, 10, 0, 355})
|
||||
if spread > 30 {
|
||||
t.Errorf("spread %d° across north should be small (lo=%d hi=%d)", spread, lo, hi)
|
||||
}
|
||||
if _, _, s := arc([]int{0, 90, 180, 270}); s < 270 {
|
||||
t.Errorf("bearings on all four quadrants should span nearly the circle, got %d", s)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
-- MY_IOTA: the island reference the station operates FROM, e.g. "EU-005".
|
||||
--
|
||||
-- An official ADIF field, and the QSO table has carried my_iota since 0001 —
|
||||
-- only the station profile could not supply it, so an island activation had to
|
||||
-- have the reference typed on every contact or added afterwards. Blank by
|
||||
-- default: the overwhelming majority of stations are not on an island.
|
||||
ALTER TABLE station_profiles ADD COLUMN my_iota TEXT NOT NULL DEFAULT '';
|
||||
@@ -47,18 +47,19 @@ func reusingListenConfig() net.ListenConfig {
|
||||
// Event is what a Server emits to its consumer for every parsed packet.
|
||||
// At most one of the fields is populated per event.
|
||||
type Event struct {
|
||||
ConfigID int64
|
||||
Service ServiceType
|
||||
Source string // remote addr that sent the packet, for diagnostics
|
||||
ConfigID int64
|
||||
Service ServiceType
|
||||
Source string // remote addr that sent the packet, for diagnostics
|
||||
|
||||
DXCall string // ServiceWSJT (Status) or ServiceRemoteCall
|
||||
DXGrid string // ServiceWSJT (Status)
|
||||
Mode string // ServiceWSJT (Status/Decode)
|
||||
FreqHz int64 // ServiceWSJT (Status)
|
||||
LoggedADIF string // ServiceWSJT (LoggedADIF), ServiceADIF or ServiceN1MM
|
||||
DXCall string // ServiceWSJT (Status) or ServiceRemoteCall
|
||||
DXGrid string // ServiceWSJT (Status)
|
||||
Mode string // ServiceWSJT (Status/Decode)
|
||||
FreqHz int64 // ServiceWSJT (Status)
|
||||
LoggedADIF string // ServiceWSJT (LoggedADIF), ServiceADIF or ServiceN1MM
|
||||
|
||||
// A WSJT-X Decode (heard station) to render on the panadapter.
|
||||
DecodeCall string // transmitting (DE) callsign
|
||||
DecodeGrid string // 4-char grid, CQ decodes only
|
||||
DecodeFreqHz int64 // RF frequency (dial + audio offset)
|
||||
DecodeSNR int // reported SNR (dB)
|
||||
DecodeCQ bool // the decode was a CQ
|
||||
@@ -93,7 +94,7 @@ type Server struct {
|
||||
// 50.400 panadapter. WSJT-X requires --rig-name for a second instance, so the
|
||||
// id is distinct whenever there is more than one.
|
||||
dialHz map[string]int64
|
||||
lastDX string // WSJT: last non-empty DX Call seen, to detect a clear
|
||||
lastDX string // WSJT: last non-empty DX Call seen, to detect a clear
|
||||
|
||||
// badPkts counts datagrams this listener could not parse, so the diagnostic
|
||||
// dump below stays bounded. A misconfigured port is not a one-off: the
|
||||
@@ -300,6 +301,7 @@ func (s *Server) handle(pkt []byte, remote *net.UDPAddr) {
|
||||
return
|
||||
}
|
||||
ev.DecodeCall = w.DecodeCall
|
||||
ev.DecodeGrid = w.DecodeGrid
|
||||
ev.DecodeFreqHz = dial + w.DeltaFreqHz
|
||||
ev.DecodeSNR = w.SNR
|
||||
ev.DecodeCQ = w.IsCQ
|
||||
|
||||
@@ -39,18 +39,19 @@ const (
|
||||
// WSJTEvent is the parsed, typed result of decoding a single packet.
|
||||
// One of (DXCall, LoggedADIF, DecodeCall) is non-empty depending on the message.
|
||||
type WSJTEvent struct {
|
||||
DXCall string // current "DX Call" field in the WSJT app (Status)
|
||||
DXGrid string // optional grid for that call (Status)
|
||||
Mode string // FT8 / FT4 / …
|
||||
FreqHz int64 // current dial freq when available (Status)
|
||||
LoggedADIF string // full ADIF text when message is LoggedADIF
|
||||
ProgramID string // "WSJT-X" / "JTDX" / "MSHV" — for diagnostics / dedup
|
||||
DXCall string // current "DX Call" field in the WSJT app (Status)
|
||||
DXGrid string // optional grid for that call (Status)
|
||||
Mode string // FT8 / FT4 / …
|
||||
FreqHz int64 // current dial freq when available (Status)
|
||||
LoggedADIF string // full ADIF text when message is LoggedADIF
|
||||
ProgramID string // "WSJT-X" / "JTDX" / "MSHV" — for diagnostics / dedup
|
||||
|
||||
// Decode (type 2): the transmitting station heard on the band. FreqHz is NOT
|
||||
// set here (Decode carries only the audio offset); the caller adds the last
|
||||
// known dial frequency (from Status) to DeltaFreqHz to get the RF frequency.
|
||||
IsDecode bool
|
||||
DecodeCall string // the sender (DE) callsign extracted from the message text
|
||||
DecodeGrid string // 4-char grid, CQ decodes only — the exchange carries none
|
||||
DeltaFreqHz int64 // audio offset within the passband (Hz)
|
||||
SNR int // reported signal-to-noise (dB)
|
||||
IsCQ bool // the decode was a CQ call
|
||||
@@ -239,13 +240,14 @@ func ParseWSJT(pkt []byte) (WSJTEvent, bool, error) {
|
||||
if err != nil {
|
||||
return WSJTEvent{}, false, err
|
||||
}
|
||||
call, isCQ := wsjtSender(msg)
|
||||
call, isCQ, grid := wsjtSender(msg)
|
||||
if call == "" {
|
||||
return WSJTEvent{}, false, nil // free-text / telemetry / unparseable → ignore
|
||||
}
|
||||
ev.IsDecode = true
|
||||
ev.DecodeCall = call
|
||||
ev.IsCQ = isCQ
|
||||
ev.DecodeGrid = grid
|
||||
ev.DeltaFreqHz = int64(df)
|
||||
ev.SNR = int(snr)
|
||||
ev.Mode = strings.ToUpper(strings.TrimSpace(mode))
|
||||
@@ -263,17 +265,20 @@ func ParseWSJT(pkt []byte) (WSJTEvent, bool, error) {
|
||||
return WSJTEvent{}, false, nil
|
||||
}
|
||||
|
||||
// wsjtSender extracts the transmitting (DE) callsign from a WSJT-X message and
|
||||
// whether it was a CQ. Grammar:
|
||||
// wsjtSender extracts the transmitting (DE) callsign from a WSJT-X message,
|
||||
// whether it was a CQ, and the grid when the message carries one. Grammar:
|
||||
//
|
||||
// CQ [modifier] <de_call> [grid] → de_call, isCQ=true
|
||||
// CQ [modifier] <de_call> [grid] → de_call, isCQ=true, grid
|
||||
// <to_call> <de_call> [report|…] → de_call, isCQ=false
|
||||
//
|
||||
// Only a CQ carries a grid: the standard exchange puts a signal report in that
|
||||
// third slot, never a locator.
|
||||
//
|
||||
// Returns "" for free-text / telemetry / hashed-call messages we can't resolve.
|
||||
func wsjtSender(message string) (call string, isCQ bool) {
|
||||
func wsjtSender(message string) (call string, isCQ bool, grid string) {
|
||||
f := strings.Fields(strings.ToUpper(strings.TrimSpace(message)))
|
||||
if len(f) == 0 {
|
||||
return "", false
|
||||
return "", false, ""
|
||||
}
|
||||
if f[0] == "CQ" {
|
||||
// Skip an optional modifier after CQ (DX / a region like NA / a zone like
|
||||
@@ -283,15 +288,33 @@ func wsjtSender(message string) (call string, isCQ bool) {
|
||||
idx = 2
|
||||
}
|
||||
if idx < len(f) && looksLikeCall(f[idx]) {
|
||||
return f[idx], true
|
||||
if idx+1 < len(f) && isGridField(f[idx+1]) {
|
||||
grid = f[idx+1]
|
||||
}
|
||||
return f[idx], true, grid
|
||||
}
|
||||
return "", true
|
||||
return "", true, ""
|
||||
}
|
||||
// Standard exchange: the DE (sender) call is the second token.
|
||||
if len(f) >= 2 && looksLikeCall(f[1]) {
|
||||
return f[1], false
|
||||
return f[1], false, ""
|
||||
}
|
||||
return "", false
|
||||
return "", false, ""
|
||||
}
|
||||
|
||||
// isGridField reports a 4-character Maidenhead field+square (JN36).
|
||||
//
|
||||
// RR73 is the reason this is not a bare pattern match: it is a sign-off, not a
|
||||
// locator, yet R falls inside A–R and 73 inside 00–99, so it satisfies the
|
||||
// Maidenhead shape exactly. WSJT-X never puts it in the slot after a CQ call,
|
||||
// but a station sending "CQ RR73" style free text would silently plant a
|
||||
// nonexistent grid in the log's grid index, and nothing downstream could tell.
|
||||
func isGridField(s string) bool {
|
||||
if len(s) != 4 || s == "RR73" {
|
||||
return false
|
||||
}
|
||||
return s[0] >= 'A' && s[0] <= 'R' && s[1] >= 'A' && s[1] <= 'R' &&
|
||||
s[2] >= '0' && s[2] <= '9' && s[3] >= '0' && s[3] <= '9'
|
||||
}
|
||||
|
||||
// looksLikeCall is a loose callsign test: 3–12 chars of A–Z/0–9//, with at least
|
||||
|
||||
@@ -7,26 +7,34 @@ func TestWSJTSender(t *testing.T) {
|
||||
msg string
|
||||
wantCall string
|
||||
wantCQ bool
|
||||
wantGrid string
|
||||
}{
|
||||
{"CQ K1ABC FN42", "K1ABC", true},
|
||||
{"CQ DX W2XYZ EM12", "W2XYZ", true}, // modifier "DX" skipped
|
||||
{"CQ NA VE3ABC FN03", "VE3ABC", true}, // region modifier skipped
|
||||
{"CQ 020 JA1XYZ PM95", "JA1XYZ", true},// zone modifier skipped
|
||||
{"W2XYZ K1ABC -10", "K1ABC", false}, // exchange → sender is 2nd call
|
||||
{"W2XYZ K1ABC R-10", "K1ABC", false},
|
||||
{"W2XYZ K1ABC RR73", "K1ABC", false},
|
||||
{"F4BPO K1ABC/P 73", "K1ABC/P", false},// portable call kept
|
||||
{"CQ F/DL1ABC JO31", "F/DL1ABC", true},// compound prefix
|
||||
{"CQ K1ABC FN42", "K1ABC", true, "FN42"},
|
||||
{"CQ DX W2XYZ EM12", "W2XYZ", true, "EM12"}, // modifier "DX" skipped
|
||||
{"CQ NA VE3ABC FN03", "VE3ABC", true, "FN03"}, // region modifier skipped
|
||||
{"CQ 020 JA1XYZ PM95", "JA1XYZ", true, "PM95"}, // zone modifier skipped
|
||||
{"W2XYZ K1ABC -10", "K1ABC", false, ""}, // exchange → sender is 2nd call
|
||||
{"W2XYZ K1ABC R-10", "K1ABC", false, ""},
|
||||
{"W2XYZ K1ABC RR73", "K1ABC", false, ""},
|
||||
{"F4BPO K1ABC/P 73", "K1ABC/P", false, ""}, // portable call kept
|
||||
{"CQ F/DL1ABC JO31", "F/DL1ABC", true, "JO31"}, // compound prefix, grid still valid
|
||||
{"CQ K1ABC", "K1ABC", true, ""}, // CQ without a grid
|
||||
{"CQ K1ABC RR73", "K1ABC", true, ""}, // RR73 is a sign-off, NOT grid RR73
|
||||
{"CQ K1ABC FN4", "K1ABC", true, ""}, // 3 chars is not a field+square
|
||||
{"CQ K1ABC FN42AB", "K1ABC", true, ""}, // 6-char: WSJT-X never sends it here
|
||||
{"CQ K1ABC 73", "K1ABC", true, ""}, // bare sign-off
|
||||
{"CQ K1ABC SS42", "K1ABC", true, ""}, // S is past R — no such field
|
||||
// Non-callsign / free text → no sender.
|
||||
{"TNX 73 GL", "", false},
|
||||
{"K1ABC RR73", "", false}, // only one call + a token → 2nd token not a call
|
||||
{"", "", false},
|
||||
{"CQ CQ CQ", "", true}, // CQ but no resolvable call
|
||||
{"TNX 73 GL", "", false, ""},
|
||||
{"K1ABC RR73", "", false, ""}, // only one call + a token → 2nd token not a call
|
||||
{"", "", false, ""},
|
||||
{"CQ CQ CQ", "", true, ""}, // CQ but no resolvable call
|
||||
}
|
||||
for _, c := range cases {
|
||||
call, cq := wsjtSender(c.msg)
|
||||
if call != c.wantCall || cq != c.wantCQ {
|
||||
t.Errorf("wsjtSender(%q) = (%q,%v), want (%q,%v)", c.msg, call, cq, c.wantCall, c.wantCQ)
|
||||
call, cq, grid := wsjtSender(c.msg)
|
||||
if call != c.wantCall || cq != c.wantCQ || grid != c.wantGrid {
|
||||
t.Errorf("wsjtSender(%q) = (%q,%v,%q), want (%q,%v,%q)",
|
||||
c.msg, call, cq, grid, c.wantCall, c.wantCQ, c.wantGrid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
defaultPort = 9008
|
||||
dialTimeout = 5 * time.Second
|
||||
ioTimeout = 3 * time.Second
|
||||
defaultPort = 9008
|
||||
dialTimeout = 5 * time.Second
|
||||
ioTimeout = 3 * time.Second
|
||||
// Poll fast enough that the amp's OWN forward/current figures make a usable
|
||||
// live meter on their own — the UI prefers them over the FlexRadio VITA stream
|
||||
// (which never traverses a public-IP/NAT link), so this direct reading is what
|
||||
@@ -240,12 +240,10 @@ func (c *Client) authLocked() error {
|
||||
if _, err := fmt.Fprintf(c.conn, "C%d|auth code=%s\n", id, c.password); err != nil {
|
||||
return err
|
||||
}
|
||||
_ = c.conn.SetReadDeadline(time.Now().Add(ioTimeout))
|
||||
line, err := c.reader.ReadString('\n')
|
||||
line, err := c.readReplyLocked(fmt.Sprintf("R%d|", id))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
line = strings.TrimSpace(line)
|
||||
applog.Printf("pgxl: auth reply=%q (try %d)", line, try)
|
||||
hex, msg := "", ""
|
||||
if p := strings.SplitN(line, "|", 3); len(p) >= 2 {
|
||||
@@ -264,6 +262,39 @@ func (c *Client) authLocked() error {
|
||||
return fmt.Errorf("powergenius: authentication failed after 4 tries (R|%s|) — check the remote code", lastHex)
|
||||
}
|
||||
|
||||
// readReplyLocked reads until the reply carrying `want` as its prefix arrives,
|
||||
// feeding every unsolicited frame it passes to parse() on the way.
|
||||
//
|
||||
// The amplifier PUSHES status frames ("S0|state=…") on the same socket, and it
|
||||
// pushes them constantly once it is in OPERATE — power, SWR and temperature all
|
||||
// move while transmitting. The old code read exactly one line per command and
|
||||
// took whatever came first as its answer, so a single pushed frame put the
|
||||
// stream permanently one reply behind: every later command read the PREVIOUS
|
||||
// command's answer, and the last one waited out the 3 s deadline, failed, and
|
||||
// dropped the connection. That is the reconnect-every-few-seconds seen in the
|
||||
// field, and the stall in transmit — command() holds the mutex across that whole
|
||||
// dead wait, so anything else touching the amplifier queued behind it.
|
||||
//
|
||||
// It only showed up remotely and in OPERATE: on a LAN with an idle amplifier
|
||||
// there is almost nothing to push and the race hardly ever opens.
|
||||
func (c *Client) readReplyLocked(want string) (string, error) {
|
||||
deadline := time.Now().Add(ioTimeout)
|
||||
for {
|
||||
_ = c.conn.SetReadDeadline(deadline)
|
||||
line, err := c.reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
line = strings.TrimSpace(line)
|
||||
// Every frame is worth having, ours or not — a pushed status is fresher
|
||||
// than the one we were about to ask for.
|
||||
c.parse(line)
|
||||
if strings.HasPrefix(line, want) {
|
||||
return line, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) dropConn() {
|
||||
c.mu.Lock()
|
||||
if c.conn != nil {
|
||||
@@ -286,14 +317,7 @@ func (c *Client) command(cmd string) (string, error) {
|
||||
if _, err := fmt.Fprintf(c.conn, "C%d|%s\n", id, cmd); err != nil {
|
||||
return "", err
|
||||
}
|
||||
_ = c.conn.SetReadDeadline(time.Now().Add(ioTimeout))
|
||||
line, err := c.reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
line = strings.TrimSpace(line)
|
||||
c.parse(line)
|
||||
return line, nil
|
||||
return c.readReplyLocked(fmt.Sprintf("R%d|", id))
|
||||
}
|
||||
|
||||
// parse handles "R<id>|0|<k=v …>" and "S0|<k=v …>" status lines.
|
||||
|
||||
@@ -52,6 +52,7 @@ type Profile struct {
|
||||
MyCity string `json:"my_city"`
|
||||
MyPostalCode string `json:"my_postal_code"`
|
||||
MySOTARef string `json:"my_sota_ref"`
|
||||
MyIOTA string `json:"my_iota"`
|
||||
MyPOTARef string `json:"my_pota_ref"`
|
||||
MyRig string `json:"my_rig"`
|
||||
MyAntenna string `json:"my_antenna"`
|
||||
@@ -75,7 +76,7 @@ type Repo struct{ db *sql.DB }
|
||||
func NewRepo(db *sql.DB) *Repo { return &Repo{db: db} }
|
||||
|
||||
const selectCols = `id, name, callsign, operator, op_name, owner_callsign, my_grid, my_country, my_state, my_cnty,
|
||||
my_street, my_city, my_postal_code, my_sota_ref, my_pota_ref,
|
||||
my_street, my_city, my_postal_code, my_sota_ref, my_pota_ref, my_iota,
|
||||
my_rig, my_antenna, my_dxcc, my_cqz, my_ituz, my_lat, my_lon, tx_pwr,
|
||||
is_active, sort_order, db_config, created_at, updated_at`
|
||||
|
||||
@@ -124,12 +125,12 @@ func (r *Repo) Save(ctx context.Context, p *Profile) error {
|
||||
res, err := r.db.ExecContext(ctx, `
|
||||
INSERT INTO station_profiles
|
||||
(name, callsign, operator, op_name, owner_callsign, my_grid, my_country, my_state, my_cnty,
|
||||
my_street, my_city, my_postal_code, my_sota_ref, my_pota_ref,
|
||||
my_street, my_city, my_postal_code, my_sota_ref, my_pota_ref, my_iota,
|
||||
my_rig, my_antenna, my_dxcc, my_cqz, my_ituz, my_lat, my_lon, tx_pwr,
|
||||
is_active, sort_order, created_at, updated_at)
|
||||
VALUES(?,?,?,?,?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?,?,?,?, ?,?,?,?)`,
|
||||
VALUES(?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?, ?,?,?,?,?,?,?,?, ?,?,?,?)`,
|
||||
p.Name, p.Callsign, p.Operator, p.OpName, p.OwnerCallsign, p.MyGrid, p.MyCountry, p.MyState, p.MyCounty,
|
||||
p.MyStreet, p.MyCity, p.MyPostalCode, p.MySOTARef, p.MyPOTARef,
|
||||
p.MyStreet, p.MyCity, p.MyPostalCode, p.MySOTARef, p.MyPOTARef, p.MyIOTA,
|
||||
p.MyRig, p.MyAntenna, nullableInt(p.MyDXCC), nullableInt(p.MyCQZone), nullableInt(p.MyITUZone),
|
||||
nullableFloat(p.MyLat), nullableFloat(p.MyLon), nullableFloat(p.TxPower),
|
||||
boolInt(p.IsActive), p.SortOrder, now, now)
|
||||
@@ -144,13 +145,13 @@ func (r *Repo) Save(ctx context.Context, p *Profile) error {
|
||||
UPDATE station_profiles SET
|
||||
name = ?, callsign = ?, operator = ?, op_name = ?, owner_callsign = ?, my_grid = ?, my_country = ?,
|
||||
my_state = ?, my_cnty = ?, my_street = ?, my_city = ?, my_postal_code = ?,
|
||||
my_sota_ref = ?, my_pota_ref = ?, my_rig = ?, my_antenna = ?,
|
||||
my_sota_ref = ?, my_pota_ref = ?, my_iota = ?, my_rig = ?, my_antenna = ?,
|
||||
my_dxcc = ?, my_cqz = ?, my_ituz = ?, my_lat = ?, my_lon = ?, tx_pwr = ?,
|
||||
sort_order = ?, updated_at = ?
|
||||
WHERE id = ?`,
|
||||
p.Name, p.Callsign, p.Operator, p.OpName, p.OwnerCallsign, p.MyGrid, p.MyCountry,
|
||||
p.MyState, p.MyCounty, p.MyStreet, p.MyCity, p.MyPostalCode,
|
||||
p.MySOTARef, p.MyPOTARef, p.MyRig, p.MyAntenna,
|
||||
p.MySOTARef, p.MyPOTARef, p.MyIOTA, p.MyRig, p.MyAntenna,
|
||||
nullableInt(p.MyDXCC), nullableInt(p.MyCQZone), nullableInt(p.MyITUZone),
|
||||
nullableFloat(p.MyLat), nullableFloat(p.MyLon), nullableFloat(p.TxPower),
|
||||
p.SortOrder, now, p.ID)
|
||||
@@ -264,7 +265,7 @@ func scan(row scannable) (Profile, error) {
|
||||
var p Profile
|
||||
var (
|
||||
callsign, operator, opName, ownerCall, myGrid, myCountry, myState, myCnty,
|
||||
myStreet, myCity, myPostal, mySOTA, myPOTA,
|
||||
myStreet, myCity, myPostal, mySOTA, myPOTA, myIOTA,
|
||||
myRig, myAntenna sql.NullString
|
||||
myDXCC, myCQZ, myITUZ sql.NullInt64
|
||||
myLat, myLon, txPwr sql.NullFloat64
|
||||
@@ -273,7 +274,7 @@ func scan(row scannable) (Profile, error) {
|
||||
createdAt, updatedAt string
|
||||
)
|
||||
err := row.Scan(&p.ID, &p.Name, &callsign, &operator, &opName, &ownerCall, &myGrid, &myCountry, &myState, &myCnty,
|
||||
&myStreet, &myCity, &myPostal, &mySOTA, &myPOTA,
|
||||
&myStreet, &myCity, &myPostal, &mySOTA, &myPOTA, &myIOTA,
|
||||
&myRig, &myAntenna, &myDXCC, &myCQZ, &myITUZ, &myLat, &myLon, &txPwr,
|
||||
&isActive, &sortOrder, &dbConfig, &createdAt, &updatedAt)
|
||||
if err != nil {
|
||||
@@ -294,6 +295,7 @@ func scan(row scannable) (Profile, error) {
|
||||
p.MyCity = myCity.String
|
||||
p.MyPostalCode = myPostal.String
|
||||
p.MySOTARef = mySOTA.String
|
||||
p.MyIOTA = myIOTA.String
|
||||
p.MyPOTARef = myPOTA.String
|
||||
p.MyRig = myRig.String
|
||||
p.MyAntenna = myAntenna.String
|
||||
|
||||
@@ -3002,3 +3002,45 @@ func IsFilterable(column string) bool { return filterableColumns[column] }
|
||||
// column of their own and live in extras_json.
|
||||
func IsBulkEditableExtra(field string) bool { _, ok := bulkEditableExtras[field]; return ok }
|
||||
func IsFilterableExtra(field string) bool { _, ok := filterableExtras[field]; return ok }
|
||||
|
||||
// WorkedGridKeys returns the set of "GRID|MODE" keys already in the log, where
|
||||
// GRID is the 4-character field+square and MODE has been through normMode.
|
||||
//
|
||||
// The mode is part of the key, and normMode is what makes the DX-cluster
|
||||
// "group digital modes" option apply to grids for free: with grouping on, FT8
|
||||
// and FT4 both normalise to the same token, so a grid worked on FT8 is not new
|
||||
// on FT4; with it off they stay separate keys and it is.
|
||||
//
|
||||
// Truncated to four characters on the way in. A log holds a mix of JN36 and
|
||||
// JN36QU depending on where each QSO came from, and grid chasing is a
|
||||
// field+square game — without the truncation the same square counts as new
|
||||
// forever, once per subsquare.
|
||||
func (r *Repo) WorkedGridKeys(ctx context.Context, normMode func(string) string) (map[string]struct{}, error) {
|
||||
rows, err := r.db.QueryContext(ctx,
|
||||
// The column is "grid", not "gridsquare" — that is the ADIF field name, and
|
||||
// gridsquare_ext is a different (six-plus character) column entirely.
|
||||
`SELECT DISTINCT COALESCE(grid,''), COALESCE(mode,'') FROM qso
|
||||
WHERE grid IS NOT NULL AND grid != ''`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
out := make(map[string]struct{}, 4096)
|
||||
for rows.Next() {
|
||||
var grid, mode string
|
||||
if err := rows.Scan(&grid, &mode); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
grid = strings.ToUpper(strings.TrimSpace(grid))
|
||||
if len(grid) < 4 {
|
||||
continue
|
||||
}
|
||||
grid = grid[:4]
|
||||
mode = strings.ToUpper(strings.TrimSpace(mode))
|
||||
if normMode != nil && mode != "" {
|
||||
mode = normMode(mode)
|
||||
}
|
||||
out[grid+"|"+mode] = struct{}{}
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
+32
-12
@@ -233,6 +233,9 @@ th,td{padding:.45rem .6rem;text-align:left;border-bottom:1px solid var(--line);w
|
||||
th{position:sticky;top:0;background:var(--head);font-size:.72rem;letter-spacing:.05em;
|
||||
text-transform:uppercase;color:var(--mut);cursor:pointer;user-select:none}
|
||||
th:hover{color:var(--fg)}
|
||||
th::after{content:'';font-size:.7em;opacity:.7}
|
||||
th[data-asc="1"]::after{content:' \25B2'}
|
||||
th[data-asc="0"]::after{content:' \25BC'}
|
||||
tbody tr:nth-child(even){background:var(--zebra)}
|
||||
tbody tr:last-child td{border-bottom:0}
|
||||
td.call{font-family:ui-monospace,Consolas,monospace;font-weight:700;color:var(--accent)}
|
||||
@@ -248,7 +251,9 @@ td.call{font-family:ui-monospace,Consolas,monospace;font-weight:700;color:var(--
|
||||
}
|
||||
b.WriteString(`</tr></thead><tbody>`)
|
||||
for i := range qsos {
|
||||
b.WriteString(`<tr>`)
|
||||
// The row's position as published. Sorting is a view on top of it, so a
|
||||
// third click can put the table back the way the operator first saw it.
|
||||
b.WriteString(`<tr data-i="` + strconv.Itoa(i) + `">`)
|
||||
for _, c := range cols {
|
||||
cls := ""
|
||||
if c.Key == "callsign" {
|
||||
@@ -262,23 +267,38 @@ td.call{font-family:ui-monospace,Consolas,monospace;font-weight:700;color:var(--
|
||||
<p class="foot">Generated by OpsLog</p>
|
||||
</div>
|
||||
<script>
|
||||
// Click a header to sort. Kept tiny and dependency-free: the page has to work
|
||||
// offline and on any hosting.
|
||||
// Click a header to sort: ascending, descending, then back to the published
|
||||
// order. Kept tiny and dependency-free — the page has to work offline and on any
|
||||
// hosting, so no library is loaded.
|
||||
//
|
||||
// NUM is deliberately strict: the whole cell must be a number. parseFloat alone
|
||||
// accepts a numeric PREFIX, so "2026-08-10" became 2026 and every date in a year
|
||||
// compared equal — the date column looked as though it simply would not sort.
|
||||
// Callsigns starting with a digit (8B81SU) hit the same trap.
|
||||
var NUM=/^[+-]?\d+(\.\d+)?$/;
|
||||
document.querySelectorAll('th').forEach(function(th,i){
|
||||
th.addEventListener('click',function(){
|
||||
var tb=th.closest('table').tBodies[0],
|
||||
rows=Array.prototype.slice.call(tb.rows),
|
||||
asc=th.dataset.asc!=='1';
|
||||
rows.sort(function(a,b){
|
||||
var x=a.cells[i].textContent.trim(), y=b.cells[i].textContent.trim(),
|
||||
nx=parseFloat(x), ny=parseFloat(y),
|
||||
n=!isNaN(nx)&&!isNaN(ny)&&x!==''&&y!=='';
|
||||
var c=n?(nx-ny):x.localeCompare(y);
|
||||
return asc?c:-c;
|
||||
});
|
||||
cur=th.dataset.asc,
|
||||
next=cur===undefined?'1':(cur==='1'?'0':'');
|
||||
if(next===''){
|
||||
// Third click: restore the order the page was published in.
|
||||
rows.sort(function(a,b){return a.dataset.i-b.dataset.i});
|
||||
}else{
|
||||
var asc=next==='1';
|
||||
rows.sort(function(a,b){
|
||||
var x=a.cells[i].textContent.trim(), y=b.cells[i].textContent.trim();
|
||||
// Blanks always sink, whichever way the column is pointing: an empty
|
||||
// cell is missing data, not the smallest value.
|
||||
if(x===''||y==='') return x===y?0:(x===''?1:-1);
|
||||
var c=NUM.test(x)&&NUM.test(y)?(parseFloat(x)-parseFloat(y)):x.localeCompare(y);
|
||||
return asc?c:-c;
|
||||
});
|
||||
}
|
||||
rows.forEach(function(r){tb.appendChild(r)});
|
||||
th.closest('tr').querySelectorAll('th').forEach(function(o){delete o.dataset.asc});
|
||||
th.dataset.asc=asc?'1':'0';
|
||||
if(next!=='') th.dataset.asc=next;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package webpub
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"hamlog/internal/qso"
|
||||
)
|
||||
|
||||
// The published page carries its own sort script, so a regression there is
|
||||
// silent: the table still renders, it just sorts wrongly. These pin the two
|
||||
// things that were actually broken in the field.
|
||||
|
||||
func renderSample(t *testing.T) string {
|
||||
t.Helper()
|
||||
cfg := Config{Columns: []string{"qso_date", "callsign", "freq"}}
|
||||
cfg.Normalise()
|
||||
qsos := []qso.QSO{
|
||||
{Callsign: "8B81SU", QSODate: time.Date(2026, 8, 10, 9, 56, 0, 0, time.UTC)},
|
||||
{Callsign: "LZ8NG", QSODate: time.Date(2025, 12, 31, 23, 1, 0, 0, time.UTC)},
|
||||
}
|
||||
return string(renderHTML(cfg, columnsFor(cfg.Columns), qsos, "F4BPO"))
|
||||
}
|
||||
|
||||
// A third click restores the published order, which is only possible if each row
|
||||
// remembers where it started.
|
||||
func TestRowsCarryTheirPublishedIndex(t *testing.T) {
|
||||
html := renderSample(t)
|
||||
for _, want := range []string{`<tr data-i="0">`, `<tr data-i="1">`} {
|
||||
if !strings.Contains(html, want) {
|
||||
t.Errorf("published page is missing %s — the reset-to-original click cannot work", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// parseFloat accepts a numeric PREFIX, so "2026-08-10" became 2026 and every
|
||||
// date in the same year compared equal: the Date column looked unsortable.
|
||||
// Callsigns starting with a digit ("8B81SU") hit the same trap. The whole cell
|
||||
// must match for a numeric comparison to be used.
|
||||
func TestSortScriptRejectsNumericPrefixes(t *testing.T) {
|
||||
html := renderSample(t)
|
||||
if !strings.Contains(html, `var NUM=/^[+-]?\d+(\.\d+)?$/;`) {
|
||||
t.Error("the anchored numeric test is gone; a bare parseFloat makes dates and 8-prefixed calls sort as equal")
|
||||
}
|
||||
if strings.Contains(html, "n=!isNaN(nx)&&!isNaN(ny)") {
|
||||
t.Error("the old prefix-tolerant numeric detection is back")
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,17 @@ func acquireInstance(postUpdate bool) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// processStart is stamped on the very first instruction of main, before the
|
||||
// single-instance guard and before anything else runs.
|
||||
//
|
||||
// It exists to split a slow launch in two, because the log alone could not: the
|
||||
// first line applog writes already sits inside startup(), so everything spent
|
||||
// loading the binary and creating the WebView2 environment happened before the
|
||||
// log begins and was invisible. An operator reporting "nothing happens for three
|
||||
// seconds" was impossible to answer from a file whose first timestamp is the
|
||||
// moment the app was already running.
|
||||
var processStart = time.Now()
|
||||
|
||||
func main() {
|
||||
// Single-instance guard: if OpsLog is already running, focus that window and
|
||||
// exit instead of spawning a duplicate. A second process would open its own
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
const (
|
||||
// appVersion is stamped on every heartbeat (and could feed the About box).
|
||||
appVersion = "0.24.2"
|
||||
appVersion = "0.24.4"
|
||||
|
||||
// posthogHost is the PostHog ingestion endpoint. EU cloud by default; change
|
||||
// to https://us.i.posthog.com for a US project.
|
||||
|
||||
Reference in New Issue
Block a user