feat: aggiunta ricerca spudorata. progress: ripreso con il tentativo di invio delle mail che non creino nuovi ticket

This commit is contained in:
VVER440 committed 2026-08-25 23:24:48 +02:00
1 parent 3650bf5790
commit 8d24759a15
18 files changed
+1661 -98

No files matched your search

+77
View File
@@ -22,6 +22,40 @@ const MailManagementView = {
container.innerHTML = `
<div style="max-width: 820px; margin: 0 auto; padding: var(--space-xl) var(--space-lg); display: flex; flex-direction: column; gap: var(--space-xl);">
<!-- SECTION 0: Sender Setting Switch -->
<div class="card" style="padding: var(--space-lg);">
<div style="display:flex; align-items:center; justify-content:space-between; margin-bottom: var(--space-md); flex-wrap:wrap; gap:12px;">
<div>
<h2 style="margin:0; font-size:1.15rem; font-weight:700; color:var(--text-primary); display:flex; align-items:center; gap:8px;">
📬 Indirizzo Mittente per l'Invio Email
</h2>
<p style="margin:4px 0 0; font-size:0.82rem; color:var(--text-muted);">
Scegli se inviare le email dei ticket usando l'indirizzo dell'agente attivo oppure quello predefinito nel file .env.
</p>
</div>
</div>
<div id="sender-setting-container" style="background:var(--bg-tertiary); border:1px solid var(--border-subtle); border-radius:var(--radius-md); padding:var(--space-md);">
<div style="display:flex; flex-direction:column; gap:10px;">
<label style="display:flex; align-items:flex-start; gap:12px; cursor:pointer; padding:8px 10px; border-radius:var(--radius-md); transition:background 0.15s ease;" class="sender-option-label">
<input type="radio" name="sender-choice" value="env" id="sender-choice-env" style="margin-top:3px;" />
<div>
<div style="font-weight:600; font-size:0.9rem; color:var(--text-primary);">🏢 Usa mittente configurato nel file .env</div>
<div style="font-size:0.8rem; color:var(--text-tertiary); margin-top:2px;" id="env-sender-display">Caricamento...</div>
</div>
</label>
<label style="display:flex; align-items:flex-start; gap:12px; cursor:pointer; padding:8px 10px; border-radius:var(--radius-md); transition:background 0.15s ease;" class="sender-option-label">
<input type="radio" name="sender-choice" value="agent" id="sender-choice-agent" style="margin-top:3px;" />
<div>
<div style="font-weight:600; font-size:0.9rem; color:var(--text-primary);">👤 Usa email dell'agente selezionato</div>
<div style="font-size:0.8rem; color:var(--text-tertiary); margin-top:2px;" id="agent-email-display">Caricamento...</div>
</div>
</label>
</div>
</div>
</div>
<!-- SECTION 1: Address Groups -->
<div class="card" style="padding: var(--space-lg);">
<div style="display:flex; align-items:center; justify-content:space-between; margin-bottom: var(--space-md);">
@@ -117,11 +151,54 @@ const MailManagementView = {
// Load data
await Promise.all([
this.loadSenderSettings(),
this.loadSignatures(),
this.loadGroups()
]);
},
async loadSenderSettings() {
try {
const settings = await App.api(`/api/email/settings?agent_id=${this.agentId}`);
const envDisplay = document.getElementById('env-sender-display');
const agentDisplay = document.getElementById('agent-email-display');
const radioEnv = document.getElementById('sender-choice-env');
const radioAgent = document.getElementById('sender-choice-agent');
if (envDisplay) envDisplay.textContent = settings.env_sender ? `Indirizzo: ${settings.env_sender}` : '(Nessun mittente .env configurato)';
if (agentDisplay) agentDisplay.textContent = settings.agent_email ? `Indirizzo agente: ${settings.agent_email}` : '(Nessuna email agente registrata nelle preferenze OTRS)';
if (settings.use_agent_sender) {
if (radioAgent) radioAgent.checked = true;
} else {
if (radioEnv) radioEnv.checked = true;
}
const radios = document.querySelectorAll('input[name="sender-choice"]');
radios.forEach(radio => {
radio.addEventListener('change', async (e) => {
const useAgentSender = e.target.value === 'agent';
try {
await App.api('/api/email/settings', {
method: 'POST',
body: JSON.stringify({
agent_id: this.agentId,
use_agent_sender: useAgentSender
})
});
Toast.success(useAgentSender
? 'Configurato invio tramite email dell\'agente!'
: 'Configurato invio tramite mittente predefinito .env!');
} catch (err) {
Toast.error('Errore aggiornamento mittente: ' + err.message);
}
});
});
} catch (err) {
console.error('Error loading sender settings:', err);
}
},
injectStyles() {
if (document.getElementById('mail-management-styles')) return;
const style = document.createElement('style');