- Implemented a global toggle to enable/disable background queue processing. - Added a Side Panel (Sidebar.html) to view pending edits. - Added per-item controls: 'Delete' to remove from queue, 'Push' to force update. - Updated 'onEditQueue.ts' with robust error handling for batch processing. - Updated documentation (README, ARCHITECTURE) to reflect new features. - Fixed 'clasp' deployment issues by cleaning up manifest management.
182 lines
5.2 KiB
HTML
182 lines
5.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<base target="_top">
|
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
|
<style>
|
|
body {
|
|
font-family: 'Roboto', sans-serif;
|
|
padding: 12px;
|
|
color: #333;
|
|
}
|
|
h2 {
|
|
font-size: 18px;
|
|
margin-bottom: 8px;
|
|
color: #202124;
|
|
}
|
|
.section {
|
|
margin-bottom: 24px;
|
|
border: 1px solid #e0e0e0;
|
|
border-radius: 8px;
|
|
padding: 16px;
|
|
background-color: #fff;
|
|
}
|
|
.stat-count {
|
|
font-size: 32px;
|
|
font-weight: 500;
|
|
color: #1a73e8;
|
|
}
|
|
.stat-label {
|
|
font-size: 14px;
|
|
color: #5f6368;
|
|
}
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin-top: 12px;
|
|
font-size: 13px;
|
|
}
|
|
th {
|
|
text-align: left;
|
|
color: #5f6368;
|
|
font-weight: 500;
|
|
padding-bottom: 8px;
|
|
border-bottom: 1px solid #e0e0e0;
|
|
}
|
|
td {
|
|
padding: 8px 0;
|
|
border-bottom: 1px solid #f1f3f4;
|
|
}
|
|
button {
|
|
background-color: #1a73e8;
|
|
color: white;
|
|
border: none;
|
|
padding: 8px 16px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-family: 'Roboto', sans-serif;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
width: 100%;
|
|
}
|
|
button:hover {
|
|
background-color: #1557b0;
|
|
}
|
|
.loading {
|
|
color: #5f6368;
|
|
font-style: italic;
|
|
margin-top: 8px;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h2>System Status</h2>
|
|
|
|
<div class="section">
|
|
<label style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;">
|
|
<span>Enable Automatic Processing</span>
|
|
<input type="checkbox" id="queue-toggle" onchange="toggleQueue()">
|
|
</label>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<div class="stat-count" id="queue-count">-</div>
|
|
<div class="stat-label">Pending Edits</div>
|
|
<div id="loading" class="loading" style="display: none;">Loading...</div>
|
|
|
|
<table id="queue-table">
|
|
<thead>
|
|
<tr>
|
|
<th>SKU</th>
|
|
<th>Time</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="queue-body">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<button onclick="refreshData()">Refresh</button>
|
|
|
|
<script>
|
|
function refreshData() {
|
|
showLoading('Loading...');
|
|
google.script.run
|
|
.withSuccessHandler(updateUI)
|
|
.withFailureHandler(showError)
|
|
.getQueueStatus();
|
|
}
|
|
|
|
function toggleQueue() {
|
|
const enabled = document.getElementById('queue-toggle').checked;
|
|
showLoading('Updating...');
|
|
google.script.run
|
|
.withSuccessHandler(() => refreshData())
|
|
.withFailureHandler(showError)
|
|
.setQueueEnabled(enabled);
|
|
}
|
|
|
|
function deleteItem(sku) {
|
|
if(!confirm('Are you sure you want to remove ' + sku + ' from the queue?')) return;
|
|
showLoading('Deleting...');
|
|
google.script.run
|
|
.withSuccessHandler(() => refreshData())
|
|
.withFailureHandler(showError)
|
|
.deleteEdit(sku);
|
|
}
|
|
|
|
function pushItem(sku) {
|
|
showLoading('Pushing ' + sku + '...');
|
|
google.script.run
|
|
.withSuccessHandler(() => refreshData())
|
|
.withFailureHandler(showError)
|
|
.pushEdit(sku);
|
|
}
|
|
|
|
function updateUI(status) {
|
|
hideLoading();
|
|
document.getElementById('queue-toggle').checked = status.enabled;
|
|
|
|
const items = status.items || [];
|
|
document.getElementById('queue-count').innerText = items.length;
|
|
|
|
const tbody = document.getElementById('queue-body');
|
|
tbody.innerHTML = '';
|
|
|
|
items.forEach(item => {
|
|
const row = document.createElement('tr');
|
|
row.innerHTML = `
|
|
<td>${item.sku}</td>
|
|
<td>${item.time}</td>
|
|
<td>
|
|
<button style="padding: 4px 8px; font-size: 11px; width: auto; background-color: #d93025; margin-right: 4px;" onclick="deleteItem('${item.sku}')">Del</button>
|
|
<button style="padding: 4px 8px; font-size: 11px; width: auto; background-color: #1a73e8;" onclick="pushItem('${item.sku}')">Push</button>
|
|
</td>
|
|
`;
|
|
tbody.appendChild(row);
|
|
});
|
|
}
|
|
|
|
function showLoading(msg) {
|
|
const el = document.getElementById('loading');
|
|
el.innerText = msg;
|
|
el.style.display = 'block';
|
|
}
|
|
|
|
function hideLoading() {
|
|
document.getElementById('loading').style.display = 'none';
|
|
}
|
|
|
|
function showError(error) {
|
|
document.getElementById('loading').innerText = 'Error: ' + error.message;
|
|
document.getElementById('loading').style.display = 'block';
|
|
}
|
|
|
|
// Load on start
|
|
refreshData();
|
|
</script>
|
|
</body>
|
|
</html>
|