feat: add formatted timestamp display for firewall logs
This commit is contained in:
@@ -1460,6 +1460,7 @@ class Firewall extends Component
|
||||
'raw' => $line,
|
||||
'timestamp' => $fields['timestamp'] ?? '-',
|
||||
'timestamp_iso' => $this->convertTimestamp($fields['timestamp'] ?? ''),
|
||||
'timestamp_display' => $this->formatTimestampForDisplay($fields['timestamp'] ?? ''),
|
||||
'action' => $fields['action'] ?? '-',
|
||||
'level' => $fields['level'] ?? 0,
|
||||
'level_label' => $this->getLevelLabel($fields['level'] ?? 0),
|
||||
@@ -1498,6 +1499,22 @@ class Firewall extends Component
|
||||
}
|
||||
}
|
||||
|
||||
protected function formatTimestampForDisplay(string $timestamp): string
|
||||
{
|
||||
try {
|
||||
// Parse the Proxmox timestamp format: 04/Dec/2025:06:49:07 -1000
|
||||
$dt = Carbon::createFromFormat('d/M/Y:H:i:s O', $timestamp);
|
||||
|
||||
// Convert to user's timezone (using app timezone)
|
||||
$dt->setTimezone(config('app.timezone', 'UTC'));
|
||||
|
||||
// Format as: Dec 04, 2025 16:49:07 (or use a more readable format)
|
||||
return $dt->format('M d, Y H:i:s');
|
||||
} catch (\Exception $e) {
|
||||
return $timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getLevelLabel(int $level): string
|
||||
{
|
||||
return match($level) {
|
||||
|
||||
@@ -850,7 +850,7 @@
|
||||
<tbody>
|
||||
@foreach($this->paginatedLogs as $log)
|
||||
<tr class="border-b border-neutral/10 hover:bg-background-secondary/30 transition-colors">
|
||||
<td class="py-3 px-4 text-xs text-base/70">{{ $log['timestamp'] ?? '-' }}</td>
|
||||
<td class="py-3 px-4 text-xs text-base/70">{{ $log['timestamp_display'] ?? $log['timestamp'] ?? '-' }}</td>
|
||||
<td class="py-3 px-4 text-sm">
|
||||
<span class="px-2 py-1 rounded text-xs font-medium {{ $log['level_badge_class'] ?? '' }}">
|
||||
{{ $log['action'] ?? '-' }}
|
||||
|
||||
Reference in New Issue
Block a user