feat: add scrollable tabs to side panels for better organization

This commit is contained in:
silvertakana committed 2026-03-05 17:32:20 +13:00
1 parent ee823ec266
commit fac5da4c55
6 files changed
+305 -165

No files matched your search

+5 -1
View File
@@ -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
+44
View File
@@ -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 ──────────────────────────────────────────── */
+143 -112
View File
@@ -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 (
<aside
className={`sidebar sidebar--right glass-panel ${configPanelOpen ? "" : "sidebar--closed"
@@ -24,130 +28,157 @@ export function DataConfigPanel() {
>
<div className="sidebar__title" style={{ marginBottom: "var(--space-md)", color: "var(--text-primary)", fontSize: "14px", fontWeight: 600 }}>Data Configuration</div>
{/* Entity Filters */}
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Entity Filters</div>
<FilterSection />
<div className="panel-tabs">
<button
className={`panel-tab ${activeTab === "filters" ? "panel-tab--active" : ""}`}
onClick={() => setActiveTab("filters")}
>
Filters
</button>
<button
className={`panel-tab ${activeTab === "cache" ? "panel-tab--active" : ""}`}
onClick={() => setActiveTab("cache")}
>
Cache & Limits
</button>
<button
className={`panel-tab ${activeTab === "overlay" ? "panel-tab--active" : ""}`}
onClick={() => setActiveTab("overlay")}
>
Config & Overlay
</button>
</div>
{/* Active Layer Configurations */}
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Active Layer Configs</div>
{enabledPlugins.length === 0 ? (
<div style={{ fontSize: 12, color: "var(--text-muted)", fontStyle: "italic", padding: "var(--space-sm) 0" }}>
No layers enabled. Turn on a layer to configure it.
{activeTab === "filters" && (
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Entity Filters</div>
<FilterSection />
</div>
)}
{activeTab === "cache" && (
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Cache & Limits</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Enable Cache</label>
<input
type="checkbox"
checked={dataConfig.cacheEnabled}
onChange={(e) => updateDataConfig({ cacheEnabled: e.target.checked })}
style={checkboxStyle}
/>
</div>
) : (
enabledPlugins.map(([pluginId, interval]) => (
<div key={pluginId} style={{
marginBottom: "var(--space-md)",
background: "var(--bg-tertiary)",
padding: "var(--space-md)",
borderRadius: "var(--radius-md)",
border: "1px solid var(--border-subtle)"
}}>
<div style={{ fontSize: 13, fontWeight: 500, color: "var(--text-primary)", marginBottom: "var(--space-sm)", textTransform: "capitalize" }}>
{pluginId} Layer
<div style={inputGroupStyle}>
<label style={labelStyle}>Cache Max Age (ms)</label>
<input
type="number"
value={dataConfig.cacheMaxAge}
onChange={(e) => updateDataConfig({ cacheMaxAge: parseInt(e.target.value) || 0 })}
style={inputStyle}
/>
</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Max Concurrent Req</label>
<input
type="number"
value={dataConfig.maxConcurrentRequests}
onChange={(e) => updateDataConfig({ maxConcurrentRequests: parseInt(e.target.value) || 0 })}
style={inputStyle}
/>
</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Retry Attempts</label>
<input
type="number"
value={dataConfig.retryAttempts}
onChange={(e) => updateDataConfig({ retryAttempts: parseInt(e.target.value) || 0 })}
style={inputStyle}
/>
</div>
</div>
)}
{activeTab === "overlay" && (
<>
{/* Active Layer Configurations */}
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Active Layer Configs</div>
{enabledPlugins.length === 0 ? (
<div style={{ fontSize: 12, color: "var(--text-muted)", fontStyle: "italic", padding: "var(--space-sm) 0" }}>
No layers enabled. Turn on a layer to configure it.
</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Polling Interval (ms)</label>
<input
type="number"
value={interval}
onChange={(e) => setPollingInterval(pluginId, parseInt(e.target.value) || 0)}
style={inputStyle}
/>
</div>
</div>
))
)}
</div>
) : (
enabledPlugins.map(([pluginId, interval]) => (
<div key={pluginId} style={{
marginBottom: "var(--space-md)",
background: "var(--bg-tertiary)",
padding: "var(--space-md)",
borderRadius: "var(--radius-md)",
border: "1px solid var(--border-subtle)"
}}>
<div style={{ fontSize: 13, fontWeight: 500, color: "var(--text-primary)", marginBottom: "var(--space-sm)", textTransform: "capitalize" }}>
{pluginId} Layer
</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Polling Interval (ms)</label>
<input
type="number"
value={interval}
onChange={(e) => setPollingInterval(pluginId, parseInt(e.target.value) || 0)}
style={inputStyle}
/>
</div>
</div>
))
)}
</div>
{/* General Settings */}
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Cach & Limits</div>
{/* Experimental Features */}
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Experimental Features</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Enable Cache</label>
<input
type="checkbox"
checked={dataConfig.cacheEnabled}
onChange={(e) => updateDataConfig({ cacheEnabled: e.target.checked })}
style={checkboxStyle}
/>
</div>
{Object.entries(dataConfig.experimentalFeatures).map(([feature, enabled]) => {
const labels: Record<string, string> = {
predictiveLoading: "Predictive Loading",
realtimeStreaming: "Realtime Streaming",
clusteringEnabled: "Clustering",
showTimelineHighlight: "Timeline Data Highlights",
};
return (
<div key={feature} style={inputGroupStyle}>
<label style={labelStyle}>{labels[feature] || feature}</label>
<input
type="checkbox"
checked={enabled}
onChange={(e) => updateDataConfig({
experimentalFeatures: { ...dataConfig.experimentalFeatures, [feature]: e.target.checked }
})}
style={checkboxStyle}
/>
</div>
);
})}
</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Cache Max Age (ms)</label>
<input
type="number"
value={dataConfig.cacheMaxAge}
onChange={(e) => updateDataConfig({ cacheMaxAge: parseInt(e.target.value) || 0 })}
style={inputStyle}
/>
</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Max Concurrent Req</label>
<input
type="number"
value={dataConfig.maxConcurrentRequests}
onChange={(e) => updateDataConfig({ maxConcurrentRequests: parseInt(e.target.value) || 0 })}
style={inputStyle}
/>
</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Retry Attempts</label>
<input
type="number"
value={dataConfig.retryAttempts}
onChange={(e) => updateDataConfig({ retryAttempts: parseInt(e.target.value) || 0 })}
style={inputStyle}
/>
</div>
</div>
{/* Experimental Features */}
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Experimental Features</div>
{Object.entries(dataConfig.experimentalFeatures).map(([feature, enabled]) => {
const labels: Record<string, string> = {
predictiveLoading: "Predictive Loading",
realtimeStreaming: "Realtime Streaming",
clusteringEnabled: "Clustering",
showTimelineHighlight: "Timeline Data Highlights",
};
return (
<div key={feature} style={inputGroupStyle}>
<label style={labelStyle}>{labels[feature] || feature}</label>
{/* Map Overlays */}
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Map Overlays</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Show Labels & Borders</label>
<input
type="checkbox"
checked={enabled}
onChange={(e) => updateDataConfig({
experimentalFeatures: { ...dataConfig.experimentalFeatures, [feature]: e.target.checked }
})}
checked={mapConfig?.showLabels || false}
onChange={(e) => updateMapConfig({ showLabels: e.target.checked })}
style={checkboxStyle}
/>
</div>
);
})}
</div>
{/* Map Overlays */}
<div style={{ marginBottom: "var(--space-lg)" }}>
<div style={sectionHeaderStyle}>Map Overlays</div>
<div style={inputGroupStyle}>
<label style={labelStyle}>Show Labels & Borders</label>
<input
type="checkbox"
checked={mapConfig?.showLabels || false}
onChange={(e) => updateMapConfig({ showLabels: e.target.checked })}
style={checkboxStyle}
/>
</div>
</div>
</div>
</>
)}
</aside>
);
}
+76 -50
View File
@@ -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 (
<aside
className={`sidebar sidebar--left glass-panel ${leftSidebarOpen ? "" : "sidebar--closed"
}`}
>
<div className="sidebar__title">Data Layers</div>
{Object.entries(grouped).map(([category, plugins]) => (
<div key={category} style={{ marginBottom: "var(--space-lg)" }}>
<div
style={{
fontSize: 10,
fontWeight: 600,
letterSpacing: "0.08em",
textTransform: "uppercase",
color: "var(--text-muted)",
marginBottom: "var(--space-sm)",
paddingLeft: "var(--space-md)",
}}
>
{categoryLabels[category] || category}
</div>
{plugins.map((managed) => {
const isEnabled = layers[managed.plugin.id]?.enabled || false;
const count = (entitiesByPlugin[managed.plugin.id] || []).length;
<div className="sidebar__title">Data Sources</div>
return (
<div className="panel-tabs">
<button
className={`panel-tab ${activeTab === "layers" ? "panel-tab--active" : ""}`}
onClick={() => setActiveTab("layers")}
>
Data Layers
</button>
<button
className={`panel-tab ${activeTab === "imagery" ? "panel-tab--active" : ""}`}
onClick={() => setActiveTab("imagery")}
>
Imagery
</button>
</div>
{activeTab === "layers" && (
<>
{Object.entries(grouped).map(([category, plugins]) => (
<div key={category} style={{ marginBottom: "var(--space-lg)" }}>
<div
key={managed.plugin.id}
className="layer-item"
onClick={() => handleToggle(managed.plugin.id)}
style={{
fontSize: 10,
fontWeight: 600,
letterSpacing: "0.08em",
textTransform: "uppercase",
color: "var(--text-muted)",
marginBottom: "var(--space-sm)",
paddingLeft: "var(--space-md)",
}}
>
<span className="layer-item__icon">
{typeof managed.plugin.icon === "string" ? (
managed.plugin.icon
) : (
<managed.plugin.icon size={18} />
)}
</span>
<div className="layer-item__info">
<div className="layer-item__name">{managed.plugin.name}</div>
<div className="layer-item__desc">
{managed.plugin.description}
</div>
</div>
{isEnabled && count > 0 && (
<span className="layer-item__count">
{count.toLocaleString()}
</span>
)}
<div
className={`layer-item__toggle ${isEnabled ? "layer-item__toggle--on" : ""
}`}
/>
{categoryLabels[category] || category}
</div>
);
})}
</div>
))}
{plugins.map((managed) => {
const isEnabled = layers[managed.plugin.id]?.enabled || false;
const count = (entitiesByPlugin[managed.plugin.id] || []).length;
<ImageryPicker />
return (
<div
key={managed.plugin.id}
className="layer-item"
onClick={() => handleToggle(managed.plugin.id)}
>
<span className="layer-item__icon">
{typeof managed.plugin.icon === "string" ? (
managed.plugin.icon
) : (
<managed.plugin.icon size={18} />
)}
</span>
<div className="layer-item__info">
<div className="layer-item__name">{managed.plugin.name}</div>
<div className="layer-item__desc">
{managed.plugin.description}
</div>
</div>
{isEnabled && count > 0 && (
<span className="layer-item__count">
{count.toLocaleString()}
</span>
)}
<div
className={`layer-item__toggle ${isEnabled ? "layer-item__toggle--on" : ""
}`}
/>
</div>
);
})}
</div>
))}
</>
)}
{activeTab === "imagery" && (
<ImageryPicker />
)}
</aside>
);
}
+1 -2
View File
@@ -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();
}
}
+36
View File
@@ -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);