Creating a `<AllGpxes>` component.

This commit is contained in:
Eric van der Vlist 2022-11-27 14:32:21 +01:00
parent d0bc9422f3
commit 346b9a1186
5 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,33 @@
import {
Component,
createEffect,
createResource,
createSignal,
} from 'solid-js';
import OlMap from 'ol/Map';
import dispatch from '../../workers/dispatcher-main';
// import Gpx from './Gpx';
interface Props {
map: OlMap | null;
}
export const AllGpxes: Component<Props> = ({ map }) => {
const [allGpxes] = createResource(
async () =>
await dispatch({
action: 'getAllGpxes',
params: {},
})
);
createEffect(() => {
console.log({ caller: 'AllGpxes', allGpxes: allGpxes() });
});
return <></>;
};
export default AllGpxes;

View File

@ -0,0 +1 @@
export { default } from './AllGpxes';

View File

@ -22,6 +22,7 @@ import GetLocation, { getCurrentLocation } from '../get-location';
import ShowLocationIcon from '../get-location/ShowLocationIcon.svg'; import ShowLocationIcon from '../get-location/ShowLocationIcon.svg';
import { Back, Forward } from '../back-forward'; import { Back, Forward } from '../back-forward';
import GpxImport from '../gpx-import'; import GpxImport from '../gpx-import';
import AllGpxes from '../all-gpxes';
const [getState, setState] = createSignal({ const [getState, setState] = createSignal({
lon: 0, lon: 0,
@ -184,6 +185,7 @@ const Map: Component = () => {
<Forward /> <Forward />
<Back /> <Back />
<GpxImport /> <GpxImport />
<AllGpxes map={getMap()} />
</div> </div>
); );
}; };

View File

@ -186,6 +186,10 @@ export const pruneAndSaveImportedGpx = async (params: any) => {
} }
}; };
export const getAllGpxes = async () => {
return await getDocsByType('gpx');
};
export const getGpxesForViewport = async (params: any) => { export const getGpxesForViewport = async (params: any) => {
const { viewport, zoomLevel } = params; const { viewport, zoomLevel } = params;
const zoomedViewport: Rectangle = { const zoomedViewport: Rectangle = {

View File

@ -6,11 +6,12 @@ import {
pruneAndSaveImportedGpx, pruneAndSaveImportedGpx,
getGpxesForViewport, getGpxesForViewport,
getGpx, getGpx,
getAllGpxes,
} from '../db/gpx'; } from '../db/gpx';
import { getTrk, putNewTrk } from '../db/trk'; import { getTrk, putNewTrk } from '../db/trk';
import { getTrkseg } from '../db/trkseg'; import { getTrkseg } from '../db/trkseg';
const self = globalThis as unknown as WorkerGlobalScope; //const self = globalThis as unknown as WorkerGlobalScope;
const actions = { const actions = {
initDb, initDb,
@ -18,6 +19,7 @@ const actions = {
putNewTrk, putNewTrk,
existsGpx, existsGpx,
pruneAndSaveImportedGpx, pruneAndSaveImportedGpx,
getAllGpxes,
getGpxesForViewport, getGpxesForViewport,
getGpx, getGpx,
getTrk, getTrk,