mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-04 07:52:24 +02:00
Add radio model and stats display. Closes #64
This commit is contained in:
@@ -333,6 +333,35 @@ export function SettingsRadioSection({
|
||||
? `Connection paused${health?.connection_info ? ` (${health.connection_info})` : ''}`
|
||||
: 'Not connected';
|
||||
|
||||
const deviceInfoLabel = useMemo(() => {
|
||||
const info = health?.radio_device_info;
|
||||
if (!info) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const model = info.model?.trim() || null;
|
||||
const firmwareParts = [info.firmware_build?.trim(), info.firmware_version?.trim()].filter(
|
||||
(value): value is string => Boolean(value)
|
||||
);
|
||||
const capacityParts = [
|
||||
typeof info.max_contacts === 'number' ? `${info.max_contacts} contacts` : null,
|
||||
typeof info.max_channels === 'number' ? `${info.max_channels} channels` : null,
|
||||
].filter((value): value is string => value !== null);
|
||||
|
||||
if (!model && firmwareParts.length === 0 && capacityParts.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let label = model ?? 'Radio';
|
||||
if (firmwareParts.length > 0) {
|
||||
label += ` running ${firmwareParts.join('/')}`;
|
||||
}
|
||||
if (capacityParts.length > 0) {
|
||||
label += ` (max: ${capacityParts.join(', ')})`;
|
||||
}
|
||||
return label;
|
||||
}, [health?.radio_device_info]);
|
||||
|
||||
const handleConnectionAction = async () => {
|
||||
setConnectionBusy(true);
|
||||
try {
|
||||
@@ -377,6 +406,7 @@ export function SettingsRadioSection({
|
||||
{connectionStatusLabel}
|
||||
</span>
|
||||
</div>
|
||||
{deviceInfoLabel && <p className="text-sm text-muted-foreground">{deviceInfoLabel}</p>}
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
|
||||
@@ -205,6 +205,26 @@ describe('SettingsModal', () => {
|
||||
expect(screen.getByText(/Configured radio contact capacity/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows cached radio firmware and capacity info under the connection status', () => {
|
||||
renderModal({
|
||||
health: {
|
||||
...baseHealth,
|
||||
radio_device_info: {
|
||||
model: 'T-Echo',
|
||||
firmware_build: '2025-02-01',
|
||||
firmware_version: '1.2.3',
|
||||
max_contacts: 350,
|
||||
max_channels: 64,
|
||||
},
|
||||
},
|
||||
});
|
||||
openRadioSection();
|
||||
|
||||
expect(
|
||||
screen.getByText('T-Echo running 2025-02-01/1.2.3 (max: 350 contacts, 64 channels)')
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows reconnect action when radio connection is paused', () => {
|
||||
renderModal({
|
||||
health: { ...baseHealth, radio_state: 'paused' },
|
||||
|
||||
@@ -57,6 +57,13 @@ export interface HealthStatus {
|
||||
radio_initializing: boolean;
|
||||
radio_state?: 'connected' | 'initializing' | 'connecting' | 'disconnected' | 'paused';
|
||||
connection_info: string | null;
|
||||
radio_device_info?: {
|
||||
model: string | null;
|
||||
firmware_build: string | null;
|
||||
firmware_version: string | null;
|
||||
max_contacts: number | null;
|
||||
max_channels: number | null;
|
||||
} | null;
|
||||
database_size_mb: number;
|
||||
oldest_undecrypted_timestamp: number | null;
|
||||
fanout_statuses: Record<string, FanoutStatusEntry>;
|
||||
|
||||
Reference in New Issue
Block a user