mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
- Implement date range filtering for access logs and request statistics - Add log cleanup scheduling with configurable cron expression - Update UI components to support date range selection - Refactor log processing and parsing to handle date filtering - Add new database migration for log cleanup cron configuration - Remove deprecated log rotation management logic
100 lines
1.9 KiB
TypeScript
100 lines
1.9 KiB
TypeScript
import { api } from "@/utils/api";
|
|
import {
|
|
type ChartConfig,
|
|
ChartContainer,
|
|
ChartTooltip,
|
|
ChartTooltipContent,
|
|
} from "@/components/ui/chart";
|
|
import {
|
|
Area,
|
|
AreaChart,
|
|
CartesianGrid,
|
|
ResponsiveContainer,
|
|
XAxis,
|
|
YAxis,
|
|
} from "recharts";
|
|
|
|
export interface RequestDistributionChartProps {
|
|
dateRange?: {
|
|
from: Date | undefined;
|
|
to: Date | undefined;
|
|
};
|
|
}
|
|
|
|
const chartConfig = {
|
|
views: {
|
|
label: "Page Views",
|
|
},
|
|
count: {
|
|
label: "Count",
|
|
color: "hsl(var(--chart-1))",
|
|
},
|
|
} satisfies ChartConfig;
|
|
|
|
export const RequestDistributionChart = ({
|
|
dateRange,
|
|
}: RequestDistributionChartProps) => {
|
|
const { data: stats } = api.settings.readStats.useQuery(
|
|
{
|
|
dateRange: dateRange
|
|
? {
|
|
start: dateRange.from?.toISOString(),
|
|
end: dateRange.to?.toISOString(),
|
|
}
|
|
: undefined,
|
|
},
|
|
{
|
|
refetchInterval: 1333,
|
|
},
|
|
);
|
|
|
|
return (
|
|
<ResponsiveContainer width="100%" height={200}>
|
|
<ChartContainer config={chartConfig}>
|
|
<AreaChart
|
|
accessibilityLayer
|
|
data={stats || []}
|
|
margin={{
|
|
left: 12,
|
|
right: 12,
|
|
}}
|
|
>
|
|
<CartesianGrid vertical={false} />
|
|
<XAxis
|
|
dataKey="hour"
|
|
tickLine={false}
|
|
axisLine={false}
|
|
tickMargin={8}
|
|
tickFormatter={(value) =>
|
|
new Date(value).toLocaleTimeString([], {
|
|
hour: "2-digit",
|
|
minute: "2-digit",
|
|
})
|
|
}
|
|
/>
|
|
<YAxis tickLine={false} axisLine={false} tickMargin={8} />
|
|
<ChartTooltip
|
|
cursor={false}
|
|
content={<ChartTooltipContent indicator="line" />}
|
|
labelFormatter={(value) =>
|
|
new Date(value).toLocaleString([], {
|
|
month: "short",
|
|
day: "numeric",
|
|
hour: "2-digit",
|
|
minute: "2-digit",
|
|
})
|
|
}
|
|
/>
|
|
<Area
|
|
dataKey="count"
|
|
type="natural"
|
|
fill="hsl(var(--chart-1))"
|
|
fillOpacity={0.4}
|
|
stroke="hsl(var(--chart-1))"
|
|
/>
|
|
</AreaChart>
|
|
</ChartContainer>
|
|
</ResponsiveContainer>
|
|
);
|
|
};
|