chore: use 1s STEP

This commit is contained in:
js0ny 2025-12-06 05:09:16 +00:00
parent acf9d132f7
commit 0ce7faaa07
5 changed files with 1304 additions and 1348 deletions

View file

@ -83,7 +83,8 @@
return new Date(earliest).toISOString().slice(0, 16);
}
startTime = deriveStartTime(defaultDispatch) || new Date().toISOString().slice(0, 16);
// Set to current time
startTime = new Date().toISOString().slice(0, 16);
desiredTime = startTime;
function jumpToTime(timeValue) {
@ -186,49 +187,6 @@
stopPlaying();
});
async function requestPath() {
let payload;
try {
payload = JSON.parse(dispatchBody);
} catch (err) {
status = "Error: Invalid JSON format.";
return;
}
if (!Array.isArray(payload)) {
status = "Error: Payload must be an array.";
return;
}
const derivedStart = deriveStartTime(payload);
if (derivedStart) {
startTime = derivedStart;
desiredTime = derivedStart;
}
loading = true;
status = "Transmitting dispatch to API...";
stopPlaying();
try {
const res = await fetch(`${apiBase}/calcDeliveryPath`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
plannedPath = await res.json();
tick = 0;
fitMapToBounds();
status = "Flight path received. Ready for simulation.";
} catch (err) {
plannedPath = samplePathResponse;
status = `API Link Failed. Using offline sample data. (${err.message})`;
} finally {
loading = false;
}
}
function loadSample() {
plannedPath = samplePathResponse;
status = "Loaded sample simulation data.";
@ -386,10 +344,6 @@
<div class="text-[10px] space-y-0.5 font-mono opacity-80">
<div class="flex justify-between"><span>Lat:</span> <span>${drone.current.lat.toFixed(4)}</span></div>
<div class="flex justify-between"><span>Lng:</span> <span>${drone.current.lng.toFixed(4)}</span></div>
<div class="flex justify-between mt-1 pt-1 border-t border-white/10">
<span>Status:</span>
<span class="${isMoving ? "text-green-400" : "text-slate-400"}">${isMoving ? "MOVING" : "IDLE"}</span>
</div>
</div>
</div>
`;
@ -514,7 +468,6 @@
{status}
{loading}
on:close={() => (sidebarOpen = false)}
on:request={requestPath}
on:loadSample={loadSample}
/>
</div>

View file

@ -31,6 +31,11 @@
@apply bg-gray-800 text-white p-2 rounded-md border-gray-700 border;
}
/* Arrow should be the same color as the tooltip background */
.drone-tooltip.leaflet-tooltip-top::before {
border-top-color: theme('colors.gray.800');
}
/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
width: 6px;
@ -55,4 +60,4 @@
}
.drone-popup .leaflet-popup-content {
margin: 12px;
}
}

View file

@ -134,7 +134,7 @@
<label
for="api"
class="block text-xs text-slate-600 dark:text-slate-400 mb-1"
>Planner API Endpoint</label
>Planner API Endpoint (Debug Only)</label
>
<input
id="api"
@ -189,21 +189,16 @@
spellcheck="false"
></textarea>
</div>
<div class="flex gap-2 mt-auto pt-4 border-t border-slate-200 dark:border-slate-800">
<button
class="flex-1 p-2.5 rounded-lg font-semibold text-sm transition-all disabled:opacity-50 disabled:cursor-not-allowed text-white bg-sky-500 shadow-[0_4px_12px_theme(colors.sky.500/30)] hover:bg-sky-600 disabled:hover:bg-sky-500"
on:click={() => dispatch('request')}
disabled={loading}
>
{loading ? "CALCULATING..." : "REQUEST PATH"}
</button>
</div>
</div>
<div class="flex gap-2 mt-auto pt-4 border-t border-slate-200 dark:border-slate-800">
<button
class="flex-1 p-2.5 rounded-lg font-semibold text-sm transition-all disabled:opacity-50 disabled:cursor-not-allowed text-white bg-sky-500 shadow-[0_4px_12px_theme(colors.sky.500/30)] hover:bg-sky-600 disabled:hover:bg-sky-500"
on:click={() => dispatch('request')}
disabled={loading}
>
{loading ? "CALCULATING..." : "REQUEST PATH"}
</button>
<button
class="flex-1 p-2.5 rounded-lg font-semibold text-sm transition-all disabled:opacity-50 disabled:cursor-not-allowed text-slate-800 dark:text-slate-100 bg-slate-500/20 hover:bg-slate-500/30"
on:click={() => dispatch('loadSample')}
>
LOAD SAMPLE
</button>
</div>
</aside>
</aside>

File diff suppressed because it is too large Load diff