Files
gpx.studio/website/src/routes/[[language]]/app/+page.svelte

164 lines
6.4 KiB
Svelte
Raw Normal View History

2024-07-08 15:46:00 +02:00
<script lang="ts">
2025-10-17 23:54:45 +02:00
import GPXLayers from '$lib/components/map/gpx-layer/GPXLayers.svelte';
2025-10-20 20:17:47 +02:00
import ElevationProfile from '$lib/components/elevation-profile/ElevationProfile.svelte';
2025-10-26 12:12:23 +01:00
import FileList from '$lib/components/file-list/FileList.svelte';
2025-10-18 00:31:14 +02:00
import GPXStatistics from '$lib/components/GPXStatistics.svelte';
2025-06-21 21:07:36 +02:00
import Map from '$lib/components/map/Map.svelte';
2025-10-05 19:34:05 +02:00
import Menu from '$lib/components/Menu.svelte';
2025-10-18 16:10:08 +02:00
import Toolbar from '$lib/components/toolbar/Toolbar.svelte';
2025-06-21 21:07:36 +02:00
import StreetViewControl from '$lib/components/map/street-view-control/StreetViewControl.svelte';
import LayerControl from '$lib/components/map/layer-control/LayerControl.svelte';
2025-10-23 19:07:32 +02:00
import CoordinatesPopup from '$lib/components/map/CoordinatesPopup.svelte';
import Resizer from '$lib/components/Resizer.svelte';
import { Toaster } from '$lib/components/ui/sonner';
2025-06-21 21:07:36 +02:00
import { i18n } from '$lib/i18n.svelte';
2025-10-17 23:54:45 +02:00
import { settings } from '$lib/logic/settings';
import { loadFiles } from '$lib/logic/file-actions';
2025-11-09 18:03:27 +01:00
import { onDestroy, onMount } from 'svelte';
2025-10-05 19:34:05 +02:00
import { page } from '$app/state';
2025-10-18 00:31:14 +02:00
import { gpxStatistics, slicedGPXStatistics } from '$lib/logic/statistics';
2025-11-09 18:03:27 +01:00
import { getURLForGoogleDriveFile } from '$lib/components/embedding/embedding';
import { db } from '$lib/db';
import { fileStateCollection } from '$lib/logic/file-state';
2024-07-11 18:42:49 +02:00
const {
treeFileView,
elevationProfile,
bottomPanelSize,
rightPanelSize,
additionalDatasets,
elevationFill,
} = settings;
2024-07-11 18:42:49 +02:00
onMount(async () => {
settings.connectToDatabase(db);
fileStateCollection.connectToDatabase(db).then(() => {
let files: string[] = JSON.parse(page.url.searchParams.get('files') || '[]');
let ids: string[] = JSON.parse(page.url.searchParams.get('ids') || '[]');
let urls: string[] = files.concat(ids.map(getURLForGoogleDriveFile));
2024-07-11 18:42:49 +02:00
if (urls.length > 0) {
let downloads: Promise<File | null>[] = [];
urls.forEach((url) => {
downloads.push(
fetch(url)
.then((response) => response.blob())
.then((blob) => new File([blob], url.split('/').pop() ?? ''))
);
});
2025-11-09 18:03:27 +01:00
Promise.all(downloads).then((files) => {
loadFiles(files.filter((file) => file !== null));
});
}
});
2025-11-09 18:03:27 +01:00
});
onDestroy(() => {
settings.disconnectFromDatabase();
2025-11-09 19:00:33 +01:00
fileStateCollection.disconnectFromDatabase();
2025-10-05 19:34:05 +02:00
});
2024-07-08 15:46:00 +02:00
</script>
2025-10-19 16:14:05 +02:00
<div class="fixed mt-[100%] -z-10 text-transparent">
2025-06-21 21:07:36 +02:00
<h1>{i18n._('metadata.home_title')}{i18n._('metadata.app_title')}</h1>
<p>{i18n._('metadata.description')}</p>
<h2>{i18n._('toolbar.routing.tooltip')}</h2>
<p>{i18n._('toolbar.routing.help_no_file')}</p>
<p>{i18n._('toolbar.routing.help')}</p>
<h3>{i18n._('toolbar.routing.reverse.button')}</h3>
<p>{i18n._('toolbar.routing.reverse.tooltip')}</p>
<h3>{i18n._('toolbar.routing.route_back_to_start.button')}</h3>
<p>{i18n._('toolbar.routing.route_back_to_start.tooltip')}</p>
<h3>{i18n._('toolbar.routing.round_trip.button')}</h3>
<p>{i18n._('toolbar.routing.round_trip.tooltip')}</p>
<h3>{i18n._('toolbar.routing.start_loop_here')}</h3>
<h2>{i18n._('toolbar.scissors.tooltip')}</h2>
<p>{i18n._('toolbar.scissors.help')}</p>
<h2>{i18n._('toolbar.time.tooltip')}</h2>
<p>{i18n._('toolbar.time.help')}</p>
<h2>{i18n._('toolbar.merge.tooltip')}</h2>
<h3>{i18n._('toolbar.merge.merge_traces')}</h3>
<p>{i18n._('toolbar.merge.help_merge_traces')}</p>
<h3>{i18n._('toolbar.merge.merge_contents')}</h3>
<p>{i18n._('toolbar.merge.help_merge_contents')}</p>
<h2>{i18n._('toolbar.elevation.button')}</h2>
<p>{i18n._('toolbar.elevation.help')}</p>
<h2>{i18n._('toolbar.waypoint.tooltip')}</h2>
<p>{i18n._('toolbar.waypoint.help')}</p>
<h2>{i18n._('toolbar.reduce.tooltip')}</h2>
<p>{i18n._('toolbar.reduce.help')}</p>
<h2>{i18n._('toolbar.clean.tooltip')}</h2>
<p>{i18n._('toolbar.clean.help')}</p>
<h2>
{i18n._('gpx.files')}, {i18n._('gpx.tracks')}, {i18n._('gpx.segments')}, {i18n._(
'gpx.waypoints'
)}
</h2>
2024-10-10 11:39:14 +02:00
</div>
2024-09-12 17:10:28 +02:00
<div class="fixed flex flex-row w-screen h-screen supports-dvh:h-dvh">
<div class="flex flex-col grow h-full min-w-0">
<div class="grow relative">
2025-10-05 19:34:05 +02:00
<Menu />
<div
class="absolute top-0 bottom-0 left-0 z-20 flex flex-col justify-center pointer-events-none"
>
2025-10-18 16:10:08 +02:00
<Toolbar />
</div>
2025-10-17 23:54:45 +02:00
<Map class="h-full {$treeFileView ? '' : 'horizontal'}" />
<StreetViewControl />
<LayerControl />
2025-10-17 23:54:45 +02:00
<GPXLayers />
2025-10-23 19:07:32 +02:00
<CoordinatesPopup />
<Toaster richColors />
2025-10-17 23:54:45 +02:00
{#if !$treeFileView}
<div class="h-10 -translate-y-10 w-full pointer-events-none absolute z-30">
2025-10-26 12:12:23 +01:00
<FileList orientation="horizontal" />
</div>
2025-10-17 23:54:45 +02:00
{/if}
</div>
2025-10-17 23:54:45 +02:00
{#if $elevationProfile}
<Resizer
orientation="row"
2025-10-17 23:54:45 +02:00
bind:after={$bottomPanelSize}
minAfter={100}
maxAfter={300}
/>
{/if}
<div
2025-10-17 23:54:45 +02:00
class="{$elevationProfile ? '' : 'h-10'} flex flex-row gap-2 px-2 sm:px-4"
style={$elevationProfile ? `height: ${$bottomPanelSize}px` : ''}
>
2025-10-18 00:31:14 +02:00
<GPXStatistics
{gpxStatistics}
{slicedGPXStatistics}
panelSize={$bottomPanelSize}
orientation={$elevationProfile ? 'vertical' : 'horizontal'}
2025-10-18 00:31:14 +02:00
/>
2025-10-18 20:12:19 +02:00
{#if $elevationProfile}
<ElevationProfile
{gpxStatistics}
{slicedGPXStatistics}
2025-10-22 19:05:20 +02:00
{additionalDatasets}
{elevationFill}
/>
2025-10-18 20:12:19 +02:00
{/if}
</div>
</div>
2025-10-17 23:54:45 +02:00
{#if $treeFileView}
<Resizer orientation="col" bind:after={$rightPanelSize} minAfter={100} maxAfter={400} />
2025-10-26 12:12:23 +01:00
<FileList orientation="vertical" recursive={true} style="width: {$rightPanelSize}px" />
{/if}
2024-07-11 18:42:49 +02:00
</div>
<style lang="postcss">
2025-06-21 21:07:36 +02:00
@reference "tailwindcss";
div :global(.toaster.group) {
@apply absolute;
@apply right-2;
--offset: 50px !important;
}
2024-07-11 18:42:49 +02:00
</style>