Lint and format
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
Alessio Davoli 2024-03-06 00:14:26 +01:00
parent 9d0dbc520b
commit c80eb89db7
34 changed files with 560 additions and 565 deletions

View file

@ -1,40 +1,40 @@
{
"name": "frontend",
"version": "0.6.0",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build && ./add-sigint.sh",
"add-sigint": "./add-sigint.sh",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@sveltejs/adapter-node": "^4.0.1",
"@sveltejs/kit": "^2.5.2",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@types/leaflet": "^1.9.8",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.2",
"svelte": "^4.2.12",
"svelte-check": "^3.6.6",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vite": "^5.1.5"
},
"type": "module",
"dependencies": {
"@sentry/sveltekit": "^7.105.0",
"leaflet": "^1.9.4",
"leaflet-gpx": "^1.7.0",
"svelte-preprocess": "^5.1.3"
}
"name": "frontend",
"version": "0.6.0",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build && ./add-sigint.sh",
"add-sigint": "./add-sigint.sh",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@sveltejs/adapter-node": "^4.0.1",
"@sveltejs/kit": "^2.5.2",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@types/leaflet": "^1.9.8",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.2",
"svelte": "^4.2.12",
"svelte-check": "^3.6.6",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vite": "^5.1.5"
},
"type": "module",
"dependencies": {
"@sentry/sveltekit": "^7.105.0",
"leaflet": "^1.9.4",
"leaflet-gpx": "^1.7.0",
"svelte-preprocess": "^5.1.3"
}
}

90
frontend/src/app.d.ts vendored
View file

