Add live transmitter position (status) alongside logged points
devices/<serial>/log messages now carry a "type": "log" or "status". "log" persists a LocatePoint as before; "status" carries the same position + telemetry shape but is broadcast live over the job's realtime channel without touching locate_points — it's a current- position update, not a recorded point. The job map renders the latest status as a blue "you are here" marker (with a soft accuracy-radius halo) that moves in place as new updates arrive, separate from the colored polyline of logged points. Clicking it shows the same detail readout as a logged point. The simulator gained a message-type toggle (Log point / Status update) so both paths can be exercised from /sim. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import { useRouter } from 'next/router';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import Layout from '../../components/Layout';
|
||||
import JobMap from '../../components/map/JobMap';
|
||||
import { pointSummary, type MapPoint } from '../../components/map/types';
|
||||
import { pointSummary, type LiveStatus, type MapPoint } from '../../components/map/types';
|
||||
import { api } from '../../lib/api';
|
||||
import { useRequireAuth } from '../../lib/auth-context';
|
||||
import { useJobStream } from '../../lib/use-job-stream';
|
||||
@@ -32,6 +32,7 @@ export default function JobDetailPage() {
|
||||
const [job, setJob] = useState<JobDetail | null>(null);
|
||||
const [points, setPoints] = useState<MapPoint[]>([]);
|
||||
const [live, setLive] = useState(0);
|
||||
const [liveStatus, setLiveStatus] = useState<LiveStatus | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -57,7 +58,9 @@ export default function JobDetailPage() {
|
||||
setLive((n) => n + incoming.length);
|
||||
}, []);
|
||||
|
||||
useJobStream(jobId, onLivePoints);
|
||||
const onStatus = useCallback((status: LiveStatus) => setLiveStatus(status), []);
|
||||
|
||||
useJobStream(jobId, onLivePoints, onStatus);
|
||||
|
||||
const updateStatus = async (status: string) => {
|
||||
if (!orgId || !jobId) {
|
||||
@@ -108,9 +111,14 @@ export default function JobDetailPage() {
|
||||
{points.length > 0 && (
|
||||
<span style={{ color: '#777' }}>latest: {pointSummary(points[points.length - 1])}</span>
|
||||
)}
|
||||
{liveStatus && (
|
||||
<span style={{ color: '#1a73e8' }}>
|
||||
● transmitter {liveStatus.serial} live ({new Date(liveStatus.recordedAt).toLocaleTimeString()})
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<JobMap points={points} heightPx={520} />
|
||||
<JobMap points={points} liveStatus={liveStatus} heightPx={520} />
|
||||
</>
|
||||
)}
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user