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