diff --git a/templates/partials/devices_table.html b/templates/partials/devices_table.html index b56b8c9..ac48044 100644 --- a/templates/partials/devices_table.html +++ b/templates/partials/devices_table.html @@ -60,7 +60,9 @@ data-note="{{ unit.note if unit.note else '' }}">
- {% if unit.status == 'OK' %} + {% if not unit.deployed %} + + {% elif unit.status == 'OK' %} {% elif unit.status == 'Pending' %} @@ -208,7 +210,9 @@
- {% if unit.status == 'OK' %} + {% if not unit.deployed %} + + {% elif unit.status == 'OK' %} {% elif unit.status == 'Pending' %} diff --git a/templates/partials/roster_table.html b/templates/partials/roster_table.html index 127493c..31d1731 100644 --- a/templates/partials/roster_table.html +++ b/templates/partials/roster_table.html @@ -58,7 +58,9 @@ data-note="{{ unit.note if unit.note else '' }}">
- {% if unit.status == 'OK' %} + {% if not unit.deployed %} + + {% elif unit.status == 'OK' %} {% elif unit.status == 'Pending' %} @@ -199,7 +201,9 @@
- {% if unit.status == 'OK' %} + {% if not unit.deployed %} + + {% elif unit.status == 'OK' %} {% elif unit.status == 'Pending' %} diff --git a/templates/roster.html b/templates/roster.html index 5aa8508..157baf8 100644 --- a/templates/roster.html +++ b/templates/roster.html @@ -206,21 +206,6 @@
-
- - -
-
- - -
-
- - -
I (Impulse)
+
@@ -388,21 +379,6 @@
-
- - -
-
- - -
-
- - -
I (Impulse)
+
@@ -649,6 +631,7 @@ setFieldsDisabled(seismoFields, true); setFieldsDisabled(modemFields, true); setFieldsDisabled(slmFields, false); + toggleModemPairing(); // Check if modem pairing should be shown } } @@ -661,17 +644,26 @@ }); } - // Toggle modem pairing field visibility (only for deployed seismographs) + // Toggle modem pairing field visibility (only for deployed seismographs and SLMs) function toggleModemPairing() { const deviceType = document.getElementById('deviceTypeSelect').value; const deployedCheckbox = document.getElementById('deployedCheckbox'); const modemPairingField = document.getElementById('modemPairingField'); + const slmModemPairingField = document.getElementById('slmModemPairingField'); + // Seismograph modem pairing if (deviceType === 'seismograph' && deployedCheckbox.checked) { modemPairingField.classList.remove('hidden'); } else { modemPairingField.classList.add('hidden'); } + + // SLM modem pairing + if (deviceType === 'slm' && deployedCheckbox.checked) { + slmModemPairingField.classList.remove('hidden'); + } else { + slmModemPairingField.classList.add('hidden'); + } } // Add unknown unit to roster @@ -823,6 +815,7 @@ setFieldsDisabled(seismoFields, true); setFieldsDisabled(modemFields, true); setFieldsDisabled(slmFields, false); + toggleEditModemPairing(); // Check if modem pairing should be shown } } @@ -831,12 +824,21 @@ const deviceType = document.getElementById('editDeviceTypeSelect').value; const deployedCheckbox = document.getElementById('editDeployedCheckbox'); const modemPairingField = document.getElementById('editModemPairingField'); + const slmModemPairingField = document.getElementById('editSlmModemPairingField'); + // Seismograph modem pairing if (deviceType === 'seismograph' && deployedCheckbox.checked) { modemPairingField.classList.remove('hidden'); } else { modemPairingField.classList.add('hidden'); } + + // SLM modem pairing + if (deviceType === 'slm' && deployedCheckbox.checked) { + slmModemPairingField.classList.remove('hidden'); + } else { + slmModemPairingField.classList.add('hidden'); + } } // Edit Unit - Fetch data and populate form @@ -940,13 +942,36 @@ // SLM fields document.getElementById('editSlmModel').value = unit.slm_model || ''; - document.getElementById('editSlmHost').value = unit.slm_host || ''; - document.getElementById('editSlmTcpPort').value = unit.slm_tcp_port || ''; - document.getElementById('editSlmFtpPort').value = unit.slm_ftp_port || ''; document.getElementById('editSlmSerialNumber').value = unit.slm_serial_number || ''; document.getElementById('editSlmFrequencyWeighting').value = unit.slm_frequency_weighting || ''; document.getElementById('editSlmTimeWeighting').value = unit.slm_time_weighting || ''; + // Populate SLM modem picker (uses -edit-slm suffix) + const slmModemPickerValue = document.getElementById('modem-picker-value-edit-slm'); + const slmModemPickerSearch = document.getElementById('modem-picker-search-edit-slm'); + const slmModemPickerClear = document.getElementById('modem-picker-clear-edit-slm'); + if (slmModemPickerValue) slmModemPickerValue.value = unit.deployed_with_modem_id || ''; + if (unit.deployed_with_modem_id && unit.device_type === 'slm') { + // Fetch modem display (ID + IP + note) + fetch(`/api/roster/${unit.deployed_with_modem_id}`) + .then(r => r.ok ? r.json() : null) + .then(modem => { + if (modem && slmModemPickerSearch) { + let display = modem.id; + if (modem.ip_address) display += ` - ${modem.ip_address}`; + if (modem.note) display += ` - ${modem.note}`; + slmModemPickerSearch.value = display; + if (slmModemPickerClear) slmModemPickerClear.classList.remove('hidden'); + } + }) + .catch(() => { + if (slmModemPickerSearch) slmModemPickerSearch.value = unit.deployed_with_modem_id; + }); + } else { + if (slmModemPickerSearch) slmModemPickerSearch.value = ''; + if (slmModemPickerClear) slmModemPickerClear.classList.add('hidden'); + } + // Cascade section - show if there's a paired device const cascadeSection = document.getElementById('editCascadeSection'); const cascadeToUnitId = document.getElementById('editCascadeToUnitId'); diff --git a/templates/unit_detail.html b/templates/unit_detail.html index 12431fc..ae6dd78 100644 --- a/templates/unit_detail.html +++ b/templates/unit_detail.html @@ -689,9 +689,16 @@ function populateViewMode() { 'Missing': 'text-red-600 dark:text-red-400' }; - document.getElementById('statusIndicator').className = `w-3 h-3 rounded-full ${statusColors[unitStatus.status] || 'bg-gray-400'}`; - document.getElementById('statusText').className = `font-semibold ${statusTextColors[unitStatus.status] || 'text-gray-600'}`; - document.getElementById('statusText').textContent = unitStatus.status || 'Unknown'; + // If unit is not deployed (benched), show gray "Benched" status instead of health status + if (!currentUnit.deployed) { + document.getElementById('statusIndicator').className = 'w-3 h-3 rounded-full bg-gray-400 dark:bg-gray-500'; + document.getElementById('statusText').className = 'font-semibold text-gray-600 dark:text-gray-400'; + document.getElementById('statusText').textContent = 'Benched'; + } else { + document.getElementById('statusIndicator').className = `w-3 h-3 rounded-full ${statusColors[unitStatus.status] || 'bg-gray-400'}`; + document.getElementById('statusText').className = `font-semibold ${statusTextColors[unitStatus.status] || 'text-gray-600'}`; + document.getElementById('statusText').textContent = unitStatus.status || 'Unknown'; + } // Format "Last Seen" with timezone-aware formatting if (unitStatus.last && typeof formatFullTimestamp === 'function') { @@ -704,7 +711,8 @@ function populateViewMode() { } else { document.getElementById('statusIndicator').className = 'w-3 h-3 rounded-full bg-gray-400'; document.getElementById('statusText').className = 'font-semibold text-gray-600 dark:text-gray-400'; - document.getElementById('statusText').textContent = 'No status data'; + // Show "Benched" if not deployed, otherwise "No status data" + document.getElementById('statusText').textContent = !currentUnit.deployed ? 'Benched' : 'No status data'; document.getElementById('lastSeen').textContent = '--'; document.getElementById('age').textContent = '--'; }