0.4.2 - Early implementation of SLMs. WIP.
This commit is contained in:
@@ -240,6 +240,7 @@
|
||||
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-slate-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-seismo-orange">
|
||||
<option value="seismograph">Seismograph</option>
|
||||
<option value="modem">Modem</option>
|
||||
<option value="sound_level_meter">Sound Level Meter</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -316,6 +317,63 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sound Level Meter Fields -->
|
||||
<div id="slmFields" class="hidden space-y-4 border-t border-gray-200 dark:border-gray-700 pt-4">
|
||||
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Sound Level Meter Information</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Model</label>
|
||||
<input type="text" name="slm_model" id="slmModel" placeholder="NL-43, NL-53, etc."
|
||||
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-slate-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-seismo-orange">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Serial Number</label>
|
||||
<input type="text" name="slm_serial_number" id="slmSerialNumber" placeholder="123456"
|
||||
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-slate-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-seismo-orange">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Frequency Weighting</label>
|
||||
<select name="slm_frequency_weighting" id="slmFrequencyWeighting"
|
||||
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-slate-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-seismo-orange">
|
||||
<option value="">Not set</option>
|
||||
<option value="A">A-weighting</option>
|
||||
<option value="C">C-weighting</option>
|
||||
<option value="Z">Z-weighting (Flat)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Time Weighting</label>
|
||||
<select name="slm_time_weighting" id="slmTimeWeighting"
|
||||
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-slate-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-seismo-orange">
|
||||
<option value="">Not set</option>
|
||||
<option value="F">Fast (125ms)</option>
|
||||
<option value="S">Slow (1s)</option>
|
||||
<option value="I">Impulse (35ms)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Measurement Range</label>
|
||||
<input type="text" name="slm_measurement_range" id="slmMeasurementRange" placeholder="30-130 dB"
|
||||
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-slate-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-seismo-orange">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">TCP Port (on modem)</label>
|
||||
<input type="number" name="slm_tcp_port" id="slmTcpPort" placeholder="2255"
|
||||
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-slate-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-seismo-orange">
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">Default: 2255</p>
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Deployed With Modem</label>
|
||||
<select name="deployed_with_modem_id" id="slmDeployedWithModemId"
|
||||
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-slate-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-seismo-orange">
|
||||
<option value="">No modem assigned</option>
|
||||
<!-- Options will be populated by JavaScript -->
|
||||
</select>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">Select the modem that provides network connectivity for this SLM</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Checkboxes -->
|
||||
<div class="flex items-center gap-6 border-t border-gray-200 dark:border-gray-700 pt-4">
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
@@ -373,6 +431,9 @@ async function loadUnitData() {
|
||||
currentSnapshot = await snapshotResponse.json();
|
||||
}
|
||||
|
||||
// Load modems list for dropdown
|
||||
await loadModemsList();
|
||||
|
||||
// Populate views
|
||||
populateViewMode();
|
||||
populateEditForm();
|
||||
@@ -391,6 +452,38 @@ async function loadUnitData() {
|
||||
}
|
||||
}
|
||||
|
||||
// Load list of modems for dropdown
|
||||
async function loadModemsList() {
|
||||
try {
|
||||
const response = await fetch('/api/roster/modems');
|
||||
if (response.ok) {
|
||||
const modems = await response.json();
|
||||
|
||||
// Populate both seismograph and SLM modem dropdowns
|
||||
const seismoDropdown = document.getElementById('deployedWithModemId');
|
||||
const slmDropdown = document.getElementById('slmDeployedWithModemId');
|
||||
|
||||
// Clear existing options (except the first "No modem" option)
|
||||
[seismoDropdown, slmDropdown].forEach(dropdown => {
|
||||
if (!dropdown) return;
|
||||
while (dropdown.options.length > 1) {
|
||||
dropdown.remove(1);
|
||||
}
|
||||
|
||||
// Add modem options
|
||||
modems.forEach(modem => {
|
||||
const option = document.createElement('option');
|
||||
option.value = modem.id;
|
||||
option.textContent = `${modem.id}${modem.ip_address ? ' (' + modem.ip_address + ')' : ''}${modem.hardware_model ? ' - ' + modem.hardware_model : ''}`;
|
||||
dropdown.appendChild(option);
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load modems list:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Populate view mode (read-only display)
|
||||
function populateViewMode() {
|
||||
// Update page title and store unit ID for copy function
|
||||
@@ -491,6 +584,15 @@ function populateEditForm() {
|
||||
document.getElementById('phoneNumber').value = currentUnit.phone_number || '';
|
||||
document.getElementById('hardwareModel').value = currentUnit.hardware_model || '';
|
||||
|
||||
// Sound Level Meter fields
|
||||
document.getElementById('slmTcpPort').value = currentUnit.slm_tcp_port || '';
|
||||
document.getElementById('slmModel').value = currentUnit.slm_model || '';
|
||||
document.getElementById('slmSerialNumber').value = currentUnit.slm_serial_number || '';
|
||||
document.getElementById('slmFrequencyWeighting').value = currentUnit.slm_frequency_weighting || '';
|
||||
document.getElementById('slmTimeWeighting').value = currentUnit.slm_time_weighting || '';
|
||||
document.getElementById('slmMeasurementRange').value = currentUnit.slm_measurement_range || '';
|
||||
document.getElementById('slmDeployedWithModemId').value = currentUnit.deployed_with_modem_id || '';
|
||||
|
||||
// Show/hide fields based on device type
|
||||
toggleDetailFields();
|
||||
}
|
||||
@@ -500,13 +602,20 @@ function toggleDetailFields() {
|
||||
const deviceType = document.getElementById('deviceType').value;
|
||||
const seismoFields = document.getElementById('seismographFields');
|
||||
const modemFields = document.getElementById('modemFields');
|
||||
const slmFields = document.getElementById('slmFields');
|
||||
|
||||
// Hide all device-specific fields first
|
||||
seismoFields.classList.add('hidden');
|
||||
modemFields.classList.add('hidden');
|
||||
slmFields.classList.add('hidden');
|
||||
|
||||
// Show the relevant fields
|
||||
if (deviceType === 'seismograph') {
|
||||
seismoFields.classList.remove('hidden');
|
||||
modemFields.classList.add('hidden');
|
||||
} else {
|
||||
seismoFields.classList.add('hidden');
|
||||
} else if (deviceType === 'modem') {
|
||||
modemFields.classList.remove('hidden');
|
||||
} else if (deviceType === 'sound_level_meter') {
|
||||
slmFields.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user