dina1 commited on
Commit
c4e06ea
Β·
verified Β·
1 Parent(s): 70a8b07

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +33 -0
templates/index.html CHANGED
@@ -75,6 +75,39 @@
75
  iframe.srcdoc = data.html;
76
  outputEl.appendChild(iframe);
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  // 🌐 Add link display for full-screen view
79
  if (data.link) {
80
  const viewLink = document.createElement("a");
 
75
  iframe.srcdoc = data.html;
76
  outputEl.appendChild(iframe);
77
 
78
+ // Add Download Report button
79
+ const btn = document.createElement("button");
80
+ btn.textContent = "πŸ“₯ Download Report";
81
+ btn.style.marginTop = "12px";
82
+ btn.onclick = async () => {
83
+ btn.disabled = true;
84
+ btn.textContent = "⏳ Generating report...";
85
+ try {
86
+ const resp = await fetch("/generate_report", {
87
+ method: "POST",
88
+ headers: { "Content-Type": "application/json" },
89
+ body: JSON.stringify({ url: data.link }),
90
+ });
91
+ if (!resp.ok) throw new Error("Failed to generate report");
92
+ const blob = await resp.blob();
93
+ const url = window.URL.createObjectURL(blob);
94
+ const a = document.createElement("a");
95
+ a.href = url;
96
+ a.download = "UI_Report.pdf";
97
+ a.click();
98
+ window.URL.revokeObjectURL(url);
99
+ btn.textContent = "πŸ“₯ Download Report";
100
+ } catch (err) {
101
+ alert("Error generating report β€” check logs");
102
+ console.error(err);
103
+ btn.textContent = "❌ Failed";
104
+ } finally {
105
+ btn.disabled = false;
106
+ }
107
+ };
108
+ outputEl.appendChild(btn);
109
+
110
+
111
  // 🌐 Add link display for full-screen view
112
  if (data.link) {
113
  const viewLink = document.createElement("a");