Update templates/predict.html
Browse files- templates/predict.html +185 -186
templates/predict.html
CHANGED
@@ -1,186 +1,185 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
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 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
<
|
92 |
-
|
93 |
-
|
94 |
-
|
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 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
</
|
186 |
-
</html>
|
|
|
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/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
|
8 |
+
<style>
|
9 |
+
.container {
|
10 |
+
margin-top: 20px;
|
11 |
+
padding: 20px;
|
12 |
+
border: 1px solid #ddd;
|
13 |
+
border-radius: 10px;
|
14 |
+
}
|
15 |
+
h1 {
|
16 |
+
color: green;
|
17 |
+
font-weight: bold;
|
18 |
+
}
|
19 |
+
.result-container {
|
20 |
+
padding: 20px;
|
21 |
+
margin-top: 20px;
|
22 |
+
}
|
23 |
+
.result-container .row {
|
24 |
+
justify-content: center;
|
25 |
+
}
|
26 |
+
.form-control {
|
27 |
+
height: 45px;
|
28 |
+
font-size: 18px;
|
29 |
+
text-align: center;
|
30 |
+
font-weight: bold;
|
31 |
+
color: black;
|
32 |
+
border: 2px solid #28a745;
|
33 |
+
}
|
34 |
+
.gauge-container {
|
35 |
+
margin-top: 20px;
|
36 |
+
}
|
37 |
+
.gauge-container h5 {
|
38 |
+
margin-bottom: 10px;
|
39 |
+
}
|
40 |
+
.btn-green {
|
41 |
+
background-color: green;
|
42 |
+
color: white;
|
43 |
+
}
|
44 |
+
.info-text {
|
45 |
+
font-size: 24px;
|
46 |
+
font-weight: bold;
|
47 |
+
color: black;
|
48 |
+
margin-top: 40px;
|
49 |
+
text-align: center;
|
50 |
+
}
|
51 |
+
.camera-container {
|
52 |
+
margin-top: 20px;
|
53 |
+
text-align: center;
|
54 |
+
display: none;
|
55 |
+
}
|
56 |
+
.timer {
|
57 |
+
font-size: 36px;
|
58 |
+
color: white;
|
59 |
+
background-color: green;
|
60 |
+
font-weight: bold;
|
61 |
+
padding: 20px;
|
62 |
+
border-radius: 5px;
|
63 |
+
display: inline-block;
|
64 |
+
}
|
65 |
+
video {
|
66 |
+
width: 100%;
|
67 |
+
height: auto;
|
68 |
+
border: 1px solid #ddd;
|
69 |
+
}
|
70 |
+
.btn-start {
|
71 |
+
margin-top: 20px;
|
72 |
+
background-color: green;
|
73 |
+
color: white;
|
74 |
+
font-size: 18px;
|
75 |
+
padding: 10px 20px;
|
76 |
+
}
|
77 |
+
.alert-message {
|
78 |
+
font-size: 36px;
|
79 |
+
color: red;
|
80 |
+
font-weight: bold;
|
81 |
+
margin-top: 20px;
|
82 |
+
text-align: center;
|
83 |
+
}
|
84 |
+
</style>
|
85 |
+
</head>
|
86 |
+
<body>
|
87 |
+
<div class="container">
|
88 |
+
<h1 class="text-center">Water Requirement Prediction Results</h1>
|
89 |
+
<div class="result-container row">
|
90 |
+
<div class="col-md-6">
|
91 |
+
<div class="form-group">
|
92 |
+
<label for="water_requirement">Water Requirement Prediction (m³/sq.m):</label>
|
93 |
+
<input type="text" class="form-control" id="water_requirement" value="{{ water_requirement }}" readonly>
|
94 |
+
</div>
|
95 |
+
<div class="gauge-container">
|
96 |
+
<h5>Water Requirement Gauge:</h5>
|
97 |
+
{{ water_gauge|safe }}
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
<div class="col-md-6">
|
101 |
+
<div class="form-group">
|
102 |
+
<label for="estimated_time">Estimated Time Duration (seconds) for which motor should be On:</label>
|
103 |
+
<input type="text" class="form-control" id="estimated_time" value="{{ estimated_time_duration }} {{ time_unit }}" readonly>
|
104 |
+
</div>
|
105 |
+
<div class="gauge-container">
|
106 |
+
<h5>Estimated Motor On-Time Gauge:</h5>
|
107 |
+
{{ time_gauge|safe }}
|
108 |
+
</div>
|
109 |
+
</div>
|
110 |
+
</div>
|
111 |
+
<div class="info-text">
|
112 |
+
Want to automatically inspect your irrigation process using AI-driven Irrigation Monitoring?
|
113 |
+
<br><strong>Press "Start Motor" button</strong>
|
114 |
+
<br>Then click the green <strong>Start</strong> button below.
|
115 |
+
</div>
|
116 |
+
<div class="text-center">
|
117 |
+
<button id="startMotor" class="btn btn-start">Start Motor</button>
|
118 |
+
</div>
|
119 |
+
<div class="camera-container">
|
120 |
+
<video id="videoElement" autoplay></video>
|
121 |
+
<div class="timer" id="timer"></div>
|
122 |
+
</div>
|
123 |
+
<div class="alert-message" id="alertMessage"></div>
|
124 |
+
</div>
|
125 |
+
|
126 |
+
<script>
|
127 |
+
// Start video stream from camera
|
128 |
+
navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } })
|
129 |
+
.then(function(stream) {
|
130 |
+
document.getElementById('videoElement').srcObject = stream;
|
131 |
+
})
|
132 |
+
.catch(function(err) {
|
133 |
+
console.log("Error: " + err);
|
134 |
+
});
|
135 |
+
|
136 |
+
document.getElementById('startMotor').addEventListener('click', function() {
|
137 |
+
// Prompt for motor start confirmation via WhatsApp reply simulation
|
138 |
+
let userResponse = prompt("Do you want to start the motor? Reply 1 to start, 0 to not start:");
|
139 |
+
if (userResponse !== "1") {
|
140 |
+
alert("Motor start canceled.");
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
// Calculate estimated time in seconds
|
144 |
+
let estimatedTime = parseFloat("{{ estimated_time_duration }}");
|
145 |
+
let timeUnit = "{{ time_unit }}";
|
146 |
+
let estimatedTimeSeconds = timeUnit === "minutes" ? estimatedTime * 60 : estimatedTime;
|
147 |
+
|
148 |
+
// Show camera container and start timer
|
149 |
+
document.querySelector('.camera-container').style.display = 'block';
|
150 |
+
let timerElem = document.getElementById('timer');
|
151 |
+
let timeRemaining = Math.floor(estimatedTimeSeconds);
|
152 |
+
let countdown = setInterval(function() {
|
153 |
+
timerElem.textContent = timeRemaining + "s";
|
154 |
+
if (timeRemaining <= 0) {
|
155 |
+
clearInterval(countdown);
|
156 |
+
// Play beep sound
|
157 |
+
let beep = new Audio('/static/alarn_tune.mp3');
|
158 |
+
beep.play();
|
159 |
+
document.getElementById('alertMessage').textContent = "Irrigation time is over. Motor is off. Pump is auto-off.";
|
160 |
+
// Send irrigation complete WhatsApp message
|
161 |
+
fetch('/irrigation_complete', {
|
162 |
+
method: 'POST',
|
163 |
+
headers: { 'Content-Type': 'application/json' },
|
164 |
+
body: JSON.stringify({ crop_type: "{{ crop_type }}", city: "{{ city }}" })
|
165 |
+
})
|
166 |
+
.then(response => response.json())
|
167 |
+
.then(data => console.log("Irrigation complete message sent:", data))
|
168 |
+
.catch(error => console.error("Error sending complete message:", error));
|
169 |
+
}
|
170 |
+
timeRemaining--;
|
171 |
+
}, 1000);
|
172 |
+
|
173 |
+
// Trigger motor start
|
174 |
+
fetch('/start_motor', {
|
175 |
+
method: 'POST',
|
176 |
+
headers: { 'Content-Type': 'application/json' },
|
177 |
+
body: JSON.stringify({ estimated_time_duration: estimatedTimeSeconds, time_unit: "seconds" })
|
178 |
+
})
|
179 |
+
.then(response => response.json())
|
180 |
+
.then(data => console.log("Motor started:", data))
|
181 |
+
.catch(error => console.error("Error starting motor:", error));
|
182 |
+
});
|
183 |
+
</script>
|
184 |
+
</body>
|
185 |
+
</html>
|
|