Commit 2fc16d13 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Add copy-all button to error page for clipboard export

Big prominent button copies full error report (exception, stack trace,
request data, SQL queries, session) as formatted text to clipboard.
Visual feedback with green check animation on success.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 40d21535
......@@ -164,8 +164,18 @@
</div>
@endif
{{-- Copy All Button --}}
<div class="mt-6">
<button onclick="copyErrorReport()" id="copyBtn"
class="w-full sm:w-auto inline-flex items-center justify-center gap-3 px-8 py-4 bg-gray-900 text-white rounded-xl hover:bg-gray-800 text-base font-bold shadow-lg hover:shadow-xl transition-all">
<svg id="copyIcon" class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"/></svg>
<svg id="checkIcon" class="w-6 h-6 hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
<span id="copyText">نسخ كل تفاصيل الخطأ</span>
</button>
</div>
{{-- Navigation --}}
<div class="mt-6 flex items-center gap-4">
<div class="mt-4 flex items-center gap-4">
<a href="{{ url()->previous() }}" class="inline-flex items-center gap-2 px-4 py-2 bg-gray-600 text-white rounded-lg hover:bg-gray-700 text-sm font-medium">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/></svg>
العودة
......@@ -177,5 +187,65 @@
</div>
</div>
</div>
<script>
function copyErrorReport() {
const lines = [];
lines.push('=== ERROR REPORT ===');
lines.push('Time: {{ now()->format("Y-m-d H:i:s") }}');
lines.push('Error ID: {{ $errorId ?? "N/A" }}');
lines.push('');
lines.push('--- Exception ---');
lines.push('Class: {{ $exceptionClass ?? "Unknown" }}');
lines.push('Message: {{ addslashes($message ?? "Unknown error") }}');
lines.push('File: {{ $file ?? "N/A" }}:{{ $line ?? "?" }}');
lines.push('');
lines.push('--- Request ---');
lines.push('URL: {{ $url ?? "N/A" }}');
lines.push('Method: {{ $method ?? "N/A" }}');
lines.push('Route: {{ $routeName ?? "N/A" }}');
lines.push('User: {{ $userName ?? "Guest" }} (ID: {{ $userId ?? "-" }})');
lines.push('IP: {{ $ip ?? "N/A" }}');
lines.push('');
@if(!empty($trace))
lines.push('--- Stack Trace ---');
@foreach($trace as $i => $frame)
lines.push('#{{ $i }} {{ addslashes($frame["file"] ?? "(internal)") }}:{{ $frame["line"] ?? "?" }} {{ addslashes(($frame["class"] ?? "") . ($frame["type"] ?? "") . ($frame["function"] ?? "")) }}()');
@endforeach
lines.push('');
@endif
@if(!empty($inputData))
lines.push('--- Input Data ---');
lines.push({!! json_encode($inputData) !!});
lines.push('');
@endif
@if(!empty($queries))
lines.push('--- SQL Queries ---');
@foreach($queries as $query)
lines.push('{{ addslashes($query["query"] ?? "") }} ({{ $query["time"] ?? "?" }}ms)');
@endforeach
lines.push('');
@endif
@if(!empty($sessionData))
lines.push('--- Session ---');
lines.push({!! json_encode($sessionData) !!});
@endif
const text = lines.join('\n');
navigator.clipboard.writeText(text).then(() => {
document.getElementById('copyIcon').classList.add('hidden');
document.getElementById('checkIcon').classList.remove('hidden');
document.getElementById('copyText').textContent = 'تم النسخ!';
document.getElementById('copyBtn').classList.remove('bg-gray-900', 'hover:bg-gray-800');
document.getElementById('copyBtn').classList.add('bg-emerald-600', 'hover:bg-emerald-700');
setTimeout(() => {
document.getElementById('copyIcon').classList.remove('hidden');
document.getElementById('checkIcon').classList.add('hidden');
document.getElementById('copyText').textContent = 'نسخ كل تفاصيل الخطأ';
document.getElementById('copyBtn').classList.remove('bg-emerald-600', 'hover:bg-emerald-700');
document.getElementById('copyBtn').classList.add('bg-gray-900', 'hover:bg-gray-800');
}, 3000);
});
}
</script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment