2023-11-29 14:29:11 +01:00
|
|
|
<script lang="ts">
|
2023-12-19 22:08:00 +01:00
|
|
|
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
|
|
|
import FavouriteSummary from "./FavouriteSummary.svelte"
|
|
|
|
import Translations from "../i18n/Translations"
|
|
|
|
import Tr from "../Base/Tr.svelte"
|
|
|
|
import { DownloadIcon } from "@rgossiaux/svelte-heroicons/solid"
|
|
|
|
import { Utils } from "../../Utils"
|
|
|
|
import { GeoOperations } from "../../Logic/GeoOperations"
|
|
|
|
import type { Feature, LineString, Point } from "geojson"
|
|
|
|
import LoginToggle from "../Base/LoginToggle.svelte"
|
|
|
|
import LoginButton from "../Base/LoginButton.svelte"
|
2023-11-29 14:29:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A panel showing all your favourites
|
|
|
|
*/
|
2023-12-19 22:08:00 +01:00
|
|
|
export let state: SpecialVisualizationState
|
|
|
|
let favourites = state.favourites.allFavourites
|
2023-12-03 20:03:47 +01:00
|
|
|
|
|
|
|
function downloadGeojson() {
|
2023-12-19 22:08:00 +01:00
|
|
|
const contents = { features: favourites.data, type: "FeatureCollection" }
|
2023-12-03 20:03:47 +01:00
|
|
|
Utils.offerContentsAsDownloadableFile(
|
|
|
|
JSON.stringify(contents),
|
2023-12-19 22:08:00 +01:00
|
|
|
"mapcomplete-favourites-" + new Date().toISOString() + ".geojson",
|
2023-12-03 20:03:47 +01:00
|
|
|
{
|
2023-12-19 22:08:00 +01:00
|
|
|
mimetype: "application/vnd.geo+json",
|
2023-12-03 20:03:47 +01:00
|
|
|
}
|
2023-12-19 22:08:00 +01:00
|
|
|
)
|
2023-12-03 20:03:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function downloadGPX() {
|
2023-12-19 22:08:00 +01:00
|
|
|
const gpx = GeoOperations.toGpxPoints(<Feature<Point>>favourites.data, "MapComplete favourites")
|
|
|
|
Utils.offerContentsAsDownloadableFile(
|
|
|
|
gpx,
|
|
|
|
"mapcomplete-favourites-" + new Date().toISOString() + ".gpx",
|
2023-12-03 20:03:47 +01:00
|
|
|
{
|
2023-12-19 22:08:00 +01:00
|
|
|
mimetype: "{gpx=application/gpx+xml}",
|
|
|
|
}
|
|
|
|
)
|
2023-12-03 20:03:47 +01:00
|
|
|
}
|
2023-11-29 14:29:11 +01:00
|
|
|
</script>
|
2023-11-30 00:39:55 +01:00
|
|
|
|
2023-12-04 16:09:30 +01:00
|
|
|
<LoginToggle {state}>
|
|
|
|
<div slot="not-logged-in">
|
|
|
|
<LoginButton osmConnection={state.osmConnection}>
|
2023-12-19 22:08:00 +01:00
|
|
|
<Tr t={Translations.t.favouritePoi.loginToSeeList} />
|
2023-12-04 16:09:30 +01:00
|
|
|
</LoginButton>
|
|
|
|
</div>
|
2023-12-02 03:19:50 +01:00
|
|
|
|
2023-12-19 22:08:00 +01:00
|
|
|
<div class="flex flex-col" on:keypress={(e) => console.log("Got keypress", e)}>
|
|
|
|
<Tr t={Translations.t.favouritePoi.intro.Subs({ length: $favourites?.length ?? 0 })} />
|
|
|
|
<Tr t={Translations.t.favouritePoi.privacy} />
|
|
|
|
|
|
|
|
{#each $favourites as feature (feature.properties.id)}
|
|
|
|
<FavouriteSummary {feature} {state} />
|
|
|
|
{/each}
|
2023-12-03 20:03:47 +01:00
|
|
|
|
2023-12-19 22:08:00 +01:00
|
|
|
<div class="mt-8">
|
|
|
|
<button class="flex p-2" on:click={() => downloadGeojson()}>
|
|
|
|
<DownloadIcon class="h-6 w-6" />
|
|
|
|
<Tr t={Translations.t.favouritePoi.downloadGeojson} />
|
|
|
|
</button>
|
|
|
|
<button class="flex p-2" on:click={() => downloadGPX()}>
|
|
|
|
<DownloadIcon class="h-6 w-6" />
|
|
|
|
<Tr t={Translations.t.favouritePoi.downloadGpx} />
|
|
|
|
</button>
|
|
|
|
</div>
|
2023-12-03 20:03:47 +01:00
|
|
|
</div>
|
2023-12-04 16:09:30 +01:00
|
|
|
</LoginToggle>
|