add: Modem model # now its own config. allowing for different options on different model #s

This commit is contained in:
serversdwn
2026-02-02 21:15:27 +00:00
parent 305540f564
commit 24da5ab79f
4 changed files with 307 additions and 20 deletions

View File

@@ -182,6 +182,42 @@
</div>
</div>
<!-- Sound Level Meter Info -->
<div id="viewSlmFields" class="hidden border-t border-gray-200 dark:border-gray-700 pt-6">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Sound Level Meter Information</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Model</label>
<p id="viewSlmModel" class="mt-1 text-gray-900 dark:text-white font-medium">--</p>
</div>
<div>
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Serial Number</label>
<p id="viewSlmSerialNumber" class="mt-1 text-gray-900 dark:text-white font-medium">--</p>
</div>
<div>
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Frequency Weighting</label>
<p id="viewSlmFrequencyWeighting" class="mt-1 text-gray-900 dark:text-white font-medium">--</p>
</div>
<div>
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Time Weighting</label>
<p id="viewSlmTimeWeighting" class="mt-1 text-gray-900 dark:text-white font-medium">--</p>
</div>
<div>
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Measurement Range</label>
<p id="viewSlmMeasurementRange" class="mt-1 text-gray-900 dark:text-white font-medium">--</p>
</div>
<div>
<label class="text-sm font-medium text-gray-500 dark:text-gray-400">Deployed With Modem</label>
<p id="viewSlmDeployedWithModemContainer" class="mt-1">
<a id="viewSlmDeployedWithModemLink" href="#" class="text-seismo-orange hover:text-orange-600 font-medium hover:underline hidden">
<span id="viewSlmDeployedWithModemText">--</span>
</a>
<span id="viewSlmDeployedWithModemNoLink" class="text-gray-900 dark:text-white font-medium">--</span>
</p>
</div>
</div>
</div>
<!-- Paired Device (for modems only) -->
<div id="viewPairedDeviceSection" class="hidden border-t border-gray-200 dark:border-gray-700 pt-6">
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Paired Device</h3>
@@ -292,7 +328,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>
<option value="slm">Sound Level Meter</option>
</select>
</div>
@@ -375,8 +411,13 @@
</div>
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Hardware Model</label>
<input type="text" name="hardware_model" id="hardwareModel" placeholder="e.g., Raven XTV"
<select name="hardware_model" id="hardwareModel"
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="">Select model...</option>
<option value="RV50">RV50</option>
<option value="RV55">RV55</option>
<option value="RX55">RX55</option>
</select>
</div>
</div>
</div>
@@ -434,7 +475,7 @@
{% set input_name = "deployed_with_modem_id" %}
{% include "partials/modem_picker.html" with context %}
</div>
<button type="button" onclick="openPairDeviceModal('sound_level_meter')"
<button type="button" onclick="openPairDeviceModal('slm')"
class="px-3 py-2 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg transition-colors flex items-center gap-1"
title="Pair with modem">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -594,6 +635,19 @@ async function fetchModemDisplay(modemIdOrIp) {
return { display: modemIdOrIp, modemId: modemIdOrIp };
}
// Format weighting values for display
function formatWeighting(value, type) {
if (!value) return null;
if (type === 'frequency') {
const labels = { 'A': 'A-weighting', 'C': 'C-weighting', 'Z': 'Z-weighting (Flat)' };
return labels[value] || value;
} else if (type === 'time') {
const labels = { 'F': 'Fast (125ms)', 'S': 'Slow (1s)', 'I': 'Impulse (35ms)' };
return labels[value] || value;
}
return value;
}
// Load unit data on page load
async function loadUnitData() {
try {
@@ -787,18 +841,52 @@ function populateViewMode() {
document.getElementById('viewNote').textContent = currentUnit.note || '--';
// Show/hide fields based on device type
// Hide all device-specific sections first
document.getElementById('viewSeismographFields').classList.add('hidden');
document.getElementById('viewModemFields').classList.add('hidden');
document.getElementById('viewSlmFields').classList.add('hidden');
document.getElementById('viewPairedDeviceSection').classList.add('hidden');
document.getElementById('viewConnectivitySection').classList.add('hidden');
if (currentUnit.device_type === 'modem') {
document.getElementById('viewSeismographFields').classList.add('hidden');
document.getElementById('viewModemFields').classList.remove('hidden');
document.getElementById('viewPairedDeviceSection').classList.remove('hidden');
document.getElementById('viewConnectivitySection').classList.remove('hidden');
// Load paired device info
loadPairedDevice();
} else if (currentUnit.device_type === 'slm') {
document.getElementById('viewSlmFields').classList.remove('hidden');
// Populate SLM view fields
document.getElementById('viewSlmModel').textContent = currentUnit.slm_model || '--';
document.getElementById('viewSlmSerialNumber').textContent = currentUnit.slm_serial_number || '--';
document.getElementById('viewSlmFrequencyWeighting').textContent = formatWeighting(currentUnit.slm_frequency_weighting, 'frequency') || '--';
document.getElementById('viewSlmTimeWeighting').textContent = formatWeighting(currentUnit.slm_time_weighting, 'time') || '--';
document.getElementById('viewSlmMeasurementRange').textContent = currentUnit.slm_measurement_range || '--';
// Handle SLM modem link
const slmModemLink = document.getElementById('viewSlmDeployedWithModemLink');
const slmModemNoLink = document.getElementById('viewSlmDeployedWithModemNoLink');
const slmModemText = document.getElementById('viewSlmDeployedWithModemText');
if (currentUnit.deployed_with_modem_id) {
fetchModemDisplay(currentUnit.deployed_with_modem_id).then(result => {
if (slmModemText) slmModemText.textContent = result.display;
if (slmModemLink) {
slmModemLink.href = `/unit/${encodeURIComponent(result.modemId)}`;
slmModemLink.classList.remove('hidden');
}
if (slmModemNoLink) slmModemNoLink.classList.add('hidden');
});
} else {
if (slmModemNoLink) {
slmModemNoLink.textContent = '--';
slmModemNoLink.classList.remove('hidden');
}
if (slmModemLink) slmModemLink.classList.add('hidden');
}
} else {
// Seismograph (default)
document.getElementById('viewSeismographFields').classList.remove('hidden');
document.getElementById('viewModemFields').classList.add('hidden');
document.getElementById('viewPairedDeviceSection').classList.add('hidden');
document.getElementById('viewConnectivitySection').classList.add('hidden');
}
}
@@ -914,7 +1002,7 @@ async function checkAndShowCascadeSection() {
if (currentUnit.device_type === 'modem' && currentUnit.deployed_with_unit_id) {
// Modem is paired with a seismograph or SLM
pairedUnitId = currentUnit.deployed_with_unit_id;
} else if ((currentUnit.device_type === 'seismograph' || currentUnit.device_type === 'sound_level_meter') && currentUnit.deployed_with_modem_id) {
} else if ((currentUnit.device_type === 'seismograph' || currentUnit.device_type === 'slm') && currentUnit.deployed_with_modem_id) {
// Seismograph or SLM is paired with a modem
pairedUnitId = currentUnit.deployed_with_modem_id;
}
@@ -944,7 +1032,7 @@ function toggleDetailFields() {
seismoFields.classList.remove('hidden');
} else if (deviceType === 'modem') {
modemFields.classList.remove('hidden');
} else if (deviceType === 'sound_level_meter') {
} else if (deviceType === 'slm') {
slmFields.classList.remove('hidden');
}
}
@@ -1007,7 +1095,7 @@ function getCorrectModemPickerValue(deviceType) {
if (deviceType === 'seismograph') {
const picker = document.getElementById('modem-picker-value-detail-seismo');
return picker ? picker.value : '';
} else if (deviceType === 'sound_level_meter') {
} else if (deviceType === 'slm') {
const picker = document.getElementById('modem-picker-value-detail-slm');
return picker ? picker.value : '';
}
@@ -1544,7 +1632,7 @@ function selectModemForPairing(modemId, displayText) {
let pickerId = '';
if (pairModalDeviceType === 'seismograph') {
pickerId = '-detail-seismo';
} else if (pairModalDeviceType === 'sound_level_meter') {
} else if (pairModalDeviceType === 'slm') {
pickerId = '-detail-slm';
}
@@ -1565,7 +1653,7 @@ function clearPairing(deviceType) {
let pickerId = '';
if (deviceType === 'seismograph') {
pickerId = '-detail-seismo';
} else if (deviceType === 'sound_level_meter') {
} else if (deviceType === 'slm') {
pickerId = '-detail-slm';
}
@@ -1661,7 +1749,7 @@ function renderModemPairDeviceList() {
let filteredDevices = modemPairDevices.filter(device => {
// Filter by device type
if (device.device_type === 'seismograph' && !showSeismo) return false;
if (device.device_type === 'sound_level_meter' && !showSLM) return false;
if (device.device_type === 'slm' && !showSLM) return false;
// Hide devices paired to OTHER modems (but show unpaired and paired-to-this)
if (hidePaired && device.is_paired_to_other) return false;
@@ -1688,8 +1776,8 @@ function renderModemPairDeviceList() {
// Build device list HTML
let html = '<div class="divide-y divide-gray-200 dark:divide-gray-700">';
for (const device of filteredDevices) {
const deviceTypeLabel = device.device_type === 'sound_level_meter' ? 'SLM' : 'Seismograph';
const deviceTypeClass = device.device_type === 'sound_level_meter'
const deviceTypeLabel = device.device_type === 'slm' ? 'SLM' : 'Seismograph';
const deviceTypeClass = device.device_type === 'slm'
? 'bg-purple-100 dark:bg-purple-900/30 text-purple-800 dark:text-purple-300'
: 'bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300';