diff --git a/static/index.html b/static/index.html
index 42a343d..5fe3371 100644
--- a/static/index.html
+++ b/static/index.html
@@ -3080,8 +3080,7 @@
try {
const asset = await api(`/api/assets/search?machine_id=${encodeURIComponent(machineId)}`);
- autoCheckin(asset.id);
- showScannedAsset(asset);
+ showScanConfirm(asset, machineId);
} catch (e) {
if (e.message === 'Asset not found' || e.message.includes('404')) {
showNewAssetForm(machineId);
@@ -3112,6 +3111,78 @@
`;
}
+ function showScanConfirm(asset, machineId) {
+ AppState.currentAssetId = asset.id;
+ setScanStatus('Confirm machine ID', 'info');
+
+ const el = document.getElementById('scanResult');
+ el.style.display = 'block';
+ el.innerHTML = `
+
${esc(asset.name)}
+
+ Machine ID: ${esc(machineId)} · ${esc(asset.category || 'Other')} ·
+ ${asset.status || 'active'}
+
+
+
+
+
+ `;
+ }
+
+ async function confirmScanCheckin(assetId) {
+ setScanStatus('Checking in...', 'working');
+ await autoCheckin(assetId);
+ const asset = await api(`/api/assets/${assetId}`);
+ showScannedAsset(asset);
+ }
+
+ function showMachineIdEditor(currentId) {
+ const el = document.getElementById('scanResult');
+ el.innerHTML = `
+ Edit machine ID:
+
+
+
+
+
+
+
+
+ `;
+ document.getElementById('editMachineIdInput').focus();
+ document.getElementById('editMachineIdInput').select();
+ }
+
+ async function relookupMachineId() {
+ const newId = document.getElementById('editMachineIdInput').value.trim();
+ if (!newId) return;
+ setScanStatus('Re-looking up...', 'working');
+ try {
+ const asset = await api(`/api/assets/search?machine_id=${encodeURIComponent(newId)}`);
+ showScanConfirm(asset, newId);
+ } catch (e) {
+ if (e.message === 'Asset not found' || e.message.includes('404')) {
+ showNewAssetForm(newId);
+ } else {
+ document.getElementById('editMachineIdError').textContent = 'Lookup error: ' + e.message;
+ document.getElementById('editMachineIdError').style.display = 'block';
+ }
+ }
+ }
+
+ function showScanConfirmFromEdit() {
+ const assetId = AppState.currentAssetId;
+ if (!assetId) return;
+ api(`/api/assets/${assetId}`).then(asset => {
+ showScanConfirm(asset, asset.machine_id);
+ }).catch(() => {
+ setScanStatus('Could not reload asset', 'error');
+ });
+ }
+
function showNewAssetForm(machineId) {
currentScannedMachineId = machineId;
setScanStatus('Machine ID not in database — create asset below', 'error');