feat(platform): add vehicle data management console
This commit is contained in:
55
vehicle-data-platform/apps/web/src/pages/VehicleDetail.tsx
Normal file
55
vehicle-data-platform/apps/web/src/pages/VehicleDetail.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
import { Card, Descriptions, Table, Tabs, Toast } from '@douyinfe/semi-ui';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { api } from '../api/client';
|
||||
import type { RawFrameRow, RealtimeLocationRow } from '../api/types';
|
||||
import { PageHeader } from '../components/PageHeader';
|
||||
|
||||
export function VehicleDetail() {
|
||||
const [latest, setLatest] = useState<RealtimeLocationRow | null>(null);
|
||||
const [raw, setRaw] = useState<RawFrameRow | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const params = new URLSearchParams({ vin: 'LB9A32A24R0LS1426', limit: '1' });
|
||||
api.realtimeLocations(params)
|
||||
.then((page) => setLatest(page.items[0] ?? null))
|
||||
.catch((error: Error) => Toast.error(error.message));
|
||||
params.set('includeFields', 'true');
|
||||
api.rawFrames(params)
|
||||
.then((page) => setRaw(page.items[0] ?? null))
|
||||
.catch((error: Error) => Toast.error(error.message));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="vp-page">
|
||||
<PageHeader title="车辆详情" description="单车身份、实时、历史、RAW、里程和质量的综合视图" />
|
||||
<Card bordered>
|
||||
<Descriptions row data={[
|
||||
{ key: 'VIN', value: latest?.vin ?? 'LB9A32A24R0LS1426' },
|
||||
{ key: '车牌', value: latest?.plate ?? '-' },
|
||||
{ key: '协议', value: latest?.protocol ?? '-' },
|
||||
{ key: '最后时间', value: latest?.lastSeen ?? '-' }
|
||||
]} />
|
||||
</Card>
|
||||
<Card bordered style={{ marginTop: 16 }}>
|
||||
<Tabs>
|
||||
<Tabs.TabPane tab="最新状态" itemKey="latest">
|
||||
<Table
|
||||
pagination={false}
|
||||
dataSource={latest ? [latest] : []}
|
||||
columns={[
|
||||
{ title: '经度', dataIndex: 'longitude' },
|
||||
{ title: '纬度', dataIndex: 'latitude' },
|
||||
{ title: '速度', dataIndex: 'speedKmh' },
|
||||
{ title: 'SOC', dataIndex: 'socPercent' },
|
||||
{ title: '总里程', dataIndex: 'totalMileageKm' }
|
||||
]}
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="RAW 字段" itemKey="raw">
|
||||
<pre className="vp-json">{JSON.stringify(raw?.parsedFields ?? {}, null, 2)}</pre>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user