RushiMane2003 commited on
Commit
e4d7927
·
verified ·
1 Parent(s): a8880c6

Update templates/predict.html

Browse files
Files changed (1) hide show
  1. templates/predict.html +20 -2
templates/predict.html CHANGED
@@ -32,12 +32,24 @@
32
  <div class="col-md-6 mb-4">
33
  <label for="water_requirement" class="result-label">Predicted Water Requirement (m³/sq.m):</label>
34
  <input type="text" class="form-control" id="water_requirement" value="{{ water_requirement }}" readonly>
35
- <div class="gauge-container">{{ water_gauge|safe }}</div>
 
 
 
 
 
 
36
  </div>
37
  <div class="col-md-6 mb-4">
38
  <label for="estimated_time" class="result-label">Estimated Motor On-Time:</label>
39
  <input type="text" class="form-control" id="estimated_time" value="{{ estimated_time_duration }} {{ time_unit }}" readonly>
40
- <div class="gauge-container">{{ time_gauge|safe }}</div>
 
 
 
 
 
 
41
  </div>
42
  </div>
43
 
@@ -61,6 +73,7 @@
61
  let clientTimerInterval = null;
62
  let cameraStream = null;
63
  let isMonitoringActive = false;
 
64
  // --- MAIN FUNCTION TO START POLLING ---
65
  window.onload = function() {
66
  // Start polling the server for status updates every 3 seconds
@@ -93,6 +106,7 @@
93
  clearInterval(pollingInterval);
94
  });
95
  }
 
96
  // --- FUNCTION TO ACTIVATE CAMERA AND VISUAL TIMER ---
97
  function startCameraAndTimer(timeRemainingSeconds) {
98
  // Show camera container
@@ -112,10 +126,12 @@
112
  } else {
113
  alert("Camera API not supported in this browser.");
114
  }
 
115
  // Start client-side visual countdown timer
116
  let timeRemaining = Math.floor(timeRemainingSeconds);
117
  let timerElem = document.getElementById('timer');
118
  timerElem.classList.remove('timer-finished');
 
119
  clearInterval(clientTimerInterval); // Clear any existing timer
120
  clientTimerInterval = setInterval(function() {
121
  if (timeRemaining <= 0) {
@@ -130,10 +146,12 @@
130
  timeRemaining--;
131
  }, 1000);
132
  }
 
133
  // --- FUNCTION TO STOP CAMERA AND TIMER ---
134
  function stopCameraAndTimer() {
135
  clearInterval(clientTimerInterval);
136
  clearInterval(pollingInterval); // Stop polling once task is over
 
137
  if (cameraStream) {
138
  cameraStream.getTracks().forEach(track => track.stop());
139
  cameraStream = null;
 
32
  <div class="col-md-6 mb-4">
33
  <label for="water_requirement" class="result-label">Predicted Water Requirement (m³/sq.m):</label>
34
  <input type="text" class="form-control" id="water_requirement" value="{{ water_requirement }}" readonly>
35
+ <div class="gauge-container">
36
+ {% if water_img %}
37
+ <img src="{{ water_img }}" alt="Water gauge" class="img-fluid" style="max-height:360px;">
38
+ {% else %}
39
+ {{ water_gauge|safe }}
40
+ {% endif %}
41
+ </div>
42
  </div>
43
  <div class="col-md-6 mb-4">
44
  <label for="estimated_time" class="result-label">Estimated Motor On-Time:</label>
45
  <input type="text" class="form-control" id="estimated_time" value="{{ estimated_time_duration }} {{ time_unit }}" readonly>
46
+ <div class="gauge-container">
47
+ {% if time_img %}
48
+ <img src="{{ time_img }}" alt="Time gauge" class="img-fluid" style="max-height:360px;">
49
+ {% else %}
50
+ {{ time_gauge|safe }}
51
+ {% endif %}
52
+ </div>
53
  </div>
54
  </div>
55
 
 
73
  let clientTimerInterval = null;
74
  let cameraStream = null;
75
  let isMonitoringActive = false;
76
+
77
  // --- MAIN FUNCTION TO START POLLING ---
78
  window.onload = function() {
79
  // Start polling the server for status updates every 3 seconds
 
106
  clearInterval(pollingInterval);
107
  });
108
  }
109
+
110
  // --- FUNCTION TO ACTIVATE CAMERA AND VISUAL TIMER ---
111
  function startCameraAndTimer(timeRemainingSeconds) {
112
  // Show camera container
 
126
  } else {
127
  alert("Camera API not supported in this browser.");
128
  }
129
+
130
  // Start client-side visual countdown timer
131
  let timeRemaining = Math.floor(timeRemainingSeconds);
132
  let timerElem = document.getElementById('timer');
133
  timerElem.classList.remove('timer-finished');
134
+
135
  clearInterval(clientTimerInterval); // Clear any existing timer
136
  clientTimerInterval = setInterval(function() {
137
  if (timeRemaining <= 0) {
 
146
  timeRemaining--;
147
  }, 1000);
148
  }
149
+
150
  // --- FUNCTION TO STOP CAMERA AND TIMER ---
151
  function stopCameraAndTimer() {
152
  clearInterval(clientTimerInterval);
153
  clearInterval(pollingInterval); // Stop polling once task is over
154
+
155
  if (cameraStream) {
156
  cameraStream.getTracks().forEach(track => track.stop());
157
  cameraStream = null;