@ -9,51 +9,50 @@ declare global {
// interface PageData {}
// interface Platform {}
interface Category {
"id": 1,
"name_it": "Natura",
"name_en": "Nature",
"description_it": "Giri nella natura",
"description_en": "Countryside routes",
"icon": "",
"created_at": null,
"updated_at": null,
"deleted_at": null,
"color": string,
"cover": string,
id: 1;
name_it: 'Natura';
name_en: 'Nature';
description_it: 'Giri nella natura';
description_en: 'Countryside routes';
icon: '';
created_at: null;
updated_at: null;
deleted_at: null;
color: string;
cover: string;
}
interface Sport {
"id": 1,
"name_it": "Trekking",
"name_en": "Trekking",
"description_it": "Percorso escursionistico",
"description_en": "Trekking route",
"icon": "",
"created_at": "2023-10-31T18:37:30.000000Z",
"updated_at": null,
"deleted_at": null
id: 1;
name_it: 'Trekking';
name_en: 'Trekking';
description_it: 'Percorso escursionistico';
description_en: 'Trekking route';
icon: '';
created_at: '2023-10-31T18:37:30.000000Z';
updated_at: null;
deleted_at: null;
}
interface SportDetails {
id: 1,
route_id: 1,
sport_id: 1,
short_description_it: "Percorso escursionistico intermedio. Buon allenamento richiesto. Sentieri facilmente percorribili. Adatto a ogni livello di abilit\u00e0. ",
short_description_en: "Intermediate hiking route. Good training required. Easily accessible paths. Suitable for all skill levels.",
gpx_path: "",
distance: 16800,
duration: 288,
elevation_gain: 439,
elevation_loss: null,
altitude_max: 620,
altitude_min: 180,
difficulty_it: "Facile",
difficulty_en: "Easy",
route_type_it: "Percorso ad anello",
route_type_en: "Ring route",
created_at: "2023-11-02T10:57:41.000000Z",
updated_at: null,
deleted_at: null,
sport: Sport
id: 1;
route_id: 1;
sport_id: 1;
short_description_it: 'Percorso escursionistico intermedio. Buon allenamento richiesto. Sentieri facilmente percorribili. Adatto a ogni livello di abilit\u00e0. ';
short_description_en: 'Intermediate hiking route. Good training required. Easily accessible paths. Suitable for all skill levels.';
gpx_path: '';
distance: 16800;
duration: 288;
elevation_gain: 439;
elevation_loss: null;
altitude_max: 620;
altitude_min: 180;
difficulty_it: 'Facile';
difficulty_en: 'Easy';
route_type_it: 'Percorso ad anello';
route_type_en: 'Ring route';
created_at: '2023-11-02T10:57:41.000000Z';
updated_at: null;
deleted_at: null;
sport: Sport;
}
interface Route {
id: number;
@ -66,7 +65,7 @@ declare global {
description_it: string;
description_en: string;
route_category_id: number;
created_at: "2023-11-02T10:50:07.000000Z";
created_at: '2023-11-02T10:50:07.000000Z';
updated_at: null;
deleted_at: null;
route_sport_details: Array<SportDetails>;
@ -74,9 +73,4 @@ declare global {
}
}
}
export {
Route,
Category,
Sport,
SportDetails
};
export { Route, Category, Sport, SportDetails };

View file

@ -1,50 +1,48 @@
<!DOCTYPE html>
<!doctype html>
<html lang="it">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
<link rel="manifest" href="manifest.json" />
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
<link rel="manifest" href="manifest.json" />
%sveltekit.head%
</head>
<style>
:root {
--footer-height: 108px;
--accent-color: #213c8b;
--pianello-red: #de0e1b;
--pianello-yellow: #f6ae04;
--pianello-blue: #213c8b;
--card-background-color: #f9f4f1;
}
%sveltekit.head%
</head>
<style>
:root {
--footer-height: 108px;
--accent-color: #213c8b;
--pianello-red: #de0e1b;
--pianello-yellow: #f6ae04;
--pianello-blue: #213c8b;
--card-background-color: #f9f4f1;
}
* {
box-sizing: border-box;
}
* {
box-sizing: border-box;
}
html {
width: 100%;
height: 100%;
}
html {
width: 100%;
height: 100%;
}
body {
width: 100%;
height: 100%;
margin: 0px;
background-color: #fff;
font-family: 'Roboto-Regular';
display: grid;
}
body {
width: 100%;
height: 100%;
margin: 0px;
background-color: #fff;
font-family: 'Roboto-Regular';
display: grid;
}
@font-face {
font-family: 'Roboto-Regular';
src: url('/fonts/roboto/Roboto-Regular.ttf') format('TrueType');
}
</style>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
@font-face {
font-family: 'Roboto-Regular';
src: url('/fonts/roboto/Roboto-Regular.ttf') format('TrueType');
}
</style>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

View file

@ -1,42 +1,41 @@
:root {
--footer-height: calc(68px + 20px + 20px);
--accent-color: #213c8b;
--pianello-red: #de0e1b;
--pianello-yellow: #f6ae04;
--pianello-blue: #213c8b;
--card-background-color: #f9f4f1;
--footer-height: calc(68px + 20px + 20px);
--accent-color: #213c8b;
--pianello-red: #de0e1b;
--pianello-yellow: #f6ae04;
--pianello-blue: #213c8b;
--card-background-color: #f9f4f1;
}
* {
box-sizing: border-box;
box-sizing: border-box;
}
html {
width: 100%;
height: 100%;
width: 100%;
height: 100%;
}
body {
width: 100%;
height: 100%;
margin: 0px;
background-color: #fff;
font-family: 'Roboto-Regular';
display: grid;
width: 100%;
height: 100%;
margin: 0px;
background-color: #fff;
font-family: 'Roboto-Regular';
display: grid;
}
header,
main,
footer {
background: white;
height: 100%;
width: 100%;
display: grid;
place-items: center;
background: white;
height: 100%;
width: 100%;
display: grid;
place-items: center;
}
@font-face {
font-family: 'Roboto-Regular';
src: url('/fonts/roboto/Roboto-Regular.ttf') format('TrueType');
font-family: 'Roboto-Regular';
src: url('/fonts/roboto/Roboto-Regular.ttf') format('TrueType');
}

View file

@ -1,13 +1,13 @@
.header {
padding: 15px;
background-color: transparent;
color: black;
margin: 0 auto;
padding-left: 25px;
padding-right: 25px;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
height: 70px;
padding: 15px;
background-color: transparent;
color: black;
margin: 0 auto;
padding-left: 25px;
padding-right: 25px;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
height: 70px;
}

View file

@ -1,43 +1,41 @@
<html>
<head>
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
<head>
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
background-image: url(/splash.webp);
background-size: cover;
display: grid;
place-content: center;
height: 100%;
font-size: 24px;
font-family: monospace;
}
.wrapper {
display: flex;
backdrop-filter: blur(5px);
border-radius: 10px;
border: 1px solid black;
}
body {
background-image: url(/splash.webp);
background-size: cover;
display: grid;
place-content: center;
height: 100%;
font-size: 24px;
font-family: monospace;
}
.wrapper {
display: flex;
backdrop-filter: blur(5px);
border-radius: 10px;
border: 1px solid black;
}
#status {
border-right: 1px solid black;
}
p {
padding: 20px;
}
</style>
</head>
<body>
<div class="wrapper">
<p id="status">Code %sveltekit.status%</p>
<p id="message">%sveltekit.error.message%</p>
</div>
</body>
#status {
border-right: 1px solid black;
}
p {
padding: 20px;
}
</style>
</head>
<body>
<div class="wrapper">
<p id="status">Code %sveltekit.status%</p>
<p id="message">%sveltekit.error.message%</p>
</div>
</body>
</html>

