diff --git a/AppImage/components/system-logs.tsx b/AppImage/components/system-logs.tsx index 972cd59..2799b78 100644 --- a/AppImage/components/system-logs.tsx +++ b/AppImage/components/system-logs.tsx @@ -95,9 +95,11 @@ export function SystemLogs() { const [selectedLog, setSelectedLog] = useState(null) const [selectedEvent, setSelectedEvent] = useState(null) const [selectedBackup, setSelectedBackup] = useState(null) + const [selectedNotification, setSelectedNotification] = useState(null) // Added const [isLogModalOpen, setIsLogModalOpen] = useState(false) const [isEventModalOpen, setIsEventModalOpen] = useState(false) const [isBackupModalOpen, setIsBackupModalOpen] = useState(false) + const [isNotificationModalOpen, setIsNotificationModalOpen] = useState(false) // Added const getApiUrl = (endpoint: string) => { if (typeof window !== "undefined") { @@ -172,20 +174,52 @@ export function SystemLogs() { const handleDownloadLogs = async (type = "system") => { try { - const response = await fetch(getApiUrl(`/api/logs/download?type=${type}&lines=1000`)) + const hours = 48 + let url = getApiUrl(`/api/logs/download?type=${type}&hours=${hours}`) + + // Apply filters if any are active + if (levelFilter !== "all") { + url += `&level=${levelFilter}` + } + if (serviceFilter !== "all") { + url += `&service=${serviceFilter}` + } + + const response = await fetch(url) + if (response.ok) { + const blob = await response.blob() + const downloadUrl = window.URL.createObjectURL(blob) + const a = document.createElement("a") + a.href = downloadUrl + a.download = `proxmox_${type}_${hours}h.log` + document.body.appendChild(a) + a.click() + window.URL.revokeObjectURL(downloadUrl) + document.body.removeChild(a) + } + } catch (err) { + console.error("[v0] Error downloading logs:", err) + } + } + + const handleDownloadNotificationLog = async (notification: Notification) => { + // Added + try { + // Download the complete log for this notification + const response = await fetch(getApiUrl(`/api/notifications/download?timestamp=${notification.timestamp}`)) if (response.ok) { const blob = await response.blob() const url = window.URL.createObjectURL(blob) const a = document.createElement("a") a.href = url - a.download = `proxmox_${type}.log` + a.download = `notification_${notification.timestamp.replace(/[:\s]/g, "_")}.log` document.body.appendChild(a) a.click() window.URL.revokeObjectURL(url) document.body.removeChild(a) } } catch (err) { - console.error("[v0] Error downloading logs:", err) + console.error("[v0] Error downloading notification log:", err) } } @@ -264,6 +298,25 @@ export function SystemLogs() { const uniqueServices = [...new Set(logs.map((log) => log.service))] + const getBackupType = (volid: string): "vm" | "lxc" => { + if (volid.includes("/vm/") || volid.includes("vzdump-qemu")) { + return "vm" + } + return "lxc" + } + + const getBackupTypeColor = (volid: string) => { + const type = getBackupType(volid) + return type === "vm" + ? "bg-cyan-500/10 text-cyan-500 border-cyan-500/20" + : "bg-orange-500/10 text-orange-500 border-orange-500/20" + } + + const getBackupTypeLabel = (volid: string) => { + const type = getBackupType(volid) + return type === "vm" ? "VM" : "LXC" + } + const getBackupStorageType = (volid: string): "pbs" | "pve" => { // PBS backups have format: storage:backup/type/vmid/timestamp // PVE backups have format: storage:backup/vzdump-type-vmid-timestamp.vma.zst @@ -537,13 +590,13 @@ export function SystemLogs() {
-
{backupStats.qemu}
+
{backupStats.qemu}

QEMU Backups

-
{backupStats.lxc}
+
{backupStats.lxc}

LXC Backups

@@ -573,20 +626,16 @@ export function SystemLogs() {
-
- {backup.volid.includes("/vm/") || backup.volid.includes("vzdump-qemu") ? "QEMU" : "LXC"} - {backup.vmid && ` VM ${backup.vmid}`} -
+ + {getBackupTypeLabel(backup.volid)} + {getBackupStorageLabel(backup.volid)}
-
- - - {backup.size_human} - -
+ + {backup.size_human} +
Storage: {backup.storage}
@@ -614,7 +663,11 @@ export function SystemLogs() { {notifications.map((notification, index) => (
{ + setSelectedNotification(notification) + setIsNotificationModalOpen(true) + }} >
{getNotificationIcon(notification.type)}
@@ -778,10 +831,8 @@ export function SystemLogs() {
Type
- - {selectedBackup.volid.includes("/vm/") || selectedBackup.volid.includes("vzdump-qemu") - ? "QEMU" - : "LXC"} + + {getBackupTypeLabel(selectedBackup.volid)}
@@ -821,6 +872,61 @@ export function SystemLogs() { )} + + + + + + + Notification Details + + Complete information about this notification + + {selectedNotification && ( +
+
+
+
Type
+
+ {getNotificationIcon(selectedNotification.type)} + {selectedNotification.type} +
+
+
+
Timestamp
+
{selectedNotification.timestamp}
+
+
+
Service
+
{selectedNotification.service}
+
+
+
Source
+
{selectedNotification.source}
+
+
+
+
Message
+
+
+                    {selectedNotification.message}
+                  
+
+
+
+ +
+
+ )} +
+
) }