rot finished
This commit is contained in:
15
web/index.html
Normal file
15
web/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ShackMaster - F4BPO Shack</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
18
web/package.json
Normal file
18
web/package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "shackmaster-web",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.1",
|
||||
"svelte": "^4.2.8",
|
||||
"vite": "^5.0.11"
|
||||
},
|
||||
"dependencies": {
|
||||
"@turf/turf": "^6.5.0"
|
||||
}
|
||||
}
|
||||
265
web/src/App.svelte
Normal file
265
web/src/App.svelte
Normal file
@@ -0,0 +1,265 @@
|
||||
<script>
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { wsService, connected, systemStatus } from './lib/websocket.js';
|
||||
import { api } from './lib/api.js';
|
||||
import WebSwitch from './components/WebSwitch.svelte';
|
||||
import PowerGenius from './components/PowerGenius.svelte';
|
||||
import TunerGenius from './components/TunerGenius.svelte';
|
||||
import AntennaGenius from './components/AntennaGenius.svelte';
|
||||
import RotatorGenius from './components/RotatorGenius.svelte';
|
||||
|
||||
let status = null;
|
||||
let isConnected = false;
|
||||
let currentTime = new Date();
|
||||
let callsign = 'F4BPO'; // Default
|
||||
|
||||
const unsubscribeStatus = systemStatus.subscribe(value => {
|
||||
status = value;
|
||||
});
|
||||
|
||||
const unsubscribeConnected = connected.subscribe(value => {
|
||||
isConnected = value;
|
||||
});
|
||||
|
||||
// Solar data from status
|
||||
$: solarData = status?.solar || {
|
||||
sfi: 0,
|
||||
sunspots: 0,
|
||||
a_index: 0,
|
||||
k_index: 0,
|
||||
geomag: 'Unknown'
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
wsService.connect();
|
||||
|
||||
// Fetch config to get callsign
|
||||
try {
|
||||
const config = await api.getConfig();
|
||||
if (config.callsign) {
|
||||
callsign = config.callsign;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch config:', err);
|
||||
}
|
||||
|
||||
// Update clock every second
|
||||
const clockInterval = setInterval(() => {
|
||||
currentTime = new Date();
|
||||
}, 1000);
|
||||
|
||||
return () => {
|
||||
clearInterval(clockInterval);
|
||||
};
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
wsService.disconnect();
|
||||
unsubscribeStatus();
|
||||
unsubscribeConnected();
|
||||
});
|
||||
|
||||
function formatTime(date) {
|
||||
return date.toTimeString().slice(0, 8);
|
||||
}
|
||||
|
||||
// Weather data from status
|
||||
$: weatherData = status?.weather || {
|
||||
wind_speed: 0,
|
||||
wind_gust: 0,
|
||||
temp: 0,
|
||||
feels_like: 0
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="app">
|
||||
<header>
|
||||
<div class="header-left">
|
||||
<h1>{callsign} Shack</h1>
|
||||
<div class="connection-status">
|
||||
<span class="status-indicator" class:status-online={isConnected} class:status-offline={!isConnected}></span>
|
||||
{isConnected ? 'Connected' : 'Disconnected'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header-center">
|
||||
<div class="solar-info">
|
||||
<span class="solar-item">SFI <span class="value">{solarData.sfi}</span></span>
|
||||
<span class="solar-item">Spots <span class="value">{solarData.sunspots}</span></span>
|
||||
<span class="solar-item">A <span class="value">{solarData.a_index}</span></span>
|
||||
<span class="solar-item">K <span class="value">{solarData.k_index}</span></span>
|
||||
<span class="solar-item">G <span class="value">{solarData.geomag}</span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header-right">
|
||||
<div class="weather-info">
|
||||
<span title="Wind">🌬️ {weatherData.wind_speed.toFixed(1)}m/s</span>
|
||||
<span title="Gust">💨 {weatherData.wind_gust.toFixed(1)}m/s</span>
|
||||
<span title="Temperature">🌡️ {weatherData.temp.toFixed(1)}°C</span>
|
||||
<span title="Feels like">→ {weatherData.feels_like.toFixed(1)}°C</span>
|
||||
</div>
|
||||
<div class="clock">
|
||||
<span class="time">{formatTime(currentTime)}</span>
|
||||
<span class="date">{currentTime.toLocaleDateString()}</span>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="dashboard-grid">
|
||||
<div class="row">
|
||||
<WebSwitch status={status?.webswitch} />
|
||||
<PowerGenius status={status?.power_genius} />
|
||||
<TunerGenius status={status?.tuner_genius} />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<AntennaGenius status={status?.antenna_genius} />
|
||||
<RotatorGenius status={status?.rotator_genius} />
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.app {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
header {
|
||||
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
|
||||
padding: 16px 24px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
font-weight: 500;
|
||||
margin: 0;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.connection-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 14px;
|
||||
padding: 6px 12px;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.header-center {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.solar-info {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.solar-item {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.solar-item .value {
|
||||
color: var(--accent-teal);
|
||||
font-weight: 500;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.weather-info {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
font-size: 14px;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.clock {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.date {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
|
||||
main {
|
||||
flex: 1;
|
||||
padding: 24px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.dashboard-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
max-width: 1800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.row > :global(*) {
|
||||
flex: 1;
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.row {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.header-center,
|
||||
.header-right {
|
||||
width: 100%;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.solar-info {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
438
web/src/app.css
Normal file
438
web/src/app.css
Normal file
@@ -0,0 +1,438 @@
|
||||
:root {
|
||||
/* Modern dark theme inspired by FlexDXCluster */
|
||||
--bg-primary: #0a1628;
|
||||
--bg-secondary: #1a2332;
|
||||
--bg-tertiary: #243447;
|
||||
--bg-hover: #2a3f5f;
|
||||
|
||||
--text-primary: #e0e6ed;
|
||||
--text-secondary: #a0aec0;
|
||||
--text-muted: #718096;
|
||||
|
||||
--accent-cyan: #4fc3f7;
|
||||
--accent-blue: #2196f3;
|
||||
--accent-green: #4caf50;
|
||||
--accent-orange: #ff9800;
|
||||
--accent-red: #f44336;
|
||||
--accent-purple: #9c27b0;
|
||||
--accent-yellow: #ffc107;
|
||||
|
||||
--border-color: #2d3748;
|
||||
--border-light: #374151;
|
||||
|
||||
--card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
||||
--card-radius: 6px;
|
||||
|
||||
--header-height: 56px;
|
||||
--spacing-xs: 4px;
|
||||
--spacing-sm: 8px;
|
||||
--spacing-md: 12px;
|
||||
--spacing-lg: 16px;
|
||||
--spacing-xl: 20px;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ==================== HEADER ==================== */
|
||||
header {
|
||||
height: var(--header-height);
|
||||
background: var(--bg-secondary);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 var(--spacing-lg);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.header-left h1 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-cyan);
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.connection-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.status-indicator {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent-red);
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.status-indicator.status-online {
|
||||
background: var(--accent-green);
|
||||
box-shadow: 0 0 8px var(--accent-green);
|
||||
}
|
||||
|
||||
.header-center {
|
||||
display: flex;
|
||||
gap: var(--spacing-xl);
|
||||
}
|
||||
|
||||
.solar-info {
|
||||
display: flex;
|
||||
gap: var(--spacing-md);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.solar-item {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.solar-item .value {
|
||||
color: var(--accent-cyan);
|
||||
font-weight: 600;
|
||||
margin-left: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.weather-info {
|
||||
display: flex;
|
||||
gap: var(--spacing-md);
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.clock {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.clock .time {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.clock .date {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
/* ==================== MAIN CONTENT ==================== */
|
||||
main {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
.dashboard-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
max-width: 1800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* ==================== CARDS ==================== */
|
||||
.card {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--card-radius);
|
||||
padding: var(--spacing-md);
|
||||
box-shadow: var(--card-shadow);
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
border-color: var(--border-light);
|
||||
}
|
||||
|
||||
.card h2 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-cyan);
|
||||
margin-bottom: var(--spacing-md);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.card h2::before {
|
||||
content: '';
|
||||
width: 3px;
|
||||
height: 14px;
|
||||
background: var(--accent-cyan);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
/* Status indicators */
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent-green);
|
||||
}
|
||||
|
||||
.status-dot.disconnected {
|
||||
background: var(--accent-red);
|
||||
}
|
||||
|
||||
/* ==================== LABELS & VALUES ==================== */
|
||||
.label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
margin-bottom: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: 18px;
|
||||
font-weight: 300;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* ==================== BUTTONS ==================== */
|
||||
button, .button {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
button:hover, .button:hover {
|
||||
background: var(--bg-hover);
|
||||
border-color: var(--border-light);
|
||||
}
|
||||
|
||||
button:active, .button:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
button.primary {
|
||||
background: var(--accent-cyan);
|
||||
border-color: var(--accent-cyan);
|
||||
color: #000;
|
||||
}
|
||||
|
||||
button.primary:hover {
|
||||
background: #29b6f6;
|
||||
border-color: #29b6f6;
|
||||
}
|
||||
|
||||
button.success {
|
||||
background: var(--accent-green);
|
||||
border-color: var(--accent-green);
|
||||
color: white;
|
||||
}
|
||||
|
||||
button.danger {
|
||||
background: var(--accent-red);
|
||||
border-color: var(--accent-red);
|
||||
color: white;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* ==================== SELECT ==================== */
|
||||
select {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
padding: var(--spacing-sm);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
select:hover {
|
||||
border-color: var(--border-light);
|
||||
}
|
||||
|
||||
select:focus {
|
||||
border-color: var(--accent-cyan);
|
||||
}
|
||||
|
||||
/* ==================== BADGES ==================== */
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 4px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.badge.green {
|
||||
background: rgba(76, 175, 80, 0.2);
|
||||
color: var(--accent-green);
|
||||
}
|
||||
|
||||
.badge.red {
|
||||
background: rgba(244, 67, 54, 0.2);
|
||||
color: var(--accent-red);
|
||||
}
|
||||
|
||||
.badge.orange {
|
||||
background: rgba(255, 152, 0, 0.2);
|
||||
color: var(--accent-orange);
|
||||
}
|
||||
|
||||
.badge.cyan {
|
||||
background: rgba(79, 195, 247, 0.2);
|
||||
color: var(--accent-cyan);
|
||||
}
|
||||
|
||||
.badge.purple {
|
||||
background: rgba(156, 39, 176, 0.2);
|
||||
color: var(--accent-purple);
|
||||
}
|
||||
|
||||
/* ==================== PROGRESS BARS ==================== */
|
||||
.bar {
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
margin: var(--spacing-xs) 0;
|
||||
}
|
||||
|
||||
.bar-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, var(--accent-green), var(--accent-orange), var(--accent-red));
|
||||
transition: width 0.3s ease;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.scale {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
margin-top: var(--spacing-xs);
|
||||
}
|
||||
|
||||
/* ==================== METRICS ==================== */
|
||||
.metrics {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.metric {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.metric-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.metric.small {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* ==================== SCROLLBAR ==================== */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
/* ==================== RESPONSIVE ==================== */
|
||||
@media (max-width: 1400px) {
|
||||
.dashboard-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
header {
|
||||
flex-direction: column;
|
||||
height: auto;
|
||||
padding: var(--spacing-sm);
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.dashboard-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.header-center {
|
||||
order: 3;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
310
web/src/components/AntennaGenius.svelte
Normal file
310
web/src/components/AntennaGenius.svelte
Normal file
@@ -0,0 +1,310 @@
|
||||
<script>
|
||||
import { api } from '../lib/api.js';
|
||||
|
||||
export let status;
|
||||
|
||||
$: connected = status?.connected || false;
|
||||
$: portA = status?.port_a || {};
|
||||
$: portB = status?.port_b || {};
|
||||
$: antennas = status?.antennas || [];
|
||||
|
||||
// Band names
|
||||
const bandNames = {
|
||||
0: '160M', 1: '80M', 2: '60M', 3: '40M', 4: '30M',
|
||||
5: '20M', 6: '17M', 7: '15M', 8: '12M', 9: '10M',
|
||||
10: '6M', 11: '4M', 12: '2M', 13: '1.25M', 14: '70CM', 15: 'GEN'
|
||||
};
|
||||
|
||||
$: bandAName = bandNames[portA.band] || 'None';
|
||||
$: bandBName = bandNames[portB.band] || 'None';
|
||||
|
||||
async function selectAntenna(port, antennaNum) {
|
||||
try {
|
||||
await api.antenna.selectAntenna(port, antennaNum, antennaNum);
|
||||
} catch (err) {
|
||||
console.error('Failed to select antenna:', err);
|
||||
alert('Failed to select antenna');
|
||||
}
|
||||
}
|
||||
|
||||
async function reboot() {
|
||||
if (!confirm('Are you sure you want to reboot the Antenna Genius?')) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await api.antenna.reboot();
|
||||
} catch (err) {
|
||||
console.error('Failed to reboot:', err);
|
||||
alert('Failed to reboot');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Antenna Genius</h2>
|
||||
<span class="status-dot" class:disconnected={!connected}></span>
|
||||
</div>
|
||||
|
||||
<div class="metrics">
|
||||
<!-- Radio Sources -->
|
||||
<div class="sources">
|
||||
<div class="source-item">
|
||||
<div class="source-label">{portA.source || 'FLEX'}</div>
|
||||
</div>
|
||||
<div class="source-item">
|
||||
<div class="source-label">{portB.source || 'FLEX'}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bands -->
|
||||
<div class="bands">
|
||||
<div class="band-item">
|
||||
<div class="band-value">{bandAName}</div>
|
||||
</div>
|
||||
<div class="band-item">
|
||||
<div class="band-value">{bandBName}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Antennas -->
|
||||
<div class="antennas">
|
||||
{#each antennas as antenna}
|
||||
{@const isPortATx = portA.tx && portA.tx_ant === antenna.number}
|
||||
{@const isPortBTx = portB.tx && portB.tx_ant === antenna.number}
|
||||
{@const isPortARx = !portA.tx && (portA.rx_ant === antenna.number || portA.tx_ant === antenna.number)}
|
||||
{@const isPortBRx = !portB.tx && (portB.rx_ant === antenna.number || portB.tx_ant === antenna.number)}
|
||||
{@const isTx = isPortATx || isPortBTx}
|
||||
{@const isActive = isPortARx || isPortBRx}
|
||||
|
||||
<div
|
||||
class="antenna-card"
|
||||
class:tx={isTx}
|
||||
class:active-a={isPortARx}
|
||||
class:active-b={isPortBRx}
|
||||
>
|
||||
<div class="antenna-name">{antenna.name}</div>
|
||||
<div class="antenna-ports">
|
||||
<button
|
||||
class="port-btn"
|
||||
class:active={portA.tx_ant === antenna.number || portA.rx_ant === antenna.number}
|
||||
on:click={() => selectAntenna(1, antenna.number)}
|
||||
>
|
||||
A
|
||||
</button>
|
||||
<button
|
||||
class="port-btn"
|
||||
class:active={portB.tx_ant === antenna.number || portB.rx_ant === antenna.number}
|
||||
on:click={() => selectAntenna(2, antenna.number)}
|
||||
>
|
||||
B
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<!-- Reboot Button -->
|
||||
<button class="reboot-btn" on:click={reboot}>
|
||||
<span class="reboot-icon">🔄</span>
|
||||
REBOOT
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 16px;
|
||||
background: rgba(79, 195, 247, 0.05);
|
||||
border-bottom: 1px solid #2d3748;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-cyan);
|
||||
margin: 0;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #4caf50;
|
||||
box-shadow: 0 0 8px #4caf50;
|
||||
}
|
||||
|
||||
.status-dot.disconnected {
|
||||
background: #f44336;
|
||||
box-shadow: 0 0 8px #f44336;
|
||||
}
|
||||
|
||||
.metrics {
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* Sources */
|
||||
.sources {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.source-item {
|
||||
padding: 8px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.source-label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* Bands */
|
||||
.bands {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.band-item {
|
||||
padding: 10px;
|
||||
background: rgba(79, 195, 247, 0.1);
|
||||
border: 1px solid rgba(79, 195, 247, 0.3);
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.band-value {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-cyan);
|
||||
}
|
||||
|
||||
/* Antennas */
|
||||
.antennas {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.antenna-card {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px;
|
||||
background: var(--bg-tertiary);
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.antenna-card.tx {
|
||||
background: rgba(244, 67, 54, 0.2);
|
||||
border-color: #f44336;
|
||||
box-shadow: 0 0 20px rgba(244, 67, 54, 0.4);
|
||||
}
|
||||
|
||||
.antenna-card.active-a {
|
||||
background: rgba(76, 175, 80, 0.2);
|
||||
border-color: #4caf50;
|
||||
box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
|
||||
}
|
||||
|
||||
.antenna-card.active-b {
|
||||
background: rgba(33, 150, 243, 0.2);
|
||||
border-color: #2196f3;
|
||||
box-shadow: 0 0 20px rgba(33, 150, 243, 0.3);
|
||||
}
|
||||
|
||||
.antenna-name {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.antenna-ports {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.port-btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-secondary);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.port-btn:hover {
|
||||
border-color: var(--accent-cyan);
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.port-btn.active {
|
||||
background: var(--accent-cyan);
|
||||
border-color: var(--accent-cyan);
|
||||
color: #000;
|
||||
box-shadow: 0 0 12px rgba(79, 195, 247, 0.5);
|
||||
}
|
||||
|
||||
/* Reboot Button */
|
||||
.reboot-btn {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: linear-gradient(135deg, #ff9800, #f57c00);
|
||||
color: white;
|
||||
transition: all 0.2s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.reboot-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 16px rgba(255, 152, 0, 0.5);
|
||||
}
|
||||
|
||||
.reboot-btn:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.reboot-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
492
web/src/components/PowerGenius.svelte
Normal file
492
web/src/components/PowerGenius.svelte
Normal file
@@ -0,0 +1,492 @@
|
||||
<script>
|
||||
import { api } from '../lib/api.js';
|
||||
|
||||
export let status;
|
||||
|
||||
$: powerForward = status?.power_forward || 0;
|
||||
$: powerReflected = status?.power_reflected || 0;
|
||||
$: swr = status?.swr || 1.0;
|
||||
$: voltage = status?.voltage || 0;
|
||||
$: vdd = status?.vdd || 0;
|
||||
$: current = status?.current || 0;
|
||||
$: peakCurrent = status?.peak_current || 0;
|
||||
$: temperature = status?.temperature || 0;
|
||||
$: harmonicLoadTemp = status?.harmonic_load_temp || 0;
|
||||
$: fanMode = status?.fan_mode || 'CONTEST';
|
||||
$: state = status?.state || 'IDLE';
|
||||
$: bandA = status?.band_a || '0';
|
||||
$: bandB = status?.band_b || '0';
|
||||
$: connected = status?.connected || false;
|
||||
|
||||
$: displayState = state.replace('TRANSMIT_A', 'TRANSMIT').replace('TRANSMIT_B', 'TRANSMIT');
|
||||
|
||||
// Color functions
|
||||
$: tempColor = temperature < 40 ? '#4caf50' : temperature < 60 ? '#ffc107' : temperature < 75 ? '#ff9800' : '#f44336';
|
||||
$: swrColor = swr < 1.5 ? '#4caf50' : swr < 2.0 ? '#ffc107' : swr < 3.0 ? '#ff9800' : '#f44336';
|
||||
$: powerPercent = Math.min((powerForward / 2000) * 100, 100);
|
||||
|
||||
async function setFanMode(mode) {
|
||||
try {
|
||||
await api.power.setFanMode(mode);
|
||||
} catch (err) {
|
||||
console.error('Failed to set fan mode:', err);
|
||||
alert('Failed to set fan mode');
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleOperate() {
|
||||
try {
|
||||
const operateValue = state === 'IDLE' ? 0 : 1;
|
||||
await api.power.setOperate(operateValue);
|
||||
} catch (err) {
|
||||
console.error('Failed to toggle operate:', err);
|
||||
alert('Failed to toggle operate mode');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Power Genius XL</h2>
|
||||
<div class="header-right">
|
||||
<button
|
||||
class="state-badge"
|
||||
class:idle={state === 'IDLE'}
|
||||
class:transmit={state.includes('TRANSMIT')}
|
||||
on:click={toggleOperate}
|
||||
>
|
||||
{displayState}
|
||||
</button>
|
||||
<span class="status-dot" class:disconnected={!connected}></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="metrics">
|
||||
<!-- Power Display - Big and Bold -->
|
||||
<div class="power-display">
|
||||
<div class="power-main">
|
||||
<div class="power-value">{powerForward.toFixed(0)}<span class="unit">W</span></div>
|
||||
<div class="power-label">Forward Power</div>
|
||||
</div>
|
||||
<div class="power-bar">
|
||||
<div class="power-bar-fill" style="width: {powerPercent}%">
|
||||
<div class="power-bar-glow"></div>
|
||||
</div>
|
||||
<div class="power-scale">
|
||||
<span>0</span>
|
||||
<span>1000</span>
|
||||
<span>2000</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SWR Circle Indicator -->
|
||||
<div class="swr-container">
|
||||
<div class="swr-circle" style="--swr-color: {swrColor}">
|
||||
<div class="swr-value">{swr.toFixed(2)}</div>
|
||||
<div class="swr-label">SWR</div>
|
||||
</div>
|
||||
<div class="swr-status">
|
||||
{#if swr < 1.5}
|
||||
<span class="status-text good">Excellent</span>
|
||||
{:else if swr < 2.0}
|
||||
<span class="status-text ok">Good</span>
|
||||
{:else if swr < 3.0}
|
||||
<span class="status-text warning">Caution</span>
|
||||
{:else}
|
||||
<span class="status-text danger">High!</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Temperature Gauges -->
|
||||
<div class="temp-group">
|
||||
<div class="temp-item">
|
||||
<div class="temp-value" style="color: {tempColor}">{temperature.toFixed(0)}°</div>
|
||||
<div class="temp-label">PA Temp</div>
|
||||
<div class="temp-mini-bar">
|
||||
<div class="temp-mini-fill" style="width: {(temperature / 80) * 100}%; background: {tempColor}"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="temp-item">
|
||||
<div class="temp-value" style="color: {tempColor}">{harmonicLoadTemp.toFixed(0)}°</div>
|
||||
<div class="temp-label">HL Temp</div>
|
||||
<div class="temp-mini-bar">
|
||||
<div class="temp-mini-fill" style="width: {(harmonicLoadTemp / 80) * 100}%; background: {tempColor}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Electrical Parameters -->
|
||||
<div class="params-grid">
|
||||
<div class="param-box">
|
||||
<div class="param-label">VAC</div>
|
||||
<div class="param-value">{voltage.toFixed(0)}</div>
|
||||
</div>
|
||||
<div class="param-box">
|
||||
<div class="param-label">VDD</div>
|
||||
<div class="param-value">{vdd.toFixed(1)}</div>
|
||||
</div>
|
||||
<div class="param-box">
|
||||
<div class="param-label">ID Peak</div>
|
||||
<div class="param-value">{peakCurrent.toFixed(1)}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Band Display -->
|
||||
<div class="band-display">
|
||||
<div class="band-item">
|
||||
<span class="band-label">Band A</span>
|
||||
<span class="band-value">{bandA}</span>
|
||||
</div>
|
||||
<div class="band-item">
|
||||
<span class="band-label">Band B</span>
|
||||
<span class="band-value">{bandB}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Fan Control -->
|
||||
<div class="fan-control">
|
||||
<label class="control-label">Fan Mode</label>
|
||||
<select value={fanMode} on:change={(e) => setFanMode(e.target.value)}>
|
||||
<option value="STANDARD">Standard</option>
|
||||
<option value="CONTEST">Contest</option>
|
||||
<option value="BROADCAST">Broadcast</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 16px;
|
||||
background: rgba(79, 195, 247, 0.05);
|
||||
border-bottom: 1px solid #2d3748;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-cyan);
|
||||
margin: 0;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.state-badge {
|
||||
padding: 4px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.state-badge.idle {
|
||||
background: rgba(76, 175, 80, 0.2);
|
||||
color: #4caf50;
|
||||
}
|
||||
|
||||
.state-badge.transmit {
|
||||
background: rgba(255, 152, 0, 0.2);
|
||||
color: #ff9800;
|
||||
animation: pulse 1s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.7; }
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #4caf50;
|
||||
box-shadow: 0 0 8px #4caf50;
|
||||
}
|
||||
|
||||
.status-dot.disconnected {
|
||||
background: #f44336;
|
||||
box-shadow: 0 0 8px #f44336;
|
||||
}
|
||||
|
||||
.metrics {
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
/* Power Display */
|
||||
.power-display {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.power-main {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.power-value {
|
||||
font-size: 48px;
|
||||
font-weight: 200;
|
||||
color: var(--accent-cyan);
|
||||
line-height: 1;
|
||||
text-shadow: 0 0 20px rgba(79, 195, 247, 0.5);
|
||||
}
|
||||
|
||||
.power-value .unit {
|
||||
font-size: 24px;
|
||||
color: var(--text-secondary);
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.power-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.power-bar {
|
||||
position: relative;
|
||||
height: 8px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.power-bar-fill {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #4caf50, #ffc107, #ff9800, #f44336);
|
||||
border-radius: 4px;
|
||||
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%); }
|
||||
}
|
||||
|
||||
.power-scale {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 9px;
|
||||
color: var(--text-muted);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* SWR Circle */
|
||||
.swr-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.swr-circle {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(circle, rgba(79, 195, 247, 0.1), transparent);
|
||||
border: 3px solid var(--swr-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 0 20px var(--swr-color);
|
||||
}
|
||||
|
||||
.swr-value {
|
||||
font-size: 24px;
|
||||
font-weight: 300;
|
||||
color: var(--swr-color);
|
||||
}
|
||||
|
||||
.swr-label {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.swr-status {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.status-text.good { color: #4caf50; }
|
||||
.status-text.ok { color: #ffc107; }
|
||||
.status-text.warning { color: #ff9800; }
|
||||
.status-text.danger { color: #f44336; }
|
||||
|
||||
/* Temperature */
|
||||
.temp-group {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.temp-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 12px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.temp-value {
|
||||
font-size: 32px;
|
||||
font-weight: 300;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.temp-label {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.temp-mini-bar {
|
||||
height: 4px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.temp-mini-fill {
|
||||
height: 100%;
|
||||
border-radius: 2px;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
/* Parameters Grid */
|
||||
.params-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.param-box {
|
||||
padding: 8px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.param-label {
|
||||
font-size: 9px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.param-value {
|
||||
font-size: 18px;
|
||||
font-weight: 300;
|
||||
color: var(--text-primary);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* Band Display */
|
||||
.band-display {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
background: rgba(79, 195, 247, 0.05);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.band-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.band-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.band-value {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-cyan);
|
||||
}
|
||||
|
||||
/* Fan Control */
|
||||
.fan-control {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.control-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
select {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
select:hover {
|
||||
border-color: var(--accent-cyan);
|
||||
}
|
||||
|
||||
select:focus {
|
||||
border-color: var(--accent-cyan);
|
||||
box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
|
||||
}
|
||||
</style>
|
||||
427
web/src/components/RotatorGenius.svelte
Normal file
427
web/src/components/RotatorGenius.svelte
Normal file
@@ -0,0 +1,427 @@
|
||||
<script>
|
||||
import { api } from '../lib/api.js';
|
||||
|
||||
export let status;
|
||||
|
||||
$: heading = status?.heading || 0;
|
||||
$: connected = status?.connected || false;
|
||||
|
||||
let targetHeading = 0;
|
||||
|
||||
async function goToHeading() {
|
||||
if (targetHeading < 0 || targetHeading > 359) {
|
||||
alert('Heading must be between 0 and 359');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Subtract 10 degrees to compensate for rotator momentum
|
||||
const adjustedHeading = (targetHeading - 10 + 360) % 360;
|
||||
await api.rotator.setHeading(adjustedHeading);
|
||||
} catch (err) {
|
||||
console.error('Failed to set heading:', err);
|
||||
alert('Failed to rotate');
|
||||
}
|
||||
}
|
||||
|
||||
async function rotateCW() {
|
||||
try {
|
||||
await api.rotator.rotateCW();
|
||||
} catch (err) {
|
||||
console.error('Failed to rotate CW:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function rotateCCW() {
|
||||
try {
|
||||
await api.rotator.rotateCCW();
|
||||
} catch (err) {
|
||||
console.error('Failed to rotate CCW:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function stop() {
|
||||
try {
|
||||
await api.rotator.stop();
|
||||
} catch (err) {
|
||||
console.error('Failed to stop:', err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Rotator Genius</h2>
|
||||
<span class="status-dot" class:disconnected={!connected}></span>
|
||||
</div>
|
||||
|
||||
<div class="metrics">
|
||||
<!-- Current Heading Display -->
|
||||
<div class="heading-display">
|
||||
<div class="heading-label">CURRENT HEADING</div>
|
||||
<div class="heading-value">{heading}°</div>
|
||||
</div>
|
||||
|
||||
<!-- Map with Beam -->
|
||||
<div class="map-container">
|
||||
<svg viewBox="0 0 500 500" class="map-svg">
|
||||
<defs>
|
||||
<!-- Gradient for beam -->
|
||||
<radialGradient id="beamGradient">
|
||||
<stop offset="0%" style="stop-color:rgba(79, 195, 247, 0.7);stop-opacity:1" />
|
||||
<stop offset="100%" style="stop-color:rgba(79, 195, 247, 0);stop-opacity:0" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
|
||||
<!-- Ocean background -->
|
||||
<circle cx="250" cy="250" r="240" fill="rgba(30, 64, 175, 0.2)" stroke="rgba(79, 195, 247, 0.4)" stroke-width="3"/>
|
||||
|
||||
<!-- Simplified world map (Azimuthal centered on France ~46°N 6°E) -->
|
||||
<g transform="translate(250, 250)" opacity="0.5">
|
||||
|
||||
<!-- Europe (enlarged and centered) -->
|
||||
<!-- France -->
|
||||
<path d="M -20,-15 L -15,-25 L -5,-28 L 5,-25 L 10,-18 L 8,-8 L 0,-5 L -10,-8 L -18,-12 Z"
|
||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
||||
|
||||
<!-- Spain/Portugal -->
|
||||
<path d="M -30,-8 L -22,-12 L -18,-8 L -20,0 L -25,5 L -32,3 L -35,-2 Z"
|
||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
||||
|
||||
<!-- Italy -->
|
||||
<path d="M 5,-10 L 10,-12 L 15,-8 L 18,5 L 15,15 L 10,12 L 8,0 Z"
|
||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
||||
|
||||
<!-- Germany/Central Europe -->
|
||||
<path d="M -5,-28 L 5,-32 L 15,-30 L 20,-22 L 15,-18 L 5,-20 L 0,-25 Z"
|
||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
||||
|
||||
<!-- UK/Ireland -->
|
||||
<path d="M -45,-25 L -40,-32 L -32,-35 L -28,-28 L -32,-20 L -40,-22 Z"
|
||||
fill="#4CAF50" stroke="#81C784" stroke-width="1.5"/>
|
||||
|
||||
<!-- Scandinavia -->
|
||||
<path d="M 0,-40 L 10,-50 L 20,-48 L 25,-38 L 20,-32 L 10,-35 L 5,-38 Z"
|
||||
fill="#66BB6A" stroke="#81C784" stroke-width="1.5"/>
|
||||
|
||||
<!-- Eastern Europe/Russia West -->
|
||||
<path d="M 20,-35 L 35,-40 L 50,-35 L 55,-20 L 50,-10 L 35,-8 L 25,-15 Z"
|
||||
fill="#66BB6A" stroke="#81C784" stroke-width="1.5"/>
|
||||
|
||||
<!-- North Africa -->
|
||||
<path d="M -35,10 L -20,8 L 0,12 L 15,18 L 10,35 L -5,40 L -25,35 L -35,25 Z"
|
||||
fill="#FFA726" stroke="#FFB74D" stroke-width="1.5"/>
|
||||
|
||||
<!-- Sub-Saharan Africa -->
|
||||
<path d="M -20,42 L 0,45 L 15,50 L 20,70 L 10,95 L -10,100 L -30,90 L -35,70 L -30,50 Z"
|
||||
fill="#FF9800" stroke="#FFB74D" stroke-width="1.5"/>
|
||||
|
||||
<!-- Middle East -->
|
||||
<path d="M 25,0 L 40,5 L 55,10 L 60,25 L 55,38 L 42,42 L 30,35 L 22,20 Z"
|
||||
fill="#FFEB3B" stroke="#FFF176" stroke-width="1.5"/>
|
||||
|
||||
<!-- Russia East/Central Asia -->
|
||||
<path d="M 60,-30 L 90,-35 L 120,-25 L 135,-10 L 140,15 L 130,30 L 105,35 L 80,28 L 65,10 L 62,-10 Z"
|
||||
fill="#AB47BC" stroke="#BA68C8" stroke-width="1.5"/>
|
||||
|
||||
<!-- India/South Asia -->
|
||||
<path d="M 70,40 L 85,38 L 95,45 L 98,60 L 92,75 L 78,80 L 68,72 L 65,55 Z"
|
||||
fill="#EC407A" stroke="#F06292" stroke-width="1.5"/>
|
||||
|
||||
<!-- China/East Asia -->
|
||||
<path d="M 110,0 L 135,5 L 150,18 L 155,35 L 145,52 L 125,58 L 105,50 L 95,32 L 100,15 Z"
|
||||
fill="#7E57C2" stroke="#9575CD" stroke-width="1.5"/>
|
||||
|
||||
<!-- Japan -->
|
||||
<path d="M 165,25 L 172,22 L 178,28 L 175,40 L 168,45 L 162,42 L 160,32 Z"
|
||||
fill="#E91E63" stroke="#F06292" stroke-width="1.5"/>
|
||||
|
||||
<!-- North America -->
|
||||
<path d="M -140,-40 L -110,-50 L -80,-48 L -60,-35 L -55,-15 L -65,5 L -85,15 L -110,12 L -135,-5 L -145,-25 Z"
|
||||
fill="#42A5F5" stroke="#64B5F6" stroke-width="1.5"/>
|
||||
|
||||
<!-- Central America -->
|
||||
<path d="M -75,20 L -65,18 L -55,25 L -58,35 L -68,38 L -78,32 Z"
|
||||
fill="#29B6F6" stroke="#4FC3F7" stroke-width="1.5"/>
|
||||
|
||||
<!-- South America -->
|
||||
<path d="M -70,45 L -60,42 L -48,50 L -45,70 L -50,100 L -60,120 L -75,125 L -88,115 L -92,90 L -85,65 L -78,52 Z"
|
||||
fill="#26C6DA" stroke="#4DD0E1" stroke-width="1.5"/>
|
||||
|
||||
<!-- Australia -->
|
||||
<path d="M 130,95 L 155,92 L 175,100 L 180,120 L 170,135 L 145,138 L 125,128 L 122,110 Z"
|
||||
fill="#66BB6A" stroke="#81C784" stroke-width="1.5"/>
|
||||
|
||||
</g>
|
||||
|
||||
<!-- Distance circles -->
|
||||
<circle cx="250" cy="250" r="180" fill="none" stroke="rgba(79,195,247,0.2)" stroke-width="1" stroke-dasharray="4,4"/>
|
||||
<circle cx="250" cy="250" r="120" fill="none" stroke="rgba(79,195,247,0.2)" stroke-width="1" stroke-dasharray="4,4"/>
|
||||
<circle cx="250" cy="250" r="60" fill="none" stroke="rgba(79,195,247,0.2)" stroke-width="1" stroke-dasharray="4,4"/>
|
||||
|
||||
<!-- Rotated group for beam -->
|
||||
<g transform="translate(250, 250)">
|
||||
<!-- Beam (rotates with heading) -->
|
||||
<g transform="rotate({heading})">
|
||||
<!-- Beam sector (±15° = 30° total beamwidth) -->
|
||||
<path d="M 0,0 L {-Math.sin(15 * Math.PI/180) * 220},{-Math.cos(15 * Math.PI/180) * 220}
|
||||
A 220,220 0 0,1 {Math.sin(15 * Math.PI/180) * 220},{-Math.cos(15 * Math.PI/180) * 220} Z"
|
||||
fill="url(#beamGradient)"
|
||||
opacity="0.85"/>
|
||||
|
||||
<!-- Beam outline -->
|
||||
<line x1="0" y1="0" x2={-Math.sin(15 * Math.PI/180) * 220} y2={-Math.cos(15 * Math.PI/180) * 220}
|
||||
stroke="#4fc3f7" stroke-width="3" opacity="0.9"/>
|
||||
<line x1="0" y1="0" x2={Math.sin(15 * Math.PI/180) * 220} y2={-Math.cos(15 * Math.PI/180) * 220}
|
||||
stroke="#4fc3f7" stroke-width="3" opacity="0.9"/>
|
||||
|
||||
<!-- Direction arrow -->
|
||||
<g transform="translate(0, -190)">
|
||||
<polygon points="0,-30 -12,8 0,0 12,8"
|
||||
fill="#4fc3f7"
|
||||
stroke="#0288d1"
|
||||
stroke-width="3"
|
||||
style="filter: drop-shadow(0 0 15px rgba(79, 195, 247, 1))"/>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<!-- Center dot (your QTH - JN36dg) -->
|
||||
<circle cx="0" cy="0" r="6" fill="#f44336" stroke="#fff" stroke-width="3">
|
||||
<animate attributeName="r" values="6;9;6" dur="2s" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="0" cy="0" r="12" fill="none" stroke="#f44336" stroke-width="2" opacity="0.5">
|
||||
<animate attributeName="r" values="12;20;12" dur="2s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity" values="0.5;0;0.5" dur="2s" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
</g>
|
||||
|
||||
<!-- Cardinal points -->
|
||||
<text x="250" y="30" text-anchor="middle" class="cardinal">N</text>
|
||||
<text x="470" y="255" text-anchor="middle" class="cardinal">E</text>
|
||||
<text x="250" y="480" text-anchor="middle" class="cardinal">S</text>
|
||||
<text x="30" y="255" text-anchor="middle" class="cardinal">W</text>
|
||||
|
||||
<!-- Degree markers every 30° -->
|
||||
{#each [30, 60, 120, 150, 210, 240, 300, 330] as angle}
|
||||
{@const x = 250 + 215 * Math.sin(angle * Math.PI / 180)}
|
||||
{@const y = 250 - 215 * Math.cos(angle * Math.PI / 180)}
|
||||
<text x={x} y={y} text-anchor="middle" dominant-baseline="middle" class="degree-label">{angle}°</text>
|
||||
{/each}
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<!-- Go To Heading -->
|
||||
<div class="goto-container">
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="359"
|
||||
bind:value={targetHeading}
|
||||
placeholder="Enter heading"
|
||||
class="heading-input"
|
||||
/>
|
||||
<button class="go-btn" on:click={goToHeading}>GO</button>
|
||||
</div>
|
||||
|
||||
<!-- Control Buttons -->
|
||||
<div class="controls">
|
||||
<button class="control-btn ccw" on:click={rotateCCW}>
|
||||
<span class="arrow">↺</span>
|
||||
CCW
|
||||
</button>
|
||||
<button class="control-btn stop" on:click={stop}>
|
||||
STOP
|
||||
</button>
|
||||
<button class="control-btn cw" on:click={rotateCW}>
|
||||
<span class="arrow">↻</span>
|
||||
CW
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 16px;
|
||||
background: rgba(79, 195, 247, 0.05);
|
||||
border-bottom: 1px solid #2d3748;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-cyan);
|
||||
margin: 0;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #4caf50;
|
||||
box-shadow: 0 0 8px #4caf50;
|
||||
}
|
||||
|
||||
.status-dot.disconnected {
|
||||
background: #f44336;
|
||||
box-shadow: 0 0 8px #f44336;
|
||||
}
|
||||
|
||||
.metrics {
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
/* Heading Display */
|
||||
.heading-display {
|
||||
text-align: center;
|
||||
padding: 12px;
|
||||
background: rgba(79, 195, 247, 0.1);
|
||||
border-radius: 6px;
|
||||
border: 1px solid rgba(79, 195, 247, 0.3);
|
||||
}
|
||||
|
||||
.heading-label {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.heading-value {
|
||||
font-size: 42px;
|
||||
font-weight: 200;
|
||||
color: var(--accent-cyan);
|
||||
text-shadow: 0 0 20px rgba(79, 195, 247, 0.5);
|
||||
}
|
||||
|
||||
/* Map */
|
||||
.map-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 10px;
|
||||
background: rgba(10, 22, 40, 0.6);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.map-svg {
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.cardinal {
|
||||
fill: var(--accent-cyan);
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
text-shadow: 0 0 10px rgba(79, 195, 247, 0.8);
|
||||
}
|
||||
|
||||
.degree-label {
|
||||
fill: rgba(79, 195, 247, 0.7);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Go To Heading */
|
||||
.goto-container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.heading-input {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
padding: 10px 12px;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.heading-input:focus {
|
||||
border-color: var(--accent-cyan);
|
||||
box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
|
||||
}
|
||||
|
||||
.go-btn {
|
||||
padding: 10px 24px;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: linear-gradient(135deg, var(--accent-cyan), #0288d1);
|
||||
color: #000;
|
||||
transition: all 0.2s;
|
||||
box-shadow: 0 4px 12px rgba(79, 195, 247, 0.4);
|
||||
}
|
||||
|
||||
.go-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 16px rgba(79, 195, 247, 0.5);
|
||||
}
|
||||
|
||||
/* Controls */
|
||||
.controls {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.control-btn {
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
transition: all 0.2s;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.control-btn:hover {
|
||||
border-color: var(--accent-cyan);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.control-btn.stop {
|
||||
background: linear-gradient(135deg, #f44336, #d32f2f);
|
||||
border-color: #f44336;
|
||||
color: white;
|
||||
box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
|
||||
}
|
||||
|
||||
.control-btn.stop:hover {
|
||||
box-shadow: 0 6px 16px rgba(244, 67, 54, 0.5);
|
||||
}
|
||||
|
||||
.arrow {
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
}
|
||||
</style>
|
||||
477
web/src/components/TunerGenius.svelte
Normal file
477
web/src/components/TunerGenius.svelte
Normal file
@@ -0,0 +1,477 @@
|
||||
<script>
|
||||
import { api } from '../lib/api.js';
|
||||
|
||||
export let status;
|
||||
|
||||
$: powerForward = status?.power_forward || 0;
|
||||
$: swr = status?.swr || 1.0;
|
||||
$: tuningStatus = status?.tuning_status || 'READY';
|
||||
$: frequencyA = status?.frequency_a || 0;
|
||||
$: frequencyB = status?.frequency_b || 0;
|
||||
$: bypass = status?.bypass || false;
|
||||
$: state = status?.state || 0;
|
||||
$: relayC1 = status?.c1 || 0;
|
||||
$: relayL = status?.l || 0;
|
||||
$: relayC2 = status?.c2 || 0;
|
||||
$: connected = status?.connected || false;
|
||||
|
||||
// Color functions
|
||||
$: swrColor = swr < 1.5 ? '#4caf50' : swr < 2.0 ? '#ffc107' : swr < 3.0 ? '#ff9800' : '#f44336';
|
||||
$: powerPercent = Math.min((powerForward / 2000) * 100, 100);
|
||||
|
||||
async function autoTune() {
|
||||
try {
|
||||
await api.tuner.autoTune();
|
||||
} catch (err) {
|
||||
console.error('Failed to tune:', err);
|
||||
alert('Failed to start tuning');
|
||||
}
|
||||
}
|
||||
|
||||
async function setBypass(value) {
|
||||
try {
|
||||
await api.tuner.setBypass(value);
|
||||
} catch (err) {
|
||||
console.error('Failed to set bypass:', err);
|
||||
alert('Failed to set bypass');
|
||||
}
|
||||
}
|
||||
|
||||
async function setOperate(value) {
|
||||
try {
|
||||
await api.tuner.setOperate(value);
|
||||
} catch (err) {
|
||||
console.error('Failed to set operate:', err);
|
||||
alert('Failed to set operate');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Tuner Genius XL</h2>
|
||||
<div class="header-right">
|
||||
<span class="tuning-badge" class:tuning={tuningStatus === 'TUNING'}>{tuningStatus}</span>
|
||||
<span class="status-dot" class:disconnected={!connected}></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="metrics">
|
||||
<!-- Power Display -->
|
||||
<div class="power-display">
|
||||
<div class="power-main">
|
||||
<div class="power-value">{powerForward.toFixed(0)}<span class="unit">W</span></div>
|
||||
<div class="power-label">Forward Power</div>
|
||||
</div>
|
||||
<div class="power-bar">
|
||||
<div class="power-bar-fill" style="width: {powerPercent}%">
|
||||
<div class="power-bar-glow"></div>
|
||||
</div>
|
||||
<div class="power-scale">
|
||||
<span>0</span>
|
||||
<span>1000</span>
|
||||
<span>2000</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SWR Circle -->
|
||||
<div class="swr-container">
|
||||
<div class="swr-circle" style="--swr-color: {swrColor}">
|
||||
<div class="swr-value">{swr.toFixed(2)}</div>
|
||||
<div class="swr-label">SWR</div>
|
||||
</div>
|
||||
<div class="swr-status">
|
||||
{#if swr < 1.5}
|
||||
<span class="status-text good">Excellent</span>
|
||||
{:else if swr < 2.0}
|
||||
<span class="status-text ok">Good</span>
|
||||
{:else if swr < 3.0}
|
||||
<span class="status-text warning">Caution</span>
|
||||
{:else}
|
||||
<span class="status-text danger">High!</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tuning Capacitors -->
|
||||
<div class="capacitors">
|
||||
<div class="cap-item">
|
||||
<div class="cap-value">{relayC1}</div>
|
||||
<div class="cap-label">C1</div>
|
||||
</div>
|
||||
<div class="cap-item">
|
||||
<div class="cap-value">{relayL}</div>
|
||||
<div class="cap-label">L</div>
|
||||
</div>
|
||||
<div class="cap-item">
|
||||
<div class="cap-value">{relayC2}</div>
|
||||
<div class="cap-label">C2</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Frequencies -->
|
||||
<div class="freq-display">
|
||||
<div class="freq-item">
|
||||
<div class="freq-label">Freq A</div>
|
||||
<div class="freq-value">{(frequencyA / 1000).toFixed(3)}<span class="freq-unit">MHz</span></div>
|
||||
</div>
|
||||
<div class="freq-item">
|
||||
<div class="freq-label">Freq B</div>
|
||||
<div class="freq-value">{(frequencyB / 1000).toFixed(3)}<span class="freq-unit">MHz</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Control Buttons -->
|
||||
<div class="controls">
|
||||
<button
|
||||
class="control-btn operate"
|
||||
class:active={state === 1}
|
||||
on:click={() => setOperate(state === 1 ? 0 : 1)}
|
||||
>
|
||||
{state === 1 ? 'OPERATE' : 'STANDBY'}
|
||||
</button>
|
||||
<button
|
||||
class="control-btn bypass"
|
||||
class:active={bypass}
|
||||
on:click={() => setBypass(bypass ? 0 : 1)}
|
||||
>
|
||||
BYPASS
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button class="tune-btn" on:click={autoTune}>
|
||||
<span class="tune-icon">⚡</span>
|
||||
AUTO TUNE
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 16px;
|
||||
background: rgba(79, 195, 247, 0.05);
|
||||
border-bottom: 1px solid #2d3748;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-cyan);
|
||||
margin: 0;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.tuning-badge {
|
||||
padding: 4px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
background: rgba(76, 175, 80, 0.2);
|
||||
color: #4caf50;
|
||||
}
|
||||
|
||||
.tuning-badge.tuning {
|
||||
background: rgba(255, 152, 0, 0.2);
|
||||
color: #ff9800;
|
||||
animation: pulse 1s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.7; }
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #4caf50;
|
||||
box-shadow: 0 0 8px #4caf50;
|
||||
}
|
||||
|
||||
.status-dot.disconnected {
|
||||
background: #f44336;
|
||||
box-shadow: 0 0 8px #f44336;
|
||||
}
|
||||
|
||||
.metrics {
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
/* Power Display */
|
||||
.power-display {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.power-main {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.power-value {
|
||||
font-size: 48px;
|
||||
font-weight: 200;
|
||||
color: var(--accent-cyan);
|
||||
line-height: 1;
|
||||
text-shadow: 0 0 20px rgba(79, 195, 247, 0.5);
|
||||
}
|
||||
|
||||
.power-value .unit {
|
||||
font-size: 24px;
|
||||
color: var(--text-secondary);
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.power-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.power-bar {
|
||||
position: relative;
|
||||
height: 8px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.power-bar-fill {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #4caf50, #ffc107, #ff9800, #f44336);
|
||||
border-radius: 4px;
|
||||
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%); }
|
||||
}
|
||||
|
||||
.power-scale {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 9px;
|
||||
color: var(--text-muted);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* SWR Circle */
|
||||
.swr-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.swr-circle {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(circle, rgba(79, 195, 247, 0.1), transparent);
|
||||
border: 3px solid var(--swr-color);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 0 20px var(--swr-color);
|
||||
}
|
||||
|
||||
.swr-value {
|
||||
font-size: 24px;
|
||||
font-weight: 300;
|
||||
color: var(--swr-color);
|
||||
}
|
||||
|
||||
.swr-label {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.swr-status {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.status-text.good { color: #4caf50; }
|
||||
.status-text.ok { color: #ffc107; }
|
||||
.status-text.warning { color: #ff9800; }
|
||||
.status-text.danger { color: #f44336; }
|
||||
|
||||
/* Capacitors */
|
||||
.capacitors {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
background: rgba(79, 195, 247, 0.05);
|
||||
border-radius: 6px;
|
||||
border: 1px solid rgba(79, 195, 247, 0.2);
|
||||
}
|
||||
|
||||
.cap-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.cap-value {
|
||||
font-size: 32px;
|
||||
font-weight: 300;
|
||||
color: var(--accent-cyan);
|
||||
text-shadow: 0 0 15px rgba(79, 195, 247, 0.5);
|
||||
}
|
||||
|
||||
.cap-label {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
/* Frequencies */
|
||||
.freq-display {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.freq-item {
|
||||
padding: 10px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.freq-label {
|
||||
font-size: 9px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.freq-value {
|
||||
font-size: 16px;
|
||||
font-weight: 300;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.freq-unit {
|
||||
font-size: 11px;
|
||||
color: var(--text-secondary);
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
/* Controls */
|
||||
.controls {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.control-btn {
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--border-color);
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.control-btn:hover {
|
||||
border-color: var(--accent-cyan);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.control-btn.active {
|
||||
background: var(--accent-cyan);
|
||||
border-color: var(--accent-cyan);
|
||||
color: #000;
|
||||
box-shadow: 0 0 15px rgba(79, 195, 247, 0.5);
|
||||
}
|
||||
|
||||
.tune-btn {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: linear-gradient(135deg, #f44336, #d32f2f);
|
||||
color: white;
|
||||
transition: all 0.2s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
|
||||
}
|
||||
|
||||
.tune-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 16px rgba(244, 67, 54, 0.5);
|
||||
}
|
||||
|
||||
.tune-btn:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.tune-icon {
|
||||
font-size: 18px;
|
||||
}
|
||||
</style>
|
||||
305
web/src/components/WebSwitch.svelte
Normal file
305
web/src/components/WebSwitch.svelte
Normal file
@@ -0,0 +1,305 @@
|
||||
<script>
|
||||
import { api } from '../lib/api.js';
|
||||
|
||||
export let status;
|
||||
|
||||
$: relays = status?.relays || [];
|
||||
$: connected = status?.connected || false;
|
||||
|
||||
const relayNames = {
|
||||
1: 'Power Supply',
|
||||
2: 'PGXL',
|
||||
3: 'TGXL',
|
||||
4: 'Flex Radio Start',
|
||||
5: 'Reserve'
|
||||
};
|
||||
|
||||
let loading = {};
|
||||
|
||||
async function toggleRelay(relayNum) {
|
||||
const relay = relays.find(r => r.number === relayNum);
|
||||
const currentState = relay?.state || false;
|
||||
|
||||
loading[relayNum] = true;
|
||||
try {
|
||||
if (currentState) {
|
||||
await api.webswitch.relayOff(relayNum);
|
||||
} else {
|
||||
await api.webswitch.relayOn(relayNum);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to toggle relay:', err);
|
||||
alert('Failed to control relay');
|
||||
} finally {
|
||||
loading[relayNum] = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function allOn() {
|
||||
try {
|
||||
await api.webswitch.allOn();
|
||||
} catch (err) {
|
||||
console.error('Failed to turn all on:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function allOff() {
|
||||
try {
|
||||
await api.webswitch.allOff();
|
||||
} catch (err) {
|
||||
console.error('Failed to turn all off:', err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>WebSwitch</h2>
|
||||
<span class="status-dot" class:disconnected={!connected}></span>
|
||||
</div>
|
||||
|
||||
<div class="metrics">
|
||||
<div class="relays">
|
||||
{#each [1, 2, 3, 4, 5] as relayNum}
|
||||
{@const relay = relays.find(r => r.number === relayNum)}
|
||||
{@const isOn = relay?.state || false}
|
||||
<div class="relay-card" class:relay-on={isOn}>
|
||||
<div class="relay-info">
|
||||
<div class="relay-details">
|
||||
<div class="relay-name">{relayNames[relayNum]}</div>
|
||||
<div class="relay-status">{isOn ? 'ON' : 'OFF'}</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="relay-toggle"
|
||||
class:active={isOn}
|
||||
class:loading={loading[relayNum]}
|
||||
disabled={loading[relayNum]}
|
||||
on:click={() => toggleRelay(relayNum)}
|
||||
>
|
||||
<div class="toggle-track">
|
||||
<div class="toggle-thumb"></div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<button class="control-btn all-on" on:click={allOn}>
|
||||
<span class="btn-icon">⚡</span>
|
||||
ALL ON
|
||||
</button>
|
||||
<button class="control-btn all-off" on:click={allOff}>
|
||||
<span class="btn-icon">⏻</span>
|
||||
ALL OFF
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
background: linear-gradient(135deg, #1a2332 0%, #0f1923 100%);
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 16px;
|
||||
background: rgba(79, 195, 247, 0.05);
|
||||
border-bottom: 1px solid #2d3748;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--accent-cyan);
|
||||
margin: 0;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #4caf50;
|
||||
box-shadow: 0 0 8px #4caf50;
|
||||
}
|
||||
|
||||
.status-dot.disconnected {
|
||||
background: #f44336;
|
||||
box-shadow: 0 0 8px #f44336;
|
||||
}
|
||||
|
||||
.metrics {
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* Relays */
|
||||
.relays {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.relay-card {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--border-color);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.relay-card.relay-on {
|
||||
background: rgba(76, 175, 80, 0.1);
|
||||
border-color: rgba(76, 175, 80, 0.3);
|
||||
box-shadow: 0 0 15px rgba(76, 175, 80, 0.2);
|
||||
}
|
||||
|
||||
.relay-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.relay-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.relay-name {
|
||||
font-size: 12px;
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.relay-status {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.relay-card.relay-on .relay-status {
|
||||
color: #4caf50;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Toggle Switch */
|
||||
.relay-toggle {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toggle-track {
|
||||
width: 52px;
|
||||
height: 28px;
|
||||
background: var(--bg-primary);
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 14px;
|
||||
position: relative;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.relay-toggle:hover .toggle-track {
|
||||
border-color: var(--accent-cyan);
|
||||
}
|
||||
|
||||
.relay-toggle.active .toggle-track {
|
||||
background: linear-gradient(135deg, #4caf50, #66bb6a);
|
||||
border-color: #4caf50;
|
||||
box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
|
||||
}
|
||||
|
||||
.toggle-thumb {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: white;
|
||||
border-radius: 50%;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 2px;
|
||||
transition: all 0.3s;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.relay-toggle.active .toggle-thumb {
|
||||
transform: translateX(24px);
|
||||
}
|
||||
|
||||
.relay-toggle:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* Controls */
|
||||
.controls {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.control-btn {
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
transition: all 0.2s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.control-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.control-btn:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.all-on {
|
||||
background: linear-gradient(135deg, #4caf50, #66bb6a);
|
||||
color: white;
|
||||
box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
|
||||
}
|
||||
|
||||
.all-on:hover {
|
||||
box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
|
||||
}
|
||||
|
||||
.all-off {
|
||||
background: linear-gradient(135deg, #f44336, #d32f2f);
|
||||
color: white;
|
||||
box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
|
||||
}
|
||||
|
||||
.all-off:hover {
|
||||
box-shadow: 0 6px 16px rgba(244, 67, 54, 0.5);
|
||||
}
|
||||
</style>
|
||||
92
web/src/lib/api.js
Normal file
92
web/src/lib/api.js
Normal file
@@ -0,0 +1,92 @@
|
||||
const API_BASE = '/api';
|
||||
|
||||
async function request(endpoint, options = {}) {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}${endpoint}`, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('API request failed:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export const api = {
|
||||
// Status
|
||||
getStatus: () => request('/status'),
|
||||
getConfig: () => request('/config'),
|
||||
|
||||
// WebSwitch
|
||||
webswitch: {
|
||||
relayOn: (relay) => request(`/webswitch/relay/on?relay=${relay}`, { method: 'POST' }),
|
||||
relayOff: (relay) => request(`/webswitch/relay/off?relay=${relay}`, { method: 'POST' }),
|
||||
allOn: () => request('/webswitch/all/on', { method: 'POST' }),
|
||||
allOff: () => request('/webswitch/all/off', { method: 'POST' }),
|
||||
},
|
||||
|
||||
// Rotator
|
||||
rotator: {
|
||||
move: (rotator, azimuth) => request('/rotator/move', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ rotator, azimuth }),
|
||||
}),
|
||||
cw: (rotator) => request(`/rotator/cw?rotator=${rotator}`, { method: 'POST' }),
|
||||
ccw: (rotator) => request(`/rotator/ccw?rotator=${rotator}`, { method: 'POST' }),
|
||||
stop: () => request('/rotator/stop', { method: 'POST' }),
|
||||
},
|
||||
|
||||
// Tuner
|
||||
tuner: {
|
||||
setOperate: (value) => request('/tuner/operate', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ value }),
|
||||
}),
|
||||
setBypass: (value) => request('/tuner/bypass', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ value }),
|
||||
}),
|
||||
autoTune: () => request('/tuner/autotune', { method: 'POST' }),
|
||||
},
|
||||
|
||||
// Antenna Genius
|
||||
antenna: {
|
||||
selectAntenna: (port, antenna) => request('/antenna/select', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ port, antenna }),
|
||||
}),
|
||||
reboot: () => request('/antenna/reboot', { method: 'POST' }),
|
||||
},
|
||||
|
||||
// Power Genius
|
||||
power: {
|
||||
setFanMode: (mode) => request('/power/fanmode', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ mode }),
|
||||
}),
|
||||
setOperate: (value) => request('/power/operate', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ value }),
|
||||
}),
|
||||
},
|
||||
|
||||
// Rotator Genius
|
||||
rotator: {
|
||||
setHeading: (heading) => request('/rotator/heading', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ heading }),
|
||||
}),
|
||||
rotateCW: () => request('/rotator/cw', { method: 'POST' }),
|
||||
rotateCCW: () => request('/rotator/ccw', { method: 'POST' }),
|
||||
stop: () => request('/rotator/stop', { method: 'POST' }),
|
||||
},
|
||||
};
|
||||
82
web/src/lib/websocket.js
Normal file
82
web/src/lib/websocket.js
Normal file
@@ -0,0 +1,82 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const connected = writable(false);
|
||||
export const systemStatus = writable(null);
|
||||
export const lastUpdate = writable(null);
|
||||
|
||||
class WebSocketService {
|
||||
constructor() {
|
||||
this.ws = null;
|
||||
this.reconnectTimeout = null;
|
||||
this.reconnectDelay = 3000;
|
||||
}
|
||||
|
||||
connect() {
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const wsUrl = `${protocol}//${window.location.host}/ws`;
|
||||
|
||||
try {
|
||||
this.ws = new WebSocket(wsUrl);
|
||||
|
||||
this.ws.onopen = () => {
|
||||
console.log('WebSocket connected');
|
||||
connected.set(true);
|
||||
};
|
||||
|
||||
this.ws.onmessage = (event) => {
|
||||
try {
|
||||
const message = JSON.parse(event.data);
|
||||
|
||||
if (message.type === 'update') {
|
||||
console.log('System status updated:', message.data);
|
||||
systemStatus.set(message.data);
|
||||
lastUpdate.set(new Date(message.timestamp));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error parsing message:', err);
|
||||
}
|
||||
};
|
||||
|
||||
this.ws.onerror = (error) => {
|
||||
console.error('WebSocket error:', error);
|
||||
};
|
||||
|
||||
this.ws.onclose = () => {
|
||||
console.log('WebSocket disconnected');
|
||||
connected.set(false);
|
||||
this.scheduleReconnect();
|
||||
};
|
||||
} catch (err) {
|
||||
console.error('Error creating WebSocket:', err);
|
||||
this.scheduleReconnect();
|
||||
}
|
||||
}
|
||||
|
||||
scheduleReconnect() {
|
||||
if (this.reconnectTimeout) {
|
||||
clearTimeout(this.reconnectTimeout);
|
||||
}
|
||||
|
||||
this.reconnectTimeout = setTimeout(() => {
|
||||
console.log('Attempting to reconnect...');
|
||||
this.connect();
|
||||
}, this.reconnectDelay);
|
||||
}
|
||||
|
||||
send(message) {
|
||||
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
||||
this.ws.send(JSON.stringify(message));
|
||||
}
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
if (this.reconnectTimeout) {
|
||||
clearTimeout(this.reconnectTimeout);
|
||||
}
|
||||
if (this.ws) {
|
||||
this.ws.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const wsService = new WebSocketService();
|
||||
8
web/src/main.js
Normal file
8
web/src/main.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import App from './App.svelte'
|
||||
import './app.css'
|
||||
|
||||
const app = new App({
|
||||
target: document.getElementById('app')
|
||||
})
|
||||
|
||||
export default app
|
||||
1
web/svelte.config.js
Normal file
1
web/svelte.config.js
Normal file
@@ -0,0 +1 @@
|
||||
export default {}
|
||||
19
web/vite.config.js
Normal file
19
web/vite.config.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [svelte()],
|
||||
build: {
|
||||
outDir: 'dist'
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: {
|
||||
'/api': 'http://localhost:8081',
|
||||
'/ws': {
|
||||
target: 'ws://localhost:8081',
|
||||
ws: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user