feat(platform): harden telemetry pipeline and unify Semi UI workspaces
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { MonitorViewport } from '../hooks/useMonitorData';
|
||||
import { normalizeMonitorBounds } from '../domain/monitor';
|
||||
|
||||
export const MONITOR_RETURN_PARAM = 'monitorReturn';
|
||||
|
||||
@@ -38,19 +39,10 @@ function decimal(value: string | null, fallback: number, minimum: number, maximu
|
||||
return Number.isFinite(parsed) && parsed >= minimum && parsed <= maximum ? parsed : fallback;
|
||||
}
|
||||
|
||||
function validBounds(value: string | null) {
|
||||
if (!value) return '';
|
||||
const coordinates = value.split(',').map(Number);
|
||||
if (coordinates.length !== 4 || coordinates.some((coordinate) => !Number.isFinite(coordinate))) return '';
|
||||
const [west, south, east, north] = coordinates;
|
||||
if (west < -180 || east > 180 || south < -90 || north > 90 || west >= east || south >= north) return '';
|
||||
return coordinates.map((coordinate) => coordinate.toFixed(6)).join(',');
|
||||
}
|
||||
|
||||
export function parseMonitorRouteContext(search: string | URLSearchParams): MonitorRouteContext {
|
||||
const params = typeof search === 'string' ? new URLSearchParams(search) : search;
|
||||
const selectedVin = params.get('selectedVin')?.trim().toUpperCase() ?? '';
|
||||
const bounds = validBounds(params.get('bounds'));
|
||||
const bounds = normalizeMonitorBounds(params.get('bounds'));
|
||||
const hasViewport = params.has('zoom') || Boolean(bounds);
|
||||
return {
|
||||
mode: params.get('mode') === 'list' ? 'list' : 'map',
|
||||
@@ -80,7 +72,8 @@ export function buildMonitorPath(context: Omit<MonitorRouteContext, 'hasViewport
|
||||
params.set('detail', context.detailOpen ? 'open' : 'collapsed');
|
||||
}
|
||||
params.set('zoom', String(Math.round(context.viewport.zoom * 100) / 100));
|
||||
if (validBounds(context.viewport.bounds)) params.set('bounds', validBounds(context.viewport.bounds));
|
||||
const bounds = normalizeMonitorBounds(context.viewport.bounds);
|
||||
if (bounds) params.set('bounds', bounds);
|
||||
if (context.listOffset) params.set('listOffset', String(context.listOffset));
|
||||
if (context.listLimit !== 50) params.set('listLimit', String(context.listLimit));
|
||||
const query = params.toString();
|
||||
|
||||
Reference in New Issue
Block a user