CI / changes (push) Successful in 11s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Successful in 49s
CI / go (push) Successful in 1m2s
CI / bird2 (push) Successful in 16s
CI / release (push) Successful in 3m57s
Added the AnalyticsDashboardSkeleton component to improve loading states in the dashboard and monitoring pages. Refactored the dashboard to utilize the new skeleton for initial loading, replacing the previous SectionCardsSkeleton. Updated the overview queries to increase job limit from 10 to 100 for better data handling. Enhanced the network and operations components to incorporate new analytics cards, streamlining the user experience and improving data presentation.
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { useMemo, useState } from 'react'
|
|
|
|
import { AnalyticsCardShell } from '@/components/analytics/analytics-card-shell'
|
|
import { AnalyticsSegmentControl } from '@/components/analytics/analytics-segment-control'
|
|
import { ChartDonutMetric } from '@/components/analytics/chart-donut-metric'
|
|
import { jobStatusBreakdown, moduleTypeBreakdown } from '@/lib/metrics'
|
|
import type { JobRow, ModuleRow } from '@/types/api'
|
|
|
|
type FlowMode = 'jobs' | 'modules'
|
|
|
|
export function DashboardOperationsFlowCard({
|
|
jobs,
|
|
modules,
|
|
loading,
|
|
}: {
|
|
jobs: JobRow[]
|
|
modules: ModuleRow[]
|
|
loading?: boolean
|
|
}) {
|
|
const [mode, setMode] = useState<FlowMode>('jobs')
|
|
|
|
const slices = useMemo(
|
|
() => (mode === 'jobs' ? jobStatusBreakdown(jobs) : moduleTypeBreakdown(modules)),
|
|
[mode, jobs, modules],
|
|
)
|
|
|
|
const total = slices.reduce((sum, slice) => sum + slice.count, 0)
|
|
const centerLabel = mode === 'jobs' ? 'Задачи' : 'Модули'
|
|
|
|
return (
|
|
<AnalyticsCardShell
|
|
title="Поток операций"
|
|
description="Распределение фоновых задач и типов модулей"
|
|
info="Donut строится по текущей выборке API (до 100 последних задач)."
|
|
actions={
|
|
<AnalyticsSegmentControl
|
|
value={mode}
|
|
onChange={setMode}
|
|
options={[
|
|
{ value: 'jobs', label: 'Задачи' },
|
|
{ value: 'modules', label: 'Модули' },
|
|
]}
|
|
/>
|
|
}
|
|
>
|
|
{loading ? (
|
|
<div className="flex h-48 items-center justify-center text-sm text-muted-foreground">
|
|
Загрузка…
|
|
</div>
|
|
) : (
|
|
<ChartDonutMetric
|
|
slices={slices}
|
|
centerLabel={centerLabel}
|
|
centerValue={total}
|
|
/>
|
|
)}
|
|
</AnalyticsCardShell>
|
|
)
|
|
}
|