local conversion

This commit is contained in:
Davide Scaini
2026-04-06 22:25:57 +02:00
parent b633d72258
commit 5bf0f3636c
11 changed files with 426 additions and 28 deletions
+3 -3
View File
@@ -7,6 +7,7 @@
import ActivityMap from './ActivityMap.svelte';
import ActivityCharts from './ActivityCharts.svelte';
import EditDrawer from './EditDrawer.svelte';
import { loadActivity } from '../lib/dataloader';
export let activity: ActivitySummary;
export let base: string = '/';
@@ -28,9 +29,8 @@
onMount(async () => {
if (!activity.detail_url) return;
try {
const res = await fetch(`${base}data/${activity.detail_url}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
detail = await res.json();
detail = await loadActivity(activity.id, activity.detail_url, base);
if (!detail) throw new Error('Activity not found');
} catch (e: any) {
error = e.message;
}
+2 -3
View File
@@ -2,6 +2,7 @@
import { onMount } from 'svelte';
import type { ActivitySummary, BASIndex, Sport } from '../lib/types';
import { formatDistance, formatDuration, formatElevation, formatDate, sportIcon, sportColor, sportLabel } from '../lib/format';
import { loadIndex } from '../lib/dataloader';
/** Render preview_coords as an SVG polyline path string. */
function trackPath(coords: [number, number][] | null, w: number, h: number): string {
@@ -53,9 +54,7 @@
sport = (new URLSearchParams(window.location.search).get('sport') as Sport | 'all') ?? 'all';
mounted = true;
try {
const res = await fetch(`${import.meta.env.BASE_URL}data/index.json`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const index: BASIndex = await res.json();
const index = await loadIndex(import.meta.env.BASE_URL);
all = index.activities.filter(a => a.privacy !== 'private');
} catch (e: any) {
error = e.message;
+6 -6
View File
@@ -4,6 +4,7 @@
import MmpChart from './MmpChart.svelte';
import RecordsView from './RecordsView.svelte';
import AthleteDrawer from './AthleteDrawer.svelte';
import { loadIndex, loadAthlete } from '../lib/dataloader';
export let base: string = '/';
@@ -32,13 +33,12 @@
activeTab = TABS.includes(rawTab as Tab) ? (rawTab as Tab) : 'power';
mounted = true;
try {
const [athleteRes, indexRes] = await Promise.all([
fetch(`${import.meta.env.BASE_URL}data/athlete.json`),
fetch(`${import.meta.env.BASE_URL}data/index.json`),
const [athleteData, index] = await Promise.all([
loadAthlete(import.meta.env.BASE_URL),
loadIndex(import.meta.env.BASE_URL),
]);
if (!athleteRes.ok) throw new Error('athlete.json not found — run bincio extract first');
athlete = await athleteRes.json();
const index: BASIndex = await indexRes.json();
if (!athleteData) throw new Error('athlete.json not found — run bincio extract first');
athlete = athleteData;
activities = index.activities.filter(a => a.mmp && a.privacy !== 'private');
} catch (e: any) {
error = e.message;
+2 -3
View File
@@ -2,6 +2,7 @@
import { onMount } from 'svelte';
import type { ActivitySummary, BASIndex, Sport } from '../lib/types';
import { formatDistance, formatDuration, sportIcon, sportColor, sportLabel } from '../lib/format';
import { loadIndex } from '../lib/dataloader';
const PAGE_YEARS = 4;
@@ -30,9 +31,7 @@
page = parseInt(params.get('page') ?? '0', 10) || 0;
mounted = true;
try {
const res = await fetch(`${import.meta.env.BASE_URL}data/index.json`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const index: BASIndex = await res.json();
const index = await loadIndex(import.meta.env.BASE_URL);
all = index.activities.filter(a => a.privacy !== 'private' && a.distance_m);
} catch (e: any) {
error = e.message;