View file

@ -1,6 +1,6 @@
export async function handleError({ error, event, status, message }) {
const errorId = crypto.randomUUID();
console.error(error)
console.error(error);
// console.error(event)
// console.error(status)
return {

View file

@ -9,7 +9,7 @@ export async function handleFetch({ request, fetch }) {
export async function handleError({ error, event, status, message }) {
const errorId = crypto.randomUUID();
console.error(error)
console.error(error);
// console.error(event)
// console.error(status)
return {

View file

@ -30,7 +30,6 @@
box-shadow: 0 0 50px #ccc;
background-color: var(--card-background-color);
margin: 0 auto;
}
#container > a {

View file

@ -1,40 +1,40 @@
<script lang="ts">
import '../../css/header.css';
import '../../css/header.css';
export const title: string = 'Naturalistici';
export const title: string = 'Naturalistici';
const goBack = () => {
history.back();
};
const goBack = () => {
history.back();
};
</script>
<div class='header'>
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-missing-attribute -->
<a on:click={goBack}>
<img class="back" src="/images/black-back-arrow.png" alt="" />
</a>
<div class="header">
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-missing-attribute -->
<a on:click={goBack}>
<img class="back" src="/images/black-back-arrow.png" alt="" />
</a>
<img src="/images/app-bar-logo.png" alt="" />
<img src="/images/app-bar-logo.png" alt="" />
</div>
<style>
div {
background-color: transparent;
color: black;
}
div a {
cursor: pointer;
}
div a img {
height: 40px;
}
div {
background-color: transparent;
color: black;
}
div a {
cursor: pointer;
}
div a img {
height: 40px;
}
img {
height: 40px;
}
.back {
height: 20px;
}
img {
height: 40px;
}
.back {
height: 20px;
}
</style>

View file

@ -8,7 +8,7 @@
};
</script>
<div class='header'>
<div class="header">
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-missing-attribute -->

View file

@ -1,5 +1,5 @@
<script lang="ts">
import {PUBLIC_BACKEND_URL} from '$env/static/public'
import { PUBLIC_BACKEND_URL } from '$env/static/public';
export let name: string;
export let id: number;
@ -7,7 +7,7 @@
export const path = `/paths/${id}`;
export let src: string;
let image = '/archi.png'
let image = '/archi.png';
switch (id) {
case 1:
image = '/archi.png';
@ -30,16 +30,16 @@
<div class="bold">{name}</div>
</div>
</div>
<div class="route-card-right" style:background-image='url({PUBLIC_BACKEND_URL}{src})' />
<div class="route-card-right" style:background-image="url({PUBLIC_BACKEND_URL}{src})" />
</a>
<style>
a {
text-decoration: inherit;
color: inherit;
cursor: pointer;
color: inherit;
cursor: pointer;
display: grid;
grid-template-columns: 20% minmax(1px,1fr) 20%;
grid-template-columns: 20% minmax(1px, 1fr) 20%;
max-width: 100%;
width: calc(100% - 20px);
margin: 0 auto;

View file

@ -1,16 +1,16 @@
<script lang="ts">
import {PUBLIC_BACKEND_URL} from '$env/static/public'
import { PUBLIC_BACKEND_URL } from '$env/static/public';
export let route: App.Route;
</script>
<a href="/routes/{route.id}">
<div id="image" style:background-image="url({PUBLIC_BACKEND_URL}{route.cover})" />
<div id='path-holder'>
<p class='path-name'>{route.title_it}</p>
<div id="path-holder">
<p class="path-name">{route.title_it}</p>
</div>
<div id='duration-holder'>
<div style='font-size: 15px;'>Dislivello</div>
<div id="duration-holder">
<div style="font-size: 15px;">Dislivello</div>
<p id="duration">{route.elevation_gain}</p>
</div>
</a>

View file

@ -1,13 +1,13 @@
<script>
import { onMount } from 'svelte';
import { fade } from 'svelte/transition';
import { dev } from '$app/environment'
import { dev } from '$app/environment';
let visible = dev ? false : true;
let time = 2000;
onMount(() => {
if(dev) return
if (dev) return;
setTimeout(() => {
visible = false;
@ -16,9 +16,9 @@
</script>
{#if visible}
<img class='background' transition:fade src="/splash.webp" alt="splash" />
<div class='wrapper'>
<img transition:fade class='logo' src="/images/splash-logo.png" alt="splash-logo" />
<img class="background" transition:fade src="/splash.webp" alt="splash" />
<div class="wrapper">
<img transition:fade class="logo" src="/images/splash-logo.png" alt="splash-logo" />
</div>
{/if}

View file

@ -12,8 +12,8 @@
let component = InfoTabTrekking;
onMount(() => {
console.log(route)
})
console.log(route);
});
const dispatchClick = (c: InfoTabTrekking | InfoTabBike | DescTab | MapTab) => {
component = c;
dispatch('tab-click', { component });
@ -21,14 +21,30 @@
</script>
<div id="tabs">
<button class:active={component === InfoTabTrekking} on:click={() => dispatchClick(InfoTabTrekking)} id="info-trekking"> <img src='/trekking.svg' alt='trekking'> </button>
<button class:active={component === InfoTabBike} on:click={() => dispatchClick(InfoTabBike)} id="info-bike"> <img src='/bike.svg' alt='bike'> </button>
<button class:active={component === DescTab} on:click={() => dispatchClick(DescTab)} id="desc"> Descrizione</button>
<button class:active={component === MapTab} on:click={() => dispatchClick(MapTab)} id="map"> Mappa</button>
<button
class:active={component === InfoTabTrekking}
on:click={() => dispatchClick(InfoTabTrekking)}
id="info-trekking"
>
<img src="/trekking.svg" alt="trekking" />
</button>
<button
class:active={component === InfoTabBike}
on:click={() => dispatchClick(InfoTabBike)}
id="info-bike"
>
<img src="/bike.svg" alt="bike" />
</button>
<button class:active={component === DescTab} on:click={() => dispatchClick(DescTab)} id="desc">
Descrizione</button
>
<button class:active={component === MapTab} on:click={() => dispatchClick(MapTab)} id="map">
Mappa</button
>
</div>
<div id="container">
<div class="tab" bind:this={ref} role="tab">
<svelte:component this={component} route={route} />
<svelte:component this={component} {route} />
</div>
</div>
@ -72,7 +88,8 @@
border-bottom: 1px solid black !important;
}
#info-bike, #info-trekking {
#info-bike,
#info-trekking {
display: flex;
justify-content: center;
align-items: center;

View file

@ -1,4 +1,4 @@
<script lang='ts'>
<script lang="ts">
import { fade } from 'svelte/transition';
export let route: App.Route;

View file

@ -50,28 +50,28 @@
</div>
<style>
#grid {
display: grid;
grid-template-rows: repeat(3, 33%);
grid-template-columns: repeat(3, 1fr);
width: 100%;
background: white;
place-items: center;
font-size: 14px;
}
#grid {
display: grid;
grid-template-rows: repeat(3, 33%);
grid-template-columns: repeat(3, 1fr);
width: 100%;
background: white;
place-items: center;
font-size: 14px;
}
#grid div {
margin: 0 auto;
display: flex;
text-align: center;
flex-direction: column;
}
#grid div > p {
padding: 10px;
margin: 0px;
}
#grid div p:nth-child(2) {
font-weight: bold;
font-size: 16px;
}
#grid div {
margin: 0 auto;
display: flex;
text-align: center;
flex-direction: column;
}
#grid div > p {
padding: 10px;
margin: 0px;
}
#grid div p:nth-child(2) {
font-weight: bold;
font-size: 16px;
}
</style>

