From fac5da4c55710415ff6b8d576b679c36aa5dcda2 Mon Sep 17 00:00:00 2001 From: silvertakana Date: Thu, 5 Mar 2026 17:32:20 +1300 Subject: [PATCH] feat: add scrollable tabs to side panels for better organization --- src/app/api/maritime/route.ts | 6 +- src/app/globals.css | 44 ++++ src/components/panels/DataConfigPanel.tsx | 255 ++++++++++++---------- src/components/panels/LayerPanel.tsx | 126 ++++++----- src/instrumentation.ts | 3 +- src/lib/test-ws.js | 36 +++ 6 files changed, 305 insertions(+), 165 deletions(-) create mode 100644 src/lib/test-ws.js diff --git a/src/app/api/maritime/route.ts b/src/app/api/maritime/route.ts index 72dbcb94..568f33d0 100644 --- a/src/app/api/maritime/route.ts +++ b/src/app/api/maritime/route.ts @@ -1,11 +1,15 @@ import { NextResponse } from "next/server"; -import { getCachedVessels } from "@/lib/ais-stream"; +import { getCachedVessels, startAisStream } from "@/lib/ais-stream"; + +export const dynamic = 'force-dynamic'; /** * Maritime AIS proxy. * Returns live data from aisstream.io. */ export async function GET() { + startAisStream(); // Ensure stream is initialized + const vessels = getCachedVessels(); // If the cache is completely empty, we return null to trigger the fallback demo data diff --git a/src/app/globals.css b/src/app/globals.css index 3cab6115..295a1bbc 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -277,7 +277,51 @@ html, body { letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); + margin-bottom: var(--space-sm); +} + +/* ─── Panel Tabs ──────────────────────────────────────────── */ +.panel-tabs { + display: flex; + align-items: center; + gap: var(--space-sm); margin-bottom: var(--space-lg); + padding-bottom: var(--space-sm); + border-bottom: 1px solid var(--border-subtle); + overflow-x: auto; + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE */ +} + +.panel-tabs::-webkit-scrollbar { + display: none; +} + +.panel-tab { + display: inline-flex; + align-items: center; + justify-content: center; + padding: var(--space-xs) var(--space-sm); + font-size: 11px; + font-weight: 500; + color: var(--text-muted); + background: transparent; + border: none; + border-radius: var(--radius-sm); + cursor: pointer; + white-space: nowrap; + transition: all var(--duration-fast) var(--ease-smooth); +} + +.panel-tab:hover { + color: var(--text-primary); + background: var(--bg-glass-hover); +} + +.panel-tab--active { + color: var(--accent-cyan); + background: rgba(34, 211, 238, 0.1); + font-weight: 600; } /* ─── Layer Item ──────────────────────────────────────────── */ diff --git a/src/components/panels/DataConfigPanel.tsx b/src/components/panels/DataConfigPanel.tsx index 9009b623..892fa923 100644 --- a/src/components/panels/DataConfigPanel.tsx +++ b/src/components/panels/DataConfigPanel.tsx @@ -1,5 +1,7 @@ "use client"; +import { useState } from "react"; + import { useStore } from "@/core/state/store"; import { FilterSection } from "./FilterPanel"; @@ -16,6 +18,8 @@ export function DataConfigPanel() { ([pluginId]) => layers[pluginId]?.enabled ); + const [activeTab, setActiveTab] = useState<"filters" | "cache" | "overlay">("filters"); + return ( ); } diff --git a/src/components/panels/LayerPanel.tsx b/src/components/panels/LayerPanel.tsx index ef37318c..f200e880 100644 --- a/src/components/panels/LayerPanel.tsx +++ b/src/components/panels/LayerPanel.tsx @@ -1,5 +1,7 @@ "use client"; +import { useState } from "react"; + import { useStore } from "@/core/state/store"; import { pluginManager } from "@/core/plugins/PluginManager"; import { ImageryPicker } from "./ImageryPicker"; @@ -44,66 +46,90 @@ export function LayerPanel() { } }; + const [activeTab, setActiveTab] = useState<"layers" | "imagery">("layers"); + return ( ); } diff --git a/src/instrumentation.ts b/src/instrumentation.ts index efd6db02..66a60aa7 100644 --- a/src/instrumentation.ts +++ b/src/instrumentation.ts @@ -1,8 +1,7 @@ export async function register() { if (process.env.NEXT_RUNTIME === "nodejs") { const { startAviationPolling } = await import("./lib/aviation-polling"); - const { startAisStream } = await import("./lib/ais-stream"); + // startAisStream is handled by api route to prevent serverless deadlocks startAviationPolling(); - startAisStream(); } } diff --git a/src/lib/test-ws.js b/src/lib/test-ws.js new file mode 100644 index 00000000..85f8524d --- /dev/null +++ b/src/lib/test-ws.js @@ -0,0 +1,36 @@ +const WebSocket = require('ws'); + +console.log("Starting test script..."); +const ws = new WebSocket('wss://stream.aisstream.io/v0/stream'); + +ws.on('open', () => { + console.log('[Test] Connected securely to aisstream.io'); + const subscriptionMessage = { + ApiKey: '091996a067bdae356f6b57244109e0192b373aef', + BoundingBoxes: [[[-90, -180], [90, 180]]], + FilterMessageTypes: ["PositionReport"] + }; + ws.send(JSON.stringify(subscriptionMessage)); +}); + +ws.on('message', (data) => { + console.log('[Test] Received:', data.toString().substring(0, 100)); +}); + +ws.on('close', (code, reason) => { + console.log('[Test] Connection closed. Code:', code, 'Reason:', reason.toString()); +}); + +ws.on('error', (err) => { + console.error('[Test] Error:', err); +}); + +// Ping interval +setInterval(() => { + if (ws.readyState === WebSocket.OPEN) { + console.log("Pinging..."); + ws.ping(); + } else { + console.log("WS state is", ws.readyState); + } +}, 3000);