220 lines
6.0 KiB
HTML
220 lines
6.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Today's Scan Logs</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
<style>
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
line-height: 1.6;
|
|
color: #333;
|
|
background-color: #f5f5f5;
|
|
padding: 20px;
|
|
}
|
|
|
|
h1 {
|
|
text-align: center;
|
|
color: #2c3e50;
|
|
margin: 20px 0;
|
|
font-size: 1.8rem;
|
|
}
|
|
|
|
#logs-container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
background: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
overflow: hidden;
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
background: white;
|
|
}
|
|
|
|
th, td {
|
|
padding: 12px 15px;
|
|
text-align: left;
|
|
border-bottom: 1px solid #eee;
|
|
}
|
|
|
|
th {
|
|
background-color: #f8f9fa;
|
|
font-weight: 600;
|
|
color: #2c3e50;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
tr:hover {
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
.empty-name {
|
|
background-color: #fff3f3;
|
|
}
|
|
|
|
.empty-name:hover {
|
|
background-color: #ffe6e6;
|
|
}
|
|
|
|
.retry-button {
|
|
padding: 8px 16px;
|
|
background-color: #4CAF50;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 0.9rem;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.retry-button:hover {
|
|
background-color: #45a049;
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.retry-button:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
/* 响应式设计 */
|
|
@media screen and (max-width: 768px) {
|
|
body {
|
|
padding: 10px;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
table {
|
|
display: block;
|
|
overflow-x: auto;
|
|
-webkit-overflow-scrolling: touch;
|
|
}
|
|
|
|
th, td {
|
|
padding: 10px;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.retry-button {
|
|
padding: 6px 12px;
|
|
font-size: 0.8rem;
|
|
}
|
|
}
|
|
|
|
/* 加载动画 */
|
|
.loading {
|
|
text-align: center;
|
|
padding: 20px;
|
|
color: #666;
|
|
}
|
|
|
|
/* 空状态样式 */
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 40px 20px;
|
|
color: #666;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Today's Scan Logs</h1>
|
|
<div id="logs-container">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Barcode</th>
|
|
<th>Name</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="logs-body">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<script>
|
|
function loadLogs() {
|
|
const logsBody = $('#logs-body');
|
|
logsBody.html('<tr><td colspan="3" class="loading">Loading...</td></tr>');
|
|
|
|
$.ajax({
|
|
url: '/scanlogs/today',
|
|
method: 'GET',
|
|
success: function(response) {
|
|
const tbody = $('#logs-body');
|
|
tbody.empty();
|
|
|
|
if (!response.logs || response.logs.length === 0) {
|
|
tbody.html('<tr><td colspan="3" class="empty-state">No logs found</td></tr>');
|
|
return;
|
|
}
|
|
|
|
response.logs.forEach(function(log) {
|
|
const row = $('<tr>');
|
|
if (!log.name) {
|
|
row.addClass('empty-name');
|
|
}
|
|
|
|
row.append($('<td>').text(log.barcode));
|
|
row.append($('<td>').text(log.name || 'Empty'));
|
|
|
|
const actionCell = $('<td>');
|
|
if (!log.name) {
|
|
const retryButton = $('<button>')
|
|
.addClass('retry-button')
|
|
.text('Retry')
|
|
.click(() => retryBarcode(log.barcode));
|
|
actionCell.append(retryButton);
|
|
}
|
|
row.append(actionCell);
|
|
|
|
tbody.append(row);
|
|
});
|
|
},
|
|
error: function(xhr, status, error) {
|
|
const tbody = $('#logs-body');
|
|
tbody.html('<tr><td colspan="3" class="empty-state">Failed to load logs: ' + error + '</td></tr>');
|
|
}
|
|
});
|
|
}
|
|
|
|
function retryBarcode(barcode) {
|
|
$.ajax({
|
|
url: '/barcode',
|
|
method: 'POST',
|
|
data: JSON.stringify({
|
|
data: {
|
|
data: barcode
|
|
}
|
|
}),
|
|
contentType: 'application/json',
|
|
success: function(response) {
|
|
alert('Barcode has been added to queue');
|
|
loadLogs();
|
|
},
|
|
error: function(xhr, status, error) {
|
|
alert('Failed to process barcode: ' + error);
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
loadLogs();
|
|
setInterval(loadLogs, 30000);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |