style: run prettier
This commit is contained in:
@ -183,6 +183,10 @@
|
||||
|
||||
<!-- <HazardMarker hazard="bumpy-road" lat={51.347447} lon={7.4028181} /> -->
|
||||
{#each hazards as hazard (hazard.latitude + "-" + hazard.longitude)}
|
||||
<HazardMarker hazard={hazard.type} lat={hazard.latitude} lon={hazard.longitude} />
|
||||
<HazardMarker
|
||||
hazard={hazard.type}
|
||||
lat={hazard.latitude}
|
||||
lon={hazard.longitude}
|
||||
/>
|
||||
{/each}
|
||||
</MapLibre>
|
||||
|
||||
@ -2,11 +2,17 @@
|
||||
import { Marker } from "svelte-maplibre-gl";
|
||||
import { map } from "./map.svelte";
|
||||
|
||||
let { hazard, lat, lon }: { hazard: string, lat: number, lon: number } = $props();
|
||||
let { hazard, lat, lon }: { hazard: string; lat: number; lon: number } =
|
||||
$props();
|
||||
let img: HTMLImageElement | undefined = $state();
|
||||
</script>
|
||||
|
||||
<img src="/img/hazards/{hazard}.png" alt="{hazard} Marker" bind:this={img} style="width: 32px; {map.zoom < 15 ? "display: none;" : ""}" />
|
||||
<img
|
||||
src="/img/hazards/{hazard}.png"
|
||||
alt="{hazard} Marker"
|
||||
bind:this={img}
|
||||
style="width: 32px; {map.zoom < 15 ? 'display: none;' : ''}"
|
||||
/>
|
||||
<Marker
|
||||
lnglat={{
|
||||
lat: lat,
|
||||
|
||||
@ -287,7 +287,10 @@
|
||||
<Button
|
||||
variant="outline"
|
||||
onclick={async () => {
|
||||
await postHazard({ lat: location.lat, lon: location.lng }, "bumpy-road");
|
||||
await postHazard(
|
||||
{ lat: location.lat, lon: location.lng },
|
||||
"bumpy-road",
|
||||
);
|
||||
alert("Thanks for your report!");
|
||||
await fetchHazards();
|
||||
}}
|
||||
|
||||
@ -4,19 +4,25 @@ import { location } from "./location.svelte";
|
||||
export const hazards: Hazard[] = $state([]);
|
||||
|
||||
export async function fetchHazards() {
|
||||
if(!location.available) return;
|
||||
const newHazards = await getHazards({ lat: location.lat, lon: location.lng }, 100); // TODO: get radius from server config
|
||||
if (!location.available) return;
|
||||
const newHazards = await getHazards(
|
||||
{ lat: location.lat, lon: location.lng },
|
||||
100,
|
||||
); // TODO: get radius from server config
|
||||
hazards.splice(0, hazards.length, ...newHazards);
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
fetchHazards();
|
||||
}, 1000 * 60 * 5) // Every 5 minutes
|
||||
setInterval(
|
||||
() => {
|
||||
fetchHazards();
|
||||
},
|
||||
1000 * 60 * 5,
|
||||
); // Every 5 minutes
|
||||
// TODO: get from server config
|
||||
|
||||
const initalFetch = setInterval(() => {
|
||||
if(location.available) {
|
||||
if (location.available) {
|
||||
fetchHazards();
|
||||
clearInterval(initalFetch);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
@ -138,7 +138,10 @@
|
||||
// TODO: include partial maneuver time
|
||||
if (!routing.currentTrip) return 0;
|
||||
let total = 0;
|
||||
for (const [index, maneuver] of routing.currentTrip.legs[0].maneuvers.entries()) {
|
||||
for (const [
|
||||
index,
|
||||
maneuver,
|
||||
] of routing.currentTrip.legs[0].maneuvers.entries()) {
|
||||
if (index >= routing.currentTripInfo.maneuverIdx) {
|
||||
total += maneuver.time;
|
||||
}
|
||||
@ -148,7 +151,7 @@
|
||||
|
||||
const timeLeft = $derived.by(() => {
|
||||
return formatTimeLeft(getTimeLeft());
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
{fullDistanceText}, {timeLeft}
|
||||
|
||||
@ -243,7 +243,8 @@ export async function getHazards(location: WorldLocation, radius = 50) {
|
||||
// throw new Error("Hazards capability is not available");
|
||||
// }
|
||||
const res = await fetch(
|
||||
LNV_SERVER + `/hazards?lat=${location.lat}&lon=${location.lon}&radius=${radius}`,
|
||||
LNV_SERVER +
|
||||
`/hazards?lat=${location.lat}&lon=${location.lon}&radius=${radius}`,
|
||||
);
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to fetch hazards: ${res.statusText}`);
|
||||
|
||||
Reference in New Issue
Block a user