using Astralis; using Inversion; using Spry; /** * AuroraStatsEndpoint - Returns the aurora stats for HTMX polling * * This component is polled every 5 seconds alongside the canvas. * It renders the stats display with polling attributes to continue polling. */ public class AuroraStatsEndpoint : Component { private AuroraState aurora_state = inject(); public override string markup { get { return """
Solar Wind
Waves
Intensity
Color Mode
"""; }} public override async void prepare() throws Error { this["solar-wind"].text_content = "%.1f km/s".printf(aurora_state.solar_wind_speed); this["wave-count"].text_content = aurora_state.wave_count.to_string(); this["intensity"].text_content = "%.0f%%".printf(aurora_state.intensity * 100); this["color-mode"].text_content = aurora_state.color_mode; } public async override void handle_action(string action) throws Error { if (action == "Poll") { // Stats are updated in prepare() automatically // No additional state changes needed here } } }