First version of the new importer (stiil needs to convert non timed tracks into routes).
This commit is contained in:
1 parent
102a2feddc
commit
90fb0e6944
4 files changed
+194
-138
No files matched your search
@@ -21,50 +21,6 @@ const GpxImport: Component = () => {
|
||||
files: event.target.files,
|
||||
});
|
||||
setFilesToImport(event.target.files);
|
||||
// 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 });
|
||||
// if (gpx) {
|
||||
// const startTime = new Date(findStartTime(gpx)!);
|
||||
// await dispatch({
|
||||
// action: 'pruneAndSaveImportedGpx',
|
||||
// params: {
|
||||
// id: { gpx: intToGpxId(startTime.valueOf()) },
|
||||
// gpx: gpx,
|
||||
// tech: {
|
||||
// lastModified: new Date(file.lastModified).toISOString(),
|
||||
// importDate: new Date().toISOString(),
|
||||
// name: file.name,
|
||||
// size: file.size,
|
||||
// type: file.type,
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// console.log({ caller: 'GpxImport / JSON / done', file, gpx });
|
||||
// } else {
|
||||
// console.error({
|
||||
// message: "can't parse GPX file",
|
||||
// file,
|
||||
// xml: fileReader.result,
|
||||
// });
|
||||
// }
|
||||
// // TODO: error handling
|
||||
// },
|
||||
// false
|
||||
// );
|
||||
// }
|
||||
};
|
||||
|
||||
const handleClose = (event: any, reason?: string) => {
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
import { Component, createEffect, createSignal, Show } from 'solid-js';
|
||||
import { findStartTime } from '../../lib/gpx';
|
||||
import GPX from '../../lib/gpx-parser-builder/src/gpx';
|
||||
import dispatch from '../../workers/dispatcher-main';
|
||||
import GpxChooser from '../gpx-chooser';
|
||||
import { currentGpxId } from '../gpx-dialog';
|
||||
|
||||
@@ -76,8 +77,58 @@ const GpxImportSingleFile: Component<Props> = ({ gpxFile }) => {
|
||||
false
|
||||
);
|
||||
|
||||
const doImport = () => {
|
||||
const doImport = async () => {
|
||||
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 });
|
||||
// if (gpx) {
|
||||
// const startTime = new Date(findStartTime(gpx)!);
|
||||
await dispatch({
|
||||
action: 'pruneAndSaveImportedGpx',
|
||||
params: {
|
||||
id: gpxId(),
|
||||
gpx: statsAndGpx()?.gpx,
|
||||
tech: {
|
||||
lastModified: new Date(gpxFile.lastModified).toISOString(),
|
||||
importDate: new Date().toISOString(),
|
||||
name: gpxFile.name,
|
||||
size: gpxFile.size,
|
||||
type: gpxFile.type,
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log({
|
||||
caller: 'GpxImport / JSON / done',
|
||||
gpxFile,
|
||||
gpx: statsAndGpx()?.gpx,
|
||||
});
|
||||
setState('done');
|
||||
|
||||
// } else {
|
||||
// console.error({
|
||||
// message: "can't parse GPX file",
|
||||
// file,
|
||||
// xml: fileReader.result,
|
||||
// });
|
||||
// }
|
||||
// // TODO: error handling
|
||||
// },
|
||||
// false
|
||||
// );
|
||||
// }
|
||||
};
|
||||
|
||||
const [selectedTrkTransform, setSelectedTrkTransform] = createSignal(
|
||||
@@ -139,7 +190,11 @@ const GpxImportSingleFile: Component<Props> = ({ gpxFile }) => {
|
||||
<LinearProgress />
|
||||
</Show>
|
||||
<CardActions>
|
||||
<GpxChooser gpxId={gpxId} setGpxId={setGpxId} disabled={state() != 'init'} />
|
||||
<GpxChooser
|
||||
gpxId={gpxId}
|
||||
setGpxId={setGpxId}
|
||||
disabled={state() != 'init'}
|
||||
/>
|
||||
<Button
|
||||
variant='contained'
|
||||
disabled={state() != 'init'}
|
||||
|
||||
Reference in new issue
Block a user