Change: user sets date of previous calibration, not upcoming expire dates.
- seismograph list page enhanced with better visabilty, filtering, sorting, and calibration dates color coded.
This commit is contained in:
@@ -145,16 +145,12 @@
|
||||
<div id="seismographFields" class="space-y-4 border-t border-gray-200 dark:border-gray-700 pt-4">
|
||||
<p class="text-sm font-semibold text-gray-700 dark:text-gray-300">Seismograph Information</p>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Last Calibrated</label>
|
||||
<input type="date" name="last_calibrated"
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Date of Last Calibration</label>
|
||||
<input type="date" name="last_calibrated" id="addLastCalibrated"
|
||||
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">Next calibration due date will be calculated automatically</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Next Calibration Due</label>
|
||||
<input type="date" name="next_calibration_due"
|
||||
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">Typically 1 year after last calibration</p>
|
||||
</div>
|
||||
<input type="hidden" name="next_calibration_due" id="addNextCalibrationDue">
|
||||
<div id="modemPairingField" class="hidden">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Deployed With Modem</label>
|
||||
{% set picker_id = "-add-seismo" %}
|
||||
@@ -325,15 +321,12 @@
|
||||
<div id="editSeismographFields" class="space-y-4 border-t border-gray-200 dark:border-gray-700 pt-4">
|
||||
<p class="text-sm font-semibold text-gray-700 dark:text-gray-300">Seismograph Information</p>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Last Calibrated</label>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Date of Last Calibration</label>
|
||||
<input type="date" name="last_calibrated" id="editLastCalibrated"
|
||||
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">Next calibration due date will be calculated automatically</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Next Calibration Due</label>
|
||||
<input type="date" name="next_calibration_due" id="editNextCalibrationDue"
|
||||
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>
|
||||
<input type="hidden" name="next_calibration_due" id="editNextCalibrationDue">
|
||||
<div id="editModemPairingField" class="hidden">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Deployed With Modem</label>
|
||||
{% set picker_id = "-edit-seismo" %}
|
||||
@@ -598,6 +591,58 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Calibration interval in days (default 365, will be loaded from preferences)
|
||||
let calibrationIntervalDays = 365;
|
||||
|
||||
// Load calibration interval from preferences
|
||||
async function loadCalibrationInterval() {
|
||||
try {
|
||||
const response = await fetch('/api/settings/preferences');
|
||||
if (response.ok) {
|
||||
const prefs = await response.json();
|
||||
calibrationIntervalDays = prefs.calibration_interval_days || 365;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load calibration interval:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate next calibration due date from last calibrated date
|
||||
function calculateNextCalibrationDue(lastCalibratedStr) {
|
||||
if (!lastCalibratedStr) return '';
|
||||
const lastCalibrated = new Date(lastCalibratedStr);
|
||||
const nextDue = new Date(lastCalibrated);
|
||||
nextDue.setDate(nextDue.getDate() + calibrationIntervalDays);
|
||||
return nextDue.toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
// Setup auto-calculation for calibration fields
|
||||
function setupCalibrationAutoCalc() {
|
||||
// Add form
|
||||
const addLastCal = document.getElementById('addLastCalibrated');
|
||||
const addNextCal = document.getElementById('addNextCalibrationDue');
|
||||
if (addLastCal && addNextCal) {
|
||||
addLastCal.addEventListener('change', function() {
|
||||
addNextCal.value = calculateNextCalibrationDue(this.value);
|
||||
});
|
||||
}
|
||||
|
||||
// Edit form
|
||||
const editLastCal = document.getElementById('editLastCalibrated');
|
||||
const editNextCal = document.getElementById('editNextCalibrationDue');
|
||||
if (editLastCal && editNextCal) {
|
||||
editLastCal.addEventListener('change', function() {
|
||||
editNextCal.value = calculateNextCalibrationDue(this.value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadCalibrationInterval();
|
||||
setupCalibrationAutoCalc();
|
||||
});
|
||||
|
||||
// Add Unit Modal
|
||||
function openAddUnitModal() {
|
||||
document.getElementById('addUnitModal').classList.remove('hidden');
|
||||
@@ -891,8 +936,11 @@
|
||||
document.getElementById('editRetiredCheckbox').checked = unit.retired;
|
||||
|
||||
// Seismograph fields
|
||||
document.getElementById('editLastCalibrated').value = unit.last_calibrated;
|
||||
document.getElementById('editNextCalibrationDue').value = unit.next_calibration_due;
|
||||
document.getElementById('editLastCalibrated').value = unit.last_calibrated || '';
|
||||
// Calculate next calibration due from last calibrated
|
||||
document.getElementById('editNextCalibrationDue').value = unit.last_calibrated
|
||||
? calculateNextCalibrationDue(unit.last_calibrated)
|
||||
: '';
|
||||
|
||||
// Populate modem picker for seismograph (uses -edit-seismo suffix)
|
||||
const modemPickerValue = document.getElementById('modem-picker-value-edit-seismo');
|
||||
|
||||
Reference in New Issue
Block a user