Yash goyal commited on
Update templates/form.html
Browse files- templates/form.html +35 -21
templates/form.html
CHANGED
|
@@ -50,18 +50,24 @@
|
|
| 50 |
{% if result.message %}
|
| 51 |
<p><strong>Message:</strong> {{ result.message }}</p>
|
| 52 |
{% endif %}
|
| 53 |
-
|
| 54 |
-
{% if result.
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
</div>
|
| 59 |
{% endif %}
|
| 60 |
|
| 61 |
{% if history_plot %}
|
| 62 |
<div class="training-history">
|
| 63 |
<h2>Model Training History</h2>
|
| 64 |
-
<img src="{{
|
| 65 |
</div>
|
| 66 |
{% endif %}
|
| 67 |
|
|
@@ -87,7 +93,7 @@
|
|
| 87 |
.then(data => {
|
| 88 |
const historyDiv = document.getElementById('history-results');
|
| 89 |
historyDiv.innerHTML = '';
|
| 90 |
-
if (data.length === 0) {
|
| 91 |
historyDiv.innerHTML = '<p>No scan history found for this email.</p>';
|
| 92 |
return;
|
| 93 |
}
|
|
@@ -95,13 +101,15 @@
|
|
| 95 |
data.forEach(scan => {
|
| 96 |
const li = document.createElement('li');
|
| 97 |
li.innerHTML = `
|
| 98 |
-
<
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
| 105 |
`;
|
| 106 |
ul.appendChild(li);
|
| 107 |
});
|
|
@@ -109,11 +117,17 @@
|
|
| 109 |
})
|
| 110 |
.catch(error => {
|
| 111 |
console.error('Error fetching history:', error);
|
| 112 |
-
document.getElementById('history-results').innerHTML = '<p>Error loading history.
|
| 113 |
});
|
| 114 |
});
|
| 115 |
|
| 116 |
function resendEmail(scanId) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
fetch(`/api/email-report/${scanId}`)
|
| 118 |
.then(response => response.json())
|
| 119 |
.then(data => {
|
|
@@ -121,14 +135,14 @@
|
|
| 121 |
})
|
| 122 |
.catch(error => {
|
| 123 |
console.error('Error resending email:', error);
|
| 124 |
-
alert('Failed to resend report. Please
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
});
|
| 126 |
}
|
| 127 |
-
|
| 128 |
-
document.getElementById('resend-email-btn')?.addEventListener('click', () => {
|
| 129 |
-
const scanId = document.getElementById('resend-email-btn').getAttribute('data-scan-id');
|
| 130 |
-
resendEmail(scanId);
|
| 131 |
-
});
|
| 132 |
</script>
|
| 133 |
</body>
|
| 134 |
</html>
|
|
|
|
| 50 |
{% if result.message %}
|
| 51 |
<p><strong>Message:</strong> {{ result.message }}</p>
|
| 52 |
{% endif %}
|
| 53 |
+
|
| 54 |
+
<p id="email-status" style="font-weight: bold; color: {% if 'Success' in result.email_status %}#4CAF50{% else %}#F44336{% endif %};">
|
| 55 |
+
{{ result.email_status }}
|
| 56 |
+
</p>
|
| 57 |
+
|
| 58 |
+
<div class="action-buttons">
|
| 59 |
+
{% if result.scan_id %}
|
| 60 |
+
<button id="resend-email-btn" onclick="resendEmail({{ result.scan_id }})">Resend Report</button>
|
| 61 |
+
{% endif %}
|
| 62 |
+
<a href="{{ url_for('download_report') }}" id="download-btn">Download Report</a>
|
| 63 |
+
</div>
|
| 64 |
</div>
|
| 65 |
{% endif %}
|
| 66 |
|
| 67 |
{% if history_plot %}
|
| 68 |
<div class="training-history">
|
| 69 |
<h2>Model Training History</h2>
|
| 70 |
+
<img src="{{ url_for('training_plot') }}" alt="Training History Plot">
|
| 71 |
</div>
|
| 72 |
{% endif %}
|
| 73 |
|
|
|
|
| 93 |
.then(data => {
|
| 94 |
const historyDiv = document.getElementById('history-results');
|
| 95 |
historyDiv.innerHTML = '';
|
| 96 |
+
if (data.error || data.length === 0) {
|
| 97 |
historyDiv.innerHTML = '<p>No scan history found for this email.</p>';
|
| 98 |
return;
|
| 99 |
}
|
|
|
|
| 101 |
data.forEach(scan => {
|
| 102 |
const li = document.createElement('li');
|
| 103 |
li.innerHTML = `
|
| 104 |
+
<div class="history-item">
|
| 105 |
+
<img src="${scan.image_url}" alt="Scan Image">
|
| 106 |
+
<div class="history-details">
|
| 107 |
+
<p><strong>Prediction:</strong> ${scan.prediction} (${scan.confidence})</p>
|
| 108 |
+
<p><strong>Patient:</strong> ${scan.patient_name}</p>
|
| 109 |
+
<p><strong>Date:</strong> ${scan.timestamp}</p>
|
| 110 |
+
<button onclick="resendEmail(${scan.id})">Resend Report</button>
|
| 111 |
+
</div>
|
| 112 |
+
</div>
|
| 113 |
`;
|
| 114 |
ul.appendChild(li);
|
| 115 |
});
|
|
|
|
| 117 |
})
|
| 118 |
.catch(error => {
|
| 119 |
console.error('Error fetching history:', error);
|
| 120 |
+
document.getElementById('history-results').innerHTML = '<p>Error loading history.</p>';
|
| 121 |
});
|
| 122 |
});
|
| 123 |
|
| 124 |
function resendEmail(scanId) {
|
| 125 |
+
// Provide feedback to the user that the action has started
|
| 126 |
+
const button = event.target;
|
| 127 |
+
const originalText = button.textContent;
|
| 128 |
+
button.textContent = 'Sending...';
|
| 129 |
+
button.disabled = true;
|
| 130 |
+
|
| 131 |
fetch(`/api/email-report/${scanId}`)
|
| 132 |
.then(response => response.json())
|
| 133 |
.then(data => {
|
|
|
|
| 135 |
})
|
| 136 |
.catch(error => {
|
| 137 |
console.error('Error resending email:', error);
|
| 138 |
+
alert('Failed to resend report. Please check the console for details.');
|
| 139 |
+
})
|
| 140 |
+
.finally(() => {
|
| 141 |
+
// Restore the button to its original state
|
| 142 |
+
button.textContent = originalText;
|
| 143 |
+
button.disabled = false;
|
| 144 |
});
|
| 145 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
</script>
|
| 147 |
</body>
|
| 148 |
</html>
|