Spaces:
Paused
Paused
File size: 19,607 Bytes
27807c4 | 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 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= title %></title>
<!-- Bootstrap CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.11.2/font/bootstrap-icons.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- Auto-refresh indicator -->
<div id="autoRefreshIndicator" class="auto-refresh" style="display: none;">
<i class="bi bi-arrow-clockwise"></i> Auto-refreshing...
</div>
<!-- Navigation -->
<nav class="navbar navbar-dark">
<div class="container-fluid">
<span class="navbar-brand mb-0">
<i class="bi bi-speedometer2"></i> <%= title %>
</span>
<div class="d-flex align-items-center text-white">
<small class="me-3">
<i class="bi bi-clock"></i> <%= currentTime %>
</small>
<span class="status-badge <%= browserStatus === 'Connected' ? 'badge-online' : 'badge-offline' %>">
<i class="bi bi-<%= browserStatus === 'Connected' ? 'check-circle' : 'x-circle' %>"></i>
<%= browserStatus %>
</span>
</div>
</div>
</nav>
<div class="container-fluid py-4">
<!-- Alerts -->
<% if (query.error) { %>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="bi bi-exclamation-triangle-fill"></i>
<strong>Error:</strong> <%= decodeURIComponent(query.error) %>
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
<% } %>
<% if (query.success) { %>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<i class="bi bi-check-circle-fill"></i>
<strong>Success:</strong> <%= decodeURIComponent(query.success) %>
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
<% } %>
<% if (query.testResult) { %>
<% const testResult = JSON.parse(decodeURIComponent(query.testResult)); %>
<div class="alert <%= testResult.success ? 'alert-success' : 'alert-danger' %> alert-dismissible fade show" role="alert">
<i class="bi bi-<%= testResult.success ? 'check-circle-fill' : 'x-circle-fill' %>"></i>
<strong>Test Result:</strong><br>
<div class="mt-2">
<strong>URL:</strong> <%= testResult.url %><br>
<strong>Status:</strong> <%= testResult.success ? 'Success' : 'Failed' %><br>
<strong>Response Time:</strong> <%= testResult.responseTime %>ms<br>
<strong>Content Length:</strong> <%= testResult.contentLength.toLocaleString() %> chars<br>
<strong>Cache:</strong> <%= testResult.cached ? 'HIT' : 'MISS' %>
<% if (testResult.error) { %><br><strong>Error:</strong> <%= testResult.error %><% } %>
</div>
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
<% } %>
<!-- Performance Metrics -->
<div class="row g-3 mb-4">
<div class="col-md-3 col-sm-6">
<div class="card metric-card">
<div class="metric-value text-primary" id="totalRequests"><%= serverStats.totalRequests %></div>
<div class="metric-label">Total Requests</div>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="card metric-card">
<div class="metric-value text-success" id="hitRate"><%= serverStats.hitRate %>%</div>
<div class="metric-label">Cache Hit Rate</div>
<div class="progress mt-2">
<div class="progress-bar bg-success" style="width: <%= serverStats.hitRate %>%" id="hitRateBar"></div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="card metric-card">
<div class="metric-value text-warning" id="avgResponseTime"><%= serverStats.averageResponseTime %>ms</div>
<div class="metric-label">Avg Response Time</div>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="card metric-card">
<div class="metric-value <%= serverStats.errors > 0 ? 'text-danger' : 'text-success' %>" id="errorRate"><%= serverStats.errorRate %>%</div>
<div class="metric-label">Error Rate</div>
</div>
</div>
</div>
<!-- Main Content Grid -->
<div class="row g-4">
<!-- URL Testing -->
<div class="col-lg-6">
<div class="card">
<div class="card-header">
<i class="bi bi-search"></i> URL Testing
</div>
<div class="card-body">
<form method="POST" action="/test" id="testForm">
<div class="mb-3">
<label for="testUrl" class="form-label">Test URL</label>
<input type="url" class="form-control" id="testUrl" name="testUrl"
placeholder="https://example.com" required>
</div>
<button type="submit" class="btn btn-primary">
<i class="bi bi-play-circle"></i> Test Scraping
</button>
</form>
</div>
</div>
</div>
<!-- Management Actions -->
<div class="col-lg-6">
<div class="card">
<div class="card-header">
<i class="bi bi-gear"></i> Management
</div>
<div class="card-body">
<div class="d-grid gap-2">
<button onclick="toggleAutoRefresh()" class="btn btn-success" id="autoRefreshBtn">
<i class="bi bi-arrow-clockwise"></i> Enable Auto-Refresh
</button>
<form method="POST" action="/clear-cache" class="d-inline">
<button type="submit" class="btn btn-warning w-100"
onclick="return confirm('Clear all cache?')">
<i class="bi bi-trash"></i> Clear Cache
</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Detailed Stats -->
<div class="row g-4 mt-2">
<!-- Server Performance -->
<div class="col-lg-3 col-md-6">
<div class="card">
<div class="card-header">
<i class="bi bi-speedometer"></i> Performance
</div>
<div class="card-body">
<div class="d-flex justify-content-between mb-2">
<span>Uptime</span>
<strong class="text-primary" id="uptime"><%= serverStats.uptime %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Cache Hits</span>
<strong class="text-success" id="cacheHits"><%= serverStats.cacheHits %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Cache Misses</span>
<strong class="text-warning" id="cacheMisses"><%= serverStats.cacheMisses %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Errors</span>
<strong class="text-danger" id="errorCount"><%= serverStats.errors %></strong>
</div>
</div>
</div>
</div>
<!-- Cache Statistics -->
<div class="col-lg-3 col-md-6">
<div class="card">
<div class="card-header">
<i class="bi bi-hdd"></i> Cache Stats
</div>
<div class="card-body">
<div class="d-flex justify-content-between mb-2">
<span>Memory Entries</span>
<strong class="text-primary" id="memoryEntries"><%= cacheStats.memoryEntries %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>File Entries</span>
<strong class="text-secondary" id="fileEntries"><%= cacheStats.fileEntries %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Total Size</span>
<strong class="text-info" id="totalFileSize"><%= cacheStats.totalFileSize %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>TTL</span>
<strong class="text-secondary"><%= cacheStats.cacheTTL %></strong>
</div>
<div class="d-flex justify-content-between">
<span>Newest</span>
<small class="text-muted"><%= cacheStats.newestCache !== 'N/A' ? new Date(cacheStats.newestCache).toLocaleTimeString() : 'N/A' %></small>
</div>
</div>
</div>
</div>
<!-- System Information -->
<div class="col-lg-3 col-md-6">
<div class="card">
<div class="card-header">
<i class="bi bi-cpu"></i> System Info
</div>
<div class="card-body">
<div class="d-flex justify-content-between mb-2">
<span>Platform</span>
<strong class="text-secondary"><%= systemInfo.platform %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>CPU Cores</span>
<strong class="text-primary" id="cpuCores"><%= systemInfo.cpuCount %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Total Memory</span>
<strong class="text-info" id="totalMemory"><%= systemInfo.totalMemory %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Free Memory</span>
<strong class="text-success" id="freeMemory"><%= systemInfo.freeMemory %></strong>
</div>
<div class="d-flex justify-content-between">
<span>Node.js</span>
<strong class="text-secondary"><%= systemInfo.nodeVersion %></strong>
</div>
</div>
</div>
</div>
<!-- Browser Status -->
<div class="col-lg-3 col-md-6">
<div class="card">
<div class="card-header">
<i class="bi bi-globe"></i> Browser Status
</div>
<div class="card-body">
<div class="d-flex justify-content-between mb-2">
<span>Status</span>
<span class="status-badge <%= browserStatus === 'Connected' ? 'badge-online' : 'badge-offline' %>" id="browserStatusBadge">
<%= browserStatus %>
</span>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Process Memory</span>
<strong class="text-warning" id="processMemory"><%= systemInfo.processMemory.rss %></strong>
</div>
<div class="d-flex justify-content-between mb-2">
<span>Heap Used</span>
<strong class="text-info" id="heapUsed"><%= systemInfo.processMemory.heapUsed %></strong>
</div>
<% if (serverStats.lastError) { %>
<div class="mt-2">
<small class="text-danger">
<i class="bi bi-exclamation-triangle"></i>
Last Error: <%= serverStats.lastError.substring(0, 50) %>...
</small>
</div>
<% } %>
</div>
</div>
</div>
</div>
<!-- Recent Requests -->
<div class="row mt-4">
<div class="col-12">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<span><i class="bi bi-list-ul"></i> Recent Requests</span>
<small class="text-muted">Last 10 requests</small>
</div>
<div class="card-body p-0">
<% if (recentRequests.length > 0) { %>
<div class="table-responsive">
<table class="table table-hover mb-0" id="recentRequestsTable">
<thead>
<tr>
<th>Time</th>
<th>URL</th>
<th>Status</th>
<th>Response</th>
<th>Size</th>
<th>Cache</th>
</tr>
</thead>
<tbody>
<% recentRequests.forEach(request => { %>
<tr>
<td>
<small class="text-muted">
<%= new Date(request.timestamp).toLocaleTimeString() %>
</small>
</td>
<td>
<div class="text-truncate" style="max-width: 200px;" title="<%= request.url %>">
<%= request.url %>
</div>
</td>
<td>
<span class="status-badge <%= request.success ? 'badge-online' : 'badge-offline' %>">
<i class="bi bi-<%= request.success ? 'check' : 'x' %>"></i>
<%= request.success ? 'Success' : 'Failed' %>
</span>
</td>
<td><strong><%= request.responseTime %>ms</strong></td>
<td>
<%= request.contentLength ? (request.contentLength / 1000).toFixed(1) + 'k' : 'N/A' %>
</td>
<td>
<span class="status-badge <%= request.cached ? 'badge-cached' : 'badge-offline' %>">
<%= request.cached ? 'HIT' : 'MISS' %>
</span>
</td>
</tr>
<% }) %>
</tbody>
</table>
</div>
<% } else { %>
<div class="text-center py-5">
<i class="bi bi-inbox text-muted" style="font-size: 3rem;"></i>
<p class="text-muted mt-3">No requests yet. Start by testing a URL above!</p>
</div>
<% } %>
</div>
</div>
</div>
</div>
<!-- API Information -->
<div class="row mt-4">
<div class="col-12">
<div class="card">
<div class="card-header">
<i class="bi bi-code-square"></i> API Endpoints
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-md-6">
<h6 class="text-primary">Proxy API</h6>
<code class="d-block bg-light p-2 rounded">
GET /proxy?url=WEBSITE_URL
</code>
<small class="text-muted">Main scraping endpoint</small>
</div>
<div class="col-md-6">
<h6 class="text-primary">Stats API</h6>
<code class="d-block bg-light p-2 rounded">
GET /api/stats
</code>
<small class="text-muted">JSON statistics for integration</small>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.bundle.min.js"></script>
<!-- Auto-refresh functionality -->
<script src="sc.js"></script>
</body>
</html> |