Spaces:
Sleeping
Sleeping
Update templates/predict.html
Browse files- templates/predict.html +208 -206
templates/predict.html
CHANGED
|
@@ -1,206 +1,208 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Prediction Results</title>
|
| 7 |
-
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
-
<style>
|
| 9 |
-
body {
|
| 10 |
-
background-color: #f4f8f4;
|
| 11 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 12 |
-
}
|
| 13 |
-
.header {
|
| 14 |
-
background-color: #28a745;
|
| 15 |
-
color: white;
|
| 16 |
-
padding: 20px;
|
| 17 |
-
text-align: center;
|
| 18 |
-
font-weight: bold;
|
| 19 |
-
}
|
| 20 |
-
.container {
|
| 21 |
-
margin-top: 30px;
|
| 22 |
-
padding: 20px;
|
| 23 |
-
background-color: white;
|
| 24 |
-
border-radius: 15px;
|
| 25 |
-
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
display: none;
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
text-align: center;
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
let
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
})
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
.
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
</
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Prediction Results</title>
|
| 7 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
+
<style>
|
| 9 |
+
body {
|
| 10 |
+
background-color: #f4f8f4;
|
| 11 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 12 |
+
}
|
| 13 |
+
.header {
|
| 14 |
+
background-color: #28a745;
|
| 15 |
+
color: white;
|
| 16 |
+
padding: 20px;
|
| 17 |
+
text-align: center;
|
| 18 |
+
font-weight: bold;
|
| 19 |
+
}
|
| 20 |
+
.container {
|
| 21 |
+
margin-top: 30px;
|
| 22 |
+
padding: 20px;
|
| 23 |
+
background-color: white;
|
| 24 |
+
border-radius: 15px;
|
| 25 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 26 |
+
/* FIX 3: Start with content hidden and add a smooth fade-in transition */
|
| 27 |
+
opacity: 0;
|
| 28 |
+
transition: opacity 0.5s ease-in-out;
|
| 29 |
+
}
|
| 30 |
+
.result-label {
|
| 31 |
+
font-weight: bold;
|
| 32 |
+
color: #555;
|
| 33 |
+
}
|
| 34 |
+
.form-control[readonly] {
|
| 35 |
+
font-size: 1.2rem;
|
| 36 |
+
text-align: center;
|
| 37 |
+
font-weight: bold;
|
| 38 |
+
color: #28a745;
|
| 39 |
+
background-color: #e9f5e9;
|
| 40 |
+
border: 2px solid #28a745;
|
| 41 |
+
}
|
| 42 |
+
.gauge-container {
|
| 43 |
+
margin-top: 20px;
|
| 44 |
+
text-align: center;
|
| 45 |
+
}
|
| 46 |
+
.info-card {
|
| 47 |
+
background-color: #f8f9fa;
|
| 48 |
+
border: 1px solid #dee2e6;
|
| 49 |
+
border-radius: 10px;
|
| 50 |
+
padding: 25px;
|
| 51 |
+
margin-top: 40px;
|
| 52 |
+
text-align: center;
|
| 53 |
+
}
|
| 54 |
+
.btn-start-motor {
|
| 55 |
+
background-color: #28a745;
|
| 56 |
+
color: white;
|
| 57 |
+
font-size: 1.2rem;
|
| 58 |
+
padding: 12px 25px;
|
| 59 |
+
font-weight: bold;
|
| 60 |
+
border-radius: 8px;
|
| 61 |
+
transition: background-color 0.3s;
|
| 62 |
+
}
|
| 63 |
+
.btn-start-motor:hover {
|
| 64 |
+
background-color: #218838;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/* --- FIX 1 & 2: Camera Container, Video, and Timer Styles --- */
|
| 68 |
+
.camera-container {
|
| 69 |
+
margin-top: 20px;
|
| 70 |
+
display: none; /* Keep hidden by default */
|
| 71 |
+
/* Use Flexbox to stack and center children */
|
| 72 |
+
display: flex;
|
| 73 |
+
flex-direction: column; /* Stack items vertically */
|
| 74 |
+
align-items: center; /* Center items horizontally */
|
| 75 |
+
gap: 20px; /* Add space between video and timer */
|
| 76 |
+
}
|
| 77 |
+
video {
|
| 78 |
+
width: 100%; /* Be responsive to container width */
|
| 79 |
+
max-width: 720px; /* Set a max-width for larger screens */
|
| 80 |
+
height: auto;
|
| 81 |
+
border-radius: 10px;
|
| 82 |
+
border: 2px solid #ddd;
|
| 83 |
+
background-color: #000; /* Add a background for when the feed is loading */
|
| 84 |
+
}
|
| 85 |
+
.timer {
|
| 86 |
+
font-size: 2rem;
|
| 87 |
+
color: white;
|
| 88 |
+
background-color: #28a745;
|
| 89 |
+
font-weight: bold;
|
| 90 |
+
padding: 10px 25px;
|
| 91 |
+
border-radius: 10px;
|
| 92 |
+
display: inline-block;
|
| 93 |
+
min-width: 120px; /* Give it a minimum width */
|
| 94 |
+
text-align: center;
|
| 95 |
+
}
|
| 96 |
+
/* Style for the "Finished" button state */
|
| 97 |
+
.timer-finished {
|
| 98 |
+
font-size: 1.5rem;
|
| 99 |
+
padding: 15px 40px;
|
| 100 |
+
background-color: #28a745; /* Green button color */
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.alert-message {
|
| 104 |
+
font-size: 1.5rem;
|
| 105 |
+
color: #dc3545;
|
| 106 |
+
font-weight: bold;
|
| 107 |
+
margin-top: 20px;
|
| 108 |
+
text-align: center;
|
| 109 |
+
}
|
| 110 |
+
</style>
|
| 111 |
+
</head>
|
| 112 |
+
<body>
|
| 113 |
+
|
| 114 |
+
<div class="header">
|
| 115 |
+
<h1>Water Requirement Prediction Results</h1>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<div class="container">
|
| 119 |
+
<div class="row">
|
| 120 |
+
<!-- Water Requirement -->
|
| 121 |
+
<div class="col-md-6 mb-4">
|
| 122 |
+
<label for="water_requirement" class="result-label">Predicted Water Requirement (m³/sq.m):</label>
|
| 123 |
+
<input type="text" class="form-control" id="water_requirement" value="{{ water_requirement }}" readonly>
|
| 124 |
+
<div class="gauge-container">
|
| 125 |
+
{{ water_gauge|safe }}
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
|
| 129 |
+
<!-- Motor On Time -->
|
| 130 |
+
<div class="col-md-6 mb-4">
|
| 131 |
+
<label for="estimated_time" class="result-label">Estimated Motor On-Time:</label>
|
| 132 |
+
<input type="text" class="form-control" id="estimated_time" value="{{ estimated_time_duration }} {{ time_unit }}" readonly>
|
| 133 |
+
<div class="gauge-container">
|
| 134 |
+
{{ time_gauge|safe }}
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
</div>
|
| 138 |
+
|
| 139 |
+
<!-- AI Monitoring Section -->
|
| 140 |
+
<div class="info-card">
|
| 141 |
+
<h4>Want to automatically inspect your irrigation process?</h4>
|
| 142 |
+
<p class="mt-3">Use our AI-driven Irrigation Monitoring to watch the process from your phone. You will receive a WhatsApp message to start the motor. Once started, you can monitor it live here.</p>
|
| 143 |
+
<button id="startMonitoring" class="btn btn-start-motor">Start AI Monitoring</button>
|
| 144 |
+
</div>
|
| 145 |
+
|
| 146 |
+
<!-- The camera and timer are now properly styled to be centered and stacked -->
|
| 147 |
+
<div class="camera-container" id="cameraContainer">
|
| 148 |
+
<h4 class="text-center mb-0">Live Irrigation Feed</h4>
|
| 149 |
+
<video id="videoElement" autoplay playsinline></video>
|
| 150 |
+
<div class="timer" id="timer"></div>
|
| 151 |
+
</div>
|
| 152 |
+
|
| 153 |
+
<div class="alert-message" id="alertMessage"></div>
|
| 154 |
+
</div>
|
| 155 |
+
|
| 156 |
+
<script>
|
| 157 |
+
// FIX 3: Wait for the entire page to load, then fade in the content
|
| 158 |
+
window.onload = function() {
|
| 159 |
+
document.querySelector('.container').style.opacity = 1;
|
| 160 |
+
};
|
| 161 |
+
|
| 162 |
+
document.getElementById('startMonitoring').addEventListener('click', function() {
|
| 163 |
+
document.getElementById('cameraContainer').style.display = 'flex'; // Use flex to show it
|
| 164 |
+
|
| 165 |
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
| 166 |
+
navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } })
|
| 167 |
+
.then(function(stream) {
|
| 168 |
+
document.getElementById('videoElement').srcObject = stream;
|
| 169 |
+
})
|
| 170 |
+
.catch(function(err) {
|
| 171 |
+
console.log("Camera Error: " + err);
|
| 172 |
+
alert("Could not access the camera. Please ensure you have given permission.");
|
| 173 |
+
});
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
let estimatedTime = parseFloat("{{ estimated_time_duration }}");
|
| 177 |
+
let timeUnit = "{{ time_unit }}";
|
| 178 |
+
let estimatedTimeSeconds = timeUnit === "minutes" ? estimatedTime * 60 : estimatedTime;
|
| 179 |
+
|
| 180 |
+
let timerElem = document.getElementById('timer');
|
| 181 |
+
let timeRemaining = Math.floor(estimatedTimeSeconds);
|
| 182 |
+
|
| 183 |
+
alert("Check your WhatsApp to start the motor. The timer and monitoring will begin here once you confirm.");
|
| 184 |
+
|
| 185 |
+
let countdown = setInterval(function() {
|
| 186 |
+
if (timeRemaining <= 0) {
|
| 187 |
+
clearInterval(countdown);
|
| 188 |
+
// Update timer to look like a finished button
|
| 189 |
+
timerElem.textContent = "Finished";
|
| 190 |
+
timerElem.classList.add('timer-finished'); // Add the new class
|
| 191 |
+
|
| 192 |
+
let beep = new Audio('/static/alarn_tune.mp3');
|
| 193 |
+
beep.play();
|
| 194 |
+
document.getElementById('alertMessage').textContent = "Irrigation time is over. Motor is off automatically.";
|
| 195 |
+
} else {
|
| 196 |
+
timerElem.textContent = timeRemaining + "s";
|
| 197 |
+
}
|
| 198 |
+
timeRemaining--;
|
| 199 |
+
}, 1000);
|
| 200 |
+
|
| 201 |
+
fetch('/start_motor', { method: 'POST' })
|
| 202 |
+
.then(response => response.json())
|
| 203 |
+
.then(data => console.log("Monitoring request sent:", data))
|
| 204 |
+
.catch(error => console.error("Error sending monitoring request:", error));
|
| 205 |
+
});
|
| 206 |
+
</script>
|
| 207 |
+
</body>
|
| 208 |
+
</html>
|