ConiferousYogi commited on
Commit
33dce5c
·
verified ·
1 Parent(s): 5780454

Update templates/results.html

Browse files
Files changed (1) hide show
  1. templates/results.html +98 -1
templates/results.html CHANGED
@@ -40,7 +40,9 @@
40
  </div>
41
  <div class="flex items-center gap-3">
42
  <button
 
43
  class="inline-flex items-center gap-2 px-4 py-2 border border-slate-300 rounded-lg text-sm bg-white hover:bg-slate-50 transition-colors"
 
44
  >
45
  <svg
46
  class="h-4 w-4"
@@ -55,7 +57,7 @@
55
  d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
56
  />
57
  </svg>
58
- Export Report
59
  </button>
60
  <a
61
  href="/"
@@ -355,6 +357,7 @@
355
  </div>
356
  <div class="p-6">
357
  <div class="flex items-center gap-3">
 
358
  <svg
359
  class="h-8 w-8 text-green-600"
360
  fill="none"
@@ -368,6 +371,21 @@
368
  d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
369
  />
370
  </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  <div>
372
  <p class="text-2xl text-slate-900">{{ ocr_status }}</p>
373
  <p class="text-xs text-slate-500">{{ ocr_message }}</p>
@@ -382,6 +400,21 @@
382
  </div>
383
  <div class="p-6">
384
  <div class="flex items-center gap-3">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  <svg
386
  class="h-8 w-8 text-amber-600"
387
  fill="none"
@@ -395,6 +428,7 @@
395
  d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
396
  />
397
  </svg>
 
398
  <div>
399
  <p class="text-2xl text-slate-900">{{ qr_status }}</p>
400
  <p class="text-xs text-slate-500">{{ qr_message }}</p>
@@ -914,4 +948,67 @@
914
 
915
  <script src="{{ url_for('static', filename='js/results.js') }}"></script>
916
  </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
917
  </html>
 
40
  </div>
41
  <div class="flex items-center gap-3">
42
  <button
43
+ id="exportBtn"
44
  class="inline-flex items-center gap-2 px-4 py-2 border border-slate-300 rounded-lg text-sm bg-white hover:bg-slate-50 transition-colors"
45
+ onclick="exportToCSV()"
46
  >
47
  <svg
48
  class="h-4 w-4"
 
57
  d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
58
  />
59
  </svg>
60
+ <span id="exportBtnText">Export Report</span>
61
  </button>
62
  <a
63
  href="/"
 
357
  </div>
358
  <div class="p-6">
359
  <div class="flex items-center gap-3">
360
+ {% if ocr_status == "Success" %}
361
  <svg
362
  class="h-8 w-8 text-green-600"
363
  fill="none"
 
371
  d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
372
  />
373
  </svg>
374
+ {% else %}
375
+ <svg
376
+ class="h-8 w-8 text-amber-600"
377
+ fill="none"
378
+ stroke="currentColor"
379
+ viewBox="0 0 24 24"
380
+ >
381
+ <path
382
+ stroke-linecap="round"
383
+ stroke-linejoin="round"
384
+ stroke-width="2"
385
+ d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
386
+ />
387
+ </svg>
388
+ {% endif %}
389
  <div>
390
  <p class="text-2xl text-slate-900">{{ ocr_status }}</p>
391
  <p class="text-xs text-slate-500">{{ ocr_message }}</p>
 
400
  </div>
401
  <div class="p-6">
402
  <div class="flex items-center gap-3">
403
+ {% if qr_status == "Decoded" %}
404
+ <svg
405
+ class="h-8 w-8 text-green-600"
406
+ fill="none"
407
+ stroke="currentColor"
408
+ viewBox="0 0 24 24"
409
+ >
410
+ <path
411
+ stroke-linecap="round"
412
+ stroke-linejoin="round"
413
+ stroke-width="2"
414
+ d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
415
+ />
416
+ </svg>
417
+ {% else %}
418
  <svg
419
  class="h-8 w-8 text-amber-600"
420
  fill="none"
 
428
  d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
429
  />
430
  </svg>
431
+ {% endif %}
432
  <div>
433
  <p class="text-2xl text-slate-900">{{ qr_status }}</p>
434
  <p class="text-xs text-slate-500">{{ qr_message }}</p>
 
948
 
949
  <script src="{{ url_for('static', filename='js/results.js') }}"></script>
950
  </body>
951
+ <script>
952
+ function exportToCSV() {
953
+ const btn = document.getElementById("exportBtn");
954
+ const btnText = document.getElementById("exportBtnText");
955
+
956
+ // Disable button and show loading state
957
+ btn.disabled = true;
958
+ btnText.textContent = "Exporting...";
959
+ btn.classList.add("opacity-50", "cursor-not-allowed");
960
+
961
+ // Send POST request to Flask endpoint
962
+ fetch("/export_csv", {
963
+ method: "POST",
964
+ headers: {
965
+ "Content-Type": "application/json",
966
+ },
967
+ })
968
+ .then((response) => {
969
+ if (!response.ok) {
970
+ throw new Error("Export failed");
971
+ }
972
+ return response.blob();
973
+ })
974
+ .then((blob) => {
975
+ // Create download link
976
+ const url = window.URL.createObjectURL(blob);
977
+ const a = document.createElement("a");
978
+ a.style.display = "none";
979
+ a.href = url;
980
+
981
+ // Generate filename with timestamp
982
+ const timestamp = new Date()
983
+ .toISOString()
984
+ .replace(/[:.]/g, "-")
985
+ .slice(0, -5);
986
+ a.download = `aadhaar_analysis_${timestamp}.csv`;
987
+
988
+ // Trigger download
989
+ document.body.appendChild(a);
990
+ a.click();
991
+
992
+ // Cleanup
993
+ window.URL.revokeObjectURL(url);
994
+ document.body.removeChild(a);
995
+
996
+ // Show success message (optional)
997
+ btnText.textContent = "Exported!";
998
+ setTimeout(() => {
999
+ btnText.textContent = "Export Report";
1000
+ }, 2000);
1001
+ })
1002
+ .catch((error) => {
1003
+ console.error("Error:", error);
1004
+ alert("Failed to export CSV. Please try again.");
1005
+ btnText.textContent = "Export Report";
1006
+ })
1007
+ .finally(() => {
1008
+ // Re-enable button
1009
+ btn.disabled = false;
1010
+ btn.classList.remove("opacity-50", "cursor-not-allowed");
1011
+ });
1012
+ }
1013
+ </script>
1014
  </html>