feat(platform-web): show dashboard row service status
This commit is contained in:
@@ -23,6 +23,22 @@ function formatLag(value?: number | null) {
|
||||
return value == null ? '未接入' : value.toLocaleString();
|
||||
}
|
||||
|
||||
function rowServiceStatus(row: { serviceStatus?: { title: string; severity: string }; onlineSourceCount: number; sourceCount: number }) {
|
||||
if (row.serviceStatus) {
|
||||
return {
|
||||
label: row.serviceStatus.title,
|
||||
color: row.serviceStatus.severity === 'ok' ? 'green' as const : row.serviceStatus.severity === 'error' ? 'red' as const : 'orange' as const
|
||||
};
|
||||
}
|
||||
if (row.onlineSourceCount <= 0) {
|
||||
return { label: '车辆离线', color: 'red' as const };
|
||||
}
|
||||
if (row.onlineSourceCount < row.sourceCount) {
|
||||
return { label: '部分来源离线', color: 'orange' as const };
|
||||
}
|
||||
return { label: '服务正常', color: 'green' as const };
|
||||
}
|
||||
|
||||
export function Dashboard({ onOpenVehicle, onOpenQuality }: { onOpenVehicle: (vin: string) => void; onOpenQuality: () => void }) {
|
||||
const [summary, setSummary] = useState<DashboardSummary | null>(null);
|
||||
const [coverage, setCoverage] = useState<VehicleCoverageRow[]>([]);
|
||||
@@ -204,6 +220,14 @@ export function Dashboard({ onOpenVehicle, onOpenQuality }: { onOpenVehicle: (vi
|
||||
width: 110,
|
||||
render: (_: unknown, row: VehicleCoverageRow) => `${row.onlineSourceCount}/${row.sourceCount}`
|
||||
},
|
||||
{
|
||||
title: '服务状态',
|
||||
width: 130,
|
||||
render: (_: unknown, row: VehicleCoverageRow) => {
|
||||
const status = rowServiceStatus(row);
|
||||
return <Tag color={status.color}>{status.label}</Tag>;
|
||||
}
|
||||
},
|
||||
{ title: '在线', width: 90, render: (_: unknown, row: VehicleCoverageRow) => <StatusTag status={row.online ? 'ok' : 'offline'} /> },
|
||||
{ title: '绑定', width: 90, render: (_: unknown, row: VehicleCoverageRow) => <Tag color={row.bindingStatus === 'bound' ? 'green' : 'orange'}>{row.bindingStatus === 'bound' ? '已绑定' : '未绑定'}</Tag> },
|
||||
{ title: '最后时间', dataIndex: 'lastSeen', width: 170 },
|
||||
@@ -243,6 +267,13 @@ export function Dashboard({ onOpenVehicle, onOpenQuality }: { onOpenVehicle: (vi
|
||||
</Space>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: '服务状态',
|
||||
render: (_: unknown, row: VehicleRealtimeRow) => {
|
||||
const status = rowServiceStatus(row);
|
||||
return <Tag color={status.color}>{status.label}</Tag>;
|
||||
}
|
||||
},
|
||||
{ title: '最后时间', dataIndex: 'lastSeen' },
|
||||
{ title: '操作', width: 110, render: (_: unknown, row: VehicleRealtimeRow) => <Button onClick={() => onOpenVehicle(row.vin)}>车辆服务</Button> }
|
||||
]}
|
||||
|
||||
Reference in New Issue
Block a user