Design a website to list the logs captured of api failures , it have serial number ,Status, Method, Time ,Request URL, Error Message , and an Actions button to view details , action button have eye icon , status is coloured
Browse fileswhen view button is clicked a sidebar or modal is opened it have details like API error , resolution steps , and 2 buttons one close side /modal bar one submit ticket.
Add a search tab with on top to sort and search logs by ,Status, Method, Time ,Request URL, Error Message.
- README.md +8 -5
- components/navbar.js +49 -0
- index.html +169 -19
- script.js +163 -0
- style.css +50 -19
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: FailTrack - API Error Logger 🐞
|
| 3 |
+
colorFrom: green
|
| 4 |
+
colorTo: green
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://huggingface.co/deepsite).
|
components/navbar.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CustomNavbar extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
.navbar {
|
| 7 |
+
background-color: white;
|
| 8 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
.nav-link {
|
| 12 |
+
transition: color 0.2s;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
.nav-link:hover {
|
| 16 |
+
color: #6366f1;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
.active {
|
| 20 |
+
color: #6366f1;
|
| 21 |
+
border-bottom: 2px solid #6366f1;
|
| 22 |
+
}
|
| 23 |
+
</style>
|
| 24 |
+
<nav class="navbar px-6 py-4 border-b border-gray-200">
|
| 25 |
+
<div class="container mx-auto flex justify-between items-center">
|
| 26 |
+
<div class="flex items-center space-x-8">
|
| 27 |
+
<a href="#" class="text-xl font-bold text-gray-800">FailTrack</a>
|
| 28 |
+
<div class="hidden md:flex space-x-6">
|
| 29 |
+
<a href="#" class="nav-link text-gray-600 active">Dashboard</a>
|
| 30 |
+
<a href="#" class="nav-link text-gray-600">Analytics</a>
|
| 31 |
+
<a href="#" class="nav-link text-gray-600">Settings</a>
|
| 32 |
+
</div>
|
| 33 |
+
</div>
|
| 34 |
+
<div class="flex items-center space-x-4">
|
| 35 |
+
<button class="p-2 rounded-full hover:bg-gray-100">
|
| 36 |
+
<i data-feather="bell"></i>
|
| 37 |
+
</button>
|
| 38 |
+
<div class="flex items-center space-x-2">
|
| 39 |
+
<img src="http://static.photos/people/1200x630/1" alt="User" class="w-8 h-8 rounded-full">
|
| 40 |
+
<span class="hidden md:inline text-sm font-medium text-gray-700">Admin</span>
|
| 41 |
+
</div>
|
| 42 |
+
</div>
|
| 43 |
+
</div>
|
| 44 |
+
</nav>
|
| 45 |
+
`;
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
customElements.define('custom-navbar', CustomNavbar);
|
index.html
CHANGED
|
@@ -1,19 +1,169 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>FailTrack - API Error Logger</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
+
<script>
|
| 12 |
+
tailwind.config = {
|
| 13 |
+
theme: {
|
| 14 |
+
extend: {
|
| 15 |
+
colors: {
|
| 16 |
+
primary: {
|
| 17 |
+
500: '#6366f1',
|
| 18 |
+
},
|
| 19 |
+
secondary: {
|
| 20 |
+
500: '#ec4899',
|
| 21 |
+
},
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
</script>
|
| 27 |
+
</head>
|
| 28 |
+
<body class="bg-gray-100 min-h-screen">
|
| 29 |
+
<custom-navbar></custom-navbar>
|
| 30 |
+
|
| 31 |
+
<main class="container mx-auto px-4 py-8">
|
| 32 |
+
<div class="flex justify-between items-center mb-8">
|
| 33 |
+
<h1 class="text-3xl font-bold text-gray-800">API Error Logs</h1>
|
| 34 |
+
<div class="relative">
|
| 35 |
+
<input type="text" placeholder="Search logs..." class="pl-10 pr-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent w-64">
|
| 36 |
+
<i data-feather="search" class="absolute left-3 top-2.5 text-gray-400"></i>
|
| 37 |
+
</div>
|
| 38 |
+
</div>
|
| 39 |
+
|
| 40 |
+
<!-- Filters -->
|
| 41 |
+
<div class="bg-white rounded-lg shadow p-4 mb-6">
|
| 42 |
+
<div class="grid grid-cols-1 md:grid-cols-5 gap-4">
|
| 43 |
+
<div>
|
| 44 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Status</label>
|
| 45 |
+
<select class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 46 |
+
<option>All</option>
|
| 47 |
+
<option>200</option>
|
| 48 |
+
<option>400</option>
|
| 49 |
+
<option>500</option>
|
| 50 |
+
</select>
|
| 51 |
+
</div>
|
| 52 |
+
<div>
|
| 53 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Method</label>
|
| 54 |
+
<select class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 55 |
+
<option>All</option>
|
| 56 |
+
<option>GET</option>
|
| 57 |
+
<option>POST</option>
|
| 58 |
+
<option>PUT</option>
|
| 59 |
+
<option>DELETE</option>
|
| 60 |
+
</select>
|
| 61 |
+
</div>
|
| 62 |
+
<div>
|
| 63 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Time Range</label>
|
| 64 |
+
<select class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 65 |
+
<option>Last 24 hours</option>
|
| 66 |
+
<option>Last week</option>
|
| 67 |
+
<option>Last month</option>
|
| 68 |
+
</select>
|
| 69 |
+
</div>
|
| 70 |
+
<div>
|
| 71 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">URL Contains</label>
|
| 72 |
+
<input type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 73 |
+
</div>
|
| 74 |
+
<div>
|
| 75 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Error Contains</label>
|
| 76 |
+
<input type="text" class="w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 text-sm">
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
<div class="flex justify-end mt-4">
|
| 80 |
+
<button class="px-4 py-2 bg-primary-500 text-white rounded-md hover:bg-primary-600 transition">Apply Filters</button>
|
| 81 |
+
</div>
|
| 82 |
+
</div>
|
| 83 |
+
|
| 84 |
+
<!-- Logs Table -->
|
| 85 |
+
<div class="bg-white rounded-lg shadow overflow-hidden">
|
| 86 |
+
<div class="overflow-x-auto">
|
| 87 |
+
<table class="min-w-full divide-y divide-gray-200">
|
| 88 |
+
<thead class="bg-gray-50">
|
| 89 |
+
<tr>
|
| 90 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">#</th>
|
| 91 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
|
| 92 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Method</th>
|
| 93 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Time</th>
|
| 94 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Request URL</th>
|
| 95 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Error Message</th>
|
| 96 |
+
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
|
| 97 |
+
</tr>
|
| 98 |
+
</thead>
|
| 99 |
+
<tbody class="bg-white divide-y divide-gray-200" id="logsTable">
|
| 100 |
+
<!-- Logs will be populated here by JavaScript -->
|
| 101 |
+
</tbody>
|
| 102 |
+
</table>
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
</main>
|
| 106 |
+
|
| 107 |
+
<!-- Error Details Modal -->
|
| 108 |
+
<div id="errorModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 109 |
+
<div class="bg-white rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto">
|
| 110 |
+
<div class="p-6">
|
| 111 |
+
<div class="flex justify-between items-center mb-4">
|
| 112 |
+
<h2 class="text-xl font-bold text-gray-800">Error Details</h2>
|
| 113 |
+
<button id="closeModal" class="text-gray-500 hover:text-gray-700">
|
| 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">Time:</span> <span id="modalTime"></span></p>
|
| 125 |
+
<p><span class="font-medium">URL:</span> <span id="modalUrl" class="break-all"></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"></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>
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
|
| 145 |
+
<div class="mb-6">
|
| 146 |
+
<h3 class="font-medium text-gray-700 mb-2">Resolution Steps</h3>
|
| 147 |
+
<div id="modalResolution" class="bg-blue-50 p-4 rounded text-sm"></div>
|
| 148 |
+
</div>
|
| 149 |
+
|
| 150 |
+
<div class="flex justify-end space-x-3">
|
| 151 |
+
<button id="submitTicket" class="px-4 py-2 bg-secondary-500 text-white rounded-md hover:bg-secondary-600 transition flex items-center">
|
| 152 |
+
<i data-feather="plus" class="mr-2 w-4 h-4"></i> Submit Ticket
|
| 153 |
+
</button>
|
| 154 |
+
<button id="closeModalBtn" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300 transition">
|
| 155 |
+
Close
|
| 156 |
+
</button>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
|
| 162 |
+
<script src="components/navbar.js"></script>
|
| 163 |
+
<script src="script.js"></script>
|
| 164 |
+
<script>
|
| 165 |
+
feather.replace();
|
| 166 |
+
</script>
|
| 167 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 168 |
+
</body>
|
| 169 |
+
</html>
|
script.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Sample data - in a real app this would come from an API
|
| 2 |
+
const sampleLogs = [
|
| 3 |
+
{
|
| 4 |
+
id: 1,
|
| 5 |
+
status: 500,
|
| 6 |
+
method: 'POST',
|
| 7 |
+
time: '2023-05-15 14:32:45',
|
| 8 |
+
url: 'https://api.example.com/v1/users',
|
| 9 |
+
errorMessage: 'Internal Server Error: Database connection timeout',
|
| 10 |
+
errorCode: 'DB_CONN_TIMEOUT',
|
| 11 |
+
errorType: 'Database',
|
| 12 |
+
resolution: 'Check database connection pool. Verify database server is running and accessible. Consider increasing connection timeout setting.'
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
id: 2,
|
| 16 |
+
status: 404,
|
| 17 |
+
method: 'GET',
|
| 18 |
+
time: '2023-05-15 14:30:12',
|
| 19 |
+
url: 'https://api.example.com/v1/products/12345',
|
| 20 |
+
errorMessage: 'Product not found with ID 12345',
|
| 21 |
+
errorCode: 'RESOURCE_NOT_FOUND',
|
| 22 |
+
errorType: 'Validation',
|
| 23 |
+
resolution: 'Verify the product ID exists in the database. Check if the product was deleted. Validate the request parameters.'
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
id: 3,
|
| 27 |
+
status: 400,
|
| 28 |
+
method: 'PUT',
|
| 29 |
+
time: '2023-05-15 14:25:33',
|
| 30 |
+
url: 'https://api.example.com/v1/orders/678',
|
| 31 |
+
errorMessage: 'Invalid request body: Missing required field "quantity"',
|
| 32 |
+
errorCode: 'VALIDATION_ERROR',
|
| 33 |
+
errorType: 'Validation',
|
| 34 |
+
resolution: 'Check the API documentation for required fields. Validate the request body before sending. Ensure all required fields are included.'
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
id: 4,
|
| 38 |
+
status: 401,
|
| 39 |
+
method: 'GET',
|
| 40 |
+
time: '2023-05-15 14:20:18',
|
| 41 |
+
url: 'https://api.example.com/v1/users/me',
|
| 42 |
+
errorMessage: 'Unauthorized: Invalid or expired access token',
|
| 43 |
+
errorCode: 'INVALID_TOKEN',
|
| 44 |
+
errorType: 'Authentication',
|
| 45 |
+
resolution: 'Check if the access token is valid and not expired. Verify the token signature. Refresh the token if needed.'
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
id: 5,
|
| 49 |
+
status: 503,
|
| 50 |
+
method: 'POST',
|
| 51 |
+
time: '2023-05-15 14:15:42',
|
| 52 |
+
url: 'https://api.example.com/v1/payments',
|
| 53 |
+
errorMessage: 'Service Unavailable: Payment gateway not responding',
|
| 54 |
+
errorCode: 'GATEWAY_TIMEOUT',
|
| 55 |
+
errorType: 'Integration',
|
| 56 |
+
resolution: 'Check the payment gateway status. Verify network connectivity. Implement retry logic with exponential backoff.'
|
| 57 |
+
}
|
| 58 |
+
];
|
| 59 |
+
|
| 60 |
+
// DOM elements
|
| 61 |
+
const logsTable = document.getElementById('logsTable');
|
| 62 |
+
const errorModal = document.getElementById('errorModal');
|
| 63 |
+
const closeModal = document.getElementById('closeModal');
|
| 64 |
+
const closeModalBtn = document.getElementById('closeModalBtn');
|
| 65 |
+
const submitTicket = document.getElementById('submitTicket');
|
| 66 |
+
|
| 67 |
+
// Current selected log
|
| 68 |
+
let currentLog = null;
|
| 69 |
+
|
| 70 |
+
// Function to render logs table
|
| 71 |
+
function renderLogsTable() {
|
| 72 |
+
logsTable.innerHTML = '';
|
| 73 |
+
|
| 74 |
+
sampleLogs.forEach(log => {
|
| 75 |
+
const row = document.createElement('tr');
|
| 76 |
+
row.className = 'hover:bg-gray-50';
|
| 77 |
+
row.innerHTML = `
|
| 78 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.id}</td>
|
| 79 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 80 |
+
<span class="status-badge ${getStatusClass(log.status)}">${log.status}</span>
|
| 81 |
+
</td>
|
| 82 |
+
<td class="px-6 py-4 whitespace-nowrap">
|
| 83 |
+
<span class="status-badge ${getMethodClass(log.method)}">${log.method}</span>
|
| 84 |
+
</td>
|
| 85 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${log.time}</td>
|
| 86 |
+
<td class="px-6 py-4 text-sm text-gray-500 max-w-xs truncate">${log.url}</td>
|
| 87 |
+
<td class="px-6 py-4 text-sm text-gray-500 truncate max-w-xs">${log.errorMessage}</td>
|
| 88 |
+
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
| 89 |
+
<button class="view-btn p-1 rounded hover:bg-gray-200" data-id="${log.id}">
|
| 90 |
+
<i data-feather="eye" class="w-4 h-4 text-primary-500"></i>
|
| 91 |
+
</button>
|
| 92 |
+
</td>
|
| 93 |
+
`;
|
| 94 |
+
logsTable.appendChild(row);
|
| 95 |
+
});
|
| 96 |
+
|
| 97 |
+
// Add event listeners to view buttons
|
| 98 |
+
document.querySelectorAll('.view-btn').forEach(btn => {
|
| 99 |
+
btn.addEventListener('click', (e) => {
|
| 100 |
+
const id = parseInt(e.currentTarget.getAttribute('data-id'));
|
| 101 |
+
currentLog = sampleLogs.find(log => log.id === id);
|
| 102 |
+
showErrorDetails(currentLog);
|
| 103 |
+
});
|
| 104 |
+
});
|
| 105 |
+
|
| 106 |
+
feather.replace();
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
// Helper function to get status badge class
|
| 110 |
+
function getStatusClass(status) {
|
| 111 |
+
if (status >= 200 && status < 300) return 'status-2xx';
|
| 112 |
+
if (status >= 400 && status < 500) return 'status-4xx';
|
| 113 |
+
if (status >= 500) return 'status-5xx';
|
| 114 |
+
return '';
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
// Helper function to get method badge class
|
| 118 |
+
function getMethodClass(method) {
|
| 119 |
+
return `method-${method.toLowerCase()}`;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
// Function to show error details in modal
|
| 123 |
+
function showErrorDetails(log) {
|
| 124 |
+
document.getElementById('modalStatus').textContent = log.status;
|
| 125 |
+
document.getElementById('modalStatus').className = `status-badge ${getStatusClass(log.status)}`;
|
| 126 |
+
document.getElementById('modalMethod').textContent = log.method;
|
| 127 |
+
document.getElementById('modalTime').textContent = log.time;
|
| 128 |
+
document.getElementById('modalUrl').textContent = log.url;
|
| 129 |
+
document.getElementById('modalErrorCode').textContent = log.errorCode;
|
| 130 |
+
document.getElementById('modalErrorType').textContent = log.errorType;
|
| 131 |
+
document.getElementById('modalErrorMessage').textContent = log.errorMessage;
|
| 132 |
+
document.getElementById('modalResolution').textContent = log.resolution;
|
| 133 |
+
|
| 134 |
+
errorModal.classList.remove('hidden');
|
| 135 |
+
document.body.style.overflow = 'hidden';
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
// Function to close modal
|
| 139 |
+
function closeErrorModal() {
|
| 140 |
+
errorModal.classList.add('hidden');
|
| 141 |
+
document.body.style.overflow = 'auto';
|
| 142 |
+
currentLog = null;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
// Event listeners
|
| 146 |
+
closeModal.addEventListener('click', closeErrorModal);
|
| 147 |
+
closeModalBtn.addEventListener('click', closeErrorModal);
|
| 148 |
+
submitTicket.addEventListener('click', () => {
|
| 149 |
+
alert(`Ticket submitted for error: ${currentLog.errorCode}\nAn engineer will review this issue shortly.`);
|
| 150 |
+
closeErrorModal();
|
| 151 |
+
});
|
| 152 |
+
|
| 153 |
+
// Initialize the page
|
| 154 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 155 |
+
renderLogsTable();
|
| 156 |
+
|
| 157 |
+
// Close modal when clicking outside
|
| 158 |
+
errorModal.addEventListener('click', (e) => {
|
| 159 |
+
if (e.target === errorModal) {
|
| 160 |
+
closeErrorModal();
|
| 161 |
+
}
|
| 162 |
+
});
|
| 163 |
+
});
|
style.css
CHANGED
|
@@ -1,28 +1,59 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
margin-top: 0;
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
font-size: 15px;
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
.
|
| 19 |
-
|
| 20 |
-
margin: 0 auto;
|
| 21 |
-
padding: 16px;
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
.
|
| 27 |
-
|
| 28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Custom styles that can't be easily done with Tailwind */
|
| 2 |
+
.status-badge {
|
| 3 |
+
@apply px-2 py-1 rounded text-xs font-medium;
|
| 4 |
}
|
| 5 |
|
| 6 |
+
.status-2xx {
|
| 7 |
+
@apply bg-green-100 text-green-800;
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
+
.status-4xx {
|
| 11 |
+
@apply bg-yellow-100 text-yellow-800;
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
|
| 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 |
+
}
|
| 25 |
+
|
| 26 |
+
.method-put {
|
| 27 |
+
@apply bg-yellow-100 text-yellow-800;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.method-delete {
|
| 31 |
+
@apply bg-red-100 text-red-800;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.method-patch {
|
| 35 |
+
@apply bg-green-100 text-green-800;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/* Smooth scroll for modal */
|
| 39 |
+
.modal-content {
|
| 40 |
+
scroll-behavior: smooth;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/* Custom scrollbar for modal */
|
| 44 |
+
.modal-content::-webkit-scrollbar {
|
| 45 |
+
width: 8px;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.modal-content::-webkit-scrollbar-track {
|
| 49 |
+
background: #f1f1f1;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.modal-content::-webkit-scrollbar-thumb {
|
| 53 |
+
background: #888;
|
| 54 |
+
border-radius: 4px;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.modal-content::-webkit-scrollbar-thumb:hover {
|
| 58 |
+
background: #555;
|
| 59 |
+
}
|