View file

@ -50,28 +50,28 @@
</div>
<style>
#grid {
display: grid;
grid-template-rows: repeat(3, 33%);
grid-template-columns: repeat(3, 1fr);
width: 100%;
background: white;
place-items: center;
font-size: 14px;
}
#grid {
display: grid;
grid-template-rows: repeat(3, 33%);
grid-template-columns: repeat(3, 1fr);
width: 100%;
background: white;
place-items: center;
font-size: 14px;
}
#grid div {
margin: 0 auto;
display: flex;
text-align: center;
flex-direction: column;
}
#grid div > p {
padding: 10px;
margin: 0px;
}
#grid div p:nth-child(2) {
font-weight: bold;
font-size: 16px;
}
#grid div {
margin: 0 auto;
display: flex;
text-align: center;
flex-direction: column;
}
#grid div > p {
padding: 10px;
margin: 0px;
}
#grid div p:nth-child(2) {
font-weight: bold;
font-size: 16px;
}
</style>

View file

@ -1,7 +1,7 @@
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
import { fade } from 'svelte/transition';
const mapMarkerIcon = new URL('/icons/map.png', import.meta.url).href
const mapMarkerIcon = new URL('/icons/map.png', import.meta.url).href;
export let route;
const pianelloCoordinates = [43.14, 12.53];
@ -14,54 +14,55 @@
let longitude;
let accuracy;
let watchPositionId: number;
const errorMessage = "Geolocation not available";
const attribution = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
const errorMessage = 'Geolocation not available';
const attribution =
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
const openStreetMapTile = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
let errored = false;
const watchPosition = async () => {
if (!("geolocation" in navigator)) {
if (!('geolocation' in navigator)) {
errored = true;
throw new Error(errorMessage)
}
throw new Error(errorMessage);
}
const options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0,
};
const options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
function success(pos: GeolocationPosition) {
const crd = pos.coords;
function success(pos: GeolocationPosition) {
const crd = pos.coords;
let string = "";
let string = '';
latitude = crd.latitude;
longitude = crd.longitude;
accuracy = crd.accuracy;
latitude = crd.latitude;
longitude = crd.longitude;
accuracy = crd.accuracy;
const icon = leaflet.icon({
iconUrl: mapMarkerIcon,
iconSize: [75, 75], // size of the icon
iconSize: [75, 75] // size of the icon
});
userMarker = leaflet.marker([latitude, longitude], {icon}).addTo(map);
userMarker = leaflet.marker([latitude, longitude], { icon }).addTo(map);
// move the map to have the location in its center
map.panTo(userMarker.getLatLng());
string += "Your current position is:";
string += `Latitude : ${crd.latitude}`;
string += `Longitude: ${crd.longitude}`;
string += `More or less ${crd.accuracy} meters.`;
}
string += 'Your current position is:';
string += `Latitude : ${crd.latitude}`;
string += `Longitude: ${crd.longitude}`;
string += `More or less ${crd.accuracy} meters.`;
}
function error(err) {
console.warn(`ERROR(${err.code}): ${err.message}`);
}
function error(err) {
console.warn(`ERROR(${err.code}): ${err.message}`);
}
watchPositionId = navigator.geolocation.watchPosition(success, error, options);
};
watchPositionId = navigator.geolocation.watchPosition(success, error, options);
};
const renderMap = () => {
layerGroup = leaflet.layerGroup();
@ -75,22 +76,22 @@
map.setView(pianelloCoordinates, 13);
leaflet
.tileLayer(openStreetMapTile, {attribution})
.addTo(map);
}
leaflet.tileLayer(openStreetMapTile, { attribution }).addTo(map);
};
const renderGPX = () => {
const gpx = "/gpx/tidone.gpx"; // URL to your GPX file or the GPX itself
new leafletGPX(gpx, {async: true}).on('loaded', function(e) {
map.fitBounds(e.target.getBounds());
}).addTo(map);
}
const gpx = '/gpx/tidone.gpx'; // URL to your GPX file or the GPX itself
new leafletGPX(gpx, { async: true })
.on('loaded', function (e) {
map.fitBounds(e.target.getBounds());
})
.addTo(map);
};
onMount(async () => {
await watchPosition();
leaflet = await import('leaflet');
const {GPX} = await import('leaflet-gpx');
const { GPX } = await import('leaflet-gpx');
leafletGPX = GPX;
renderMap();
@ -115,10 +116,14 @@
{/if}
<svelte:head>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""/>
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""
/>
</svelte:head>
<style>
#map {
height: 100%;

View file

@ -1,12 +1,6 @@
let latitude;
let longitude;
onmessage = () => {};
onmessage = () => {
};
export { };
export {};

View file

@ -1,61 +1,60 @@
import {PUBLIC_BACKEND_URL} from '$env/static/public'
import { PUBLIC_BACKEND_URL } from '$env/static/public';
const API_URL = `${PUBLIC_BACKEND_URL}/api`
const API_URL = `${PUBLIC_BACKEND_URL}/api`;
const getAllRoutes = async () => {
let data = [];
let data = [];
const response = await fetch(`${API_URL}/all-routes`);
const json = await response.json();
data = json;
const response = await fetch(`${API_URL}/all-routes`);
const json = await response.json();
data = json;
return data;
}
return data;
};
const getRouteCategories = async () => {
let data = [];
let data = [];
const response = await fetch(`${API_URL}/route-categories`);
const json = await response.json();
data = json;
const response = await fetch(`${API_URL}/route-categories`);
const json = await response.json();
data = json;
return data;
}
return data;
};
const getRouteByCategory = async (categoryId: number) => {
let data = [];
const response = await fetch(`${API_URL}/route-by-category/${categoryId}`);
const json = await response.json();
data = json;
let data = [];
const response = await fetch(`${API_URL}/route-by-category/${categoryId}`);
const json = await response.json();
data = json;
return data;
}
return data;
};
const getRoute = async (routeId: number) => {
let data = {};
const response = await fetch(`${API_URL}/route/${routeId}`);
const json = await response.json();
data = json;
return data;
}
let data = {};
const response = await fetch(`${API_URL}/route/${routeId}`);
const json = await response.json();
data = json;
return data;
};
const getSport = async (routeId: number, sportId: number) => {
let data = {};
const response = await fetch(`${API_URL}/route/${routeId}/${sportId}`);
const json = await response.json();
data = json;
let data = {};
const response = await fetch(`${API_URL}/route/${routeId}/${sportId}`);
const json = await response.json();
data = json;
return data;
}
return data;
};
const getPlacemarks = async (routeId: number, sportId: number) => {
let data = {};
const response = await fetch(`${API_URL}/getPlacemarks/${routeId}/${sportId}`);
const json = await response.json();
data = json;
let data = {};
const response = await fetch(`${API_URL}/getPlacemarks/${routeId}/${sportId}`);
const json = await response.json();
data = json;
return data;
}
return data;
};
export { getAllRoutes, getPlacemarks, getSport, getRoute, getRouteByCategory, getRouteCategories };

