68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
"use client"
|
|
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogMedia,
|
|
AlertDialogTitle,
|
|
} from "@/components/ui/alert-dialog"
|
|
import type { FlowPurgeDto } from "@mmapp/contracts/traffic-flow"
|
|
import { AlertCircleIcon, LoaderCircleIcon } from "lucide-react"
|
|
|
|
export function formatFlowPurgeResult(result: FlowPurgeDto): string {
|
|
const rows =
|
|
result.deleted.buckets +
|
|
result.deleted.minuteStats +
|
|
result.deleted.minuteDims +
|
|
result.deleted.dailyDims +
|
|
(result.deleted.hourFacts ?? 0) +
|
|
(result.deleted.dailyFacts ?? 0)
|
|
return `Удалено строк: ${rows}.`
|
|
}
|
|
|
|
export function NetflowPurgeConfirm({
|
|
open,
|
|
busy,
|
|
onConfirm,
|
|
onCancel,
|
|
}: {
|
|
open: boolean
|
|
busy?: boolean
|
|
onConfirm: () => void
|
|
onCancel: () => void
|
|
}) {
|
|
return (
|
|
<AlertDialog open={open} onOpenChange={(v) => { if (!v && !busy) onCancel() }}>
|
|
<AlertDialogContent size="default">
|
|
<AlertDialogHeader>
|
|
<AlertDialogMedia className="bg-destructive/10 text-destructive">
|
|
<AlertCircleIcon />
|
|
</AlertDialogMedia>
|
|
<AlertDialogTitle>Сбросить данные NetFlow?</AlertDialogTitle>
|
|
<AlertDialogDescription>
|
|
Будут удалены сессии и агрегаты (minute/daily) в PostgreSQL.
|
|
Ключи WireGuard, пиры JH, настройки коллектора и кэш RIPE сохранятся.
|
|
На время операции приём IPFIX остановится.
|
|
</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel disabled={busy} onClick={onCancel}>Отмена</AlertDialogCancel>
|
|
<AlertDialogAction
|
|
variant="destructive"
|
|
disabled={busy}
|
|
onClick={(event) => { event.preventDefault(); onConfirm() }}
|
|
>
|
|
{busy ? <LoaderCircleIcon className="size-4 animate-spin" /> : null}
|
|
{busy ? "Сброс…" : "Сбросить"}
|
|
</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
)
|
|
}
|