- Copy app.py, templates, static, data, routes, services - Copy requirements.txt for v1 dependencies
381 lines
12 KiB
HTML
381 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>TCKRTUIYO - Calibration</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<style>
|
|
:root {
|
|
--touch-target-min: 48px;
|
|
--touch-target-primary: 64px;
|
|
--primary-color: #0d6efd;
|
|
--bg-color: #f8f9fa;
|
|
--card-bg: #ffffff;
|
|
}
|
|
|
|
body {
|
|
font-size: 18px;
|
|
background-color: var(--bg-color);
|
|
}
|
|
|
|
/* Touch-optimized navigation */
|
|
.nav-menu {
|
|
display: flex;
|
|
gap: 10px;
|
|
padding: 15px;
|
|
background: var(--card-bg);
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
}
|
|
|
|
.nav-btn {
|
|
flex: 1;
|
|
min-height: var(--touch-target-primary);
|
|
font-size: 1.2rem;
|
|
font-weight: 600;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 10px;
|
|
border-radius: 12px;
|
|
transition: transform 0.1s, box-shadow 0.1s;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.nav-btn:active {
|
|
transform: scale(0.98);
|
|
}
|
|
|
|
.nav-btn.active {
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
border: none;
|
|
}
|
|
|
|
.nav-btn:not(.active) {
|
|
background-color: #e9ecef;
|
|
color: #495057;
|
|
border: 1px solid #dee2e6;
|
|
}
|
|
|
|
/* Logo in navigation */
|
|
.nav-logo {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 0 10px;
|
|
}
|
|
.nav-logo img {
|
|
max-height: 40px;
|
|
width: auto;
|
|
}
|
|
|
|
/* Calibration cards */
|
|
.calib-card {
|
|
background: var(--card-bg);
|
|
border-radius: 16px;
|
|
padding: 20px;
|
|
margin: 15px;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
|
}
|
|
|
|
.calib-card h4 {
|
|
font-size: 1.3rem;
|
|
color: #212529;
|
|
margin-bottom: 20px;
|
|
padding-bottom: 10px;
|
|
border-bottom: 2px solid #e9ecef;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
/* ADC Channel display */
|
|
.adc-channel {
|
|
background: #f8f9fa;
|
|
border-radius: 12px;
|
|
padding: 15px;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.adc-channel h5 {
|
|
font-size: 1.1rem;
|
|
margin-bottom: 15px;
|
|
font-weight: 600;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.channel-type {
|
|
font-size: 0.85rem;
|
|
padding: 4px 10px;
|
|
background: #e9ecef;
|
|
border-radius: 6px;
|
|
color: #495057;
|
|
}
|
|
|
|
.channel-data {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 10px;
|
|
}
|
|
|
|
.channel-item {
|
|
background: white;
|
|
padding: 10px;
|
|
border-radius: 8px;
|
|
text-align: center;
|
|
}
|
|
|
|
.channel-label {
|
|
font-size: 0.8rem;
|
|
color: #6c757d;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.channel-value {
|
|
font-size: 1.2rem;
|
|
font-weight: 600;
|
|
color: #212529;
|
|
}
|
|
|
|
/* Rainfall counters */
|
|
.rainfall-counter {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 15px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.rainfall-box {
|
|
background: #e7f1ff;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
text-align: center;
|
|
}
|
|
|
|
.rainfall-label {
|
|
font-size: 0.9rem;
|
|
color: #6c757d;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.rainfall-value {
|
|
font-size: 2rem;
|
|
font-weight: 700;
|
|
color: var(--primary-color);
|
|
}
|
|
|
|
/* Reset button */
|
|
.btn-reset {
|
|
min-height: var(--touch-target-primary);
|
|
font-size: 1.1rem;
|
|
font-weight: 600;
|
|
padding: 15px 30px;
|
|
border-radius: 12px;
|
|
}
|
|
|
|
/* Alert */
|
|
.alert {
|
|
border-radius: 12px;
|
|
padding: 15px 20px;
|
|
}
|
|
|
|
/* Live indicator */
|
|
.live-indicator {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 0.9rem;
|
|
color: #198754;
|
|
}
|
|
|
|
.live-dot {
|
|
width: 10px;
|
|
height: 10px;
|
|
background: #198754;
|
|
border-radius: 50%;
|
|
animation: pulse 1.5s infinite;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0%, 100% { opacity: 1; }
|
|
50% { opacity: 0.5; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- Navigation Menu -->
|
|
<nav class="nav-menu">
|
|
<a href="/" class="nav-logo">
|
|
<img src="logo/[LOGO] TCK.svg" alt="TCK" height="40">
|
|
</a>
|
|
<a href="/" class="nav-btn">
|
|
<i class="bi bi-speedometer2"></i> Dashboard
|
|
</a>
|
|
<a href="/settings" class="nav-btn">
|
|
<i class="bi bi-gear"></i> Settings
|
|
</a>
|
|
<a href="/calibration" class="nav-btn active">
|
|
<i class="bi bi-sliders"></i> Calibration
|
|
</a>
|
|
<a href="/files" class="nav-btn">
|
|
<i class="bi bi-folder"></i> Files
|
|
</a>
|
|
</nav>
|
|
|
|
<div class="container-fluid p-0">
|
|
<!-- Alert for status -->
|
|
<div id="alertMessage" class="alert alert-success m-3" style="display: none;">
|
|
Settings saved successfully!
|
|
</div>
|
|
|
|
<!-- Live indicator -->
|
|
<div class="calib-card" style="padding: 10px 20px;">
|
|
<div class="live-indicator">
|
|
<span class="live-dot"></span>
|
|
Live ADC Readings
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ADC Channels -->
|
|
<div class="calib-card">
|
|
<h4><i class="bi bi-gpu"></i> ADC Channels</h4>
|
|
<div id="adcChannels">
|
|
<!-- ADC channels will be populated by JS -->
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Rainfall Counters -->
|
|
<div class="calib-card">
|
|
<h4><i class="bi bi-cloud-rain"></i> Rainfall Counters</h4>
|
|
<div class="rainfall-counter">
|
|
<div class="rainfall-box">
|
|
<div class="rainfall-label" id="rf1Label">RF1 Tips</div>
|
|
<div class="rainfall-value" id="rf1Tips">0</div>
|
|
</div>
|
|
<div class="rainfall-box">
|
|
<div class="rainfall-label" id="rf2Label">RF2 Tips</div>
|
|
<div class="rainfall-value" id="rf2Tips">0</div>
|
|
</div>
|
|
</div>
|
|
<button class="btn btn-danger btn-reset w-100" onclick="resetRainfall()">
|
|
<i class="bi bi-arrow-counterclockwise"></i> Reset Rainfall Counters
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/socket.io-client@4.7.4/dist/socket.io.min.js"></script>
|
|
<script>
|
|
const socket = io();
|
|
|
|
// Load calibration data
|
|
async function loadCalibration() {
|
|
try {
|
|
const response = await fetch('/api/calibration');
|
|
const data = await response.json();
|
|
|
|
// Update rainfall counters
|
|
document.getElementById('rf1Label').textContent = data.rainfall.rf1_id + ' Tips';
|
|
document.getElementById('rf1Tips').textContent = data.rainfall.rf1_tips;
|
|
document.getElementById('rf2Label').textContent = data.rainfall.rf2_id + ' Tips';
|
|
document.getElementById('rf2Tips').textContent = data.rainfall.rf2_tips;
|
|
|
|
// Render ADC channels
|
|
renderAdcChannels(data.adc);
|
|
|
|
} catch (error) {
|
|
console.error('Error loading calibration:', error);
|
|
}
|
|
}
|
|
|
|
// Render ADC channels
|
|
function renderAdcChannels(channels) {
|
|
const container = document.getElementById('adcChannels');
|
|
container.innerHTML = '';
|
|
|
|
channels.forEach(channel => {
|
|
const div = document.createElement('div');
|
|
div.className = 'adc-channel';
|
|
div.innerHTML = `
|
|
<h5>
|
|
<span>Channel ${channel.id}</span>
|
|
<span class="channel-type">${channel.type}</span>
|
|
</h5>
|
|
<div class="channel-data">
|
|
<div class="channel-item">
|
|
<div class="channel-label">ADC Value</div>
|
|
<div class="channel-value">${channel.value.toFixed(2)}</div>
|
|
</div>
|
|
<div class="channel-item">
|
|
<div class="channel-label">Datum</div>
|
|
<div class="channel-value">${channel.datum.toFixed(2)}</div>
|
|
</div>
|
|
<div class="channel-item">
|
|
<div class="channel-label">Reading</div>
|
|
<div class="channel-value">${channel.reading.toFixed(1)} ${channel.unit}</div>
|
|
</div>
|
|
<div class="channel-item">
|
|
<div class="channel-label">Status</div>
|
|
<div class="channel-value">${channel.value > 0 ? 'Active' : 'Idle'}</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
container.appendChild(div);
|
|
});
|
|
}
|
|
|
|
// Real-time ADC updates via Socket.IO
|
|
socket.on('sensor_update', function(data) {
|
|
// Refresh calibration data periodically
|
|
loadCalibration();
|
|
});
|
|
|
|
// Reset rainfall counters
|
|
async function resetRainfall() {
|
|
if (!confirm('Are you sure you want to reset all rainfall counters?')) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('/api/calibration/reset_rainfall', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' }
|
|
});
|
|
|
|
const result = await response.json();
|
|
if (result.success) {
|
|
showAlert('Rainfall counters reset successfully!');
|
|
loadCalibration();
|
|
}
|
|
} catch (error) {
|
|
console.error('Error resetting rainfall:', error);
|
|
showAlert('Error resetting rainfall counters', 'danger');
|
|
}
|
|
}
|
|
|
|
function showAlert(message, type = 'success') {
|
|
const alert = document.getElementById('alertMessage');
|
|
alert.className = 'alert alert-' + type;
|
|
alert.textContent = message;
|
|
alert.style.display = 'block';
|
|
setTimeout(() => {
|
|
alert.style.display = 'none';
|
|
}, 3000);
|
|
}
|
|
|
|
// Initial load
|
|
loadCalibration();
|
|
|
|
// Refresh every 2 seconds
|
|
setInterval(loadCalibration, 2000);
|
|
</script>
|
|
</body>
|
|
</html>
|