Kismet GPS option section per packet dcriped, refactoring to reduce loc

This commit is contained in:
Carlos Guerra
2026-03-29 16:22:07 +02:00
committed by Will Greenberg
parent adb316e2d7
commit 66f0c2a336
5 changed files with 78 additions and 259 deletions
+11 -47
View File
@@ -783,24 +783,16 @@
<div class="border-t pt-4 mt-6 space-y-3">
<h3 class="text-lg font-semibold text-gray-800 mb-4">GPS Settings</h3>
<div>
<label for="gps_mode" class="block text-sm font-medium text-gray-700 mb-1">
GPS Mode
</label>
<select
id="gps_mode"
bind:value={config.gps_mode}
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
>
<label for="gps_mode" class="block text-sm font-medium text-gray-700 mb-1">GPS Mode</label>
<select id="gps_mode" bind:value={config.gps_mode} class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue">
<option value={0}>0 - Disabled</option>
<option value={1}>1 - Fixed coordinates</option>
<option value={2}>2 - API Endpoint</option>
</select>
<p class="text-xs text-gray-500 mt-1">
{#if config.gps_mode === 2}
POST latitude, longitude, and timestamp to <code>/api/gps</code> from
any device on the network.
POST latitude, longitude, and timestamp to <code>/api/gps</code> from any device on the network.
{:else if config.gps_mode === 1}
GPS coordinates are fixed to the values below.
{:else}
@@ -808,47 +800,19 @@
{/if}
</p>
</div>
{#if config.gps_mode === 1}
<div>
<label
for="gps_fixed_latitude"
class="block text-sm font-medium text-gray-700 mb-1"
>
Fixed Latitude
</label>
<input
id="gps_fixed_latitude"
type="number"
min="-90"
max="90"
step="any"
required
bind:value={config.gps_fixed_latitude}
placeholder="e.g. 37.7749"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
/>
<label for="gps_fixed_latitude" class="block text-sm font-medium text-gray-700 mb-1">Fixed Latitude</label>
<input id="gps_fixed_latitude" type="number" min="-90" max="90" step="any" required
bind:value={config.gps_fixed_latitude} placeholder="e.g. 37.7749"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue" />
<p class="text-xs text-gray-500 mt-1">Decimal degrees, -90 to 90</p>
</div>
<div>
<label
for="gps_fixed_longitude"
class="block text-sm font-medium text-gray-700 mb-1"
>
Fixed Longitude
</label>
<input
id="gps_fixed_longitude"
type="number"
min="-180"
max="180"
step="any"
required
bind:value={config.gps_fixed_longitude}
placeholder="e.g. -122.4194"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
/>
<label for="gps_fixed_longitude" class="block text-sm font-medium text-gray-700 mb-1">Fixed Longitude</label>
<input id="gps_fixed_longitude" type="number" min="-180" max="180" step="any" required
bind:value={config.gps_fixed_longitude} placeholder="e.g. -122.4194"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue" />
<p class="text-xs text-gray-500 mt-1">Decimal degrees, -180 to 180</p>
</div>
{/if}
+28 -40
View File
@@ -291,46 +291,34 @@
<SystemStatsTable stats={system_stats!} />
</div>
{#if gps_mode !== 0}
<div class="bg-white border border-gray-200 drop-shadow rounded-md p-4 flex flex-col gap-2">
<span class="text-lg font-semibold flex flex-row items-center gap-2">
<svg
class="w-5 h-5 text-rayhunter-blue"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
fill="currentColor"
viewBox="0 0 24 24"
>
<path
fill-rule="evenodd"
d="M11.906 1.994a8.002 8.002 0 0 1 8.09 8.421 7.996 7.996 0 0 1-1.297 3.957.996.996 0 0 1-.133.204l-.108.129c-.178.243-.37.477-.573.699l-5.112 6.224a1 1 0 0 1-1.545 0L5.982 15.26l-.002-.002a18.146 18.146 0 0 1-.309-.38l-.133-.163a.999.999 0 0 1-.13-.202 7.995 7.995 0 0 1 6.498-12.518ZM15 9.997a3 3 0 1 1-5.999 0 3 3 0 0 1 5.999 0Z"
clip-rule="evenodd"
/>
</svg>
GPS Status
</span>
{#if gps_data}
<table class="w-full text-sm">
<tbody>
<tr class="border-b border-gray-100">
<td class="py-1 pr-4 text-gray-500 font-medium">Latitude</td>
<td class="py-1 font-mono">{gps_data.latitude.toFixed(6)}</td>
</tr>
<tr class="border-b border-gray-100">
<td class="py-1 pr-4 text-gray-500 font-medium">Longitude</td>
<td class="py-1 font-mono">{gps_data.longitude.toFixed(6)}</td>
</tr>
<tr>
<td class="py-1 pr-4 text-gray-500 font-medium">GPS Timestamp</td>
<td class="py-1 font-mono">{gps_data.timestamp}</td>
</tr>
</tbody>
</table>
{:else}
<span class="text-gray-400 text-sm">Awaiting GPS data...</span>
{/if}
</div>
<div class="bg-white border border-gray-200 drop-shadow rounded-md p-4 flex flex-col gap-2">
<span class="text-lg font-semibold flex flex-row items-center gap-2">
<svg class="w-5 h-5 text-rayhunter-blue" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
<path fill-rule="evenodd" d="M11.906 1.994a8.002 8.002 0 0 1 8.09 8.421 7.996 7.996 0 0 1-1.297 3.957.996.996 0 0 1-.133.204l-.108.129c-.178.243-.37.477-.573.699l-5.112 6.224a1 1 0 0 1-1.545 0L5.982 15.26l-.002-.002a18.146 18.146 0 0 1-.309-.38l-.133-.163a.999.999 0 0 1-.13-.202 7.995 7.995 0 0 1 6.498-12.518ZM15 9.997a3 3 0 1 1-5.999 0 3 3 0 0 1 5.999 0Z" clip-rule="evenodd" />
</svg>
GPS Status
</span>
{#if gps_data}
<table class="w-full text-sm">
<tbody>
<tr class="border-b border-gray-100">
<td class="py-1 pr-4 text-gray-500 font-medium">Latitude</td>
<td class="py-1 font-mono">{gps_data.latitude.toFixed(6)}</td>
</tr>
<tr class="border-b border-gray-100">
<td class="py-1 pr-4 text-gray-500 font-medium">Longitude</td>
<td class="py-1 font-mono">{gps_data.longitude.toFixed(6)}</td>
</tr>
<tr>
<td class="py-1 pr-4 text-gray-500 font-medium">GPS Timestamp</td>
<td class="py-1 font-mono">{gps_data.timestamp}</td>
</tr>
</tbody>
</table>
{:else}
<span class="text-gray-400 text-sm">Awaiting GPS data...</span>
{/if}
</div>
{/if}
<div class="flex flex-col gap-2">
<div class="flex flex-row gap-2">