|
65 | 65 | </head> |
66 | 66 | <body> |
67 | 67 | <h1>Perceptor Test Host Server</h1> |
68 | | - <div class="status"> |
69 | | - <strong>✓ Server is running</strong> |
70 | | - </div> |
71 | 68 | <div class="info"> |
72 | 69 | <h2>WebSocket Connection</h2> |
73 | 70 | <p>The server is ready to accept WebSocket connections at <code id="ws-url">ws://localhost:8080</code></p> |
@@ -133,8 +130,8 @@ <h2>Active Connections</h2> |
133 | 130 | <div class="connection-item"> |
134 | 131 | <div class="connection-id">${conn.clientName || 'Unknown Device'} <span style="color: #999; font-size: 0.85em;">(${conn.id})</span></div> |
135 | 132 | <div class="connection-details"> |
136 | | - <p>Metadata: ${conn.hasMetadata ? '✓' : '✗'} ${conn.filename ? `(${conn.filename})` : ''}</p> |
137 | | - <p>Data Received: ${conn.receivedData ? '✓' : '✗'}</p> |
| 133 | + ${conn.lastFilename ? `<p>Last File: <strong>${conn.lastFilename}</strong></p> |
| 134 | + <p>Size: ${formatFileSize(conn.lastFilesize)}</p>` : '<p style="color: #999;">No files received yet</p>'} |
138 | 135 | </div> |
139 | 136 | <div style="margin-top: 10px;"> |
140 | 137 | <label for="duration-${conn.id}" style="display: inline-block; margin-right: 10px;">Duration (ms):</label> |
@@ -168,10 +165,30 @@ <h2>Active Connections</h2> |
168 | 165 | // Then update every 5 seconds |
169 | 166 | setInterval(updateStatus, 5000); |
170 | 167 |
|
| 168 | + function formatFileSize(bytes) { |
| 169 | + if (!bytes) return 'Unknown'; |
| 170 | + if (bytes === 0) return '0 B'; |
| 171 | + const k = 1024; |
| 172 | + const sizes = ['B', 'KB', 'MB', 'GB']; |
| 173 | + const i = Math.floor(Math.log(bytes) / Math.log(k)); |
| 174 | + return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i]; |
| 175 | + } |
| 176 | + |
171 | 177 | async function sendRecordCommand(connectionId) { |
172 | 178 | try { |
173 | 179 | const durationInput = document.getElementById(`duration-${connectionId}`); |
174 | 180 | const autoUploadCheckbox = document.getElementById(`autoUpload-${connectionId}`); |
| 181 | + |
| 182 | + // Defensive checks to ensure elements exist |
| 183 | + if (!durationInput) { |
| 184 | + alert('Error: Duration input not found. The connection list may have been updated. Please try again.'); |
| 185 | + return; |
| 186 | + } |
| 187 | + if (!autoUploadCheckbox) { |
| 188 | + alert('Error: Auto Upload checkbox not found. The connection list may have been updated. Please try again.'); |
| 189 | + return; |
| 190 | + } |
| 191 | + |
175 | 192 | const duration = parseInt(durationInput.value, 10); |
176 | 193 | const autoUpload = autoUploadCheckbox.checked; |
177 | 194 |
|
|
0 commit comments