password reset

This commit is contained in:
2025-06-19 16:11:42 +02:00
parent efdb6d50c3
commit 7092167001
20 changed files with 680 additions and 72 deletions

View File

@@ -78,27 +78,38 @@ function changePage(page) {
function viewMailDetails(mailId) {
const csrfToken = document.querySelector('meta[name="csrf-token"]').content;
fetch(`/settings?tab=mails&mail_id=${mailId}`, {
fetch(`/api/mails/${mailId}`, {
headers: {
'X-CSRF-Token': csrfToken
'X-CSRF-Token': csrfToken,
'Accept': 'application/json'
}
})
.then(response => response.json())
.then(mail => {
document.getElementById('modalSubject').textContent = mail.subject;
document.getElementById('modalRecipient').textContent = mail.recipient;
document.getElementById('modalStatus').innerHTML = `
<span class="badge ${mail.status === 'pending' ? 'bg-warning' : mail.status === 'sent' ? 'bg-success' : 'bg-danger'}">
${mail.status}
</span>
`;
document.getElementById('modalTemplate').textContent = mail.template ? mail.template.name : '-';
document.getElementById('modalCreatedAt').textContent = new Date(mail.created_at).toLocaleString();
document.getElementById('modalSentAt').textContent = mail.sent_at ? new Date(mail.sent_at).toLocaleString() : '-';
document.getElementById('modalBody').innerHTML = mail.body;
new bootstrap.Modal(document.getElementById('mailDetailsModal')).show();
});
.then(response => {
if (!response.ok) {
throw new Error('Failed to fetch mail details');
}
return response.json();
})
.then(mail => {
document.getElementById('modalSubject').textContent = mail.subject;
document.getElementById('modalRecipient').textContent = mail.recipient;
document.getElementById('modalStatus').innerHTML = `
<span class="badge ${mail.status === 'pending' ? 'bg-warning' : mail.status === 'sent' ? 'bg-success' : 'bg-danger'}">
${mail.status}
</span>
`;
document.getElementById('modalTemplate').textContent = mail.template ? mail.template.name : '-';
document.getElementById('modalCreatedAt').textContent = new Date(mail.created_at).toLocaleString();
document.getElementById('modalSentAt').textContent = mail.sent_at ? new Date(mail.sent_at).toLocaleString() : '-';
document.getElementById('modalBody').innerHTML = mail.body;
new bootstrap.Modal(document.getElementById('mailDetailsModal')).show();
})
.catch(error => {
console.error('Error viewing mail details:', error);
// Show a user-friendly error message
alert('Error loading mail details. Please try again.');
});
}
function downloadMailLog() {