mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-10 07:15:09 +02:00
Show telemetry history within repeater view on load
This commit is contained in:
@@ -153,6 +153,17 @@ async def repeater_status(public_key: str) -> RepeaterStatusResponse:
|
||||
return response
|
||||
|
||||
|
||||
@router.get("/{public_key}/repeater/telemetry-history")
|
||||
async def repeater_telemetry_history(public_key: str) -> list[TelemetryHistoryEntry]:
|
||||
"""Return stored telemetry history for a repeater (no radio command needed)."""
|
||||
contact = await _resolve_contact_or_404(public_key)
|
||||
_require_repeater(contact)
|
||||
|
||||
since = int(time.time()) - 30 * 86400
|
||||
rows = await RepeaterTelemetryRepository.get_history(contact.public_key, since)
|
||||
return [TelemetryHistoryEntry(**row) for row in rows]
|
||||
|
||||
|
||||
@router.post("/{public_key}/repeater/lpp-telemetry", response_model=RepeaterLppTelemetryResponse)
|
||||
async def repeater_lpp_telemetry(public_key: str) -> RepeaterLppTelemetryResponse:
|
||||
"""Fetch CayenneLPP sensor telemetry from a repeater (single attempt, 10s timeout)."""
|
||||
|
||||
@@ -35,6 +35,7 @@ import type {
|
||||
RepeaterRadioSettingsResponse,
|
||||
RepeaterStatusResponse,
|
||||
StatisticsResponse,
|
||||
TelemetryHistoryEntry,
|
||||
TraceResponse,
|
||||
UnreadCounts,
|
||||
} from './types';
|
||||
@@ -374,6 +375,8 @@ export const api = {
|
||||
fetchJson<RepeaterStatusResponse>(`/contacts/${publicKey}/repeater/status`, {
|
||||
method: 'POST',
|
||||
}),
|
||||
repeaterTelemetryHistory: (publicKey: string) =>
|
||||
fetchJson<TelemetryHistoryEntry[]>(`/contacts/${publicKey}/repeater/telemetry-history`),
|
||||
repeaterNeighbors: (publicKey: string) =>
|
||||
fetchJson<RepeaterNeighborsResponse>(`/contacts/${publicKey}/repeater/neighbors`, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -51,10 +51,11 @@ vi.mock('../hooks/useRepeaterDashboard', () => ({
|
||||
useRepeaterDashboard: () => mockHook,
|
||||
}));
|
||||
|
||||
// Mock api module (used by routing override tests)
|
||||
// Mock api module (used by routing override tests + telemetry history fetch on mount)
|
||||
vi.mock('../api', () => ({
|
||||
api: {
|
||||
setContactRoutingOverride: vi.fn().mockResolvedValue({ status: 'ok' }),
|
||||
repeaterTelemetryHistory: vi.fn().mockResolvedValue([]),
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user