<!-- Error Details Modal --> data populate by javascript
Browse files- index.html +10 -8
- script.js +20 -4
- style.css +11 -1
index.html
CHANGED
|
@@ -114,28 +114,30 @@
|
|
| 114 |
<i data-feather="x"></i>
|
| 115 |
</button>
|
| 116 |
</div>
|
| 117 |
-
|
| 118 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
| 119 |
<div>
|
| 120 |
<h3 class="font-medium text-gray-700 mb-2">Request Information</h3>
|
| 121 |
<div class="space-y-2">
|
| 122 |
<p><span class="font-medium">Status:</span> <span id="modalStatus" class="px-2 py-1 rounded text-xs"></span></p>
|
| 123 |
-
<p><span class="font-medium">Method:</span> <span id="modalMethod"></span></p>
|
| 124 |
-
<p><span class="font-medium">
|
| 125 |
-
<p><span class="font-medium">
|
|
|
|
| 126 |
</div>
|
| 127 |
</div>
|
| 128 |
|
| 129 |
<div>
|
| 130 |
<h3 class="font-medium text-gray-700 mb-2">Error Information</h3>
|
| 131 |
<div class="space-y-2">
|
| 132 |
-
<p><span class="font-medium">Error Code:</span> <span id="modalErrorCode"></span></p>
|
| 133 |
-
<p><span class="font-medium">Error Type:</span> <span id="modalErrorType"></span></p>
|
|
|
|
|
|
|
|
|
|
| 134 |
</div>
|
| 135 |
</div>
|
| 136 |
</div>
|
| 137 |
-
|
| 138 |
-
<div class="mb-6">
|
| 139 |
<h3 class="font-medium text-gray-700 mb-2">Full Error Message</h3>
|
| 140 |
<div class="bg-gray-50 p-4 rounded">
|
| 141 |
<pre id="modalErrorMessage" class="text-sm whitespace-pre-wrap overflow-x-auto"></pre>
|
|
|
|
| 114 |
<i data-feather="x"></i>
|
| 115 |
</button>
|
| 116 |
</div>
|
|
|
|
| 117 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
| 118 |
<div>
|
| 119 |
<h3 class="font-medium text-gray-700 mb-2">Request Information</h3>
|
| 120 |
<div class="space-y-2">
|
| 121 |
<p><span class="font-medium">Status:</span> <span id="modalStatus" class="px-2 py-1 rounded text-xs"></span></p>
|
| 122 |
+
<p><span class="font-medium">Method:</span> <span id="modalMethod" class="px-2 py-1 rounded text-xs"></span></p>
|
| 123 |
+
<p><span class="font-medium">Endpoint:</span> <span id="modalEndpoint" class="break-all"></span></p>
|
| 124 |
+
<p><span class="font-medium">Timestamp:</span> <span id="modalTime" class="font-mono"></span></p>
|
| 125 |
+
<p><span class="font-medium">Request Duration:</span> <span id="modalDuration" class="font-mono">-</span></p>
|
| 126 |
</div>
|
| 127 |
</div>
|
| 128 |
|
| 129 |
<div>
|
| 130 |
<h3 class="font-medium text-gray-700 mb-2">Error Information</h3>
|
| 131 |
<div class="space-y-2">
|
| 132 |
+
<p><span class="font-medium">Error Code:</span> <span id="modalErrorCode" class="font-mono"></span></p>
|
| 133 |
+
<p><span class="font-medium">Error Type:</span> <span id="modalErrorType" class="px-2 py-1 rounded text-xs"></span></p>
|
| 134 |
+
<p><span class="font-medium">Occurrences:</span> <span id="modalOccurrences" class="font-mono">1</span></p>
|
| 135 |
+
<p><span class="font-medium">First Occurred:</span> <span id="modalFirstOccurred" class="font-mono">-</span></p>
|
| 136 |
+
<p><span class="font-medium">Last Occurred:</span> <span id="modalLastOccurred" class="font-mono">-</span></p>
|
| 137 |
</div>
|
| 138 |
</div>
|
| 139 |
</div>
|
| 140 |
+
<div class="mb-6">
|
|
|
|
| 141 |
<h3 class="font-medium text-gray-700 mb-2">Full Error Message</h3>
|
| 142 |
<div class="bg-gray-50 p-4 rounded">
|
| 143 |
<pre id="modalErrorMessage" class="text-sm whitespace-pre-wrap overflow-x-auto"></pre>
|
script.js
CHANGED
|
@@ -125,20 +125,36 @@ function getStatusClass(status) {
|
|
| 125 |
function getMethodClass(method) {
|
| 126 |
return `method-${method.toLowerCase()}`;
|
| 127 |
}
|
| 128 |
-
|
| 129 |
// Function to show error details in modal
|
| 130 |
function showErrorDetails(log) {
|
|
|
|
| 131 |
document.getElementById('modalStatus').textContent = log.status;
|
| 132 |
document.getElementById('modalStatus').className = `status-badge ${getStatusClass(log.status)}`;
|
| 133 |
document.getElementById('modalMethod').textContent = log.method;
|
| 134 |
-
document.getElementById('
|
|
|
|
|
|
|
| 135 |
document.getElementById('modalUrl').textContent = log.url;
|
|
|
|
|
|
|
| 136 |
document.getElementById('modalErrorCode').textContent = log.errorCode;
|
| 137 |
document.getElementById('modalErrorType').textContent = log.errorType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
document.getElementById('modalErrorMessage').textContent = log.errorMessage;
|
| 139 |
document.getElementById('modalResolution').textContent = log.resolution;
|
| 140 |
-
|
| 141 |
-
errorModal.classList.remove('hidden');
|
| 142 |
document.body.style.overflow = 'hidden';
|
| 143 |
}
|
| 144 |
|
|
|
|
| 125 |
function getMethodClass(method) {
|
| 126 |
return `method-${method.toLowerCase()}`;
|
| 127 |
}
|
|
|
|
| 128 |
// Function to show error details in modal
|
| 129 |
function showErrorDetails(log) {
|
| 130 |
+
// Request Info
|
| 131 |
document.getElementById('modalStatus').textContent = log.status;
|
| 132 |
document.getElementById('modalStatus').className = `status-badge ${getStatusClass(log.status)}`;
|
| 133 |
document.getElementById('modalMethod').textContent = log.method;
|
| 134 |
+
document.getElementById('modalMethod').className = `status-badge ${getMethodClass(log.method)}`;
|
| 135 |
+
document.getElementById('modalEndpoint').textContent = new URL(log.url).pathname;
|
| 136 |
+
document.getElementById('modalTime').textContent = new Date(log.time).toLocaleString();
|
| 137 |
document.getElementById('modalUrl').textContent = log.url;
|
| 138 |
+
|
| 139 |
+
// Error Info
|
| 140 |
document.getElementById('modalErrorCode').textContent = log.errorCode;
|
| 141 |
document.getElementById('modalErrorType').textContent = log.errorType;
|
| 142 |
+
document.getElementById('modalErrorType').className = 'status-badge status-4xx';
|
| 143 |
+
|
| 144 |
+
// Mock additional data
|
| 145 |
+
document.getElementById('modalDuration').textContent = `${Math.floor(Math.random() * 500) + 100}ms`;
|
| 146 |
+
document.getElementById('modalOccurrences').textContent = Math.floor(Math.random() * 10) + 1;
|
| 147 |
+
|
| 148 |
+
const firstDate = new Date(log.time);
|
| 149 |
+
const lastDate = new Date(log.time);
|
| 150 |
+
firstDate.setDate(firstDate.getDate() - Math.floor(Math.random() * 3));
|
| 151 |
+
|
| 152 |
+
document.getElementById('modalFirstOccurred').textContent = firstDate.toLocaleString();
|
| 153 |
+
document.getElementById('modalLastOccurred').textContent = lastDate.toLocaleString();
|
| 154 |
+
|
| 155 |
document.getElementById('modalErrorMessage').textContent = log.errorMessage;
|
| 156 |
document.getElementById('modalResolution').textContent = log.resolution;
|
| 157 |
+
errorModal.classList.remove('hidden');
|
|
|
|
| 158 |
document.body.style.overflow = 'hidden';
|
| 159 |
}
|
| 160 |
|
style.css
CHANGED
|
@@ -14,11 +14,21 @@
|
|
| 14 |
.status-5xx {
|
| 15 |
@apply bg-red-100 text-red-800;
|
| 16 |
}
|
| 17 |
-
|
| 18 |
.method-get {
|
| 19 |
@apply bg-blue-100 text-blue-800;
|
| 20 |
}
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
.method-post {
|
| 23 |
@apply bg-purple-100 text-purple-800;
|
| 24 |
}
|
|
|
|
| 14 |
.status-5xx {
|
| 15 |
@apply bg-red-100 text-red-800;
|
| 16 |
}
|
|
|
|
| 17 |
.method-get {
|
| 18 |
@apply bg-blue-100 text-blue-800;
|
| 19 |
}
|
| 20 |
|
| 21 |
+
.font-mono {
|
| 22 |
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
#modalEndpoint {
|
| 26 |
+
@apply text-sm bg-gray-100 p-1 rounded font-mono;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
.dark .status-badge {
|
| 30 |
+
@apply bg-opacity-20;
|
| 31 |
+
}
|
| 32 |
.method-post {
|
| 33 |
@apply bg-purple-100 text-purple-800;
|
| 34 |
}
|