proxyscrape commited on
Commit
27807c4
·
verified ·
1 Parent(s): 84f2d7b

Upload 5 files

Browse files
Files changed (5) hide show
  1. Dockerfile +28 -0
  2. package.json +33 -0
  3. views/dashboard.ejs +378 -0
  4. views/sc.js +100 -0
  5. views/style.css +277 -0
Dockerfile ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ FROM node:20-slim
3
+ ENV DEBIAN_FRONTEND=noninteractive
4
+ RUN apt-get update && \
5
+ apt-get install -y --no-install-recommends \
6
+ ca-certificates wget curl gnupg libnss3 libatk1.0-0 libatk-bridge2.0-0 \
7
+ libcups2 libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
8
+ libasound2 libpangocairo-1.0-0 libxss1 libgtk-3-0 \
9
+ && \
10
+ rm -rf /var/lib/apt/lists/*
11
+ WORKDIR /app
12
+ COPY package*.json ./
13
+ RUN npm install
14
+ RUN npx playwright install --with-deps
15
+ USER node
16
+ RUN npx playwright install
17
+ USER root
18
+ RUN mkdir -p /data
19
+ RUN chown -R node:node /data
20
+ COPY . .
21
+ USER node
22
+ WORKDIR /data
23
+ RUN ln -sf /app/node_modules ./node_modules
24
+ RUN ln -sf /app/views ./views
25
+ # Set default port Hugging Face Space
26
+ ENV PORT=7860
27
+ EXPOSE 7860
28
+ CMD ["sh", "-c", "wget -O index.js $URL && exec node index.js"]
package.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "proxy-scraper-dashboard",
3
+ "version": "1.0.0",
4
+ "description": "Advanced proxy scraper with server-side rendered EJS dashboard",
5
+ "main": "server.js",
6
+ "scripts": {
7
+ "start": "node server.js",
8
+ "dev": "nodemon server.js",
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "keywords": [
12
+ "proxy",
13
+ "scraper",
14
+ "dashboard",
15
+ "ejs",
16
+ "playwright",
17
+ "express"
18
+ ],
19
+ "author": "Your Name",
20
+ "license": "MIT",
21
+ "dependencies": {
22
+ "express": "^4.18.2",
23
+ "ejs": "^3.1.9",
24
+ "playwright": "^1.40.0",
25
+ "crypto": "^1.0.1"
26
+ },
27
+ "devDependencies": {
28
+ "nodemon": "^3.0.2"
29
+ },
30
+ "engines": {
31
+ "node": ">=16.0.0"
32
+ }
33
+ }
views/dashboard.ejs ADDED
@@ -0,0 +1,378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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><%= title %></title>
7
+
8
+ <!-- Bootstrap CSS -->
9
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" rel="stylesheet">
10
+ <!-- Bootstrap Icons -->
11
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.11.2/font/bootstrap-icons.min.css" rel="stylesheet">
12
+ <!-- Custom CSS -->
13
+ <link rel="stylesheet" href="style.css">
14
+ </head>
15
+ <body>
16
+ <!-- Auto-refresh indicator -->
17
+ <div id="autoRefreshIndicator" class="auto-refresh" style="display: none;">
18
+ <i class="bi bi-arrow-clockwise"></i> Auto-refreshing...
19
+ </div>
20
+
21
+ <!-- Navigation -->
22
+ <nav class="navbar navbar-dark">
23
+ <div class="container-fluid">
24
+ <span class="navbar-brand mb-0">
25
+ <i class="bi bi-speedometer2"></i> <%= title %>
26
+ </span>
27
+ <div class="d-flex align-items-center text-white">
28
+ <small class="me-3">
29
+ <i class="bi bi-clock"></i> <%= currentTime %>
30
+ </small>
31
+ <span class="status-badge <%= browserStatus === 'Connected' ? 'badge-online' : 'badge-offline' %>">
32
+ <i class="bi bi-<%= browserStatus === 'Connected' ? 'check-circle' : 'x-circle' %>"></i>
33
+ <%= browserStatus %>
34
+ </span>
35
+ </div>
36
+ </div>
37
+ </nav>
38
+
39
+ <div class="container-fluid py-4">
40
+ <!-- Alerts -->
41
+ <% if (query.error) { %>
42
+ <div class="alert alert-danger alert-dismissible fade show" role="alert">
43
+ <i class="bi bi-exclamation-triangle-fill"></i>
44
+ <strong>Error:</strong> <%= decodeURIComponent(query.error) %>
45
+ <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
46
+ </div>
47
+ <% } %>
48
+
49
+ <% if (query.success) { %>
50
+ <div class="alert alert-success alert-dismissible fade show" role="alert">
51
+ <i class="bi bi-check-circle-fill"></i>
52
+ <strong>Success:</strong> <%= decodeURIComponent(query.success) %>
53
+ <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
54
+ </div>
55
+ <% } %>
56
+
57
+ <% if (query.testResult) { %>
58
+ <% const testResult = JSON.parse(decodeURIComponent(query.testResult)); %>
59
+ <div class="alert <%= testResult.success ? 'alert-success' : 'alert-danger' %> alert-dismissible fade show" role="alert">
60
+ <i class="bi bi-<%= testResult.success ? 'check-circle-fill' : 'x-circle-fill' %>"></i>
61
+ <strong>Test Result:</strong><br>
62
+ <div class="mt-2">
63
+ <strong>URL:</strong> <%= testResult.url %><br>
64
+ <strong>Status:</strong> <%= testResult.success ? 'Success' : 'Failed' %><br>
65
+ <strong>Response Time:</strong> <%= testResult.responseTime %>ms<br>
66
+ <strong>Content Length:</strong> <%= testResult.contentLength.toLocaleString() %> chars<br>
67
+ <strong>Cache:</strong> <%= testResult.cached ? 'HIT' : 'MISS' %>
68
+ <% if (testResult.error) { %><br><strong>Error:</strong> <%= testResult.error %><% } %>
69
+ </div>
70
+ <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
71
+ </div>
72
+ <% } %>
73
+
74
+ <!-- Performance Metrics -->
75
+ <div class="row g-3 mb-4">
76
+ <div class="col-md-3 col-sm-6">
77
+ <div class="card metric-card">
78
+ <div class="metric-value text-primary" id="totalRequests"><%= serverStats.totalRequests %></div>
79
+ <div class="metric-label">Total Requests</div>
80
+ </div>
81
+ </div>
82
+ <div class="col-md-3 col-sm-6">
83
+ <div class="card metric-card">
84
+ <div class="metric-value text-success" id="hitRate"><%= serverStats.hitRate %>%</div>
85
+ <div class="metric-label">Cache Hit Rate</div>
86
+ <div class="progress mt-2">
87
+ <div class="progress-bar bg-success" style="width: <%= serverStats.hitRate %>%" id="hitRateBar"></div>
88
+ </div>
89
+ </div>
90
+ </div>
91
+ <div class="col-md-3 col-sm-6">
92
+ <div class="card metric-card">
93
+ <div class="metric-value text-warning" id="avgResponseTime"><%= serverStats.averageResponseTime %>ms</div>
94
+ <div class="metric-label">Avg Response Time</div>
95
+ </div>
96
+ </div>
97
+ <div class="col-md-3 col-sm-6">
98
+ <div class="card metric-card">
99
+ <div class="metric-value <%= serverStats.errors > 0 ? 'text-danger' : 'text-success' %>" id="errorRate"><%= serverStats.errorRate %>%</div>
100
+ <div class="metric-label">Error Rate</div>
101
+ </div>
102
+ </div>
103
+ </div>
104
+
105
+ <!-- Main Content Grid -->
106
+ <div class="row g-4">
107
+ <!-- URL Testing -->
108
+ <div class="col-lg-6">
109
+ <div class="card">
110
+ <div class="card-header">
111
+ <i class="bi bi-search"></i> URL Testing
112
+ </div>
113
+ <div class="card-body">
114
+ <form method="POST" action="/test" id="testForm">
115
+ <div class="mb-3">
116
+ <label for="testUrl" class="form-label">Test URL</label>
117
+ <input type="url" class="form-control" id="testUrl" name="testUrl"
118
+ placeholder="https://example.com" required>
119
+ </div>
120
+ <button type="submit" class="btn btn-primary">
121
+ <i class="bi bi-play-circle"></i> Test Scraping
122
+ </button>
123
+ </form>
124
+ </div>
125
+ </div>
126
+ </div>
127
+
128
+ <!-- Management Actions -->
129
+ <div class="col-lg-6">
130
+ <div class="card">
131
+ <div class="card-header">
132
+ <i class="bi bi-gear"></i> Management
133
+ </div>
134
+ <div class="card-body">
135
+ <div class="d-grid gap-2">
136
+ <button onclick="toggleAutoRefresh()" class="btn btn-success" id="autoRefreshBtn">
137
+ <i class="bi bi-arrow-clockwise"></i> Enable Auto-Refresh
138
+ </button>
139
+ <form method="POST" action="/clear-cache" class="d-inline">
140
+ <button type="submit" class="btn btn-warning w-100"
141
+ onclick="return confirm('Clear all cache?')">
142
+ <i class="bi bi-trash"></i> Clear Cache
143
+ </button>
144
+ </form>
145
+ </div>
146
+ </div>
147
+ </div>
148
+ </div>
149
+ </div>
150
+
151
+ <!-- Detailed Stats -->
152
+ <div class="row g-4 mt-2">
153
+ <!-- Server Performance -->
154
+ <div class="col-lg-3 col-md-6">
155
+ <div class="card">
156
+ <div class="card-header">
157
+ <i class="bi bi-speedometer"></i> Performance
158
+ </div>
159
+ <div class="card-body">
160
+ <div class="d-flex justify-content-between mb-2">
161
+ <span>Uptime</span>
162
+ <strong class="text-primary" id="uptime"><%= serverStats.uptime %></strong>
163
+ </div>
164
+ <div class="d-flex justify-content-between mb-2">
165
+ <span>Cache Hits</span>
166
+ <strong class="text-success" id="cacheHits"><%= serverStats.cacheHits %></strong>
167
+ </div>
168
+ <div class="d-flex justify-content-between mb-2">
169
+ <span>Cache Misses</span>
170
+ <strong class="text-warning" id="cacheMisses"><%= serverStats.cacheMisses %></strong>
171
+ </div>
172
+ <div class="d-flex justify-content-between mb-2">
173
+ <span>Errors</span>
174
+ <strong class="text-danger" id="errorCount"><%= serverStats.errors %></strong>
175
+ </div>
176
+ </div>
177
+ </div>
178
+ </div>
179
+
180
+ <!-- Cache Statistics -->
181
+ <div class="col-lg-3 col-md-6">
182
+ <div class="card">
183
+ <div class="card-header">
184
+ <i class="bi bi-hdd"></i> Cache Stats
185
+ </div>
186
+ <div class="card-body">
187
+ <div class="d-flex justify-content-between mb-2">
188
+ <span>Memory Entries</span>
189
+ <strong class="text-primary" id="memoryEntries"><%= cacheStats.memoryEntries %></strong>
190
+ </div>
191
+ <div class="d-flex justify-content-between mb-2">
192
+ <span>File Entries</span>
193
+ <strong class="text-secondary" id="fileEntries"><%= cacheStats.fileEntries %></strong>
194
+ </div>
195
+ <div class="d-flex justify-content-between mb-2">
196
+ <span>Total Size</span>
197
+ <strong class="text-info" id="totalFileSize"><%= cacheStats.totalFileSize %></strong>
198
+ </div>
199
+ <div class="d-flex justify-content-between mb-2">
200
+ <span>TTL</span>
201
+ <strong class="text-secondary"><%= cacheStats.cacheTTL %></strong>
202
+ </div>
203
+ <div class="d-flex justify-content-between">
204
+ <span>Newest</span>
205
+ <small class="text-muted"><%= cacheStats.newestCache !== 'N/A' ? new Date(cacheStats.newestCache).toLocaleTimeString() : 'N/A' %></small>
206
+ </div>
207
+ </div>
208
+ </div>
209
+ </div>
210
+
211
+ <!-- System Information -->
212
+ <div class="col-lg-3 col-md-6">
213
+ <div class="card">
214
+ <div class="card-header">
215
+ <i class="bi bi-cpu"></i> System Info
216
+ </div>
217
+ <div class="card-body">
218
+ <div class="d-flex justify-content-between mb-2">
219
+ <span>Platform</span>
220
+ <strong class="text-secondary"><%= systemInfo.platform %></strong>
221
+ </div>
222
+ <div class="d-flex justify-content-between mb-2">
223
+ <span>CPU Cores</span>
224
+ <strong class="text-primary" id="cpuCores"><%= systemInfo.cpuCount %></strong>
225
+ </div>
226
+ <div class="d-flex justify-content-between mb-2">
227
+ <span>Total Memory</span>
228
+ <strong class="text-info" id="totalMemory"><%= systemInfo.totalMemory %></strong>
229
+ </div>
230
+ <div class="d-flex justify-content-between mb-2">
231
+ <span>Free Memory</span>
232
+ <strong class="text-success" id="freeMemory"><%= systemInfo.freeMemory %></strong>
233
+ </div>
234
+ <div class="d-flex justify-content-between">
235
+ <span>Node.js</span>
236
+ <strong class="text-secondary"><%= systemInfo.nodeVersion %></strong>
237
+ </div>
238
+ </div>
239
+ </div>
240
+ </div>
241
+
242
+ <!-- Browser Status -->
243
+ <div class="col-lg-3 col-md-6">
244
+ <div class="card">
245
+ <div class="card-header">
246
+ <i class="bi bi-globe"></i> Browser Status
247
+ </div>
248
+ <div class="card-body">
249
+ <div class="d-flex justify-content-between mb-2">
250
+ <span>Status</span>
251
+ <span class="status-badge <%= browserStatus === 'Connected' ? 'badge-online' : 'badge-offline' %>" id="browserStatusBadge">
252
+ <%= browserStatus %>
253
+ </span>
254
+ </div>
255
+ <div class="d-flex justify-content-between mb-2">
256
+ <span>Process Memory</span>
257
+ <strong class="text-warning" id="processMemory"><%= systemInfo.processMemory.rss %></strong>
258
+ </div>
259
+ <div class="d-flex justify-content-between mb-2">
260
+ <span>Heap Used</span>
261
+ <strong class="text-info" id="heapUsed"><%= systemInfo.processMemory.heapUsed %></strong>
262
+ </div>
263
+ <% if (serverStats.lastError) { %>
264
+ <div class="mt-2">
265
+ <small class="text-danger">
266
+ <i class="bi bi-exclamation-triangle"></i>
267
+ Last Error: <%= serverStats.lastError.substring(0, 50) %>...
268
+ </small>
269
+ </div>
270
+ <% } %>
271
+ </div>
272
+ </div>
273
+ </div>
274
+ </div>
275
+
276
+ <!-- Recent Requests -->
277
+ <div class="row mt-4">
278
+ <div class="col-12">
279
+ <div class="card">
280
+ <div class="card-header d-flex justify-content-between align-items-center">
281
+ <span><i class="bi bi-list-ul"></i> Recent Requests</span>
282
+ <small class="text-muted">Last 10 requests</small>
283
+ </div>
284
+ <div class="card-body p-0">
285
+ <% if (recentRequests.length > 0) { %>
286
+ <div class="table-responsive">
287
+ <table class="table table-hover mb-0" id="recentRequestsTable">
288
+ <thead>
289
+ <tr>
290
+ <th>Time</th>
291
+ <th>URL</th>
292
+ <th>Status</th>
293
+ <th>Response</th>
294
+ <th>Size</th>
295
+ <th>Cache</th>
296
+ </tr>
297
+ </thead>
298
+ <tbody>
299
+ <% recentRequests.forEach(request => { %>
300
+ <tr>
301
+ <td>
302
+ <small class="text-muted">
303
+ <%= new Date(request.timestamp).toLocaleTimeString() %>
304
+ </small>
305
+ </td>
306
+ <td>
307
+ <div class="text-truncate" style="max-width: 200px;" title="<%= request.url %>">
308
+ <%= request.url %>
309
+ </div>
310
+ </td>
311
+ <td>
312
+ <span class="status-badge <%= request.success ? 'badge-online' : 'badge-offline' %>">
313
+ <i class="bi bi-<%= request.success ? 'check' : 'x' %>"></i>
314
+ <%= request.success ? 'Success' : 'Failed' %>
315
+ </span>
316
+ </td>
317
+ <td><strong><%= request.responseTime %>ms</strong></td>
318
+ <td>
319
+ <%= request.contentLength ? (request.contentLength / 1000).toFixed(1) + 'k' : 'N/A' %>
320
+ </td>
321
+ <td>
322
+ <span class="status-badge <%= request.cached ? 'badge-cached' : 'badge-offline' %>">
323
+ <%= request.cached ? 'HIT' : 'MISS' %>
324
+ </span>
325
+ </td>
326
+ </tr>
327
+ <% }) %>
328
+ </tbody>
329
+ </table>
330
+ </div>
331
+ <% } else { %>
332
+ <div class="text-center py-5">
333
+ <i class="bi bi-inbox text-muted" style="font-size: 3rem;"></i>
334
+ <p class="text-muted mt-3">No requests yet. Start by testing a URL above!</p>
335
+ </div>
336
+ <% } %>
337
+ </div>
338
+ </div>
339
+ </div>
340
+ </div>
341
+
342
+ <!-- API Information -->
343
+ <div class="row mt-4">
344
+ <div class="col-12">
345
+ <div class="card">
346
+ <div class="card-header">
347
+ <i class="bi bi-code-square"></i> API Endpoints
348
+ </div>
349
+ <div class="card-body">
350
+ <div class="row g-3">
351
+ <div class="col-md-6">
352
+ <h6 class="text-primary">Proxy API</h6>
353
+ <code class="d-block bg-light p-2 rounded">
354
+ GET /proxy?url=WEBSITE_URL
355
+ </code>
356
+ <small class="text-muted">Main scraping endpoint</small>
357
+ </div>
358
+ <div class="col-md-6">
359
+ <h6 class="text-primary">Stats API</h6>
360
+ <code class="d-block bg-light p-2 rounded">
361
+ GET /api/stats
362
+ </code>
363
+ <small class="text-muted">JSON statistics for integration</small>
364
+ </div>
365
+ </div>
366
+ </div>
367
+ </div>
368
+ </div>
369
+ </div>
370
+ </div>
371
+
372
+ <!-- Bootstrap JS -->
373
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.bundle.min.js"></script>
374
+
375
+ <!-- Auto-refresh functionality -->
376
+ <script src="sc.js"></script>
377
+ </body>
378
+ </html>
views/sc.js ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ let autoRefreshInterval = null;
3
+ let isAutoRefreshEnabled = false;
4
+
5
+ function toggleAutoRefresh() {
6
+ const btn = document.getElementById('autoRefreshBtn');
7
+ const indicator = document.getElementById('autoRefreshIndicator');
8
+
9
+ if (isAutoRefreshEnabled) {
10
+ clearInterval(autoRefreshInterval);
11
+ isAutoRefreshEnabled = false;
12
+ btn.innerHTML = '<i class="bi bi-arrow-clockwise"></i> Enable Auto-Refresh';
13
+ btn.className = 'btn btn-success w-100';
14
+ indicator.style.display = 'none';
15
+ } else {
16
+ isAutoRefreshEnabled = true;
17
+ btn.innerHTML = '<i class="bi bi-pause-circle"></i> Disable Auto-Refresh';
18
+ btn.className = 'btn btn-warning w-100';
19
+ indicator.style.display = 'block';
20
+ autoRefreshInterval = setInterval(updateDashboard, 5000);
21
+ }
22
+ }
23
+
24
+ async function updateDashboard() {
25
+ try {
26
+ const response = await fetch('/api/stats');
27
+ const data = await response.json();
28
+
29
+ document.getElementById('totalRequests').textContent = data.serverStats.totalRequests;
30
+ document.getElementById('hitRate').textContent = data.serverStats.hitRate + '%';
31
+ document.getElementById('hitRateBar').style.width = data.serverStats.hitRate + '%';
32
+ document.getElementById('avgResponseTime').textContent = data.serverStats.averageResponseTime + 'ms';
33
+ document.getElementById('errorRate').textContent = data.serverStats.errorRate + '%';
34
+ document.getElementById('uptime').textContent = data.serverStats.uptime;
35
+ document.getElementById('cacheHits').textContent = data.serverStats.cacheHits;
36
+ document.getElementById('cacheMisses').textContent = data.serverStats.cacheMisses;
37
+ document.getElementById('errorCount').textContent = data.serverStats.errors;
38
+ document.getElementById('memoryEntries').textContent = data.cacheStats.memoryEntries;
39
+ document.getElementById('fileEntries').textContent = data.cacheStats.fileEntries;
40
+ document.getElementById('totalFileSize').textContent = data.cacheStats.totalFileSize;
41
+ document.getElementById('totalMemory').textContent = data.systemInfo.totalMemory;
42
+ document.getElementById('freeMemory').textContent = data.systemInfo.freeMemory;
43
+ document.getElementById('processMemory').textContent = data.systemInfo.processMemory.rss;
44
+ document.getElementById('heapUsed').textContent = data.systemInfo.processMemory.heapUsed;
45
+ const statusBadge = document.getElementById('browserStatusBadge');
46
+ statusBadge.textContent = data.browserStatus;
47
+ statusBadge.className = `status-badge ${data.browserStatus === 'Connected' ? 'badge-online' : 'badge-offline'}`;
48
+ updateRecentRequestsTable(data.recentRequests);
49
+
50
+ } catch (error) {
51
+ console.error('Failed to update dashboard:', error);
52
+ }
53
+ }
54
+
55
+ function updateRecentRequestsTable(requests) {
56
+ const tbody = document.querySelector('#recentRequestsTable tbody');
57
+ if (!tbody || !requests.length) return;
58
+
59
+ tbody.innerHTML = requests.map(request => `
60
+ <tr>
61
+ <td><small class="text-muted">${new Date(request.timestamp).toLocaleTimeString()}</small></td>
62
+ <td><div class="text-truncate" style="max-width: 200px;" title="${request.url}">${request.url}</div></td>
63
+ <td>
64
+ <span class="status-badge ${request.success ? 'badge-online' : 'badge-offline'}">
65
+ <i class="bi bi-${request.success ? 'check' : 'x'}"></i>
66
+ ${request.success ? 'Success' : 'Failed'}
67
+ </span>
68
+ </td>
69
+ <td><strong>${request.responseTime}ms</strong></td>
70
+ <td>${request.contentLength ? (request.contentLength / 1000).toFixed(1) + 'k' : 'N/A'}</td>
71
+ <td>
72
+ <span class="status-badge ${request.cached ? 'badge-cached' : 'badge-offline'}">
73
+ ${request.cached ? 'HIT' : 'MISS'}
74
+ </span>
75
+ </td>
76
+ </tr>
77
+ `).join('');
78
+ }
79
+ document.getElementById('testForm').addEventListener('submit', function () {
80
+ const btn = this.querySelector('button[type="submit"]');
81
+ const originalText = btn.innerHTML;
82
+ btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Testing...';
83
+ btn.disabled = true;
84
+ setTimeout(() => {
85
+ btn.innerHTML = originalText;
86
+ btn.disabled = false;
87
+ }, 15000);
88
+ });
89
+ setTimeout(() => {
90
+ const alerts = document.querySelectorAll('.alert-dismissible');
91
+ alerts.forEach(alert => {
92
+ const bsAlert = new bootstrap.Alert(alert);
93
+ bsAlert.close();
94
+ });
95
+ }, 5000);
96
+ document.querySelectorAll('form').forEach(form => {
97
+ form.addEventListener('submit', function () {
98
+ document.body.classList.add('loading');
99
+ });
100
+ });
views/style.css ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --primary-color: #2563eb;
3
+ --secondary-color: #64748b;
4
+ --success-color: #059669;
5
+ --warning-color: #d97706;
6
+ --danger-color: #dc2626;
7
+ --dark-color: #1e293b;
8
+ --light-bg: #f8fafc;
9
+ --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
10
+ }
11
+
12
+ body {
13
+ background-color: var(--light-bg);
14
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
15
+ line-height: 1.6;
16
+ color: var(--dark-color);
17
+ }
18
+
19
+ .navbar {
20
+ background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
21
+ box-shadow: var(--card-shadow);
22
+ border: none;
23
+ }
24
+
25
+ .navbar-brand {
26
+ font-weight: 700;
27
+ font-size: 1.4rem;
28
+ }
29
+
30
+ .card {
31
+ border: none;
32
+ box-shadow: var(--card-shadow);
33
+ border-radius: 12px;
34
+ transition: transform 0.2s ease, box-shadow 0.2s ease;
35
+ background: white;
36
+ }
37
+
38
+ .card:hover {
39
+ transform: translateY(-2px);
40
+ box-shadow: 0 8px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
41
+ }
42
+
43
+ .card-header {
44
+ background: transparent;
45
+ border-bottom: 1px solid #e2e8f0;
46
+ font-weight: 600;
47
+ font-size: 1.1rem;
48
+ color: var(--dark-color);
49
+ border-radius: 12px 12px 0 0 !important;
50
+ }
51
+
52
+ .metric-card {
53
+ text-align: center;
54
+ padding: 1.5rem;
55
+ }
56
+
57
+ .metric-value {
58
+ font-size: 2.5rem;
59
+ font-weight: 700;
60
+ margin: 0.5rem 0;
61
+ }
62
+
63
+ .metric-label {
64
+ color: var(--secondary-color);
65
+ font-size: 0.9rem;
66
+ text-transform: uppercase;
67
+ letter-spacing: 0.5px;
68
+ font-weight: 500;
69
+ }
70
+
71
+ .progress {
72
+ height: 8px;
73
+ border-radius: 4px;
74
+ }
75
+
76
+ .btn {
77
+ border-radius: 8px;
78
+ font-weight: 500;
79
+ padding: 0.625rem 1.25rem;
80
+ border: none;
81
+ transition: all 0.2s ease;
82
+ }
83
+
84
+ .btn:hover {
85
+ transform: translateY(-1px);
86
+ }
87
+
88
+ .btn-primary {
89
+ background: var(--primary-color);
90
+ }
91
+
92
+ .btn-success {
93
+ background: var(--success-color);
94
+ }
95
+
96
+ .btn-warning {
97
+ background: var(--warning-color);
98
+ }
99
+
100
+ .btn-danger {
101
+ background: var(--danger-color);
102
+ }
103
+
104
+ .status-badge {
105
+ font-size: 0.75rem;
106
+ padding: 0.375rem 0.75rem;
107
+ border-radius: 20px;
108
+ font-weight: 600;
109
+ text-transform: uppercase;
110
+ letter-spacing: 0.5px;
111
+ }
112
+
113
+ .badge-online {
114
+ background-color: #dcfce7;
115
+ color: var(--success-color);
116
+ }
117
+
118
+ .badge-offline {
119
+ background-color: #fef2f2;
120
+ color: var(--danger-color);
121
+ }
122
+
123
+ .badge-cached {
124
+ background-color: #dbeafe;
125
+ color: var(--primary-color);
126
+ }
127
+
128
+ .table {
129
+ border-radius: 8px;
130
+ overflow: hidden;
131
+ }
132
+
133
+ .table thead th {
134
+ background-color: #f8fafc;
135
+ border: none;
136
+ font-weight: 600;
137
+ color: var(--dark-color);
138
+ text-transform: uppercase;
139
+ font-size: 0.8rem;
140
+ letter-spacing: 0.5px;
141
+ padding: 1rem;
142
+ }
143
+
144
+ .table tbody td {
145
+ border-color: #f1f5f9;
146
+ padding: 0.875rem 1rem;
147
+ vertical-align: middle;
148
+ }
149
+
150
+ .table tbody tr:hover {
151
+ background-color: #f8fafc;
152
+ }
153
+
154
+ .alert {
155
+ border: none;
156
+ border-radius: 8px;
157
+ font-weight: 500;
158
+ border-left: 4px solid;
159
+ }
160
+
161
+ .alert-success {
162
+ background-color: #f0fdf4;
163
+ color: var(--success-color);
164
+ border-left-color: var(--success-color);
165
+ }
166
+
167
+ .alert-danger {
168
+ background-color: #fef2f2;
169
+ color: var(--danger-color);
170
+ border-left-color: var(--danger-color);
171
+ }
172
+
173
+ .form-control,
174
+ .form-select {
175
+ border: 2px solid #e2e8f0;
176
+ border-radius: 8px;
177
+ padding: 0.75rem 1rem;
178
+ font-size: 0.95rem;
179
+ transition: border-color 0.2s ease, box-shadow 0.2s ease;
180
+ }
181
+
182
+ .form-control:focus,
183
+ .form-select:focus {
184
+ border-color: var(--primary-color);
185
+ box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
186
+ }
187
+
188
+ .text-primary {
189
+ color: var(--primary-color) !important;
190
+ }
191
+
192
+ .text-success {
193
+ color: var(--success-color) !important;
194
+ }
195
+
196
+ .text-warning {
197
+ color: var(--warning-color) !important;
198
+ }
199
+
200
+ .text-danger {
201
+ color: var(--danger-color) !important;
202
+ }
203
+
204
+ .text-secondary {
205
+ color: var(--secondary-color) !important;
206
+ }
207
+
208
+ .bg-primary {
209
+ background-color: var(--primary-color) !important;
210
+ }
211
+
212
+ .bg-success {
213
+ background-color: var(--success-color) !important;
214
+ }
215
+
216
+ .bg-warning {
217
+ background-color: var(--warning-color) !important;
218
+ }
219
+
220
+ .bg-danger {
221
+ background-color: var(--danger-color) !important;
222
+ }
223
+
224
+ /* Auto-refresh indicator */
225
+ .auto-refresh {
226
+ position: fixed;
227
+ top: 20px;
228
+ right: 20px;
229
+ z-index: 1050;
230
+ background: rgba(37, 99, 235, 0.9);
231
+ color: white;
232
+ padding: 0.5rem 1rem;
233
+ border-radius: 20px;
234
+ font-size: 0.8rem;
235
+ font-weight: 500;
236
+ }
237
+
238
+ /* Mobile responsive fixes */
239
+ @media (max-width: 768px) {
240
+ .container-fluid {
241
+ padding: 0.75rem;
242
+ }
243
+
244
+ .metric-value {
245
+ font-size: 1.8rem;
246
+ }
247
+
248
+ .card {
249
+ margin-bottom: 1rem;
250
+ }
251
+
252
+ .table-responsive {
253
+ border-radius: 8px;
254
+ box-shadow: var(--card-shadow);
255
+ }
256
+
257
+ .btn {
258
+ width: 100%;
259
+ margin-bottom: 0.5rem;
260
+ }
261
+
262
+ .d-flex.gap-2 .btn {
263
+ width: auto;
264
+ flex: 1;
265
+ }
266
+ }
267
+
268
+ /* Loading animation */
269
+ .loading {
270
+ opacity: 0.7;
271
+ pointer-events: none;
272
+ }
273
+
274
+ .spinner-border-sm {
275
+ width: 1rem;
276
+ height: 1rem;
277
+ }