From de3fda26483a7197b3b182555138a9f5b94c74a8 Mon Sep 17 00:00:00 2001 From: rouggy Date: Thu, 15 Jan 2026 06:44:29 +0100 Subject: [PATCH] Revert "updated frontend" This reverts commit b8884d89e38fee39499f0b46bb366d81071578da. --- internal/devices/flexradio/flexradio.go | 91 +--- web/src/App.svelte | 27 +- web/src/components/PowerGenius.svelte | 11 + web/src/components/StatusBanner.svelte | 631 ------------------------ web/src/components/TunerGenius.svelte | 11 + 5 files changed, 46 insertions(+), 725 deletions(-) delete mode 100644 web/src/components/StatusBanner.svelte diff --git a/internal/devices/flexradio/flexradio.go b/internal/devices/flexradio/flexradio.go index d8d7642..7e1fafe 100644 --- a/internal/devices/flexradio/flexradio.go +++ b/internal/devices/flexradio/flexradio.go @@ -32,9 +32,6 @@ type Client struct { // Callbacks onFrequencyChange func(freqMHz float64) checkTransmitAllowed func() bool // Returns true if transmit allowed (motors not moving) - - // Reconnection settings - reconnectInterval time.Duration } func New(host string, port int) *Client { @@ -45,7 +42,6 @@ func New(host string, port int) *Client { lastStatus: &Status{ Connected: false, }, - reconnectInterval: 5 * time.Second, // Reconnect every 5 seconds if disconnected } } @@ -72,7 +68,6 @@ func (c *Client) Connect() error { conn, err := net.DialTimeout("tcp", addr, 5*time.Second) if err != nil { - log.Printf("FlexRadio: Connection failed: %v", err) return fmt.Errorf("failed to connect: %w", err) } @@ -88,37 +83,30 @@ func (c *Client) Start() error { return nil } - c.running = true - - // Try initial connection but don't fail if it doesn't work - // The messageLoop will handle reconnection - err := c.Connect() - if err != nil { - log.Printf("FlexRadio: Initial connection failed, will retry: %v", err) - } else { - // Update connected status - c.statusMu.Lock() - if c.lastStatus != nil { - c.lastStatus.Connected = true - } - c.statusMu.Unlock() - - // Subscribe to slice updates for frequency tracking - c.subscribeToSlices() + if err := c.Connect(); err != nil { + return err } - // Start message listener (handles reconnection) + // Update connected status + c.statusMu.Lock() + if c.lastStatus != nil { + c.lastStatus.Connected = true + } + c.statusMu.Unlock() + + c.running = true + + // Start message listener go c.messageLoop() - return nil -} - -func (c *Client) subscribeToSlices() { + // Subscribe to slice updates for frequency tracking log.Println("FlexRadio: Subscribing to slice updates...") _, err := c.sendCommand("sub slice all") if err != nil { log.Printf("FlexRadio: Warning - failed to subscribe to slices: %v", err) } + + return nil } func (c *Client) Stop() { @@ -185,52 +173,15 @@ func (c *Client) sendCommand(cmd string) (string, error) { func (c *Client) messageLoop() { log.Println("FlexRadio: Message loop started") - reconnectTicker := time.NewTicker(c.reconnectInterval) - defer reconnectTicker.Stop() - for c.running { - c.connMu.Lock() - isConnected := c.conn != nil && c.reader != nil - c.connMu.Unlock() - - if !isConnected { - // Update status to disconnected - c.statusMu.Lock() - if c.lastStatus != nil { - c.lastStatus.Connected = false - } - c.statusMu.Unlock() - - // Wait for reconnect interval - select { - case <-reconnectTicker.C: - log.Println("FlexRadio: Attempting to reconnect...") - if err := c.Connect(); err != nil { - log.Printf("FlexRadio: Reconnect failed: %v", err) - continue - } - - // Successfully reconnected - c.statusMu.Lock() - if c.lastStatus != nil { - c.lastStatus.Connected = true - } - c.statusMu.Unlock() - - // Re-subscribe to slices after reconnection - c.subscribeToSlices() - - case <-c.stopChan: - log.Println("FlexRadio: Message loop stopping (stop signal received)") - return - } - continue - } - - // Read from connection c.connMu.Lock() if c.conn == nil || c.reader == nil { c.connMu.Unlock() + time.Sleep(1 * time.Second) + if err := c.Connect(); err != nil { + log.Printf("FlexRadio: Reconnect failed: %v", err) + continue + } continue } @@ -260,8 +211,6 @@ func (c *Client) messageLoop() { c.lastStatus.Connected = false } c.statusMu.Unlock() - - log.Println("FlexRadio: Connection lost, will attempt reconnection...") continue } diff --git a/web/src/App.svelte b/web/src/App.svelte index 9f0e9c6..2bd383f 100644 --- a/web/src/App.svelte +++ b/web/src/App.svelte @@ -2,7 +2,6 @@ import { onMount, onDestroy } from 'svelte'; import { wsService, connected, systemStatus } from './lib/websocket.js'; import { api } from './lib/api.js'; - import StatusBanner from './components/StatusBanner.svelte'; import WebSwitch from './components/WebSwitch.svelte'; import PowerGenius from './components/PowerGenius.svelte'; import TunerGenius from './components/TunerGenius.svelte'; @@ -14,8 +13,6 @@ let isConnected = false; let currentTime = new Date(); let callsign = 'F4BPO'; // Default - let latitude = null; - let longitude = null; const unsubscribeStatus = systemStatus.subscribe(value => { status = value; @@ -43,10 +40,6 @@ if (config.callsign) { callsign = config.callsign; } - if (config.location) { - latitude = config.location.latitude; - longitude = config.location.longitude; - } } catch (err) { console.error('Failed to fetch config:', err); } @@ -114,16 +107,6 @@ - - -
@@ -149,13 +132,12 @@ } header { - background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); - padding: 8px 24px; + background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); + padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; - box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); - border-bottom: 1px solid rgba(79, 195, 247, 0.2); + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); flex-wrap: wrap; gap: 16px; } @@ -261,7 +243,6 @@ .date { font-size: 12px; color: rgba(255, 255, 255, 0.7); - padding-top: 0px; } main { @@ -311,4 +292,4 @@ flex-wrap: wrap; } } - \ No newline at end of file + diff --git a/web/src/components/PowerGenius.svelte b/web/src/components/PowerGenius.svelte index b0a25f0..6f3f80c 100644 --- a/web/src/components/PowerGenius.svelte +++ b/web/src/components/PowerGenius.svelte @@ -73,6 +73,7 @@
+
@@ -281,6 +282,16 @@ transition: width 0.3s ease; } + .power-bar-glow { + position: absolute; + top: 0; + right: 0; + width: 20px; + height: 100%; + background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5)); + animation: shimmer 2s infinite; + } + @keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } diff --git a/web/src/components/StatusBanner.svelte b/web/src/components/StatusBanner.svelte deleted file mode 100644 index a7b76af..0000000 --- a/web/src/components/StatusBanner.svelte +++ /dev/null @@ -1,631 +0,0 @@ - - -
- -
-
- 📻 -
- - {#if connected && frequency > 0} -
- - {formatFrequency(frequency)} - - MHz -
- - {#if currentBand} - - {currentBand} - - {/if} - - {#if mode} - - {mode} - - {/if} - - {#if txEnabled} - - TX - - {/if} - {:else} - FlexRadio non connecté - {/if} -
- - -
- - -
- {#if latitude && longitude} -
- - - - - - - - - - - - {formatTime(sunrise)} - - - - - - - - - - - - - {formatTime(sunset)} - -
- - {#if isGrayline} - - ✨ GRAYLINE - - {:else if timeToNextEvent} - - {timeToNextEvent} - - {/if} - {:else} - 📍 Position not set - {/if} -
- - -
- - -
- {#if hasWindWarning} -
- ⚠️ - - Vent: {windSpeed.toFixed(0)} km/h - -
- {/if} - - {#if hasGustWarning} -
- 🌪️ - - Rafales: {windGust.toFixed(0)} km/h - -
- {/if} - - {#if !hasAnyWarning} -
- - Météo OK -
- {/if} -
-
- - \ No newline at end of file diff --git a/web/src/components/TunerGenius.svelte b/web/src/components/TunerGenius.svelte index 558ee24..5dbf8d8 100644 --- a/web/src/components/TunerGenius.svelte +++ b/web/src/components/TunerGenius.svelte @@ -67,6 +67,7 @@
+
@@ -264,6 +265,16 @@ transition: width 0.3s ease; } + .power-bar-glow { + position: absolute; + top: 0; + right: 0; + width: 20px; + height: 100%; + background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5)); + animation: shimmer 2s infinite; + } + @keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); }