CI / changes (push) Successful in 10s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Successful in 54s
CI / go (push) Successful in 1m3s
CI / bird2 (push) Successful in 20s
CI / release (push) Successful in 4m29s
Updated the Settings and Auth components to include better navigation handling by adding search parameters for tab selection. Enhanced the Access component to utilize badges for status indicators, improving visual clarity. Refactored the Schedule component to streamline job status display with badges, ensuring a more cohesive user experience. Additionally, integrated client directives in UI components for better performance.
93 lines
2.8 KiB
TypeScript
93 lines
2.8 KiB
TypeScript
import { Clock, Gauge, Globe, Tags } from 'lucide-react'
|
|
|
|
import { KpiStatGrid, type KpiStatItem } from '@/components/kpi-stat-grid'
|
|
import { Badge } from '@/components/reui/badge'
|
|
import { formatDateTime, moduleIntervalLabel } from '@/lib/modules/display'
|
|
import {
|
|
communityLabel,
|
|
dohProfileLabel,
|
|
moduleDohProfileIds,
|
|
} from '@/lib/modules/helpers'
|
|
import { dohPolicyRu } from '@/lib/ui-labels'
|
|
import { KpiStatGridSkeleton } from '@/components/skeletons'
|
|
import type { AsEntry, BgpCommunity, DohProfile, ModuleRow } from '@/types/api'
|
|
|
|
interface ModuleKpiCardsProps {
|
|
mod: ModuleRow | null
|
|
communities: BgpCommunity[]
|
|
dohProfiles: DohProfile[]
|
|
asEntries: AsEntry[]
|
|
loading?: boolean
|
|
}
|
|
|
|
export function ModuleKpiCards({
|
|
mod,
|
|
communities,
|
|
dohProfiles,
|
|
asEntries,
|
|
loading = false,
|
|
}: ModuleKpiCardsProps) {
|
|
if (loading || !mod) {
|
|
return <KpiStatGridSkeleton count={4} />
|
|
}
|
|
|
|
const asPrefixTotal = asEntries.reduce((acc, entry) => acc + (entry.prefix_count ?? 0), 0)
|
|
const dohIds = moduleDohProfileIds(mod)
|
|
|
|
const items: KpiStatItem[] = [
|
|
{
|
|
id: 'priority',
|
|
icon: <Gauge aria-hidden />,
|
|
iconClassName: 'text-info',
|
|
value: String(mod.priority ?? 0),
|
|
label: 'Приоритет',
|
|
footer: (
|
|
<Badge variant={mod.enabled !== false ? 'success-light' : 'outline'} size="sm">
|
|
{mod.enabled !== false ? 'активен' : 'выключен'} · {mod.type}
|
|
</Badge>
|
|
),
|
|
},
|
|
{
|
|
id: 'interval',
|
|
icon: <Clock aria-hidden />,
|
|
iconClassName: 'text-warning',
|
|
value: moduleIntervalLabel(mod),
|
|
label: 'Интервал обновления',
|
|
footer: (
|
|
<Badge variant="primary-light" size="sm">
|
|
{formatDateTime(mod.last_refreshed_at) || 'никогда'}
|
|
</Badge>
|
|
),
|
|
},
|
|
{
|
|
id: 'prefixes',
|
|
icon: <Tags aria-hidden />,
|
|
iconClassName: 'text-success',
|
|
value: mod.type === 'AS_PREFIXES' ? String(asPrefixTotal) : String(asEntries.length),
|
|
label: mod.type === 'AS_PREFIXES' ? 'Префиксы AS' : 'Записи модуля',
|
|
footer: (
|
|
<Badge variant="success-light" size="sm">
|
|
{asEntries.length} AS · в модуле
|
|
</Badge>
|
|
),
|
|
},
|
|
{
|
|
id: 'policy',
|
|
icon: <Globe aria-hidden />,
|
|
iconClassName: 'text-primary',
|
|
value: dohIds.length > 0 ? String(dohIds.length) : '—',
|
|
label: communityLabel(mod.default_community_id, communities),
|
|
footer: (
|
|
<Badge variant="info-light" size="sm">
|
|
{dohPolicyRu(mod.doh_resolver_policy)}
|
|
{dohIds.length > 0
|
|
? ` · ${dohIds.map((id) => dohProfileLabel(id, dohProfiles)).join(', ')}`
|
|
: ' · без DoH'}
|
|
</Badge>
|
|
),
|
|
},
|
|
]
|
|
|
|
return <KpiStatGrid items={items} aria-label="KPI модуля" />
|
|
}
|