Rajkhanke007 commited on
Commit
0994aa5
·
verified ·
1 Parent(s): 2014c64

Update templates/predict.html

Browse files
Files changed (1) hide show
  1. templates/predict.html +185 -186
templates/predict.html CHANGED
@@ -1,186 +1,185 @@
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; /* Bold text */
31
- color: black; /* Black text */
32
- border: 2px solid #28a745; /* Green border */
33
- }
34
- .result {
35
- text-align: center;
36
- }
37
- .gauge-container {
38
- margin-top: 20px;
39
- }
40
- .gauge-container h5 {
41
- margin-bottom: 10px;
42
- }
43
- .btn-green {
44
- background-color: green;
45
- color: white;
46
- }
47
-
48
- /* New styles below */
49
- .info-text {
50
- font-size: 24px; /* Increased font size */
51
- font-weight: bold;
52
- color: black;
53
- margin-top: 40px;
54
- text-align: center; /* Center-aligned */
55
- }
56
- .camera-container {
57
- margin-top: 20px;
58
- text-align: center;
59
- display: none; /* Hidden by default, shown after button click */
60
- }
61
- .timer {
62
- font-size: 36px; /* Increased size */
63
- color: white; /* White text */
64
- background-color: green; /* Green background */
65
- font-weight: bold; /* Bold font */
66
- padding: 20px;
67
- border-radius: 5px;
68
- display: inline-block;
69
- }
70
- video {
71
- width: 100%;
72
- height: auto;
73
- border: 1px solid #ddd;
74
- }
75
- .btn-start {
76
- margin-top: 20px;
77
- background-color: green;
78
- color: white;
79
- font-size: 18px;
80
- padding: 10px 20px;
81
- }
82
- .alert-message {
83
- font-size: 36px; /* Increased size for alert message */
84
- color: red;
85
- font-weight: bold;
86
- margin-top: 20px;
87
- text-align: center;
88
- }
89
- </style>
90
- </head>
91
- <body>
92
- <div class="container">
93
- <h1 class="text-center">Water Requirement Prediction Results</h1>
94
- <div class="result-container row">
95
- <div class="col-md-6">
96
- <div class="form-group">
97
- <label for="water_requirement">Water Requirement Prediction (m³/sq.m):</label>
98
- <input type="text" class="form-control" id="water_requirement" value="{{ water_requirement }}" readonly>
99
- </div>
100
- <div class="gauge-container">
101
- <h5>Water Requirement Gauge:</h5>
102
- {{ water_gauge|safe }}
103
- </div>
104
- </div>
105
-
106
- <div class="col-md-6">
107
- <div class="form-group">
108
- <label for="estimated_time">Estimated Time Duration (seconds) for which motor should be On:</label>
109
- <input type="text" class="form-control" id="estimated_time" value="{{ estimated_time_duration }} {{ time_unit }}" readonly>
110
- </div>
111
- <div class="gauge-container">
112
- <h5>Estimated Motor On-Time Gauge:</h5>
113
- {{ time_gauge|safe }}
114
- </div>
115
- </div>
116
- </div>
117
-
118
- <!-- New section below -->
119
- <div class="info-text">
120
- Want to automatically inspect your irrigation process using AI-driven Irrigation Monitoring?
121
- <br><strong>Press "Start Motor" button</strong>
122
- <br>Then click the green <strong>Start</strong> button below.
123
- </div>
124
-
125
- <!-- "Start Motor" Button -->
126
- <div class="text-center">
127
- <button id="startMotor" class="btn btn-start">Start Motor</button>
128
- </div>
129
-
130
- <div class="camera-container">
131
- <video id="videoElement" autoplay></video>
132
- <div class="timer" id="timer"></div>
133
- </div>
134
-
135
- <div class="alert-message" id="alertMessage"></div>
136
- </div>
137
-
138
- <script>
139
- // Access camera and start video stream
140
- navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } })
141
- .then(function(stream) {
142
- document.getElementById('videoElement').srcObject = stream;
143
- })
144
- .catch(function(err) {
145
- console.log("Error: " + err);
146
- });
147
-
148
- document.getElementById('startMotor').addEventListener('click', function() {
149
- let estimatedTime = {{ estimated_time_duration }};
150
- if (estimatedTime < 10) {
151
- estimatedTime = estimatedTime * 60; // Convert minutes to seconds
152
- }
153
- let timeUnit = "{{ time_unit }}";
154
-
155
- // Show the camera container after the button is clicked
156
- document.querySelector('.camera-container').style.display = 'block';
157
-
158
- // Start the timer
159
- let timer = document.getElementById('timer');
160
- let timeRemaining = parseInt(estimatedTime, 10); // Convert to integer
161
- let countdown = setInterval(function() {
162
- let seconds = timeRemaining;
163
- timer.textContent = seconds + "s";
164
- if (timeRemaining <= 0) {
165
- clearInterval(countdown);
166
- // Play beep sound
167
- let beep = new Audio('/static/alarn_tune.mp3');
168
- beep.play();
169
-
170
- // Display alert message
171
- document.getElementById('alertMessage').textContent = "Stop Irrigation!";
172
- }
173
- timeRemaining--;
174
- }, 1000);
175
-
176
- fetch('/start_motor', {
177
- method: 'POST',
178
- headers: {
179
- 'Content-Type': 'application/json',
180
- },
181
- body: JSON.stringify({ estimated_time_duration: estimated_time_duration_seconds })
182
- });
183
- });
184
- </script>
185
- </body>
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>