Файловый менеджер - Редактировать - /home/gqdcvggs/fort-jaco.be/mail.imators.systems.tar
Назад
public/admin.html 0000644 00000023023 15114731546 0010007 0 ustar 00 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Imators - Email Sender Admin Panel</title> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet"> <style> :root { --primary-color: #3498db; --secondary-color: #2ecc71; --background-color: #1a1a1a; --text-color: #ffffff; --error-color: #e74c3c; } body { font-family: 'Poppins', sans-serif; background-color: var(--background-color); color: var(--text-color); line-height: 1.6; padding: 20px; margin: 0; } .container { max-width: 800px; margin: 0 auto; } h1, h2 { font-weight: 600; margin-bottom: 20px; color: var(--primary-color); } label, select, input, button, textarea { display: block; width: 100%; margin-bottom: 15px; } select, input, button, textarea { font-family: 'Poppins', sans-serif; padding: 10px; background-color: #333; color: var(--text-color); border: 1px solid #555; border-radius: 4px; } button { background-color: var(--primary-color); cursor: pointer; transition: background-color 0.3s; } button:hover { background-color: #2980b9; } button:disabled { background-color: #95a5a6; cursor: not-allowed; } #loading, #result { margin-top: 20px; padding: 10px; border-radius: 4px; } #loading { background-color: #34495e; } #result.success { background-color: var(--secondary-color); } #result.error { background-color: var(--error-color); } #progressBar { height: 4px; background-color: #555; margin-top: 10px; border-radius: 2px; } #progressBar div { height: 100%; background-color: var(--secondary-color); width: 0; transition: width 0.3s; border-radius: 2px; } #previewModal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); display: none; justify-content: center; align-items: center; } #previewContent { background-color: #222; padding: 20px; border-radius: 4px; width: 80%; max-width: 800px; } #previewFrame { width: 100%; height: 400px; border: none; background-color: #fff; } .button-group { display: flex; justify-content: space-between; } .button-group button { width: 48%; } </style> </head> <body> <div class="container"> <h1>Imators Email Sender Admin Panel</h1> <form id="emailForm"> <label for="templateName">Template Name:</label> <select id="templateName" name="templateName" required> <option value="">Choose a template</option> <option value="newsletter-termes">Changes to our terms and conditions</option> <option value="promotion">Promotion</option> <option value="update">Update</option> <option value="elegant-newsletter">Elegant Newsletter</option> </select> <label for="subject">Email Subject:</label> <input type="text" id="subject" name="subject" required> <label for="testEmail">Test Email (optional):</label> <input type="email" id="testEmail" name="testEmail" placeholder="Enter email for test send"> <div class="button-group"> <button type="submit" id="sendButton">Send Emails</button> <button type="button" id="previewBtn">Preview</button> </div> </form> <div id="loading" style="display: none;"> <p>Sending emails...</p> <div id="progressBar"><div></div></div> <p id="progressText">0 emails sent</p> </div> <div id="result" style="display: none;"></div> <h2>Email Log</h2> <textarea id="emailLog" rows="10" readonly></textarea> </div> <div id="previewModal"> <div id="previewContent"> <h2>Email Preview</h2> <iframe id="previewFrame"></iframe> <button id="closePreviewBtn">Close</button> </div> </div> <script> const form = document.getElementById('emailForm'); const sendButton = document.getElementById('sendButton'); const previewBtn = document.getElementById('previewBtn'); const closePreviewBtn = document.getElementById('closePreviewBtn'); const loadingDiv = document.getElementById('loading'); const resultDiv = document.getElementById('result'); const progressBar = document.getElementById('progressBar').firstElementChild; const progressText = document.getElementById('progressText'); const previewModal = document.getElementById('previewModal'); const previewFrame = document.getElementById('previewFrame'); const emailLog = document.getElementById('emailLog'); form.addEventListener('submit', async (e) => { e.preventDefault(); const templateName = document.getElementById('templateName').value; const subject = document.getElementById('subject').value; const testEmail = document.getElementById('testEmail').value; sendButton.disabled = true; loadingDiv.style.display = 'block'; resultDiv.style.display = 'none'; progressBar.style.width = '0%'; progressText.textContent = '0 emails sent'; emailLog.value = ''; try { const response = await fetch('/send-emails', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ templateName, subject, testEmail }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const reader = response.body.getReader(); let totalEmails = 0; while(true) { const {done, value} = await reader.read(); if (done) break; const text = new TextDecoder().decode(value); const updates = text.split('\n').filter(Boolean); for (const update of updates) { try { const data = JSON.parse(update); if (data.totalEmails) { totalEmails = data.totalEmails; } if (data.sentEmails) { const percentage = (data.sentEmails / totalEmails) * 100; progressBar.style.width = `${percentage}%`; progressText.textContent = `${data.sentEmails} out of ${totalEmails} emails sent`; } if (data.message) { emailLog.value += data.message + '\n'; emailLog.scrollTop = emailLog.scrollHeight; } } catch (parseError) { console.error('Error parsing update:', parseError); } } } if (!totalEmails) { throw new Error('No emails were sent'); } resultDiv.textContent = `All emails sent successfully (${totalEmails} total)`; resultDiv.className = 'success'; } catch (error) { resultDiv.textContent = 'Error: ' + error.message; resultDiv.className = 'error'; } finally { loadingDiv.style.display = 'none'; resultDiv.style.display = 'block'; sendButton.disabled = false; } }); previewBtn.addEventListener('click', async () => { const templateName = document.getElementById('templateName').value; if (!templateName) { alert('Please select a template'); return; } try { const response = await fetch(`../templates/${templateName}`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const html = await response.text(); previewFrame.srcdoc = html; previewModal.style.display = 'flex'; } catch (error) { alert('Error during preview: ' + error.message); } }); closePreviewBtn.addEventListener('click', () => { previewModal.style.display = 'none'; }); </script> </body> </html>