feat(platform): filter dashboard by missing source
This commit is contained in:
@@ -29,6 +29,12 @@ const serviceStatusTitle: Record<string, string> = {
|
||||
identity_required: '身份未绑定'
|
||||
};
|
||||
|
||||
const missingProtocolTitle: Record<string, string> = {
|
||||
GB32960: '缺 GB32960',
|
||||
JT808: '缺 JT808',
|
||||
YUTONG_MQTT: '缺 YUTONG_MQTT'
|
||||
};
|
||||
|
||||
function formatLag(value?: number | null) {
|
||||
return value == null ? '未接入' : value.toLocaleString();
|
||||
}
|
||||
@@ -69,10 +75,15 @@ export function Dashboard({ onOpenVehicle, onOpenQuality, onOpenVehicles }: { on
|
||||
|
||||
const loadCoverage = (values?: Record<string, string>) => {
|
||||
setCoverageLoading(true);
|
||||
setCoverageServiceStatusTitle(values?.serviceStatus ? serviceStatusTitle[values.serviceStatus] ?? values.serviceStatus : '');
|
||||
const scopeTitle = [
|
||||
values?.serviceStatus ? serviceStatusTitle[values.serviceStatus] ?? values.serviceStatus : '',
|
||||
values?.missingProtocol ? missingProtocolTitle[values.missingProtocol] ?? `缺 ${values.missingProtocol}` : ''
|
||||
].filter(Boolean).join(' / ');
|
||||
setCoverageServiceStatusTitle(scopeTitle);
|
||||
const params = new URLSearchParams({ limit: '8' });
|
||||
if (values?.keyword) params.set('keyword', values.keyword);
|
||||
if (values?.coverage) params.set('coverage', values.coverage);
|
||||
if (values?.missingProtocol) params.set('missingProtocol', values.missingProtocol);
|
||||
if (values?.online) params.set('online', values.online);
|
||||
if (values?.bindingStatus) params.set('bindingStatus', values.bindingStatus);
|
||||
if (values?.serviceStatus) params.set('serviceStatus', values.serviceStatus);
|
||||
@@ -230,6 +241,11 @@ export function Dashboard({ onOpenVehicle, onOpenQuality, onOpenVehicles }: { on
|
||||
<Select.Option value="single">单源</Select.Option>
|
||||
<Select.Option value="multi">多源</Select.Option>
|
||||
</Form.Select>
|
||||
<Form.Select field="missingProtocol" label="缺失来源" placeholder="全部" style={{ width: 170 }} data-testid="dashboard-missing-protocol-filter">
|
||||
<Select.Option value="GB32960">缺 GB32960</Select.Option>
|
||||
<Select.Option value="JT808">缺 JT808</Select.Option>
|
||||
<Select.Option value="YUTONG_MQTT">缺 YUTONG_MQTT</Select.Option>
|
||||
</Form.Select>
|
||||
<Form.Select field="online" label="在线" placeholder="全部" style={{ width: 130 }}>
|
||||
<Select.Option value="online">在线</Select.Option>
|
||||
<Select.Option value="offline">离线</Select.Option>
|
||||
|
||||
@@ -755,6 +755,52 @@ test('filters dashboard coverage by service status', async () => {
|
||||
expect(screen.getByText('当前筛选:部分来源离线')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('filters dashboard coverage by missing source evidence', async () => {
|
||||
window.history.replaceState(null, '', '/#/dashboard');
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/dashboard/summary')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
onlineVehicles: 3,
|
||||
activeToday: 4,
|
||||
frameToday: 1286320,
|
||||
issueVehicles: 7,
|
||||
kafkaLag: 0,
|
||||
protocols: [],
|
||||
serviceStatuses: [],
|
||||
linkHealth: []
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { items: [], total: 0, limit: 8, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('车辆服务覆盖')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByTestId('dashboard-missing-protocol-filter'));
|
||||
fireEvent.click(await screen.findByText('缺 YUTONG_MQTT'));
|
||||
fireEvent.click(screen.getByRole('button', { name: '筛选' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('missingProtocol=YUTONG_MQTT'), undefined);
|
||||
});
|
||||
expect(screen.getByText('当前筛选:缺 YUTONG_MQTT')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('opens dashboard coverage from service status distribution', async () => {
|
||||
window.history.replaceState(null, '', '/#/dashboard');
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
|
||||
Reference in New Issue
Block a user