2025-09-28 23:09:31 +02:00
|
|
|
"use client"
|
|
|
|
|
|
|
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card"
|
|
|
|
|
import { Badge } from "./ui/badge"
|
|
|
|
|
import { Button } from "./ui/button"
|
|
|
|
|
import { Input } from "./ui/input"
|
|
|
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./ui/select"
|
|
|
|
|
import { ScrollArea } from "./ui/scroll-area"
|
2025-10-11 01:36:42 +02:00
|
|
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./ui/tabs"
|
2025-10-11 12:06:59 +02:00
|
|
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "./ui/dialog"
|
2025-10-11 16:51:27 +02:00
|
|
|
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "./ui/sheet"
|
2025-10-11 01:36:42 +02:00
|
|
|
import {
|
|
|
|
|
FileText,
|
|
|
|
|
Search,
|
|
|
|
|
Download,
|
|
|
|
|
AlertTriangle,
|
|
|
|
|
Info,
|
|
|
|
|
CheckCircle,
|
|
|
|
|
XCircle,
|
|
|
|
|
Database,
|
|
|
|
|
Activity,
|
|
|
|
|
HardDrive,
|
|
|
|
|
Calendar,
|
|
|
|
|
RefreshCw,
|
2025-10-11 11:30:45 +02:00
|
|
|
Bell,
|
|
|
|
|
Mail,
|
2025-10-11 16:51:27 +02:00
|
|
|
Menu,
|
|
|
|
|
Terminal,
|
|
|
|
|
CalendarDays,
|
2025-10-11 17:18:52 +02:00
|
|
|
Clock,
|
2025-10-11 01:36:42 +02:00
|
|
|
} from "lucide-react"
|
|
|
|
|
import { useState, useEffect } from "react"
|
|
|
|
|
|
|
|
|
|
interface Log {
|
|
|
|
|
timestamp: string
|
|
|
|
|
level: string
|
|
|
|
|
service: string
|
|
|
|
|
message: string
|
|
|
|
|
source: string
|
|
|
|
|
pid?: string
|
|
|
|
|
hostname?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface Backup {
|
|
|
|
|
volid: string
|
|
|
|
|
storage: string
|
|
|
|
|
vmid: string | null
|
|
|
|
|
type: string | null
|
|
|
|
|
size: number
|
|
|
|
|
size_human: string
|
|
|
|
|
created: string
|
|
|
|
|
timestamp: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface Event {
|
|
|
|
|
upid: string
|
|
|
|
|
type: string
|
|
|
|
|
status: string
|
|
|
|
|
level: string
|
|
|
|
|
node: string
|
|
|
|
|
user: string
|
|
|
|
|
vmid: string
|
|
|
|
|
starttime: string
|
|
|
|
|
endtime: string
|
|
|
|
|
duration: string
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 11:30:45 +02:00
|
|
|
interface Notification {
|
|
|
|
|
timestamp: string
|
|
|
|
|
type: string
|
|
|
|
|
service: string
|
|
|
|
|
message: string
|
|
|
|
|
source: string
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
interface SystemLog {
|
|
|
|
|
timestamp: string
|
|
|
|
|
level: string
|
|
|
|
|
service: string
|
|
|
|
|
message: string
|
|
|
|
|
source: string
|
|
|
|
|
pid?: string
|
|
|
|
|
hostname?: string
|
|
|
|
|
}
|
2025-09-28 23:09:31 +02:00
|
|
|
|
|
|
|
|
export function SystemLogs() {
|
2025-10-11 01:36:42 +02:00
|
|
|
const [logs, setLogs] = useState<SystemLog[]>([])
|
|
|
|
|
const [backups, setBackups] = useState<Backup[]>([])
|
|
|
|
|
const [events, setEvents] = useState<Event[]>([])
|
2025-10-11 11:30:45 +02:00
|
|
|
const [notifications, setNotifications] = useState<Notification[]>([])
|
2025-10-11 01:36:42 +02:00
|
|
|
const [loading, setLoading] = useState(true)
|
|
|
|
|
const [error, setError] = useState<string | null>(null)
|
|
|
|
|
|
2025-09-28 23:09:31 +02:00
|
|
|
const [searchTerm, setSearchTerm] = useState("")
|
|
|
|
|
const [levelFilter, setLevelFilter] = useState("all")
|
|
|
|
|
const [serviceFilter, setServiceFilter] = useState("all")
|
2025-10-11 17:18:52 +02:00
|
|
|
const [timeRange, setTimeRange] = useState("1") // Default 1 minute for fast loading
|
2025-10-11 01:36:42 +02:00
|
|
|
const [activeTab, setActiveTab] = useState("logs")
|
|
|
|
|
|
2025-10-11 12:06:59 +02:00
|
|
|
const [selectedLog, setSelectedLog] = useState<SystemLog | null>(null)
|
|
|
|
|
const [selectedEvent, setSelectedEvent] = useState<Event | null>(null)
|
|
|
|
|
const [selectedBackup, setSelectedBackup] = useState<Backup | null>(null)
|
2025-10-11 16:04:42 +02:00
|
|
|
const [selectedNotification, setSelectedNotification] = useState<Notification | null>(null) // Added
|
2025-10-11 12:06:59 +02:00
|
|
|
const [isLogModalOpen, setIsLogModalOpen] = useState(false)
|
|
|
|
|
const [isEventModalOpen, setIsEventModalOpen] = useState(false)
|
|
|
|
|
const [isBackupModalOpen, setIsBackupModalOpen] = useState(false)
|
2025-10-11 16:04:42 +02:00
|
|
|
const [isNotificationModalOpen, setIsNotificationModalOpen] = useState(false) // Added
|
2025-10-11 12:06:59 +02:00
|
|
|
|
2025-10-11 16:51:27 +02:00
|
|
|
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false)
|
|
|
|
|
|
2025-10-11 11:30:45 +02:00
|
|
|
const getApiUrl = (endpoint: string) => {
|
|
|
|
|
if (typeof window !== "undefined") {
|
|
|
|
|
return `${window.location.protocol}//${window.location.hostname}:8008${endpoint}`
|
|
|
|
|
}
|
|
|
|
|
return `http://localhost:8008${endpoint}`
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
fetchAllData()
|
2025-10-11 17:18:52 +02:00
|
|
|
}, [timeRange]) // Re-fetch when time range changes
|
2025-10-11 01:36:42 +02:00
|
|
|
|
|
|
|
|
const fetchAllData = async () => {
|
|
|
|
|
try {
|
|
|
|
|
setLoading(true)
|
|
|
|
|
setError(null)
|
|
|
|
|
|
2025-10-11 11:30:45 +02:00
|
|
|
const [logsRes, backupsRes, eventsRes, notificationsRes] = await Promise.all([
|
2025-10-11 01:36:42 +02:00
|
|
|
fetchSystemLogs(),
|
2025-10-11 11:30:45 +02:00
|
|
|
fetch(getApiUrl("/api/backups")),
|
|
|
|
|
fetch(getApiUrl("/api/events?limit=50")),
|
|
|
|
|
fetch(getApiUrl("/api/notifications")),
|
2025-10-11 01:36:42 +02:00
|
|
|
])
|
2025-09-28 23:09:31 +02:00
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
setLogs(logsRes)
|
|
|
|
|
|
|
|
|
|
if (backupsRes.ok) {
|
|
|
|
|
const backupsData = await backupsRes.json()
|
|
|
|
|
setBackups(backupsData.backups || [])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (eventsRes.ok) {
|
|
|
|
|
const eventsData = await eventsRes.json()
|
|
|
|
|
setEvents(eventsData.events || [])
|
|
|
|
|
}
|
2025-10-11 11:30:45 +02:00
|
|
|
|
|
|
|
|
if (notificationsRes.ok) {
|
|
|
|
|
const notificationsData = await notificationsRes.json()
|
|
|
|
|
setNotifications(notificationsData.notifications || [])
|
|
|
|
|
}
|
2025-10-11 01:36:42 +02:00
|
|
|
} catch (err) {
|
|
|
|
|
console.error("[v0] Error fetching system logs data:", err)
|
|
|
|
|
setError("Failed to connect to server")
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fetchSystemLogs = async (): Promise<SystemLog[]> => {
|
|
|
|
|
try {
|
2025-10-11 17:18:52 +02:00
|
|
|
const apiUrl = getApiUrl(`/api/logs?minutes=${timeRange}`)
|
2025-10-11 01:36:42 +02:00
|
|
|
|
|
|
|
|
const response = await fetch(apiUrl, {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
cache: "no-store",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
throw new Error(`Flask server responded with status: ${response.status}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const data = await response.json()
|
|
|
|
|
return Array.isArray(data) ? data : data.logs || []
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("[v0] Failed to fetch system logs:", error)
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDownloadLogs = async (type = "system") => {
|
|
|
|
|
try {
|
2025-10-11 16:04:42 +02:00
|
|
|
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}`))
|
2025-10-11 01:36:42 +02:00
|
|
|
if (response.ok) {
|
|
|
|
|
const blob = await response.blob()
|
|
|
|
|
const url = window.URL.createObjectURL(blob)
|
|
|
|
|
const a = document.createElement("a")
|
|
|
|
|
a.href = url
|
2025-10-11 16:04:42 +02:00
|
|
|
a.download = `notification_${notification.timestamp.replace(/[:\s]/g, "_")}.log`
|
2025-10-11 01:36:42 +02:00
|
|
|
document.body.appendChild(a)
|
|
|
|
|
a.click()
|
|
|
|
|
window.URL.revokeObjectURL(url)
|
|
|
|
|
document.body.removeChild(a)
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
2025-10-11 16:04:42 +02:00
|
|
|
console.error("[v0] Error downloading notification log:", err)
|
2025-10-11 01:36:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Filter logs
|
|
|
|
|
const filteredLogs = logs.filter((log) => {
|
2025-09-28 23:09:31 +02:00
|
|
|
const matchesSearch =
|
|
|
|
|
log.message.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
|
|
|
log.service.toLowerCase().includes(searchTerm.toLowerCase())
|
|
|
|
|
const matchesLevel = levelFilter === "all" || log.level === levelFilter
|
|
|
|
|
const matchesService = serviceFilter === "all" || log.service === serviceFilter
|
|
|
|
|
|
|
|
|
|
return matchesSearch && matchesLevel && matchesService
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const getLevelColor = (level: string) => {
|
|
|
|
|
switch (level) {
|
|
|
|
|
case "error":
|
2025-10-11 01:36:42 +02:00
|
|
|
case "critical":
|
|
|
|
|
case "emergency":
|
|
|
|
|
case "alert":
|
2025-09-28 23:09:31 +02:00
|
|
|
return "bg-red-500/10 text-red-500 border-red-500/20"
|
|
|
|
|
case "warning":
|
|
|
|
|
return "bg-yellow-500/10 text-yellow-500 border-yellow-500/20"
|
|
|
|
|
case "info":
|
2025-10-11 01:36:42 +02:00
|
|
|
case "notice":
|
2025-09-28 23:09:31 +02:00
|
|
|
return "bg-blue-500/10 text-blue-500 border-blue-500/20"
|
2025-10-11 11:30:45 +02:00
|
|
|
case "success":
|
|
|
|
|
return "bg-green-500/10 text-green-500 border-green-500/20"
|
2025-09-28 23:09:31 +02:00
|
|
|
default:
|
|
|
|
|
return "bg-gray-500/10 text-gray-500 border-gray-500/20"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getLevelIcon = (level: string) => {
|
|
|
|
|
switch (level) {
|
|
|
|
|
case "error":
|
2025-10-11 01:36:42 +02:00
|
|
|
case "critical":
|
|
|
|
|
case "emergency":
|
|
|
|
|
case "alert":
|
2025-09-28 23:09:31 +02:00
|
|
|
return <XCircle className="h-3 w-3 mr-1" />
|
|
|
|
|
case "warning":
|
|
|
|
|
return <AlertTriangle className="h-3 w-3 mr-1" />
|
|
|
|
|
case "info":
|
2025-10-11 01:36:42 +02:00
|
|
|
case "notice":
|
2025-09-28 23:09:31 +02:00
|
|
|
return <Info className="h-3 w-3 mr-1" />
|
2025-10-11 11:30:45 +02:00
|
|
|
case "success":
|
|
|
|
|
return <CheckCircle className="h-3 w-3 mr-1" />
|
2025-09-28 23:09:31 +02:00
|
|
|
default:
|
|
|
|
|
return <CheckCircle className="h-3 w-3 mr-1" />
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 11:30:45 +02:00
|
|
|
const getNotificationIcon = (type: string) => {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case "email":
|
|
|
|
|
return <Mail className="h-4 w-4 text-blue-500" />
|
|
|
|
|
case "webhook":
|
|
|
|
|
return <Activity className="h-4 w-4 text-purple-500" />
|
|
|
|
|
case "alert":
|
|
|
|
|
return <AlertTriangle className="h-4 w-4 text-yellow-500" />
|
|
|
|
|
case "error":
|
|
|
|
|
return <XCircle className="h-4 w-4 text-red-500" />
|
|
|
|
|
case "success":
|
|
|
|
|
return <CheckCircle className="h-4 w-4 text-green-500" />
|
|
|
|
|
default:
|
|
|
|
|
return <Bell className="h-4 w-4 text-gray-500" />
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 17:18:52 +02:00
|
|
|
const getNotificationTypeColor = (type: string) => {
|
|
|
|
|
const lowerType = type.toLowerCase()
|
|
|
|
|
if (lowerType.includes("error") || lowerType.includes("critical") || lowerType.includes("alert")) {
|
|
|
|
|
return "bg-red-500/10 text-red-500 border-red-500/20"
|
|
|
|
|
} else if (lowerType.includes("warning") || lowerType.includes("warn")) {
|
|
|
|
|
return "bg-yellow-500/10 text-yellow-500 border-yellow-500/20"
|
|
|
|
|
} else if (lowerType.includes("success") || lowerType.includes("ok")) {
|
|
|
|
|
return "bg-green-500/10 text-green-500 border-green-500/20"
|
|
|
|
|
} else if (lowerType.includes("info")) {
|
|
|
|
|
return "bg-blue-500/10 text-blue-500 border-blue-500/20"
|
|
|
|
|
}
|
|
|
|
|
return "bg-gray-500/10 text-gray-500 border-gray-500/20"
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-28 23:09:31 +02:00
|
|
|
const logCounts = {
|
2025-10-11 01:36:42 +02:00
|
|
|
total: logs.length,
|
|
|
|
|
error: logs.filter((log) => ["error", "critical", "emergency", "alert"].includes(log.level)).length,
|
|
|
|
|
warning: logs.filter((log) => log.level === "warning").length,
|
|
|
|
|
info: logs.filter((log) => ["info", "notice", "debug"].includes(log.level)).length,
|
2025-09-28 23:09:31 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
const uniqueServices = [...new Set(logs.map((log) => log.service))]
|
|
|
|
|
|
2025-10-11 16:04:42 +02:00
|
|
|
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"
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 12:06:59 +02:00
|
|
|
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
|
|
|
|
|
if (volid.includes(":backup/vm/") || volid.includes(":backup/ct/")) {
|
|
|
|
|
return "pbs"
|
|
|
|
|
}
|
|
|
|
|
return "pve"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getBackupStorageColor = (volid: string) => {
|
|
|
|
|
const type = getBackupStorageType(volid)
|
|
|
|
|
return type === "pbs"
|
|
|
|
|
? "bg-purple-500/10 text-purple-500 border-purple-500/20"
|
|
|
|
|
: "bg-blue-500/10 text-blue-500 border-blue-500/20"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getBackupStorageLabel = (volid: string) => {
|
|
|
|
|
const type = getBackupStorageType(volid)
|
|
|
|
|
return type === "pbs" ? "PBS" : "PVE"
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
const backupStats = {
|
|
|
|
|
total: backups.length,
|
|
|
|
|
totalSize: backups.reduce((sum, b) => sum + b.size, 0),
|
2025-10-11 12:06:59 +02:00
|
|
|
qemu: backups.filter((b) => {
|
|
|
|
|
// Check if volid contains /vm/ for QEMU or vzdump-qemu for PVE
|
|
|
|
|
return b.volid.includes("/vm/") || b.volid.includes("vzdump-qemu")
|
|
|
|
|
}).length,
|
|
|
|
|
lxc: backups.filter((b) => {
|
|
|
|
|
// Check if volid contains /ct/ for LXC or vzdump-lxc for PVE
|
|
|
|
|
return b.volid.includes("/ct/") || b.volid.includes("vzdump-lxc")
|
|
|
|
|
}).length,
|
2025-10-11 01:36:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formatBytes = (bytes: number) => {
|
|
|
|
|
if (bytes === 0) return "0 B"
|
|
|
|
|
const k = 1024
|
|
|
|
|
const sizes = ["B", "KB", "MB", "GB", "TB"]
|
|
|
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
|
|
|
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 16:51:27 +02:00
|
|
|
const getSectionIcon = (section: string) => {
|
|
|
|
|
switch (section) {
|
|
|
|
|
case "logs":
|
|
|
|
|
return <Terminal className="h-4 w-4" />
|
|
|
|
|
case "events":
|
|
|
|
|
return <CalendarDays className="h-4 w-4" />
|
|
|
|
|
case "backups":
|
|
|
|
|
return <Database className="h-4 w-4" />
|
|
|
|
|
case "notifications":
|
|
|
|
|
return <Bell className="h-4 w-4" />
|
|
|
|
|
default:
|
|
|
|
|
return <FileText className="h-4 w-4" />
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getSectionLabel = (section: string) => {
|
|
|
|
|
switch (section) {
|
|
|
|
|
case "logs":
|
|
|
|
|
return "System Logs"
|
|
|
|
|
case "events":
|
|
|
|
|
return "Recent Events"
|
|
|
|
|
case "backups":
|
|
|
|
|
return "Backups"
|
|
|
|
|
case "notifications":
|
|
|
|
|
return "Notifications"
|
|
|
|
|
default:
|
|
|
|
|
return section
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
if (loading && logs.length === 0) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center justify-center h-64">
|
|
|
|
|
<RefreshCw className="h-8 w-8 animate-spin text-muted-foreground" />
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
2025-09-28 23:09:31 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="space-y-6">
|
2025-10-11 01:36:42 +02:00
|
|
|
{/* Statistics Cards */}
|
2025-09-28 23:09:31 +02:00
|
|
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
|
|
|
|
<Card className="bg-card border-border">
|
|
|
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
|
|
|
<CardTitle className="text-sm font-medium text-muted-foreground">Total Logs</CardTitle>
|
|
|
|
|
<FileText className="h-4 w-4 text-muted-foreground" />
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<div className="text-2xl font-bold text-foreground">{logCounts.total}</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
<p className="text-xs text-muted-foreground mt-2">Last 200 entries</p>
|
2025-09-28 23:09:31 +02:00
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<Card className="bg-card border-border">
|
|
|
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
|
|
|
<CardTitle className="text-sm font-medium text-muted-foreground">Errors</CardTitle>
|
|
|
|
|
<XCircle className="h-4 w-4 text-red-500" />
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<div className="text-2xl font-bold text-red-500">{logCounts.error}</div>
|
|
|
|
|
<p className="text-xs text-muted-foreground mt-2">Requires attention</p>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<Card className="bg-card border-border">
|
|
|
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
|
|
|
<CardTitle className="text-sm font-medium text-muted-foreground">Warnings</CardTitle>
|
|
|
|
|
<AlertTriangle className="h-4 w-4 text-yellow-500" />
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<div className="text-2xl font-bold text-yellow-500">{logCounts.warning}</div>
|
|
|
|
|
<p className="text-xs text-muted-foreground mt-2">Monitor closely</p>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<Card className="bg-card border-border">
|
|
|
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
2025-10-11 01:36:42 +02:00
|
|
|
<CardTitle className="text-sm font-medium text-muted-foreground">Backups</CardTitle>
|
|
|
|
|
<Database className="h-4 w-4 text-blue-500" />
|
2025-09-28 23:09:31 +02:00
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
2025-10-11 01:36:42 +02:00
|
|
|
<div className="text-2xl font-bold text-blue-500">{backupStats.total}</div>
|
|
|
|
|
<p className="text-xs text-muted-foreground mt-2">{formatBytes(backupStats.totalSize)}</p>
|
2025-09-28 23:09:31 +02:00
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
{/* Main Content with Tabs */}
|
2025-09-28 23:09:31 +02:00
|
|
|
<Card className="bg-card border-border">
|
|
|
|
|
<CardHeader>
|
2025-10-11 01:36:42 +02:00
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<CardTitle className="text-foreground flex items-center">
|
|
|
|
|
<Activity className="h-5 w-5 mr-2" />
|
|
|
|
|
System Logs & Events
|
|
|
|
|
</CardTitle>
|
|
|
|
|
<Button variant="outline" size="sm" onClick={fetchAllData} disabled={loading}>
|
|
|
|
|
<RefreshCw className={`h-4 w-4 mr-2 ${loading ? "animate-spin" : ""}`} />
|
|
|
|
|
Refresh
|
2025-09-28 23:09:31 +02:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<Tabs value={activeTab} onValueChange={setActiveTab}>
|
2025-10-11 16:51:27 +02:00
|
|
|
<TabsList className="hidden md:grid w-full grid-cols-4">
|
2025-10-11 01:36:42 +02:00
|
|
|
<TabsTrigger value="logs">System Logs</TabsTrigger>
|
|
|
|
|
<TabsTrigger value="events">Recent Events</TabsTrigger>
|
|
|
|
|
<TabsTrigger value="backups">Backups</TabsTrigger>
|
2025-10-11 11:30:45 +02:00
|
|
|
<TabsTrigger value="notifications">Notifications</TabsTrigger>
|
2025-10-11 01:36:42 +02:00
|
|
|
</TabsList>
|
2025-09-28 23:09:31 +02:00
|
|
|
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="md:hidden mb-4">
|
|
|
|
|
<Sheet open={isMobileMenuOpen} onOpenChange={setIsMobileMenuOpen}>
|
|
|
|
|
<SheetTrigger asChild>
|
|
|
|
|
<Button variant="outline" className="w-full justify-start gap-2 bg-transparent">
|
|
|
|
|
<Menu className="h-4 w-4" />
|
|
|
|
|
{getSectionIcon(activeTab)}
|
|
|
|
|
<span>{getSectionLabel(activeTab)}</span>
|
|
|
|
|
</Button>
|
|
|
|
|
</SheetTrigger>
|
|
|
|
|
<SheetContent side="left" className="w-[280px]">
|
|
|
|
|
<SheetHeader>
|
|
|
|
|
<SheetTitle>Sections</SheetTitle>
|
|
|
|
|
</SheetHeader>
|
|
|
|
|
<div className="mt-6 space-y-2">
|
|
|
|
|
<Button
|
|
|
|
|
variant={activeTab === "logs" ? "default" : "ghost"}
|
|
|
|
|
className="w-full justify-start gap-3"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setActiveTab("logs")
|
|
|
|
|
setIsMobileMenuOpen(false)
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Terminal className="h-4 w-4" />
|
|
|
|
|
System Logs
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant={activeTab === "events" ? "default" : "ghost"}
|
|
|
|
|
className="w-full justify-start gap-3"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setActiveTab("events")
|
|
|
|
|
setIsMobileMenuOpen(false)
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<CalendarDays className="h-4 w-4" />
|
|
|
|
|
Recent Events
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant={activeTab === "backups" ? "default" : "ghost"}
|
|
|
|
|
className="w-full justify-start gap-3"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setActiveTab("backups")
|
|
|
|
|
setIsMobileMenuOpen(false)
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Database className="h-4 w-4" />
|
|
|
|
|
Backups
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant={activeTab === "notifications" ? "default" : "ghost"}
|
|
|
|
|
className="w-full justify-start gap-3"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setActiveTab("notifications")
|
|
|
|
|
setIsMobileMenuOpen(false)
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Bell className="h-4 w-4" />
|
|
|
|
|
Notifications
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</SheetContent>
|
|
|
|
|
</Sheet>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
{/* System Logs Tab */}
|
|
|
|
|
<TabsContent value="logs" className="space-y-4">
|
|
|
|
|
<div className="flex flex-col sm:flex-row gap-4">
|
|
|
|
|
<div className="flex-1">
|
|
|
|
|
<div className="relative">
|
|
|
|
|
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
|
|
|
|
<Input
|
|
|
|
|
placeholder="Search logs..."
|
|
|
|
|
value={searchTerm}
|
|
|
|
|
onChange={(e) => setSearchTerm(e.target.value)}
|
|
|
|
|
className="pl-10 bg-background border-border"
|
|
|
|
|
/>
|
2025-09-28 23:09:31 +02:00
|
|
|
</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
</div>
|
|
|
|
|
|
2025-10-11 17:18:52 +02:00
|
|
|
<Select value={timeRange} onValueChange={setTimeRange}>
|
|
|
|
|
<SelectTrigger className="w-full sm:w-[180px] bg-background border-border">
|
|
|
|
|
<Clock className="h-4 w-4 mr-2" />
|
|
|
|
|
<SelectValue placeholder="Time range" />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
<SelectItem value="1">Last 1 minute</SelectItem>
|
|
|
|
|
<SelectItem value="5">Last 5 minutes</SelectItem>
|
|
|
|
|
<SelectItem value="15">Last 15 minutes</SelectItem>
|
|
|
|
|
<SelectItem value="30">Last 30 minutes</SelectItem>
|
|
|
|
|
<SelectItem value="60">Last 1 hour</SelectItem>
|
|
|
|
|
<SelectItem value="360">Last 6 hours</SelectItem>
|
|
|
|
|
<SelectItem value="1440">Last 24 hours</SelectItem>
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
<Select value={levelFilter} onValueChange={setLevelFilter}>
|
|
|
|
|
<SelectTrigger className="w-full sm:w-[180px] bg-background border-border">
|
|
|
|
|
<SelectValue placeholder="Filter by level" />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
<SelectItem value="all">All Levels</SelectItem>
|
|
|
|
|
<SelectItem value="error">Error</SelectItem>
|
|
|
|
|
<SelectItem value="warning">Warning</SelectItem>
|
|
|
|
|
<SelectItem value="info">Info</SelectItem>
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
|
|
<Select value={serviceFilter} onValueChange={setServiceFilter}>
|
|
|
|
|
<SelectTrigger className="w-full sm:w-[180px] bg-background border-border">
|
|
|
|
|
<SelectValue placeholder="Filter by service" />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
<SelectItem value="all">All Services</SelectItem>
|
|
|
|
|
{uniqueServices.slice(0, 20).map((service) => (
|
|
|
|
|
<SelectItem key={service} value={service}>
|
|
|
|
|
{service}
|
|
|
|
|
</SelectItem>
|
|
|
|
|
))}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
className="border-border bg-transparent"
|
|
|
|
|
onClick={() => handleDownloadLogs("system")}
|
|
|
|
|
>
|
|
|
|
|
<Download className="h-4 w-4 mr-2" />
|
|
|
|
|
Export
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ScrollArea className="h-[600px] w-full rounded-md border border-border">
|
|
|
|
|
<div className="space-y-2 p-4">
|
|
|
|
|
{filteredLogs.map((log, index) => (
|
|
|
|
|
<div
|
|
|
|
|
key={index}
|
2025-10-11 17:18:52 +02:00
|
|
|
className="flex flex-col md:flex-row md:items-start space-y-2 md:space-y-0 md:space-x-4 p-3 rounded-lg bg-card/50 border border-border/50 hover:bg-card/80 transition-colors cursor-pointer"
|
2025-10-11 12:06:59 +02:00
|
|
|
onClick={() => {
|
|
|
|
|
setSelectedLog(log)
|
|
|
|
|
setIsLogModalOpen(true)
|
|
|
|
|
}}
|
2025-10-11 01:36:42 +02:00
|
|
|
>
|
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
|
<Badge variant="outline" className={getLevelColor(log.level)}>
|
|
|
|
|
{getLevelIcon(log.level)}
|
|
|
|
|
{log.level.toUpperCase()}
|
|
|
|
|
</Badge>
|
|
|
|
|
</div>
|
2025-09-28 23:09:31 +02:00
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
<div className="flex-1 min-w-0">
|
|
|
|
|
<div className="flex items-center justify-between mb-1">
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="text-sm font-medium text-foreground truncate">{log.service}</div>
|
|
|
|
|
<div className="text-xs text-muted-foreground font-mono whitespace-nowrap ml-2">
|
|
|
|
|
{log.timestamp}
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
<div className="text-sm text-foreground mb-1 line-clamp-2">{log.message}</div>
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="text-xs text-muted-foreground truncate">
|
2025-10-11 01:36:42 +02:00
|
|
|
Source: {log.source}
|
|
|
|
|
{log.pid && ` • PID: ${log.pid}`}
|
|
|
|
|
{log.hostname && ` • Host: ${log.hostname}`}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-09-28 23:09:31 +02:00
|
|
|
</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
{filteredLogs.length === 0 && (
|
|
|
|
|
<div className="text-center py-8 text-muted-foreground">
|
|
|
|
|
<FileText className="h-12 w-12 mx-auto mb-4 opacity-50" />
|
|
|
|
|
<p>No logs found matching your criteria</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-09-28 23:09:31 +02:00
|
|
|
</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
</ScrollArea>
|
|
|
|
|
</TabsContent>
|
|
|
|
|
|
|
|
|
|
{/* Recent Events Tab */}
|
|
|
|
|
<TabsContent value="events" className="space-y-4">
|
|
|
|
|
<ScrollArea className="h-[600px] w-full rounded-md border border-border">
|
|
|
|
|
<div className="space-y-2 p-4">
|
|
|
|
|
{events.map((event, index) => (
|
|
|
|
|
<div
|
|
|
|
|
key={index}
|
2025-10-11 17:18:52 +02:00
|
|
|
className="flex flex-col md:flex-row md:items-start space-y-2 md:space-y-0 md:space-x-4 p-3 rounded-lg bg-card/50 border border-border/50 hover:bg-card/80 transition-colors cursor-pointer"
|
2025-10-11 12:06:59 +02:00
|
|
|
onClick={() => {
|
|
|
|
|
setSelectedEvent(event)
|
|
|
|
|
setIsEventModalOpen(true)
|
|
|
|
|
}}
|
2025-10-11 01:36:42 +02:00
|
|
|
>
|
|
|
|
|
<div className="flex-shrink-0">
|
2025-10-11 16:25:22 +02:00
|
|
|
<Badge variant="outline" className={`${getLevelColor(event.level)} max-w-[120px] truncate`}>
|
2025-10-11 01:36:42 +02:00
|
|
|
{getLevelIcon(event.level)}
|
2025-10-11 16:25:22 +02:00
|
|
|
<span className="truncate">{event.status}</span>
|
2025-10-11 01:36:42 +02:00
|
|
|
</Badge>
|
|
|
|
|
</div>
|
2025-09-28 23:09:31 +02:00
|
|
|
|
2025-10-11 01:36:42 +02:00
|
|
|
<div className="flex-1 min-w-0">
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="flex items-center justify-between mb-1 gap-2">
|
|
|
|
|
<div className="text-sm font-medium text-foreground truncate">
|
2025-10-11 01:36:42 +02:00
|
|
|
{event.type}
|
|
|
|
|
{event.vmid && ` (VM/CT ${event.vmid})`}
|
|
|
|
|
</div>
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="text-xs text-muted-foreground whitespace-nowrap">{event.duration}</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
</div>
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="text-xs text-muted-foreground truncate">
|
2025-10-11 01:36:42 +02:00
|
|
|
Node: {event.node} • User: {event.user}
|
|
|
|
|
</div>
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="text-xs text-muted-foreground mt-1">{event.starttime}</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
{events.length === 0 && (
|
|
|
|
|
<div className="text-center py-8 text-muted-foreground">
|
|
|
|
|
<Activity className="h-12 w-12 mx-auto mb-4 opacity-50" />
|
|
|
|
|
<p>No recent events found</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</ScrollArea>
|
|
|
|
|
</TabsContent>
|
|
|
|
|
|
|
|
|
|
{/* Backups Tab */}
|
|
|
|
|
<TabsContent value="backups" className="space-y-4">
|
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-4">
|
|
|
|
|
<Card className="bg-card/50 border-border">
|
|
|
|
|
<CardContent className="pt-6">
|
2025-10-11 16:04:42 +02:00
|
|
|
<div className="text-2xl font-bold text-cyan-500">{backupStats.qemu}</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
<p className="text-xs text-muted-foreground mt-1">QEMU Backups</p>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card className="bg-card/50 border-border">
|
|
|
|
|
<CardContent className="pt-6">
|
2025-10-11 16:04:42 +02:00
|
|
|
<div className="text-2xl font-bold text-orange-500">{backupStats.lxc}</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
<p className="text-xs text-muted-foreground mt-1">LXC Backups</p>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card className="bg-card/50 border-border">
|
|
|
|
|
<CardContent className="pt-6">
|
|
|
|
|
<div className="text-2xl font-bold text-foreground">{formatBytes(backupStats.totalSize)}</div>
|
|
|
|
|
<p className="text-xs text-muted-foreground mt-1">Total Size</p>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ScrollArea className="h-[500px] w-full rounded-md border border-border">
|
|
|
|
|
<div className="space-y-2 p-4">
|
|
|
|
|
{backups.map((backup, index) => (
|
|
|
|
|
<div
|
|
|
|
|
key={index}
|
2025-10-11 12:06:59 +02:00
|
|
|
className="flex items-start space-x-4 p-3 rounded-lg bg-card/50 border border-border/50 hover:bg-card/80 transition-colors cursor-pointer"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setSelectedBackup(backup)
|
|
|
|
|
setIsBackupModalOpen(true)
|
|
|
|
|
}}
|
2025-10-11 01:36:42 +02:00
|
|
|
>
|
|
|
|
|
<div className="flex-shrink-0">
|
|
|
|
|
<HardDrive className="h-5 w-5 text-blue-500" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex-1 min-w-0">
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="flex items-center justify-between mb-1 gap-2 flex-wrap">
|
|
|
|
|
<div className="flex items-center gap-2 flex-wrap">
|
2025-10-11 16:04:42 +02:00
|
|
|
<Badge variant="outline" className={getBackupTypeColor(backup.volid)}>
|
|
|
|
|
{getBackupTypeLabel(backup.volid)}
|
|
|
|
|
</Badge>
|
2025-10-11 12:06:59 +02:00
|
|
|
<Badge variant="outline" className={getBackupStorageColor(backup.volid)}>
|
|
|
|
|
{getBackupStorageLabel(backup.volid)}
|
|
|
|
|
</Badge>
|
|
|
|
|
</div>
|
2025-10-11 16:25:22 +02:00
|
|
|
<Badge
|
|
|
|
|
variant="outline"
|
|
|
|
|
className="bg-green-500/10 text-green-500 border-green-500/20 whitespace-nowrap"
|
|
|
|
|
>
|
2025-10-11 16:04:42 +02:00
|
|
|
{backup.size_human}
|
|
|
|
|
</Badge>
|
2025-10-11 01:36:42 +02:00
|
|
|
</div>
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="text-xs text-muted-foreground mb-1 truncate">Storage: {backup.storage}</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
<div className="text-xs text-muted-foreground flex items-center">
|
2025-10-11 16:25:22 +02:00
|
|
|
<Calendar className="h-3 w-3 mr-1 flex-shrink-0" />
|
|
|
|
|
<span className="truncate">{backup.created}</span>
|
2025-10-11 01:36:42 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
{backups.length === 0 && (
|
|
|
|
|
<div className="text-center py-8 text-muted-foreground">
|
|
|
|
|
<Database className="h-12 w-12 mx-auto mb-4 opacity-50" />
|
|
|
|
|
<p>No backups found</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-09-28 23:09:31 +02:00
|
|
|
</div>
|
2025-10-11 01:36:42 +02:00
|
|
|
</ScrollArea>
|
|
|
|
|
</TabsContent>
|
2025-10-11 11:30:45 +02:00
|
|
|
|
2025-10-11 12:06:59 +02:00
|
|
|
{/* Notifications Tab */}
|
2025-10-11 11:30:45 +02:00
|
|
|
<TabsContent value="notifications" className="space-y-4">
|
|
|
|
|
<ScrollArea className="h-[600px] w-full rounded-md border border-border">
|
|
|
|
|
<div className="space-y-2 p-4">
|
|
|
|
|
{notifications.map((notification, index) => (
|
|
|
|
|
<div
|
|
|
|
|
key={index}
|
2025-10-11 17:18:52 +02:00
|
|
|
className="flex flex-col md:flex-row md:items-start space-y-2 md:space-y-0 md:space-x-4 p-3 rounded-lg bg-card/50 border border-border/50 hover:bg-card/80 transition-colors cursor-pointer"
|
2025-10-11 16:04:42 +02:00
|
|
|
onClick={() => {
|
|
|
|
|
setSelectedNotification(notification)
|
|
|
|
|
setIsNotificationModalOpen(true)
|
|
|
|
|
}}
|
2025-10-11 11:30:45 +02:00
|
|
|
>
|
2025-10-11 17:18:52 +02:00
|
|
|
<div className="flex-shrink-0">
|
|
|
|
|
<Badge variant="outline" className={getNotificationTypeColor(notification.type)}>
|
|
|
|
|
{getNotificationIcon(notification.type)}
|
|
|
|
|
{notification.type.toUpperCase()}
|
|
|
|
|
</Badge>
|
|
|
|
|
</div>
|
2025-10-11 11:30:45 +02:00
|
|
|
|
|
|
|
|
<div className="flex-1 min-w-0">
|
|
|
|
|
<div className="flex items-center justify-between mb-1">
|
2025-10-11 17:18:52 +02:00
|
|
|
<div className="text-sm font-medium text-foreground truncate">{notification.service}</div>
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="text-xs text-muted-foreground font-mono whitespace-nowrap ml-2">
|
|
|
|
|
{notification.timestamp}
|
|
|
|
|
</div>
|
2025-10-11 11:30:45 +02:00
|
|
|
</div>
|
2025-10-11 16:25:22 +02:00
|
|
|
<div className="text-sm text-foreground mb-1 line-clamp-2">{notification.message}</div>
|
2025-10-11 17:18:52 +02:00
|
|
|
<div className="text-xs text-muted-foreground truncate">Source: {notification.source}</div>
|
2025-10-11 11:30:45 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
{notifications.length === 0 && (
|
|
|
|
|
<div className="text-center py-8 text-muted-foreground">
|
|
|
|
|
<Bell className="h-12 w-12 mx-auto mb-4 opacity-50" />
|
|
|
|
|
<p>No notifications found</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</ScrollArea>
|
|
|
|
|
</TabsContent>
|
2025-10-11 01:36:42 +02:00
|
|
|
</Tabs>
|
2025-09-28 23:09:31 +02:00
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
2025-10-11 12:06:59 +02:00
|
|
|
|
|
|
|
|
<Dialog open={isLogModalOpen} onOpenChange={setIsLogModalOpen}>
|
|
|
|
|
<DialogContent className="max-w-3xl max-h-[80vh] overflow-y-auto">
|
|
|
|
|
<DialogHeader>
|
|
|
|
|
<DialogTitle className="flex items-center gap-2">
|
|
|
|
|
<FileText className="h-5 w-5" />
|
|
|
|
|
Log Details
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
<DialogDescription>Complete information about this log entry</DialogDescription>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
{selectedLog && (
|
|
|
|
|
<div className="space-y-4">
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
2025-10-11 12:06:59 +02:00
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Level</div>
|
|
|
|
|
<Badge variant="outline" className={getLevelColor(selectedLog.level)}>
|
|
|
|
|
{getLevelIcon(selectedLog.level)}
|
|
|
|
|
{selectedLog.level.toUpperCase()}
|
|
|
|
|
</Badge>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Service</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedLog.service}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="sm:col-span-2">
|
2025-10-11 12:06:59 +02:00
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Timestamp</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground font-mono break-words">{selectedLog.timestamp}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Source</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedLog.source}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
|
|
|
|
{selectedLog.pid && (
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Process ID</div>
|
|
|
|
|
<div className="text-sm text-foreground font-mono">{selectedLog.pid}</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{selectedLog.hostname && (
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="sm:col-span-2">
|
2025-10-11 12:06:59 +02:00
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Hostname</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedLog.hostname}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-2">Message</div>
|
|
|
|
|
<div className="p-4 rounded-lg bg-muted/50 border border-border">
|
|
|
|
|
<pre className="text-sm text-foreground whitespace-pre-wrap break-words">{selectedLog.message}</pre>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
|
|
|
|
|
<Dialog open={isEventModalOpen} onOpenChange={setIsEventModalOpen}>
|
|
|
|
|
<DialogContent className="max-w-3xl max-h-[80vh] overflow-y-auto">
|
|
|
|
|
<DialogHeader>
|
|
|
|
|
<DialogTitle className="flex items-center gap-2">
|
|
|
|
|
<Activity className="h-5 w-5" />
|
|
|
|
|
Event Details
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
<DialogDescription>Complete information about this event</DialogDescription>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
{selectedEvent && (
|
|
|
|
|
<div className="space-y-4">
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
2025-10-11 12:06:59 +02:00
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Status</div>
|
|
|
|
|
<Badge variant="outline" className={getLevelColor(selectedEvent.level)}>
|
|
|
|
|
{getLevelIcon(selectedEvent.level)}
|
|
|
|
|
{selectedEvent.status}
|
|
|
|
|
</Badge>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Type</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedEvent.type}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Node</div>
|
|
|
|
|
<div className="text-sm text-foreground">{selectedEvent.node}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">User</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedEvent.user}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
|
|
|
|
{selectedEvent.vmid && (
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">VM/CT ID</div>
|
|
|
|
|
<div className="text-sm text-foreground font-mono">{selectedEvent.vmid}</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Duration</div>
|
|
|
|
|
<div className="text-sm text-foreground">{selectedEvent.duration}</div>
|
|
|
|
|
</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="sm:col-span-2">
|
2025-10-11 12:06:59 +02:00
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Start Time</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedEvent.starttime}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="sm:col-span-2">
|
2025-10-11 12:06:59 +02:00
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">End Time</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedEvent.endtime}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-2">UPID</div>
|
|
|
|
|
<div className="p-4 rounded-lg bg-muted/50 border border-border">
|
|
|
|
|
<pre className="text-sm text-foreground font-mono whitespace-pre-wrap break-all">
|
|
|
|
|
{selectedEvent.upid}
|
|
|
|
|
</pre>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
|
|
|
|
|
<Dialog open={isBackupModalOpen} onOpenChange={setIsBackupModalOpen}>
|
|
|
|
|
<DialogContent className="max-w-3xl max-h-[80vh] overflow-y-auto">
|
|
|
|
|
<DialogHeader>
|
|
|
|
|
<DialogTitle className="flex items-center gap-2">
|
|
|
|
|
<Database className="h-5 w-5" />
|
|
|
|
|
Backup Details
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
<DialogDescription>Complete information about this backup</DialogDescription>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
{selectedBackup && (
|
|
|
|
|
<div className="space-y-4">
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
2025-10-11 12:06:59 +02:00
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Type</div>
|
2025-10-11 16:04:42 +02:00
|
|
|
<Badge variant="outline" className={getBackupTypeColor(selectedBackup.volid)}>
|
|
|
|
|
{getBackupTypeLabel(selectedBackup.volid)}
|
2025-10-11 12:06:59 +02:00
|
|
|
</Badge>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Storage Type</div>
|
|
|
|
|
<Badge variant="outline" className={getBackupStorageColor(selectedBackup.volid)}>
|
|
|
|
|
{getBackupStorageLabel(selectedBackup.volid)}
|
|
|
|
|
</Badge>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Storage</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedBackup.storage}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
2025-10-11 16:25:22 +02:00
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Size</div>
|
|
|
|
|
<Badge variant="outline" className="bg-green-500/10 text-green-500 border-green-500/20">
|
|
|
|
|
{selectedBackup.size_human}
|
|
|
|
|
</Badge>
|
|
|
|
|
</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
{selectedBackup.vmid && (
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">VM/CT ID</div>
|
|
|
|
|
<div className="text-sm text-foreground font-mono">{selectedBackup.vmid}</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="sm:col-span-2">
|
2025-10-11 12:06:59 +02:00
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Created</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedBackup.created}</div>
|
2025-10-11 12:06:59 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-2">Volume ID</div>
|
|
|
|
|
<div className="p-4 rounded-lg bg-muted/50 border border-border">
|
|
|
|
|
<pre className="text-sm text-foreground font-mono whitespace-pre-wrap break-all">
|
|
|
|
|
{selectedBackup.volid}
|
|
|
|
|
</pre>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
2025-10-11 16:04:42 +02:00
|
|
|
|
|
|
|
|
<Dialog open={isNotificationModalOpen} onOpenChange={setIsNotificationModalOpen}>
|
|
|
|
|
<DialogContent className="max-w-3xl max-h-[80vh] overflow-y-auto">
|
|
|
|
|
<DialogHeader>
|
|
|
|
|
<DialogTitle className="flex items-center gap-2">
|
|
|
|
|
<Bell className="h-5 w-5" />
|
|
|
|
|
Notification Details
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
<DialogDescription>Complete information about this notification</DialogDescription>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
{selectedNotification && (
|
|
|
|
|
<div className="space-y-4">
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
2025-10-11 16:04:42 +02:00
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Type</div>
|
2025-10-11 17:18:52 +02:00
|
|
|
<Badge variant="outline" className={getNotificationTypeColor(selectedNotification.type)}>
|
2025-10-11 16:04:42 +02:00
|
|
|
{getNotificationIcon(selectedNotification.type)}
|
2025-10-11 17:18:52 +02:00
|
|
|
{selectedNotification.type.toUpperCase()}
|
|
|
|
|
</Badge>
|
2025-10-11 16:04:42 +02:00
|
|
|
</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="sm:col-span-2">
|
2025-10-11 16:04:42 +02:00
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Timestamp</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground font-mono break-words">{selectedNotification.timestamp}</div>
|
2025-10-11 16:04:42 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Service</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedNotification.service}</div>
|
2025-10-11 16:04:42 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-1">Source</div>
|
2025-10-11 16:51:27 +02:00
|
|
|
<div className="text-sm text-foreground break-words">{selectedNotification.source}</div>
|
2025-10-11 16:04:42 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2025-10-11 17:18:52 +02:00
|
|
|
<div className="text-sm font-medium text-muted-foreground mb-2">Message (First 20 lines)</div>
|
|
|
|
|
<div className="p-4 rounded-lg bg-muted/50 border border-border max-h-[300px] overflow-y-auto">
|
2025-10-11 16:04:42 +02:00
|
|
|
<pre className="text-sm text-foreground whitespace-pre-wrap break-words">
|
2025-10-11 17:18:52 +02:00
|
|
|
{selectedNotification.message.split("\n").slice(0, 20).join("\n")}
|
|
|
|
|
{selectedNotification.message.split("\n").length > 20 && "\n\n... (download full log to see more)"}
|
2025-10-11 16:04:42 +02:00
|
|
|
</pre>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex justify-end">
|
|
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
onClick={() => handleDownloadNotificationLog(selectedNotification)}
|
2025-10-11 16:51:27 +02:00
|
|
|
className="border-border w-full sm:w-auto"
|
2025-10-11 16:04:42 +02:00
|
|
|
>
|
|
|
|
|
<Download className="h-4 w-4 mr-2" />
|
|
|
|
|
Download Complete Log
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
2025-09-28 23:09:31 +02:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|