up
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 - XV9Q 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>
|
||||
128
web/src/app.css
Normal file
128
web/src/app.css
Normal file
@@ -0,0 +1,128 @@
|
||||
:root {
|
||||
--bg-primary: #1a1a1a;
|
||||
--bg-secondary: #2a2a2a;
|
||||
--bg-card: #333333;
|
||||
--text-primary: #ffffff;
|
||||
--text-secondary: #b0b0b0;
|
||||
--accent-teal: #00bcd4;
|
||||
--accent-green: #4caf50;
|
||||
--accent-red: #f44336;
|
||||
--accent-blue: #2196f3;
|
||||
--border-color: #444444;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
background-color: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
#app {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
button {
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
outline: none;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
button:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
input, select {
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.status-indicator {
|
||||
display: inline-block;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.status-online {
|
||||
background-color: var(--accent-green);
|
||||
box-shadow: 0 0 8px var(--accent-green);
|
||||
}
|
||||
|
||||
.status-offline {
|
||||
background-color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 12px 24px;
|
||||
border-radius: 6px;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--accent-green);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #45a049;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: var(--accent-red);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #da190b;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: var(--bg-card);
|
||||
}
|
||||
|
||||
.value-display {
|
||||
font-size: 24px;
|
||||
font-weight: 300;
|
||||
color: var(--accent-teal);
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
129
web/src/components/AntennaGenius.svelte
Normal file
129
web/src/components/AntennaGenius.svelte
Normal file
@@ -0,0 +1,129 @@
|
||||
<script>
|
||||
import { api } from '../lib/api.js';
|
||||
|
||||
export let status;
|
||||
|
||||
$: radio1Antenna = status?.radio1_antenna || 0;
|
||||
$: radio2Antenna = status?.radio2_antenna || 0;
|
||||
$: connected = status?.connected || false;
|
||||
|
||||
async function setRadioAntenna(radio, antenna) {
|
||||
try {
|
||||
await api.antenna.set(radio, antenna);
|
||||
} catch (err) {
|
||||
console.error('Failed to set antenna:', err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="antenna-card card">
|
||||
<h2>
|
||||
AG 8X2
|
||||
<span class="status-indicator" class:status-online={connected} class:status-offline={!connected}></span>
|
||||
</h2>
|
||||
|
||||
<div class="radio-section">
|
||||
<div class="radio-label">Radio 1 / Radio 2</div>
|
||||
|
||||
<div class="radio-grid">
|
||||
<div class="radio-column">
|
||||
<div class="radio-title">Radio 1</div>
|
||||
<div class="antenna-slots">
|
||||
{#each Array(4) as _, i}
|
||||
<button
|
||||
class="slot"
|
||||
class:active={radio1Antenna === i}
|
||||
on:click={() => setRadioAntenna(1, i)}
|
||||
>
|
||||
{i + 1}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="radio-column">
|
||||
<div class="radio-title">Radio 2</div>
|
||||
<div class="antenna-slots">
|
||||
{#each Array(4) as _, i}
|
||||
<button
|
||||
class="slot"
|
||||
class:active={radio2Antenna === i}
|
||||
on:click={() => setRadioAntenna(2, i)}
|
||||
>
|
||||
{i + 1}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.antenna-card {
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
color: var(--accent-teal);
|
||||
}
|
||||
|
||||
.radio-section {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.radio-label {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.radio-grid {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.radio-column {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.radio-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.antenna-slots {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.slot {
|
||||
padding: 16px;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.slot:hover {
|
||||
border-color: var(--accent-blue);
|
||||
}
|
||||
|
||||
.slot.active {
|
||||
background: var(--accent-blue);
|
||||
border-color: var(--accent-blue);
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
209
web/src/components/PowerGenius.svelte
Normal file
209
web/src/components/PowerGenius.svelte
Normal file
@@ -0,0 +1,209 @@
|
||||
<script>
|
||||
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');
|
||||
$: meffa = status?.meffa || 'STANDBY';
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="powergenius-card card">
|
||||
<h2>
|
||||
PGXL
|
||||
<span class="status-indicator" class:status-online={connected} class:status-offline={!connected}></span>
|
||||
</h2>
|
||||
|
||||
<div class="status-row">
|
||||
<div class="status-label" class:normal={state === 'IDLE'} class:warning={state.includes('TRANSMIT')}>
|
||||
{displayState}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="metrics">
|
||||
<div class="metric">
|
||||
<div class="label">FWD PWR (W)</div>
|
||||
<div class="value">{powerForward.toFixed(1)}</div>
|
||||
<div class="bar">
|
||||
<div class="bar-fill" style="width: {Math.min(100, (powerForward / 1500) * 100)}%"></div>
|
||||
</div>
|
||||
<div class="scale">
|
||||
<span>0</span>
|
||||
<span>1000</span>
|
||||
<span>2000</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="metric">
|
||||
<div class="label">PG XL SWR 1:1.00 use</div>
|
||||
<div class="value">{swr.toFixed(2)}</div>
|
||||
</div>
|
||||
|
||||
<div class="metric">
|
||||
<div class="label">Temp / HL Temp</div>
|
||||
<div class="value">{temperature.toFixed(0)}°C / {harmonicLoadTemp.toFixed(1)}°C</div>
|
||||
<div class="bar">
|
||||
<div class="bar-fill" style="width: {(temperature / 80) * 100}%"></div>
|
||||
</div>
|
||||
<div class="scale">
|
||||
<span>25</span>
|
||||
<span>55</span>
|
||||
<span>80</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="metric-row">
|
||||
<div class="metric small">
|
||||
<div class="label">VAC</div>
|
||||
<div class="value">{voltage.toFixed(0)}</div>
|
||||
</div>
|
||||
<div class="metric small">
|
||||
<div class="label">VDD</div>
|
||||
<div class="value">{vdd.toFixed(1)}</div>
|
||||
</div>
|
||||
<div class="metric small">
|
||||
<div class="label">ID peak</div>
|
||||
<div class="value">{peakCurrent.toFixed(1)}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fan-speed">
|
||||
<div class="label">Fan Speed</div>
|
||||
<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 class="band-info">
|
||||
<div class="label">Band A</div>
|
||||
<div class="value">{bandA}</div>
|
||||
</div>
|
||||
<div class="band-info">
|
||||
<div class="label">Band B</div>
|
||||
<div class="value">{bandB}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
.powergenius-card {
|
||||
min-width: 350px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
color: var(--accent-teal);
|
||||
}
|
||||
|
||||
.status-label {
|
||||
display: inline-block;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.status-label.normal {
|
||||
background: var(--accent-green);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.status-label.warning {
|
||||
background: var(--accent-red);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.metric {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.metric-row {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.metric.small {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.value {
|
||||
font-size: 20px;
|
||||
font-weight: 300;
|
||||
color: var(--accent-teal);
|
||||
}
|
||||
|
||||
.bar {
|
||||
width: 100%;
|
||||
height: 8px;
|
||||
background: #555;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bar-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, var(--accent-green), var(--accent-red));
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.scale {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 10px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.fan-speed select {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.band-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
334
web/src/components/RotatorGenius.svelte
Normal file
334
web/src/components/RotatorGenius.svelte
Normal file
@@ -0,0 +1,334 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { api } from '../lib/api.js';
|
||||
|
||||
export let status;
|
||||
|
||||
$: rotator1 = status?.rotator1 || {};
|
||||
$: rotator2 = status?.rotator2 || {};
|
||||
$: currentHeading = rotator1.current_azimuth || 0;
|
||||
$: targetHeading = rotator1.target_azimuth || 0;
|
||||
$: moving = rotator1.moving || 0;
|
||||
$: connected = rotator1.connected || false;
|
||||
|
||||
let targetInput = currentHeading;
|
||||
let canvas;
|
||||
let ctx;
|
||||
|
||||
onMount(() => {
|
||||
if (canvas) {
|
||||
ctx = canvas.getContext('2d');
|
||||
drawGlobe();
|
||||
}
|
||||
});
|
||||
|
||||
$: if (ctx && currentHeading !== undefined) {
|
||||
drawGlobe();
|
||||
}
|
||||
|
||||
function drawGlobe() {
|
||||
if (!ctx) return;
|
||||
|
||||
const width = canvas.width;
|
||||
const height = canvas.height;
|
||||
const centerX = width / 2;
|
||||
const centerY = height / 2;
|
||||
const radius = Math.min(width, height) / 2 - 20;
|
||||
|
||||
// Clear canvas
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
|
||||
// Draw globe circle
|
||||
ctx.beginPath();
|
||||
ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI);
|
||||
ctx.strokeStyle = '#444';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.stroke();
|
||||
|
||||
// Draw grid lines (latitude/longitude)
|
||||
ctx.strokeStyle = '#333';
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
// Latitude lines
|
||||
for (let i = 1; i < 4; i++) {
|
||||
const y = centerY - radius + (radius * 2 * i / 4);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(centerX - radius, y);
|
||||
ctx.lineTo(centerX + radius, y);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// Longitude lines
|
||||
for (let i = 1; i < 4; i++) {
|
||||
const x = centerX - radius + (radius * 2 * i / 4);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, centerY - radius);
|
||||
ctx.lineTo(x, centerY + radius);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// Draw cardinal directions
|
||||
ctx.fillStyle = '#888';
|
||||
ctx.font = '14px Roboto';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
|
||||
ctx.fillText('N', centerX, centerY - radius - 10);
|
||||
ctx.fillText('S', centerX, centerY + radius + 10);
|
||||
ctx.fillText('E', centerX + radius + 10, centerY);
|
||||
ctx.fillText('W', centerX - radius - 10, centerY);
|
||||
|
||||
// Draw heading indicator
|
||||
const angle = (currentHeading - 90) * Math.PI / 180;
|
||||
const lineLength = radius - 10;
|
||||
const endX = centerX + Math.cos(angle) * lineLength;
|
||||
const endY = centerY + Math.sin(angle) * lineLength;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(centerX, centerY);
|
||||
ctx.lineTo(endX, endY);
|
||||
ctx.strokeStyle = '#00bcd4';
|
||||
ctx.lineWidth = 3;
|
||||
ctx.stroke();
|
||||
|
||||
// Draw arrow head
|
||||
const arrowSize = 15;
|
||||
const arrowAngle1 = angle + Math.PI * 0.85;
|
||||
const arrowAngle2 = angle - Math.PI * 0.85;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(endX, endY);
|
||||
ctx.lineTo(endX + Math.cos(arrowAngle1) * arrowSize, endY + Math.sin(arrowAngle1) * arrowSize);
|
||||
ctx.moveTo(endX, endY);
|
||||
ctx.lineTo(endX + Math.cos(arrowAngle2) * arrowSize, endY + Math.sin(arrowAngle2) * arrowSize);
|
||||
ctx.strokeStyle = '#00bcd4';
|
||||
ctx.lineWidth = 3;
|
||||
ctx.stroke();
|
||||
|
||||
// Draw center dot
|
||||
ctx.beginPath();
|
||||
ctx.arc(centerX, centerY, 5, 0, 2 * Math.PI);
|
||||
ctx.fillStyle = '#f44336';
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
async function moveToHeading() {
|
||||
const heading = parseInt(targetInput);
|
||||
if (isNaN(heading) || heading < 0 || heading > 360) {
|
||||
alert('Please enter a valid heading (0-360)');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await api.rotator.move(1, heading);
|
||||
} catch (err) {
|
||||
console.error('Failed to move rotator:', err);
|
||||
alert('Failed to move rotator');
|
||||
}
|
||||
}
|
||||
|
||||
async function rotateCW() {
|
||||
try {
|
||||
await api.rotator.cw(1);
|
||||
} catch (err) {
|
||||
console.error('Failed to rotate CW:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function rotateCCW() {
|
||||
try {
|
||||
await api.rotator.ccw(1);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
// Preset directions
|
||||
const presets = [
|
||||
{ name: 'EU-0', heading: 0 },
|
||||
{ name: 'JA-35', heading: 35 },
|
||||
{ name: 'AS-75', heading: 75 },
|
||||
{ name: 'VK-120', heading: 120 },
|
||||
{ name: 'AF-180', heading: 180 },
|
||||
{ name: 'SA-230', heading: 230 },
|
||||
{ name: 'WI-270', heading: 270 },
|
||||
{ name: 'NA-300', heading: 300 }
|
||||
];
|
||||
|
||||
async function gotoPreset(heading) {
|
||||
try {
|
||||
await api.rotator.move(1, heading);
|
||||
} catch (err) {
|
||||
console.error('Failed to move to preset:', err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="rotator-card card">
|
||||
<h2>
|
||||
ROTATOR GENIUS
|
||||
<span class="status-indicator" class:status-online={connected} class:status-offline={!connected}></span>
|
||||
</h2>
|
||||
|
||||
<div class="heading-display">
|
||||
CURRENT HEADING: <span class="heading-value">{currentHeading}°</span>
|
||||
</div>
|
||||
|
||||
{#if moving > 0}
|
||||
<div class="moving-indicator">
|
||||
{moving === 1 ? '↻ ROTATING CW' : '↺ ROTATING CCW'}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<canvas bind:this={canvas} width="300" height="300"></canvas>
|
||||
|
||||
<div class="controls">
|
||||
<div class="heading-input">
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="360"
|
||||
bind:value={targetInput}
|
||||
placeholder="Enter heading"
|
||||
/>
|
||||
<button class="btn btn-primary" on:click={moveToHeading}>GO</button>
|
||||
</div>
|
||||
|
||||
<div class="rotation-controls">
|
||||
<button class="btn btn-secondary" on:click={rotateCCW}>↺ CCW</button>
|
||||
<button class="btn btn-danger" on:click={stop}>STOP</button>
|
||||
<button class="btn btn-secondary" on:click={rotateCW}>CW ↻</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="presets">
|
||||
{#each presets as preset}
|
||||
<button
|
||||
class="preset-btn"
|
||||
class:active={Math.abs(currentHeading - preset.heading) < 5}
|
||||
on:click={() => gotoPreset(preset.heading)}
|
||||
>
|
||||
{preset.name}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.rotator-card {
|
||||
min-width: 350px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
color: var(--accent-teal);
|
||||
}
|
||||
|
||||
.heading-display {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
margin-bottom: 8px;
|
||||
padding: 12px;
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.heading-value {
|
||||
color: var(--accent-blue);
|
||||
font-size: 24px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.moving-indicator {
|
||||
text-align: center;
|
||||
padding: 8px;
|
||||
background: var(--accent-green);
|
||||
color: white;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 12px;
|
||||
font-weight: 500;
|
||||
animation: pulse 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.7; }
|
||||
}
|
||||
|
||||
canvas {
|
||||
display: block;
|
||||
margin: 16px auto;
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.heading-input {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.heading-input input {
|
||||
flex: 1;
|
||||
padding: 12px;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.rotation-controls {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.rotation-controls button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.presets {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.preset-btn {
|
||||
padding: 12px 8px;
|
||||
background: var(--accent-blue);
|
||||
color: white;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.preset-btn:hover {
|
||||
background: #1976d2;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.preset-btn.active {
|
||||
background: var(--accent-green);
|
||||
}
|
||||
</style>
|
||||
257
web/src/components/TunerGenius.svelte
Normal file
257
web/src/components/TunerGenius.svelte
Normal file
@@ -0,0 +1,257 @@
|
||||
<script>
|
||||
import { api } from '../lib/api.js';
|
||||
|
||||
export let status;
|
||||
|
||||
$: operate = status?.operate || false;
|
||||
$: activeAntenna = status?.active_antenna || 0;
|
||||
$: tuningStatus = status?.tuning_status || 'READY';
|
||||
$: frequencyA = status?.frequency_a || 0;
|
||||
$: frequencyB = status?.frequency_b || 0;
|
||||
$: c1 = status?.c1 || 0;
|
||||
$: l = status?.l || 0;
|
||||
$: c2 = status?.c2 || 0;
|
||||
$: connected = status?.connected || false;
|
||||
|
||||
let tuning = false;
|
||||
|
||||
async function toggleOperate() {
|
||||
try {
|
||||
await api.tuner.operate(!operate);
|
||||
} catch (err) {
|
||||
console.error('Failed to toggle operate:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function startTune() {
|
||||
tuning = true;
|
||||
try {
|
||||
await api.tuner.tune();
|
||||
} catch (err) {
|
||||
console.error('Failed to tune:', err);
|
||||
alert('Tuning failed');
|
||||
} finally {
|
||||
tuning = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function setAntenna(ant) {
|
||||
try {
|
||||
await api.tuner.antenna(ant);
|
||||
} catch (err) {
|
||||
console.error('Failed to set antenna:', err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="tuner-card card">
|
||||
<h2>
|
||||
TGXL
|
||||
<span class="status-indicator" class:status-online={connected} class:status-offline={!connected}></span>
|
||||
</h2>
|
||||
|
||||
<div class="power-status">
|
||||
<div class="label">Power 0.0w</div>
|
||||
<div class="status-badge">1500</div>
|
||||
<div class="status-badge">1650</div>
|
||||
</div>
|
||||
|
||||
<div class="tuning-controls">
|
||||
<div class="tuning-row">
|
||||
<div class="tuning-label">TG XL SWR 1.00 use</div>
|
||||
</div>
|
||||
|
||||
<div class="antenna-buttons">
|
||||
<button
|
||||
class="antenna-btn"
|
||||
class:active={activeAntenna === 0}
|
||||
on:click={() => setAntenna(0)}
|
||||
>
|
||||
C1
|
||||
</button>
|
||||
<button
|
||||
class="antenna-btn"
|
||||
class:active={activeAntenna === 1}
|
||||
on:click={() => setAntenna(1)}
|
||||
>
|
||||
L
|
||||
</button>
|
||||
<button
|
||||
class="antenna-btn"
|
||||
class:active={activeAntenna === 2}
|
||||
on:click={() => setAntenna(2)}
|
||||
>
|
||||
C2
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="tuning-values">
|
||||
<div class="value-box">
|
||||
<div class="value">{c1}</div>
|
||||
<div class="label">C1</div>
|
||||
</div>
|
||||
<div class="value-box">
|
||||
<div class="value">{l}</div>
|
||||
<div class="label">L</div>
|
||||
</div>
|
||||
<div class="value-box">
|
||||
<div class="value">{c2}</div>
|
||||
<div class="label">C2</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-row">
|
||||
<div class="metric">
|
||||
<div class="label">Tuning Status</div>
|
||||
<div class="status-badge" class:tuning={tuningStatus === 'TUNING'}>
|
||||
{tuningStatus}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="frequency-row">
|
||||
<div class="metric">
|
||||
<div class="label">Frequency A</div>
|
||||
<div class="value-display">{(frequencyA / 1000).toFixed(3)}</div>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<div class="label">Frequency B</div>
|
||||
<div class="value-display">{(frequencyB / 1000).toFixed(3)}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="action-buttons">
|
||||
<button
|
||||
class="btn"
|
||||
class:btn-primary={!operate}
|
||||
class:btn-danger={operate}
|
||||
on:click={toggleOperate}
|
||||
>
|
||||
{operate ? 'STANDBY' : 'OPERATE'}
|
||||
</button>
|
||||
<button class="btn btn-secondary" disabled>BYPASS</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="btn btn-danger tune-btn"
|
||||
disabled={tuning || !operate}
|
||||
on:click={startTune}
|
||||
>
|
||||
{tuning ? 'TUNING...' : 'TUNE'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.tuner-card {
|
||||
min-width: 350px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
color: var(--accent-teal);
|
||||
}
|
||||
|
||||
.power-status {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 4px 12px;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.status-badge.tuning {
|
||||
background: var(--accent-green);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.tuning-controls {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.tuning-label {
|
||||
font-size: 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.antenna-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.antenna-btn {
|
||||
flex: 1;
|
||||
padding: 12px;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.antenna-btn.active {
|
||||
background: var(--accent-blue);
|
||||
border-color: var(--accent-blue);
|
||||
}
|
||||
|
||||
.tuning-values {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.value-box {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 12px;
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.value-box .value {
|
||||
font-size: 20px;
|
||||
font-weight: 300;
|
||||
color: var(--accent-teal);
|
||||
}
|
||||
|
||||
.status-row {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.frequency-row {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.metric {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.action-buttons button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.tune-btn {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
152
web/src/components/WebSwitch.svelte
Normal file
152
web/src/components/WebSwitch.svelte
Normal file
@@ -0,0 +1,152 @@
|
||||
<script>
|
||||
import { api } from '../lib/api.js';
|
||||
|
||||
export let status;
|
||||
|
||||
$: relays = status?.relays || [];
|
||||
|
||||
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="webswitch-card card">
|
||||
<h2>
|
||||
1216RH
|
||||
<span class="status-indicator" class:status-online={relays.length > 0} class:status-offline={relays.length === 0}></span>
|
||||
</h2>
|
||||
|
||||
<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-row">
|
||||
<span class="relay-name">{relayNames[relayNum]}</span>
|
||||
<button
|
||||
class="relay-toggle"
|
||||
class:active={isOn}
|
||||
disabled={loading[relayNum]}
|
||||
on:click={() => toggleRelay(relayNum)}
|
||||
>
|
||||
<div class="toggle-icon"></div>
|
||||
</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<button class="btn btn-primary" on:click={allOn}>ALL ON</button>
|
||||
<button class="btn btn-danger" on:click={allOff}>ALL OFF</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.webswitch-card {
|
||||
min-width: 280px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
color: var(--accent-teal);
|
||||
}
|
||||
|
||||
.relays {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.relay-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.relay-name {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.relay-toggle {
|
||||
width: 60px;
|
||||
height: 32px;
|
||||
background: #555;
|
||||
border-radius: 16px;
|
||||
position: relative;
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.relay-toggle.active {
|
||||
background: var(--accent-green);
|
||||
}
|
||||
|
||||
.toggle-icon {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: white;
|
||||
border-radius: 50%;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 4px;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.relay-toggle.active .toggle-icon {
|
||||
transform: translateX(28px);
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.controls button {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
76
web/src/lib/api.js
Normal file
76
web/src/lib/api.js
Normal file
@@ -0,0 +1,76 @@
|
||||
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: {
|
||||
operate: (operate) => request('/tuner/operate', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ operate }),
|
||||
}),
|
||||
tune: () => request('/tuner/tune', { method: 'POST' }),
|
||||
antenna: (antenna) => request('/tuner/antenna', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ antenna }),
|
||||
}),
|
||||
},
|
||||
|
||||
// Antenna Genius
|
||||
antenna: {
|
||||
set: (radio, antenna) => request('/antenna/set', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ radio, antenna }),
|
||||
}),
|
||||
},
|
||||
|
||||
// Power Genius
|
||||
power: {
|
||||
setFanMode: (mode) => request('/power/fanmode', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ mode }),
|
||||
}),
|
||||
},
|
||||
};
|
||||
81
web/src/lib/websocket.js
Normal file
81
web/src/lib/websocket.js
Normal file
@@ -0,0 +1,81 @@
|
||||
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') {
|
||||
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