Yash goyal commited on
Commit
08c384e
·
verified ·
1 Parent(s): 797b726

Update templates/form.html

Browse files
Files changed (1) hide show
  1. templates/form.html +23 -2
templates/form.html CHANGED
@@ -14,6 +14,7 @@
14
  const fileInput = document.getElementById("image");
15
  const fileMessage = document.getElementById("upload-message");
16
  const submitBtn = document.getElementById("submit-btn");
 
17
 
18
  fileInput.addEventListener("change", () => {
19
  const file = fileInput.files[0];
@@ -43,6 +44,22 @@
43
  submitBtn.disabled = false;
44
  }
45
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  });
47
  </script>
48
  </head>
@@ -141,10 +158,14 @@
141
  {% if result.message %}
142
  <p class="warning-message">{{ result.message }}</p>
143
  {% endif %}
 
 
144
  {% endif %}
145
  </div>
146
  </div>
147
-
 
 
148
  </section>
149
 
150
  <footer>
@@ -171,4 +192,4 @@
171
  </div>
172
  </footer>
173
  </body>
174
- </html>
 
14
  const fileInput = document.getElementById("image");
15
  const fileMessage = document.getElementById("upload-message");
16
  const submitBtn = document.getElementById("submit-btn");
17
+ const emailBtn = document.getElementById("email-report-btn");
18
 
19
  fileInput.addEventListener("change", () => {
20
  const file = fileInput.files[0];
 
44
  submitBtn.disabled = false;
45
  }
46
  });
47
+
48
+ if (emailBtn) {
49
+ emailBtn.addEventListener("click", async () => {
50
+ const scanId = emailBtn.dataset.scanId;
51
+ const emailStatus = document.getElementById("email-status");
52
+ try {
53
+ const response = await fetch(`/api/email-report/${scanId}`);
54
+ const data = await response.json();
55
+ emailStatus.textContent = data.message;
56
+ emailStatus.style.color = data.success ? "limegreen" : "red";
57
+ } catch (error) {
58
+ emailStatus.textContent = "Error sending email.";
59
+ emailStatus.style.color = "red";
60
+ }
61
+ });
62
+ }
63
  });
64
  </script>
65
  </head>
 
158
  {% if result.message %}
159
  <p class="warning-message">{{ result.message }}</p>
160
  {% endif %}
161
+ <p id="email-status" style="color: {% if result.email_status contains 'Failed' %}red{% else %}limegreen{% endif %}">{{ result.email_status }}</p>
162
+ <button id="email-report-btn" class="submit-button" data-scan-id="{{ result.scan_id }}">Resend Report to Email</button>
163
  {% endif %}
164
  </div>
165
  </div>
166
+ </div>
167
+ </div>
168
+ </div>
169
  </section>
170
 
171
  <footer>
 
192
  </div>
193
  </footer>
194
  </body>
195
+ </html>