From fde1731365a201edf95d381ebc88026fd28543b3 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Sat, 11 Oct 2025 18:51:50 +0200 Subject: [PATCH] Update AppImage --- AppImage/components/system-logs.tsx | 343 +++++----------------------- AppImage/components/ui/calendar.tsx | 9 +- 2 files changed, 60 insertions(+), 292 deletions(-) diff --git a/AppImage/components/system-logs.tsx b/AppImage/components/system-logs.tsx index 3d659ed..dbf6e68 100644 --- a/AppImage/components/system-logs.tsx +++ b/AppImage/components/system-logs.tsx @@ -7,7 +7,6 @@ import { Input } from "./ui/input" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./ui/select" import { ScrollArea } from "./ui/scroll-area" import { Tabs, TabsContent, TabsList, TabsTrigger } from "./ui/tabs" -import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "./ui/dialog" import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "./ui/sheet" import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover" import { Calendar } from "./ui/calendar" @@ -21,7 +20,6 @@ import { XCircle, Database, Activity, - HardDrive, CalendarIcon, RefreshCw, Bell, @@ -126,6 +124,13 @@ export function SystemLogs() { fetchAllData() }, []) + useEffect(() => { + if (dateFilter !== "custom") { + // Reload logs when non-custom filter changes + fetchSystemLogs().then(setLogs) + } + }, [dateFilter, customDays]) + const fetchAllData = async () => { try { setLoading(true) @@ -164,7 +169,23 @@ export function SystemLogs() { const fetchSystemLogs = async (): Promise => { try { - const apiUrl = getApiUrl("/api/logs") + let apiUrl = getApiUrl("/api/logs") + + const params = new URLSearchParams() + + if (dateFilter === "custom" && dateRange?.from && dateRange?.to) { + params.append("from_date", format(dateRange.from, "yyyy-MM-dd")) + params.append("to_date", format(dateRange.to, "yyyy-MM-dd")) + } else if (dateFilter !== "now") { + const daysAgo = dateFilter === "custom" ? Number.parseInt(customDays) : Number.parseInt(dateFilter) + params.append("since_days", daysAgo.toString()) + } + + if (params.toString()) { + apiUrl += `?${params.toString()}` + } + + console.log("[v0] Fetching logs from:", apiUrl) const response = await fetch(apiUrl, { method: "GET", @@ -455,9 +476,18 @@ export function SystemLogs() { const handleApplyDateRange = async () => { if (dateRange?.from && dateRange?.to) { + console.log("[v0] Applying date range filter:", dateRange) setIsDatePickerOpen(false) - // Fetch logs with the selected date range - await fetchSystemLogs() + setLoading(true) + try { + const newLogs = await fetchSystemLogs() + setLogs(newLogs) + console.log("[v0] Loaded", newLogs.length, "logs for date range") + } catch (error) { + console.error("[v0] Error loading logs for date range:", error) + } finally { + setLoading(false) + } } } @@ -787,12 +817,14 @@ export function SystemLogs() { {event.type} {event.vmid && ` (VM/CT ${event.vmid})`} -
{event.duration}
+
+ {event.starttime} +
+
{event.message}
Node: {event.node} • User: {event.user}
-
{event.starttime}
))} @@ -800,7 +832,7 @@ export function SystemLogs() { {events.length === 0 && (
-

No recent events found

+

No events found

)} @@ -809,64 +841,32 @@ export function SystemLogs() { {/* Backups Tab */} -
- - -
{backupStats.qemu}
-

QEMU Backups

-
-
- - -
{backupStats.lxc}
-

LXC Backups

-
-
- - -
{formatBytes(backupStats.totalSize)}
-

Total Size

-
-
-
- - +
{backups.map((backup, index) => (
{ setSelectedBackup(backup) setIsBackupModalOpen(true) }} >
- + + {getBackupTypeLabel(backup.volid)} +
-
-
- - {getBackupTypeLabel(backup.volid)} - - - {getBackupStorageLabel(backup.volid)} - +
+
{backup.storage}
+
+ {backup.created}
- - {backup.size_human} - -
-
Storage: {backup.storage}
-
- - {backup.created}
+
{backup.volid}
+
Size: {backup.size_human}
))} @@ -894,23 +894,22 @@ export function SystemLogs() { setIsNotificationModalOpen(true) }} > -
- {getNotificationIcon(notification.type)} +
+ {getNotificationIcon(notification.type)} {notification.type.toUpperCase()}
-
+
{notification.service}
+
{notification.timestamp}
{notification.message}
-
- Service: {notification.service} • Source: {notification.source} -
+
Source: {notification.source}
))} @@ -927,236 +926,6 @@ export function SystemLogs() { - - - - - - - Log Details - - Complete information about this log entry - - {selectedLog && ( -
-
-
-
Level
- - {getLevelIcon(selectedLog.level)} - {selectedLog.level.toUpperCase()} - -
-
-
Service
-
{selectedLog.service}
-
-
-
Timestamp
-
{selectedLog.timestamp}
-
-
-
Source
-
{selectedLog.source}
-
- {selectedLog.pid && ( -
-
Process ID
-
{selectedLog.pid}
-
- )} - {selectedLog.hostname && ( -
-
Hostname
-
{selectedLog.hostname}
-
- )} -
-
-
Message
-
-
{selectedLog.message}
-
-
-
- )} -
-
- - - - - - - Event Details - - Complete information about this event - - {selectedEvent && ( -
-
-
-
Status
- - {getLevelIcon(selectedEvent.level)} - {selectedEvent.status} - -
-
-
Type
-
{selectedEvent.type}
-
-
-
Node
-
{selectedEvent.node}
-
-
-
User
-
{selectedEvent.user}
-
- {selectedEvent.vmid && ( -
-
VM/CT ID
-
{selectedEvent.vmid}
-
- )} -
-
Duration
-
{selectedEvent.duration}
-
-
-
Start Time
-
{selectedEvent.starttime}
-
-
-
End Time
-
{selectedEvent.endtime}
-
-
-
-
UPID
-
-
-                    {selectedEvent.upid}
-                  
-
-
-
- )} -
-
- - - - - - - Backup Details - - Complete information about this backup - - {selectedBackup && ( -
-
-
-
Type
- - {getBackupTypeLabel(selectedBackup.volid)} - -
-
-
Storage Type
- - {getBackupStorageLabel(selectedBackup.volid)} - -
-
-
Storage
-
{selectedBackup.storage}
-
-
-
Size
- - {selectedBackup.size_human} - -
- {selectedBackup.vmid && ( -
-
VM/CT ID
-
{selectedBackup.vmid}
-
- )} -
-
Created
-
{selectedBackup.created}
-
-
-
-
Volume ID
-
-
-                    {selectedBackup.volid}
-                  
-
-
-
- )} -
-
- - - - - - - Notification Details - - Complete information about this notification - - {selectedNotification && ( -
-
-
-
Type
- - {selectedNotification.type.toUpperCase()} - -
-
-
Timestamp
-
{selectedNotification.timestamp}
-
-
-
Service
-
{selectedNotification.service}
-
-
-
Source
-
{selectedNotification.source}
-
-
-
-
Message
-
-
-                    {selectedNotification.message}
-                  
-
-
-
- -
-
- )} -
-
) } diff --git a/AppImage/components/ui/calendar.tsx b/AppImage/components/ui/calendar.tsx index 94c8344..399be24 100644 --- a/AppImage/components/ui/calendar.tsx +++ b/AppImage/components/ui/calendar.tsx @@ -22,7 +22,7 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }: C nav: "space-x-1 flex items-center", nav_button: cn( buttonVariants({ variant: "outline" }), - "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100", + "h-8 w-8 bg-background p-0 hover:bg-accent hover:text-accent-foreground border-border", ), nav_button_previous: "absolute left-1", nav_button_next: "absolute right-1", @@ -31,11 +31,10 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }: C head_cell: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem] flex items-center justify-center", row: "grid grid-cols-7 gap-1 mt-2", cell: cn( - "h-9 w-9 text-center text-sm p-0 relative", + "h-9 w-9 text-center text-sm p-0 relative flex items-center justify-center", "[&:has([aria-selected].day-range-end)]:rounded-r-md", "[&:has([aria-selected].day-range-start)]:rounded-l-md", - "[&:has([aria-selected].day-range-middle)]:bg-accent/50", - "[&:has([aria-selected])]:bg-accent", + "[&:has([aria-selected].day-range-middle)]:bg-primary/20", "focus-within:relative focus-within:z-20", ), day: cn(buttonVariants({ variant: "ghost" }), "h-9 w-9 p-0 font-normal aria-selected:opacity-100"), @@ -47,7 +46,7 @@ function Calendar({ className, classNames, showOutsideDays = true, ...props }: C day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30", day_disabled: "text-muted-foreground opacity-50", - day_range_middle: "aria-selected:bg-accent/50 aria-selected:text-accent-foreground rounded-none", + day_range_middle: "aria-selected:bg-primary/20 aria-selected:text-foreground rounded-none", day_hidden: "invisible", ...classNames, }}