Skip to content

Commit b150565

Browse files
authored
Merge pull request #3145 from Dokploy/3054-v0257-and-older-request-tab-only-shows-the-current-hour-and-not-the-day-log-stats
feat: set default date range to last 3 days in ShowRequests component
2 parents 1aac5c1 + 689c689 commit b150565

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

apps/dokploy/components/dashboard/requests/show-requests.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@ export const ShowRequests = () => {
5151
const { mutateAsync: updateLogCleanup } =
5252
api.settings.updateLogCleanup.useMutation();
5353
const [cronExpression, setCronExpression] = useState<string | null>(null);
54+
55+
// Set default date range to last 3 days
56+
const getDefaultDateRange = () => {
57+
const to = new Date();
58+
const from = new Date();
59+
from.setDate(from.getDate() - 3);
60+
return { from, to };
61+
};
62+
5463
const [dateRange, setDateRange] = useState<{
5564
from: Date | undefined;
5665
to: Date | undefined;
57-
}>({
58-
from: undefined,
59-
to: undefined,
60-
});
66+
}>(getDefaultDateRange());
6167

6268
useEffect(() => {
6369
if (logCleanupStatus) {
@@ -169,17 +175,13 @@ export const ShowRequests = () => {
169175
{isActive ? (
170176
<>
171177
<div className="flex justify-end mb-4 gap-2">
172-
{(dateRange.from || dateRange.to) && (
173-
<Button
174-
variant="outline"
175-
onClick={() =>
176-
setDateRange({ from: undefined, to: undefined })
177-
}
178-
className="px-3"
179-
>
180-
Clear dates
181-
</Button>
182-
)}
178+
<Button
179+
variant="outline"
180+
onClick={() => setDateRange(getDefaultDateRange())}
181+
className="px-3"
182+
>
183+
Reset to Last 3 Days
184+
</Button>
183185
<Popover>
184186
<PopoverTrigger asChild>
185187
<Button

0 commit comments

Comments
 (0)