From fd70f95224374d23157ee7c0357733102cd0df53 Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Sun, 18 Aug 2024 13:29:54 +0300 Subject: initial --- web/app/App.jsx | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/app/index.jsx | 7 ++++ 2 files changed, 104 insertions(+) create mode 100644 web/app/App.jsx create mode 100644 web/app/index.jsx (limited to 'web/app') diff --git a/web/app/App.jsx b/web/app/App.jsx new file mode 100644 index 0000000..a31545e --- /dev/null +++ b/web/app/App.jsx @@ -0,0 +1,97 @@ +import React, { useState, useEffect } from "react" +import { Map, Marker, GeoJson, ZoomControl } from "pigeon-maps" +import useLocalState from "@phntms/use-local-state"; +import moment from "moment"; +import 'moment/min/locales'; + +export default () => { + moment.locale('ru'); + const [point, setPoint] = useState({ + "id": "", + "user_id": "", + "lat": 0, + "lon": 0, + "time": "2024-08-15T09:54:00.666Z", + "speed": 0, + "direction": 0, + "accuracy": 0, + }); + const [selected, setSelected] = useState(null) + const [points, setPoints] = useState([]) + const [loaded, setLoaded] = useState(false); + const [zoom, setZoom] = useLocalState("zoom", 5); + const [center, setCenter] = useState([]) + const [page, setPage] = useState(0) + const updatePosition = () => { + fetch("/api/points/last").then(x => x.json()).then((p) => { + setPoint(p); + setCenter([point.lat, point.lon]) + setLoaded(true); + }) + fetch("/api/points").then(x => x.json()).then(p => { + setPoints(p.reverse()) + }) + } + useEffect(updatePosition, []) + if (!loaded) { + return

Загрузка карты

+ } + const path = { + type: "FeatureCollection", + features: [ + { + type: "Feature", + geometry: { + type: "LineString", + coordinates: points.map((pp) => [pp.lon, pp.lat]), + }, + properties: { prop0: "value0" }, + }, + ], + }; + + return ( +
+
+ {setZoom(zoom); setCenter(center)}}> + + { + return { strokeWidth: "2", stroke: "red" }; + }} + /> + + {selected ? ():null} + +
+
+
Дата последней точки: {moment(point.time).format("LTS L")}
+
Точность: {point.accuracy.toFixed(2)}м
+
+ + +
+
История перемещения:
+ + + +
+
+ ) +} \ No newline at end of file diff --git a/web/app/index.jsx b/web/app/index.jsx new file mode 100644 index 0000000..a357551 --- /dev/null +++ b/web/app/index.jsx @@ -0,0 +1,7 @@ +import { createRoot } from 'react-dom/client'; +import React from 'react' +import App from './App' + +const contentRoot = document.getElementById('app'); +const contentReactRoot = createRoot(contentRoot); +contentReactRoot.render(); \ No newline at end of file -- cgit v1.2.3