Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions daili/src/features/security/pages/SecurityBatchesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FunnelStepper } from '../../../components/security/FunnelStepper';
import { Badge } from '../../../components/ui/Badge';
import { ErrorState } from '../../../components/ui/ErrorState';
import { LoadingState } from '../../../components/ui/LoadingState';
import { EXECUTION_STATUS_LABELS, RISK_LEVEL_LABELS, SCAN_OUTCOME_LABELS } from '../../../types/labels';
import { BATCH_STATUS_LABELS,EXECUTION_STATUS_LABELS, RISK_LEVEL_LABELS, SCAN_OUTCOME_LABELS } from '../../../types/labels';
import { SecurityBatchDetail, SecurityBatchSummary } from '../../../types';

const PAGE_LIMIT = 20;
Expand Down Expand Up @@ -89,7 +89,7 @@ export function SecurityBatchesPage() {
<ChevronRight className="h-4 w-4 shrink-0 text-zinc-400" />
</div>
<div className="mt-2 flex flex-wrap gap-2">
<Badge>{batch.status}</Badge>
<Badge tone={batchStatusTone(batch.status)}>{BATCH_STATUS_LABELS[batch.status] ?? batch.status}</Badge>
<Badge tone="neutral">{batch.maxScanDepth ?? 'basic'}</Badge>
</div>
<div className="mt-2 text-xs text-zinc-500">目标 {batch.targetProxyCount},已检 {batch.checkedProxyCount},异常 {batch.anomalyEventCount}</div>
Expand All @@ -108,7 +108,7 @@ export function SecurityBatchesPage() {
<h2 className="text-lg font-bold">批次详情</h2>
<p className="mt-1 font-mono text-xs text-zinc-500">{detail.batch.batchId}</p>
</div>
<Badge>{detail.batch.status}</Badge>
<Badge tone={batchStatusTone(detail.batch.status)}>{BATCH_STATUS_LABELS[detail.batch.status] ?? detail.batch.status}</Badge>
</div>
<div className="mt-4 grid gap-3 md:grid-cols-4">
<Metric label="目标代理" value={detail.batch.targetProxyCount} />
Expand Down Expand Up @@ -152,6 +152,24 @@ export function SecurityBatchesPage() {
);
}

function batchStatusTone(status: string) {
switch (status) {
case 'completed':
return 'success';
case 'running':
return 'info';
case 'pending':
return 'warning';
case 'failed':
case 'error':
return 'danger';
case 'cancelled':
return 'neutral';
default:
return 'neutral';
}
}

function Metric({ label, value }: { label: string; value: number }) {
return <div className="rounded-lg border border-zinc-200 bg-zinc-50 p-3"><div className="text-xs text-zinc-500">{label}</div><div className="mt-1 text-2xl font-bold">{value}</div></div>;
}
9 changes: 9 additions & 0 deletions daili/src/types/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export const EXECUTION_STATUS_LABELS: Record<ExecutionStatus, string> = {
timeout: '超时',
};

export const BATCH_STATUS_LABELS: Record<string, string> = {
pending: '等待中',
running: '执行中',
completed: '已完成',
failed: '执行失败',
error: '执行错误',
cancelled: '已取消',
};

export const APPLICABILITY_LABELS: Record<Applicability, string> = {
applicable: '适用',
not_applicable: '不适用',
Expand Down