Files
ruvnet--RuView/ui/mobile/src/utils/formatters.ts
T
ruv fdc7142dfa feat: Implement RSSI service for iOS and Web platforms
- Added IosRssiService to handle synthetic RSSI data for iOS.
- Created WebRssiService to simulate RSSI scanning on the web.
- Defined shared types for WifiNetwork and RssiService in rssi.service.ts.
- Introduced simulation service to generate synthetic sensing data.
- Implemented WebSocket service for real-time data handling with reconnection logic.
- Established Zustand stores for managing application state related to MAT and pose data.
- Developed theme context and utility functions for consistent styling and formatting.
- Added type definitions for various application entities including API responses and sensing data.
- Created utility functions for color mapping and URL validation.
- Configured TypeScript settings for the mobile application.
2026-03-02 10:30:33 -05:00

35 lines
1.1 KiB
TypeScript

export function formatRssi(v: number | null | undefined): string {
if (typeof v !== 'number' || !Number.isFinite(v)) {
return '-- dBm';
}
return `${Math.round(v)} dBm`;
}
export function formatBpm(v: number | null | undefined): string {
if (typeof v !== 'number' || !Number.isFinite(v)) {
return '--';
}
return `${Math.round(v)} BPM`;
}
export function formatConfidence(v: number | null | undefined): string {
if (typeof v !== 'number' || !Number.isFinite(v)) {
return '--';
}
const normalized = v > 1 ? v / 100 : v;
return `${Math.round(Math.max(0, Math.min(1, normalized)) * 100)}%`;
}
export function formatUptime(ms: number | null | undefined): string {
if (typeof ms !== 'number' || !Number.isFinite(ms) || ms < 0) {
return '--:--:--';
}
const totalSeconds = Math.floor(ms / 1000);
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = totalSeconds % 60;
return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
}