feat(cat): several radios, switched from the status bar
The answer to 'I have two rigs' was 'make two profiles', which is a heavy
instrument for a light question: a profile carries the whole station —
logbook, callsign, awards, cluster, macros — so switching one to change
which radio is connected takes all of that with it, including a change of
logbook when the profiles point at different databases.
Radios are a list now, the way amplifiers already are. The CAT chip in the
status bar opens it, one click connects the chosen rig, and nothing else
about the station moves.
The storage keeps the ACTIVE radio in the same settings keys everything
already reads (cat.backend, cat.icom_port, …), and switching writes the
chosen entry into them and reloads the link. So the consoles, the CAT
sharing, the band-follow and every panel see exactly what they saw before
and needed no change at all — the list is a second store beside the
configuration, not a replacement for it.
Details that matter more than they look:
- An operator who has run one rig for a year opens the list and finds it
there, because a missing list reads as the CURRENT settings rather
than as nothing. It is written on the first save, not on the first
read.
- Editing the CAT panel updates the active entry, or an edit made before
switching away would be lost on the way back.
- A new radio starts as a COPY of the current one: a second rig is
usually the same shape with one port changed, and an empty form is a
form to fill in twice.
- Switching saves the panel first, so edits to the radio being left
behind are kept.
- The chip only becomes a menu with more than one radio; with one it
opens the CAT settings exactly as it always did.
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
import {
|
||||
GetLookupSettings, SaveLookupSettings, ClearLookupCache, TestLookupProvider,
|
||||
GetListsSettings, SaveListsSettings,
|
||||
GetCATSettings, SaveCATSettings, DiscoverFlexRadios,
|
||||
GetCATSettings, SaveCATSettings, GetRadios, SaveRadios, SetActiveRadio, DiscoverFlexRadios,
|
||||
ListProfiles, GetActiveProfile, SaveProfile, DeleteProfile, ActivateProfile, DuplicateProfile,
|
||||
GetRotators, SaveRotators, TestRotatorDevice, RotatorPark, RotatorStop,
|
||||
GetRotorPresets, SaveRotorPresets, ResetRotorPresets,
|
||||
@@ -1596,6 +1596,11 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
// exotic or experimental bands not listed).
|
||||
const [bandDraft, setBandDraft] = useState('');
|
||||
const [modeDraft, setModeDraft] = useState('');
|
||||
// The saved radios. The CAT panel edits ONE of them — whichever is on the air
|
||||
// — and the list is what makes switching possible without touching profiles.
|
||||
const [radios, setRadios] = useState<any[]>([]);
|
||||
const [activeRadio, setActiveRadioId] = useState('');
|
||||
const [radioBusy, setRadioBusy] = useState(false);
|
||||
const [catCfg, setCatCfg] = useState<CATSettings>({
|
||||
enabled: false, backend: 'omnirig', omnirig_rig: 1, omnirig_vfo: '', flex_host: '', flex_port: 4992, flex_spots: false, flex_decode_spots: false, flex_decode_secs: 120, flex_dvk_dax: false,
|
||||
yaesu_port: '', yaesu_baud: 38400, yaesu_low_lines: false, kenwood_low_lines: false, kenwood_port: '', kenwood_baud: 9600, kenwood_host: '', kenwood_link: 'usb', kenwood_data_mode: 'usb', xiegu_port: '', xiegu_baud: 19200, xiegu_addr: 0x70, xiegu_ptt_line: '',
|
||||
@@ -2192,6 +2197,12 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
// on a normal open and Save then wrote an empty list over the operator's
|
||||
// buttons. See rotorPresetsLoaded for the belt to this brace.
|
||||
try { setRotorPresets((((await GetRotorPresets()) ?? []) as any)); setRotorPresetsLoaded(true); } catch {}
|
||||
try {
|
||||
const rl: any = await GetRadios();
|
||||
setRadios(rl ?? []);
|
||||
const act = (rl ?? []).find((r: any) => r.active) ?? (rl ?? [])[0];
|
||||
setActiveRadioId(act?.id ?? '');
|
||||
} catch { /* one radio, never listed — the panel works as it always did */ }
|
||||
try { setUltrabeam(await GetUltrabeamSettings() as any); } catch {}
|
||||
try { setAntgenius(await GetAntGeniusSettings() as any); } catch {}
|
||||
try { setTunergenius(await GetTunerGeniusSettings() as any); } catch {}
|
||||
@@ -3189,6 +3200,75 @@ function SettingsModalImpl({ onClose, onSaved, initialSection, onMainPaneChanged
|
||||
hint={t('cat.hint')}
|
||||
/>
|
||||
<div className="space-y-4 max-w-3xl">
|
||||
{/* RADIOS. Everything below edits the one selected here, and the status
|
||||
bar's CAT chip switches between them without moving the rest of the
|
||||
station — which is what making a profile per radio used to do. */}
|
||||
<div className="rounded-lg border border-border p-3 space-y-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="shrink-0">{t('cat.radio')}</Label>
|
||||
<Select value={activeRadio || undefined} onValueChange={(v) => {
|
||||
if (v === activeRadio || radioBusy) return;
|
||||
// Saving first: the panel may hold edits to the radio being left
|
||||
// behind, and switching without them would throw them away.
|
||||
setRadioBusy(true);
|
||||
SaveCATSettings(catCfg as any)
|
||||
.then(() => SetActiveRadio(v))
|
||||
.then(async () => {
|
||||
setActiveRadioId(v);
|
||||
setCatCfg(await GetCATSettings() as any);
|
||||
setRadios(((await GetRadios()) ?? []) as any[]);
|
||||
})
|
||||
.catch((e: any) => setErr(String(e?.message ?? e)))
|
||||
.finally(() => setRadioBusy(false));
|
||||
}}>
|
||||
<SelectTrigger className="h-9 flex-1"><SelectValue placeholder={t('cat.radio')} /></SelectTrigger>
|
||||
<SelectContent>
|
||||
{radios.map((r: any, i: number) => (
|
||||
<SelectItem key={r.id} value={r.id}>{r.name?.trim() || `Radio ${i + 1}`}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input className="h-9 w-44" placeholder={t('cat.radioNamePh')}
|
||||
value={(radios.find((r: any) => r.id === activeRadio)?.name) ?? ''}
|
||||
onChange={(e) => setRadios((l) => l.map((r: any) => r.id === activeRadio ? { ...r, name: e.target.value } : r))}
|
||||
onBlur={() => { SaveRadios(radios as any).catch(() => {}); }} />
|
||||
<Button type="button" variant="outline" size="sm" className="h-9 shrink-0" disabled={radioBusy}
|
||||
title={t('cat.radioAddHint')}
|
||||
onClick={() => {
|
||||
// A new radio starts from the CURRENT one rather than from
|
||||
// nothing: a second rig is usually the same shape as the first
|
||||
// with one port changed, and an empty form is a form to fill in
|
||||
// twice.
|
||||
const next = [...radios, { id: '', name: '', backend: catCfg.backend, settings: catCfg }];
|
||||
setRadioBusy(true);
|
||||
SaveRadios(next as any)
|
||||
.then(() => GetRadios())
|
||||
.then((rl: any) => setRadios(rl ?? []))
|
||||
.catch((e: any) => setErr(String(e?.message ?? e)))
|
||||
.finally(() => setRadioBusy(false));
|
||||
}}>+</Button>
|
||||
<Button type="button" variant="ghost" size="sm" className="h-9 shrink-0 text-danger"
|
||||
disabled={radioBusy || radios.length < 2}
|
||||
title={t('cat.radioRemoveHint')}
|
||||
onClick={() => {
|
||||
const next = radios.filter((r: any) => r.id !== activeRadio);
|
||||
setRadioBusy(true);
|
||||
SaveRadios(next as any)
|
||||
.then(() => SetActiveRadio(next[0].id))
|
||||
.then(async () => {
|
||||
setActiveRadioId(next[0].id);
|
||||
setCatCfg(await GetCATSettings() as any);
|
||||
setRadios(((await GetRadios()) ?? []) as any[]);
|
||||
})
|
||||
.catch((e: any) => setErr(String(e?.message ?? e)))
|
||||
.finally(() => setRadioBusy(false));
|
||||
}}>
|
||||
<Trash2 className="size-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-[11px] text-muted-foreground">{t('cat.radioHint')}</p>
|
||||
</div>
|
||||
|
||||
<label className="flex items-center gap-2 text-sm cursor-pointer">
|
||||
<Checkbox checked={catCfg.enabled} onCheckedChange={(c) => setCatCfg((s) => ({ ...s, enabled: !!c }))} />
|
||||
{t('cat.enable')}
|
||||
|
||||
Reference in New Issue
Block a user