fix(traffic): сохранять точность объёмов и обозначать бинарные единицы
This commit is contained in:
1 parent
2358ecef60
commit
2b3d583e3b
29 files changed
+1452
-39
No files matched your search
@@ -19,7 +19,7 @@ import {
|
||||
ArrowUpIcon, ArrowDownIcon, ActivityIcon, UsersIcon, CableIcon, ServerIcon, SearchIcon, GitBranchIcon, PlusIcon,
|
||||
} from "lucide-react"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { fmtGB, fmtRate } from "@/lib/fmt-rate"
|
||||
import { fmtGiB, fmtRate } from "@/lib/fmt-rate"
|
||||
import { useDataSource } from "@/lib/data-source"
|
||||
import { useTrafficLive } from "@/hooks/use-traffic-live"
|
||||
import { useFlowLive } from "@/hooks/use-flow-live"
|
||||
@@ -86,6 +86,7 @@ function flowEmptyHint(stats: FlowStatsDto | null, collectorAlive?: boolean): st
|
||||
// ─── data model ───────────────────────────────────────────────────────────────
|
||||
|
||||
interface BoundIfaceTraffic {
|
||||
volumeUnit?: "GiB"
|
||||
observations?: TrafficObservationMeta
|
||||
id: string
|
||||
bindingId: string
|
||||
@@ -113,6 +114,7 @@ interface BoundIfaceTraffic {
|
||||
}
|
||||
|
||||
interface ServerTraffic {
|
||||
volumeUnit?: "GiB"
|
||||
observations?: TrafficObservationMeta
|
||||
id: string
|
||||
name: string
|
||||
@@ -132,6 +134,7 @@ interface ServerTraffic {
|
||||
}
|
||||
|
||||
interface UserTraffic {
|
||||
volumeUnit?: "GiB"
|
||||
observations?: TrafficObservationMeta
|
||||
id: string
|
||||
login: string
|
||||
@@ -150,6 +153,7 @@ interface UserTraffic {
|
||||
}
|
||||
|
||||
interface LiveTrafficServer {
|
||||
volumeUnit?: "GiB"
|
||||
observations?: TrafficObservationMeta
|
||||
id: string
|
||||
name: string
|
||||
@@ -497,8 +501,8 @@ function IfaceRow({ c, showServer = false }: { c: BoundIfaceTraffic; showServer?
|
||||
</div>
|
||||
</div>
|
||||
<div className="shrink-0 text-right leading-tight text-[10px] text-muted-foreground w-[72px]">
|
||||
<p className="tabular-nums">{fmtGB(c.rxTotal)}</p>
|
||||
<p className="tabular-nums">{fmtGB(c.txTotal)}</p>
|
||||
<p className="tabular-nums">{fmtGiB(c.rxTotal)}</p>
|
||||
<p className="tabular-nums">{fmtGiB(c.txTotal)}</p>
|
||||
</div>
|
||||
<span className={cn(
|
||||
"shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium tabular-nums",
|
||||
@@ -555,18 +559,18 @@ function TotalsRow({ rxTotal, txTotal, rxSeries, txSeries }: {
|
||||
rxTotal: number|null; txTotal: number|null; rxSeries: (number|null)[]; txSeries: (number|null)[]
|
||||
}) {
|
||||
return (
|
||||
<div className="mt-4 pt-4 border-t grid grid-cols-2 gap-4 [&>div]:min-w-0 [&_svg]:max-w-full">
|
||||
<div role="group" aria-label="Учтённый объём по измерениям" className="mt-4 pt-4 border-t grid grid-cols-2 gap-4 [&>div]:min-w-0 [&_svg]:max-w-full">
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground mb-1">Учтено RX по замерам</p>
|
||||
<p className="text-lg font-semibold tabular-nums">
|
||||
{fmtGB(rxTotal)}
|
||||
{fmtGiB(rxTotal)}
|
||||
</p>
|
||||
<Sparkline data={rxSeries} width={180} height={28} color="var(--chart-rx)" filled />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground mb-1">Учтено TX по замерам</p>
|
||||
<p className="text-lg font-semibold tabular-nums">
|
||||
{fmtGB(txTotal)}
|
||||
{fmtGiB(txTotal)}
|
||||
</p>
|
||||
<Sparkline data={txSeries} width={180} height={28} color="var(--chart-tx)" filled />
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user