This commit is contained in:
Eric van der Vlist 2023-02-03 11:59:40 +01:00
parent ccbcd12f96
commit 5658cc0556
6 changed files with 52 additions and 36 deletions

View File

@ -79,20 +79,6 @@ const GpxImportSingleFile: Component<Props> = ({ gpxFile }) => {
const doImport = async () => { const doImport = async () => {
setState('importing'); setState('importing');
// for (const file of event.target.files) {
// const fileReader = new FileReader();
// fileReader.readAsText(file);
// fileReader.addEventListener(
// 'load',
// async () => {
// // this will then display a text file
// console.log({
// caller: 'GpxImport / XML',
// file,
// result: fileReader.result,
// });
// const gpx = GPX.parse(fileReader.result);
// console.log({ caller: 'GpxImport / JSON', file, gpx }); // console.log({ caller: 'GpxImport / JSON', file, gpx });
// if (gpx) { // if (gpx) {
// const startTime = new Date(findStartTime(gpx)!); // const startTime = new Date(findStartTime(gpx)!);
@ -167,25 +153,6 @@ const GpxImportSingleFile: Component<Props> = ({ gpxFile }) => {
<Show when={statsAndGpx().stats.trkMaybeRte}> <Show when={statsAndGpx().stats.trkMaybeRte}>
<Typography variant='body1'>{t('trkMaybeRte')}</Typography> <Typography variant='body1'>{t('trkMaybeRte')}</Typography>
</Show> </Show>
{/* <Show when={statsAndGpx().stats.nbTrks > 0}>
<FormControl fullWidth>
<FormLabel>{t('importTrk')}</FormLabel>
<RadioGroup>
<FormControlLabel
control={<Radio color='success' />}
{...controlTrkTransformProps('importNonTimedTrksAsRtes')}
/>
<FormControlLabel
control={<Radio color='secondary' />}
{...controlTrkTransformProps('importAllTrksAsRtes')}
/>
<FormControlLabel
control={<Radio color='error' />}
{...controlTrkTransformProps('importTrksAsTrks')}
/>
</RadioGroup>
</FormControl>
</Show> */}
<Show when={state() === 'importing'}> <Show when={state() === 'importing'}>
<LinearProgress /> <LinearProgress />
</Show> </Show>

View File

@ -276,7 +276,13 @@ export const pruneAndSaveImportedGpx = async (params: any) => {
]; ];
} else { } else {
gpxId = getUri('gpx', id); gpxId = getUri('gpx', id);
previousGpx = (await getGpx(id)) ?? null; previousGpx = (await getGpx({ id })) ?? null;
console.log({
caller: 'pruneAndSaveImportedGpx / previousGpx',
id,
previousGpx,
gpxId,
});
} }
prune(gpxId, gpx, previousGpx, extensions, docs); prune(gpxId, gpx, previousGpx, extensions, docs);
console.log({ caller: 'pruneAndSaveImportedGpx / pruned', docs }); console.log({ caller: 'pruneAndSaveImportedGpx / pruned', docs });
@ -375,6 +381,14 @@ export const getGpx = async (params: any) => {
// level 0 // level 0
if (row.doc.type === 'gpx') { if (row.doc.type === 'gpx') {
if (!!gpx) { if (!!gpx) {
console.error({
caller: 'getGpx',
id,
row,
target,
gpx,
});
return false; // Hack to stop if getFamily fails return false; // Hack to stop if getFamily fails
} }
target = [row.doc.doc]; target = [row.doc.doc];

View File

@ -44,11 +44,23 @@ export const getFamily = async (
local: boolean = false local: boolean = false
) => { ) => {
const targetDb = local ? localDb : db; const targetDb = local ? localDb : db;
return await targetDb.allDocs({ const endkey = `${key}\ufff0`;
const allDocs = await targetDb.allDocs({
startkey: key, startkey: key,
endkey: `${key}\ufff0`, endkey,
...options, ...options,
}); });
if (allDocs.rows.at(-1).id > endkey) {
console.error({
caller: 'getFamilly',
key,
endkey,
options,
local,
allDocs,
});
}
return allDocs;
}; };
export const get = async (id: string, local: boolean = false) => { export const get = async (id: string, local: boolean = false) => {

View File

@ -41,6 +41,13 @@ export const getRte = async (params: any) => {
// level 0 // level 0
if (row.doc.type === 'rte') { if (row.doc.type === 'rte') {
if (!!rte) { if (!!rte) {
console.error({
caller: 'getRte',
id,
row,
target,
rte,
});
return false; // Hack to stop if getFamily fails return false; // Hack to stop if getFamily fails
} }
target = [row.doc.doc]; target = [row.doc.doc];

View File

@ -41,6 +41,14 @@ export const getTrk = async (params: any) => {
// level 0 // level 0
if (row.doc.type === 'trk') { if (row.doc.type === 'trk') {
if (!!trk) { if (!!trk) {
console.error({
caller: 'getTrk',
id,
row,
target,
trk,
});
return false; // Hack to stop if getFamily fails return false; // Hack to stop if getFamily fails
} }
target = [row.doc.doc]; target = [row.doc.doc];

View File

@ -36,6 +36,14 @@ export const getTrkseg = async (params: any) => {
// level 0 // level 0
if (row.doc.type === 'trkseg') { if (row.doc.type === 'trkseg') {
if (!!trkseg) { if (!!trkseg) {
console.error({
caller: 'getTrkseg',
id,
row,
target,
trkseg,
});
return false; // Hack to stop if getFamily fails return false; // Hack to stop if getFamily fails
} }
target = [row.doc.doc]; target = [row.doc.doc];