Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | <script setup lang="ts">
import AppLayout from '@/layouts/AppLayout.vue';
import { Head, Link } from '@inertiajs/vue3';
import { Badge } from '@/components/ui/badge';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { ArrowLeft, Calendar, Globe, User, FileText } from 'lucide-vue-next';
interface AuditLog {
id: number;
event: string;
description: string;
user: {
id: number;
name: string;
email: string;
} | null;
company: {
id: number;
name: string;
} | null;
auditable_type: string;
auditable_id: number;
old_values: Record<string, any> | null;
new_values: Record<string, any> | null;
changed_fields: string[] | null;
ip_address: string | null;
user_agent: string | null;
url: string | null;
method: string | null;
metadata: Record<string, any> | null;
created_at: string;
}
const props = defineProps<{
auditLog: AuditLog;
}>();
function getEventBadgeVariant(event: string): string {
const variants: Record<string, string> = {
created: 'default',
updated: 'secondary',
deleted: 'destructive',
restored: 'outline',
};
return variants[event] || 'default';
}
function formatModelType(type: string): string {
return type.split('\\').pop() || type;
}
function formatValue(value: any): string {
if (value === null || value === undefined) {
return 'N/A';
}
if (typeof value === 'boolean') {
return value ? 'Yes' : 'No';
}
if (typeof value === 'object') {
return JSON.stringify(value, null, 2);
}
return String(value);
}
</script>
<template>
<Head :title="`Audit Log #${auditLog.id}`" />
<AppLayout>
<div class="space-y-6 p-6">
<div class="flex items-center justify-between">
<div class="flex items-center gap-4">
<Link href="/audit-logs">
<Button variant="ghost" size="icon">
<ArrowLeft class="h-4 w-4" />
</Button>
</Link>
<div>
<h1 class="text-3xl font-bold">Audit Log Details</h1>
<p class="text-muted-foreground mt-1">
View complete change history
</p>
</div>
</div>
</div>
<div class="grid grid-cols-1 gap-6 lg:grid-cols-3">
<!-- Main Details -->
<div class="lg:col-span-2 space-y-6">
<!-- Event Information -->
<Card>
<CardHeader>
<CardTitle>Event Information</CardTitle>
</CardHeader>
<CardContent class="space-y-4">
<div class="grid grid-cols-2 gap-4">
<div>
<label class="text-sm font-medium text-muted-foreground">
Event Type
</label>
<div class="mt-1">
<Badge :variant="getEventBadgeVariant(auditLog.event)">
{{ auditLog.event }}
</Badge>
</div>
</div>
<div>
<label class="text-sm font-medium text-muted-foreground">
Date & Time
</label>
<div class="mt-1 flex items-center gap-2">
<Calendar class="h-4 w-4 text-muted-foreground" />
<span>
{{ new Date(auditLog.created_at).toLocaleString() }}
</span>
</div>
</div>
<div>
<label class="text-sm font-medium text-muted-foreground">
Model Type
</label>
<div class="mt-1">
{{ formatModelType(auditLog.auditable_type) }}
</div>
</div>
<div>
<label class="text-sm font-medium text-muted-foreground">
Model ID
</label>
<div class="mt-1">#{{ auditLog.auditable_id }}</div>
</div>
</div>
<div>
<label class="text-sm font-medium text-muted-foreground">
Description
</label>
<div class="mt-1">{{ auditLog.description }}</div>
</div>
</CardContent>
</Card>
<!-- Changes -->
<Card v-if="auditLog.changed_fields && auditLog.changed_fields.length > 0">
<CardHeader>
<CardTitle>Changes</CardTitle>
</CardHeader>
<CardContent>
<div class="space-y-4">
<div
v-for="field in auditLog.changed_fields"
:key="field"
class="rounded-lg border p-4"
>
<div class="mb-2 font-medium">{{ field }}</div>
<div class="grid grid-cols-2 gap-4">
<div>
<div class="text-sm text-muted-foreground">Old Value</div>
<div class="mt-1 font-mono text-sm">
{{ formatValue(auditLog.old_values?.[field]) }}
</div>
</div>
<div>
<div class="text-sm text-muted-foreground">New Value</div>
<div class="mt-1 font-mono text-sm">
{{ formatValue(auditLog.new_values?.[field]) }}
</div>
</div>
</div>
</div>
</div>
</CardContent>
</Card>
</div>
<!-- Sidebar -->
<div class="space-y-6">
<!-- User Information -->
<Card>
<CardHeader>
<CardTitle class="flex items-center gap-2">
<User class="h-5 w-5" />
User Information
</CardTitle>
</CardHeader>
<CardContent class="space-y-4">
<div v-if="auditLog.user">
<div class="text-sm text-muted-foreground">Name</div>
<div class="font-medium">{{ auditLog.user.name }}</div>
<div class="mt-2 text-sm text-muted-foreground">Email</div>
<div class="text-sm">{{ auditLog.user.email }}</div>
</div>
<div v-else class="text-muted-foreground">System</div>
</CardContent>
</Card>
<!-- Request Information -->
<Card>
<CardHeader>
<CardTitle class="flex items-center gap-2">
<Globe class="h-5 w-5" />
Request Information
</CardTitle>
</CardHeader>
<CardContent class="space-y-4">
<div v-if="auditLog.ip_address">
<div class="text-sm text-muted-foreground">IP Address</div>
<div class="font-mono text-sm">{{ auditLog.ip_address }}</div>
</div>
<div v-if="auditLog.method">
<div class="text-sm text-muted-foreground">HTTP Method</div>
<div class="font-medium">{{ auditLog.method }}</div>
</div>
<div v-if="auditLog.url">
<div class="text-sm text-muted-foreground">URL</div>
<div class="break-all text-sm">{{ auditLog.url }}</div>
</div>
<div v-if="auditLog.user_agent">
<div class="text-sm text-muted-foreground">User Agent</div>
<div class="break-all text-xs">{{ auditLog.user_agent }}</div>
</div>
</CardContent>
</Card>
<!-- Metadata -->
<Card v-if="auditLog.metadata">
<CardHeader>
<CardTitle class="flex items-center gap-2">
<FileText class="h-5 w-5" />
Metadata
</CardTitle>
</CardHeader>
<CardContent>
<pre class="overflow-auto text-xs">{{
JSON.stringify(auditLog.metadata, null, 2)
}}</pre>
</CardContent>
</Card>
</div>
</div>
</div>
</AppLayout>
</template>
|