View file

@ -2,7 +2,7 @@
import { page } from '$app/stores';
</script>
<div id='container'>
<div id="container">
<div class="wrapper">
<p id="status">{$page.status}</p>
<p id="message">{$page.error?.message}</p>
@ -22,9 +22,9 @@
display: grid;
place-content: center;
height: 100dvh;
width: 100dvw;
z-index: 99;
position: absolute;
width: 100dvw;
z-index: 99;
position: absolute;
font-size: 24px;
font-family: monospace;
}

View file

@ -8,7 +8,7 @@
let node: HTMLElement;
onMount(() => {
if(dev) return;
if (dev) return;
if ('serviceWorker' in navigator) {
addEventListener('load', function () {
@ -32,8 +32,8 @@
}
});
onNavigate((navigation: { complete: any; }) => {
if (!(document.startViewTransition)) return;
onNavigate((navigation: { complete: any }) => {
if (!document.startViewTransition) return;
return new Promise<void>((resolve) => {
document?.startViewTransition(async () => {

View file

@ -9,7 +9,7 @@
<div id="welcome-message">Benvenuti a <span class="bold">Pianello Val Tidone</span></div>
<div id="route-cards">
{#each categories as category}
<Path src={category.cover} color={category.color} name="{category.name_it}" id={category.id} />
<Path src={category.cover} color={category.color} name={category.name_it} id={category.id} />
{/each}
</div>
</main>

View file

@ -9,7 +9,7 @@ export async function load({ fetch }) {
const response = await fetch(`${API_URL}/route-categories`);
categories = await response.json();
} catch (ex) {
error(404, { message: 'API Not Found'});
error(404, { message: 'API Not Found' });
}
return { categories };

View file

@ -1,27 +1,26 @@
import { getRouteByCategory, getRouteCategories } from '$lib/repo.js';
import { error } from '@sveltejs/kit';
import {PUBLIC_BACKEND_URL} from '$env/static/public';
import { PUBLIC_BACKEND_URL } from '$env/static/public';
const API_URL = `${PUBLIC_BACKEND_URL}/api`;
export async function load({ params, fetch }) {
const response = await fetch(`${API_URL}/route-categories`);
const categories: App.Category[] = await response.json();
const categoryId = Number(params.slug);
const response = await fetch(`${API_URL}/route-categories`);
const categories: App.Category[] = await response.json();
const categoryId = Number(params.slug);
const category: App.Category = categories.find(c => c.id === categoryId) as App.Category;
const category: App.Category = categories.find((c) => c.id === categoryId) as App.Category;
if (!category) {
error(404);
}
if (!category) {
error(404, { message: 'Path not found' });
}
const response2 = await fetch(`${API_URL}/route-by-category/${categoryId}`);
const routes = await response2.json();
const response2 = await fetch(`${API_URL}/route-by-category/${categoryId}`);
const routes = await response2.json();
const toReturn = {
category: category.name_it,
routes,
}
const toReturn = {
category: category.name_it,
routes
};
return toReturn;
return toReturn;
}

View file

@ -8,7 +8,7 @@
let divider: HTMLDivElement;
let isMap: boolean = false;
const tabClick = (event) => {
const tabClick = (event) => {
isMap = event.detail.component === MapTab;
};
</script>
@ -18,7 +18,7 @@
<div bind:this={divider} id="divider" class:move-to-top={isMap}>
<div id="banner">
<p class='path-name'>Percorso <b>{data.name_it}</b></p>
<p class="path-name">Percorso <b>{data.name_it}</b></p>
<p id="duration">Dislivello {data?.route_sport_details[0]?.elevation_gain} m</p>
</div>
<Tabs on:tab-click={tabClick} route={data}></Tabs>

View file

@ -1,16 +1,16 @@
import { error } from '@sveltejs/kit';
import {PUBLIC_BACKEND_URL} from '$env/static/public'
import { PUBLIC_BACKEND_URL } from '$env/static/public';
const API_URL = `${PUBLIC_BACKEND_URL}/api`
const API_URL = `${PUBLIC_BACKEND_URL}/api`;
export async function load({ params, fetch }) {
const routeId = Number(params.slug);
const response = await fetch(`${API_URL}/route/${routeId}`);
const route = await response.json();
const routeId = Number(params.slug);
const response = await fetch(`${API_URL}/route/${routeId}`);
const route = await response.json();
if (!route) {
error(404);
}
if (!route) {
error(404, { message: 'Route non found' });
}
return route;
return route;
}

View file

@ -9,76 +9,72 @@ import { build, files, version, prerendered } from '$service-worker';
const CACHE = `sw-cache-${version}`;
const ASSETS = [
...build, // the app itself
...files, // everything in `static`,
...prerendered // dynamic routes
...build, // the app itself
...files, // everything in `static`,
...prerendered // dynamic routes
];
let client;
addEventListener('message', event => {
client = event.source;
addEventListener('message', (event) => {
client = event.source;
});
self.addEventListener('install', (event) => {
// Create a new cache and add all files to it
async function addFilesToCache() {
const cache = await caches.open(CACHE);
await cache.addAll(ASSETS);
}
// Create a new cache and add all files to it
async function addFilesToCache() {
const cache = await caches.open(CACHE);
await cache.addAll(ASSETS);
}
event.waitUntil(addFilesToCache());
event.waitUntil(addFilesToCache());
});
self.addEventListener('activate', (event) => {
// Remove previous cached data from disk
async function deleteOldCaches() {
for (const key of await caches.keys()) {
if (key !== CACHE) await caches.delete(key);
}
}
// Remove previous cached data from disk
async function deleteOldCaches() {
for (const key of await caches.keys()) {
if (key !== CACHE) await caches.delete(key);
}
}
event.waitUntil(deleteOldCaches());
let channel;
if(BroadcastChannel) {
channel = new BroadcastChannel('sw-messages');
channel.postMessage({title: 'Cache Downloaded'});
} else {
client.postMessage("Cache Downloaded")
}
event.waitUntil(deleteOldCaches());
let channel;
if (BroadcastChannel) {
channel = new BroadcastChannel('sw-messages');
channel.postMessage({ title: 'Cache Downloaded' });
} else {
client.postMessage('Cache Downloaded');
}
});
self.addEventListener('fetch', (event) => {
// ignore POST requests etc
if (event.request.method !== 'GET') return;
// ignore POST requests etc
if (event.request.method !== 'GET') return;
async function respond() {
const url = new URL(event.request.url);
const cache = await caches.open(CACHE);
async function respond() {
const url = new URL(event.request.url);
const cache = await caches.open(CACHE);
// `build`/`files` can always be served from the cache
if (ASSETS.includes(url.pathname)) {
return cache.match(url.pathname);
}
// `build`/`files` can always be served from the cache
if (ASSETS.includes(url.pathname)) {
return cache.match(url.pathname);
}
// for everything else, try the network first, but
// fall back to the cache if we're offline
try {
const response = await fetch(event.request);
// for everything else, try the network first, but
// fall back to the cache if we're offline
try {
const response = await fetch(event.request);
if (response.status === 200) {
cache.put(event.request, response.clone());
}
if (response.status === 200) {
cache.put(event.request, response.clone());
}
return response;
} catch {
return cache.match(event.request);
}
}
return response;
} catch {
return cache.match(event.request);
}
}
event.respondWith(respond());
event.respondWith(respond());
});

View file

@ -1,47 +1,46 @@
{
"id": "/",
"name": "PianelloExperience",
"short_name": "PianelloExperience",
"start_url": "/",
"display": "standalone",
"background_color": "#fff",
"description": "PianelloExperience",
"icons": [
{
"src": "images/app-icon-48x48.jpeg",
"sizes": "48x48",
"type": "image/jpeg"
},
{
"src": "images/app-icon-72x72.jpeg",
"sizes": "72x72",
"type": "image/jpeg"
},
{
"src": "images/app-icon-96x96.jpeg",
"sizes": "96x96",
"type": "image/jpeg"
},
{
"src": "images/app-icon-144x144.jpeg",
"sizes": "144x144",
"type": "image/jpeg"
},
{
"src": "images/app-icon-168x168.jpeg",
"sizes": "168x168",
"type": "image/jpeg"
},
{
"src": "images/app-icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "images/app-icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
"id": "/",
"name": "PianelloExperience",
"short_name": "PianelloExperience",
"start_url": "/",
"display": "standalone",
"background_color": "#fff",
"description": "PianelloExperience",
"icons": [
{
"src": "images/app-icon-48x48.jpeg",
"sizes": "48x48",
"type": "image/jpeg"
},
{
"src": "images/app-icon-72x72.jpeg",
"sizes": "72x72",
"type": "image/jpeg"
},
{
"src": "images/app-icon-96x96.jpeg",
"sizes": "96x96",
"type": "image/jpeg"
},
{
"src": "images/app-icon-144x144.jpeg",
"sizes": "144x144",
"type": "image/jpeg"
},
{
"src": "images/app-icon-168x168.jpeg",
"sizes": "168x168",
"type": "image/jpeg"
},
{
"src": "images/app-icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "images/app-icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

View file

@ -1,4 +1,4 @@
import adapter from "@sveltejs/adapter-node";
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
@ -6,17 +6,17 @@ const config = {
preprocess: vitePreprocess(),
kit: {
files: {
serviceWorker: 'src/sw.ts',
serviceWorker: 'src/sw.ts'
},
serviceWorker: {
register: false,
register: false
},
adapter: adapter({
fallback: null,
precompress: true,
strict: true
}),
},
})
}
};
export default config;

View file

@ -1,22 +1,20 @@
import { sveltekit } from '@sveltejs/kit/vite';
import adapter from "@sveltejs/adapter-node";
import adapter from '@sveltejs/adapter-node';
const config = {
plugins: [
sveltekit(),
],
test: {
include: ["src/**/*.{test,spec}.{js,ts}"],
},
build: {
minify: "esbuild",
target: "esnext",
},
kit: {
adapter: adapter({
precompress: false,
})
},
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
build: {
minify: 'esbuild',
target: 'esnext'
},
kit: {
adapter: adapter({
precompress: false
})
}
};
export default config;