[FEAT] Sistema Segnalazioni & Risoluzione AI (feedback)

Adattato da alltax.it — il sistema più maturo testato con utenti reali.

Backend:
- FeedbackController: 6 endpoint (submit, mine, list, show, update, resolve)
- FeedbackService: createReport + classifyWithAI + broadcastResolution
- AIService::classifyFeedback() — 10s timeout, 500 token, JSON puro
- EmailService::sendFeedbackResolved() — broadcast email org
- DB migration 014: tabella feedback_reports

Frontend:
- feedback.js: FAB rosso #EF4444, modal 2 fasi (form → AI → password gate)
- Tab "Le mie segnalazioni" con badge status
- Auto-init su tutte le pagine autenticate (common.js::checkAuth)
- api.js: 6 metodi client; style.css: stili completi

Worker:
- scripts/feedback-worker.php: cron ogni 30 min
  → docker exec nis2-agile-devenv + Claude Code CLI
  → risoluzione autonoma con POST /api/feedback/{id}/resolve

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
DevEnv nis2-agile
2026-03-10 08:51:52 +01:00
co-authored by Claude Sonnet 4.6
parent 3b51b5bd95
commit 1382530189
13 changed files with 1911 additions and 43 deletions
+420
View File
@@ -1967,3 +1967,423 @@ tbody tr.clickable:active {
border: 1px solid currentColor;
}
}
/* ═══════════════════════════════════════════════════════════════════
Sistema Segnalazioni & Risoluzione AI (feedback.js)
═══════════════════════════════════════════════════════════════════ */
/* FAB */
#feedback-fab {
position: fixed;
bottom: 28px;
right: 28px;
z-index: 8000;
width: 52px;
height: 52px;
border-radius: 50%;
background: #ef4444;
color: #fff;
border: none;
cursor: pointer;
box-shadow: 0 4px 16px rgba(239,68,68,.4);
display: flex;
align-items: center;
justify-content: center;
font-size: 1.1rem;
transition: background .2s, transform .15s, box-shadow .2s;
}
#feedback-fab:hover {
background: #dc2626;
transform: scale(1.08);
box-shadow: 0 6px 20px rgba(239,68,68,.5);
}
#feedback-fab:active {
transform: scale(.96);
}
/* Overlay */
.feedback-overlay {
display: none;
position: fixed;
inset: 0;
z-index: 9000;
background: rgba(15,23,42,.6);
backdrop-filter: blur(3px);
align-items: center;
justify-content: center;
padding: 16px;
}
.feedback-overlay.active {
display: flex;
}
/* Modal */
.feedback-modal {
background: #1e293b;
border: 1px solid rgba(239,68,68,.2);
border-radius: 14px;
width: 100%;
max-width: 520px;
max-height: 90vh;
overflow-y: auto;
box-shadow: 0 24px 64px rgba(0,0,0,.4);
color: #f8fafc;
font-size: .9rem;
}
/* Modal header */
.feedback-modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 20px 0;
border-bottom: 1px solid rgba(239,68,68,.12);
gap: 8px;
}
.feedback-modal-tabs {
display: flex;
gap: 4px;
flex-wrap: wrap;
}
.feedback-tab {
background: none;
border: none;
color: #94a3b8;
padding: 10px 14px;
cursor: pointer;
font-size: .82rem;
font-weight: 500;
border-bottom: 2px solid transparent;
transition: color .2s, border-color .2s;
white-space: nowrap;
}
.feedback-tab.active {
color: #ef4444;
border-bottom-color: #ef4444;
}
.feedback-tab:hover {
color: #f8fafc;
}
.feedback-close {
background: none;
border: none;
color: #64748b;
cursor: pointer;
font-size: 1rem;
padding: 8px;
border-radius: 6px;
transition: color .2s, background .2s;
flex-shrink: 0;
}
.feedback-close:hover {
color: #f8fafc;
background: rgba(255,255,255,.06);
}
/* Tab panes */
.feedback-tab-pane {
padding: 20px;
}
/* Form elements */
.feedback-form-row {
margin-bottom: 16px;
}
.feedback-label {
display: block;
font-size: .8rem;
font-weight: 600;
color: #94a3b8;
margin-bottom: 6px;
letter-spacing: .02em;
text-transform: uppercase;
}
.feedback-required {
color: #ef4444;
}
.feedback-hint {
font-weight: 400;
font-size: .75rem;
text-transform: none;
letter-spacing: 0;
color: #64748b;
margin-left: 6px;
}
.feedback-select,
.feedback-textarea,
.feedback-input {
width: 100%;
background: #0f172a;
border: 1px solid rgba(239,68,68,.2);
border-radius: 8px;
color: #f8fafc;
padding: 10px 12px;
font-size: .875rem;
font-family: inherit;
transition: border-color .2s;
box-sizing: border-box;
}
.feedback-select:focus,
.feedback-textarea:focus,
.feedback-input:focus {
outline: none;
border-color: #ef4444;
box-shadow: 0 0 0 2px rgba(239,68,68,.15);
}
.feedback-textarea {
resize: vertical;
min-height: 100px;
}
.feedback-charcount {
text-align: right;
font-size: .72rem;
color: #64748b;
margin-top: 4px;
}
/* Drag-drop area */
.feedback-drop-area {
border: 2px dashed rgba(239,68,68,.3);
border-radius: 8px;
padding: 20px;
text-align: center;
color: #64748b;
font-size: .8rem;
cursor: pointer;
transition: border-color .2s, background .2s;
position: relative;
}
.feedback-drop-area:hover,
.feedback-drop-active {
border-color: #ef4444;
background: rgba(239,68,68,.04);
}
.feedback-drop-area i {
font-size: 1.4rem;
display: block;
margin-bottom: 6px;
color: #475569;
}
.feedback-file-label {
color: #ef4444;
cursor: pointer;
text-decoration: underline;
}
.feedback-preview {
position: relative;
display: inline-block;
margin-top: 10px;
}
.feedback-preview img {
max-height: 120px;
max-width: 100%;
border-radius: 6px;
border: 1px solid rgba(239,68,68,.3);
}
.feedback-remove-img {
position: absolute;
top: -6px;
right: -6px;
background: #ef4444;
color: #fff;
border: none;
border-radius: 50%;
width: 20px;
height: 20px;
font-size: .65rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
/* Errors */
.feedback-error {
background: rgba(239,68,68,.1);
border: 1px solid rgba(239,68,68,.3);
border-radius: 6px;
color: #fca5a5;
padding: 10px 12px;
font-size: .82rem;
margin-top: 10px;
}
/* Form actions */
.feedback-form-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 20px;
padding-top: 16px;
border-top: 1px solid rgba(239,68,68,.1);
}
.btn-primary-red {
background: #ef4444;
color: #fff;
border: none;
border-radius: 8px;
padding: 10px 20px;
font-size: .875rem;
font-weight: 600;
cursor: pointer;
transition: background .2s;
}
.btn-primary-red:hover:not(:disabled) { background: #dc2626; }
.btn-primary-red:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost {
background: none;
color: #94a3b8;
border: 1px solid rgba(255,255,255,.1);
border-radius: 8px;
padding: 10px 16px;
font-size: .875rem;
font-weight: 500;
cursor: pointer;
transition: color .2s, border-color .2s;
}
.btn-ghost:hover { color: #f8fafc; border-color: rgba(255,255,255,.2); }
.btn-success {
background: #16a34a;
color: #fff;
border: none;
border-radius: 8px;
padding: 10px 20px;
font-size: .875rem;
font-weight: 600;
cursor: pointer;
transition: background .2s;
}
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-success:disabled { opacity: .6; cursor: not-allowed; }
/* Fase 2: risposta AI */
.feedback-ai-badge {
display: inline-flex;
align-items: center;
gap: 6px;
background: rgba(239,68,68,.12);
border: 1px solid rgba(239,68,68,.25);
color: #fca5a5;
padding: 5px 12px;
border-radius: 20px;
font-size: .78rem;
font-weight: 600;
margin-bottom: 14px;
}
.feedback-ai-box {
background: rgba(6,182,212,.06);
border: 1px solid rgba(6,182,212,.2);
border-radius: 8px;
padding: 14px;
color: #cbd5e1;
line-height: 1.6;
font-size: .875rem;
margin-bottom: 16px;
}
.feedback-resolve-question {
color: #94a3b8;
font-size: .85rem;
margin: 0 0 12px;
}
.feedback-resolve-actions {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.feedback-password-gate {
margin-top: 16px;
padding: 14px;
background: rgba(239,68,68,.06);
border: 1px solid rgba(239,68,68,.2);
border-radius: 8px;
}
.feedback-password-row {
display: flex;
gap: 8px;
margin-top: 8px;
}
.feedback-password-row .feedback-input {
flex: 1;
}
.feedback-resolved-ok {
display: flex;
align-items: center;
gap: 10px;
background: rgba(22,163,74,.12);
border: 1px solid rgba(22,163,74,.3);
border-radius: 8px;
color: #86efac;
padding: 14px;
margin-top: 16px;
font-size: .9rem;
}
.feedback-resolved-ok i {
font-size: 1.3rem;
color: #22c55e;
}
/* "Le mie segnalazioni" tab */
.feedback-loading {
color: #64748b;
text-align: center;
padding: 24px;
font-size: .875rem;
}
.feedback-empty {
color: #64748b;
text-align: center;
padding: 20px 0;
font-size: .875rem;
}
.feedback-mine-row {
padding: 14px 0;
border-bottom: 1px solid rgba(255,255,255,.05);
}
.feedback-mine-row:last-child { border-bottom: none; }
.feedback-mine-meta {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
margin-bottom: 6px;
}
.feedback-mine-tipo {
font-size: .78rem;
color: #94a3b8;
}
.feedback-badge {
display: inline-block;
padding: 2px 8px;
border-radius: 10px;
font-size: .72rem;
font-weight: 600;
border: 1px solid;
}
.feedback-mine-date {
font-size: .72rem;
color: #475569;
margin-left: auto;
}
.feedback-mine-desc {
color: #cbd5e1;
font-size: .85rem;
margin: 0 0 6px;
line-height: 1.5;
}
.feedback-mine-ai {
background: rgba(6,182,212,.05);
border-left: 3px solid rgba(6,182,212,.3);
padding: 8px 10px;
border-radius: 0 6px 6px 0;
color: #94a3b8;
font-size: .78rem;
line-height: 1.5;
}
/* Responsive */
@media (max-width: 480px) {
#feedback-fab { bottom: 20px; right: 20px; }
.feedback-modal { border-radius: 10px; }
.feedback-resolve-actions { flex-direction: column; }
.feedback-password-row { flex-direction: column; }
}