Compare commits

...
23 Commits
Author SHA1 Message Date
Gabriele Cimaschi f6361484cd feat: in caso di retrodatazione ora propone automaticamente una data successiva all'ora di creazione di cinque minuti. 2026-10-12 14:59:20 +02:00
Gabriele Cimaschi d32522bcbb feat: aggiunta ricerca tramite regex nella pagina ricerca supodrata con modal che fornisce rapide indicazioni. 2026-10-05 18:00:34 +02:00
Gabriele Cimaschi 2ca95e062a style: nella vista calendario, modificato con un colore neutro le giornate consuntivate a 0 ore. 2026-09-30 22:52:22 +02:00
Gabriele Cimaschi abb72d53c9 fix: correzione ricerca cliente tramite LDAP. fix: vista dettaglio che interrogava l'endpoint sbagliato. PRovocato probabilmente ancora dall'unificazione delle note rapide con le note normali. 2026-09-23 17:33:17 +02:00
Gabriele Cimaschi 0b6907969d style: riposizionati pulsanti modifiche rapide delle pagine ticket, a mio carico e ricerca spudorata. 2026-09-23 17:15:27 +02:00
Gabriele Cimaschi ce904756dd feat: aggiunto shortcut per aggiungere il ticket in una nuova scheda. style: spostata consuntivazione accanto ad utente cliente. 2026-09-23 14:15:24 +02:00
Gabriele Cimaschi 107ba10689 fix: corretta chiamata che provocava un errore su postgres. 2026-09-18 18:00:20 +02:00
Gabriele Cimaschi 60259427d3 feat: aggiunta console giocosa all'interno del sistema. fix: correzione di un warning. 2026-09-16 15:55:57 +02:00
Gabriele Cimaschi dcc0456070 feat: nella pagina nuovo ticket il tab parte dallo stato 2026-09-16 15:07:41 +02:00
Gabriele Cimaschi a1b6d9333c vari piccoli fix. Importati js e css per eliminare i warning e correzioni W3c. 2026-09-15 17:01:01 +02:00
Gabriele Cimaschi ae458256d5 style: aggiunta icona per visualizzare rapidamente gli allegati del ticket. 2026-09-14 17:10:06 +02:00
Gabriele Cimaschi d4ef03b6f4 fix: corretta intercettazione dello shortcut per l'invio delle email quando l'interfaccia è aperta. fix: corretto shortcut per tornare alla pagina ticket. 2026-09-14 13:00:33 +02:00
Gabriele Cimaschi 1bc3d8bf8a fix: corretta pulizia delle code quando si passa con il tab. feat: aggiunto shortcut per tornare alla pagina ticket. 2026-09-14 11:57:02 +02:00
Gabriele Cimaschi c33a7a4666 fix: dopo l'unificazione messaggio rapido e nota, non funzionava più la consuntivazione senza inserire oggetto o corpo. 2026-09-14 10:53:49 +02:00
Gabriele Cimaschi 44c89aa92f style: nella pagina di riepilogo del ticket unificata copia di tn ed oggetto con click sull'oggetto. feat: aggiunto pulsante assegna ed aggiungi in scheda. 2026-09-14 10:50:07 +02:00
Gabriele Cimaschi a15ab7e89d fix: ora è possibile variare la quantità di risultati dalla pagina ricerca spudorata. feat: aggiunto shortcut ctrl+shift+f per raggiungere la pagina ricerca spudorata. 2026-09-11 18:27:12 +02:00
Gabriele Cimaschi 6944b02263 fix: corretta visualizzazione di caratteri strani all'interno del testo delle email. 2026-09-10 22:20:33 +02:00
Gabriele Cimaschi c1dc86d6cd fix: corretto selettore coda nella pagina di riepilogo del ticket. 2026-09-10 20:27:38 +02:00
Gabriele Cimaschi e94ef9a38c feat: aggiunto editor immagini basilare. 2026-09-10 20:23:55 +02:00
Gabriele Cimaschi 56dcca57aa fix: ora le forme sono drag&drop. 2026-09-10 19:45:56 +02:00
Gabriele Cimaschi b06a0993d1 feat: potenziato editor html. 2026-09-10 19:40:15 +02:00
Gabriele Cimaschi b957272eb8 feat: unificata interfaccia note rapide con l'inserimento delle note. 2026-09-10 19:33:27 +02:00
Gabriele Cimaschi a5d3431008 fix: correzione del della pulizia dei campi in fase nella pagina di creazione dei ticket. feat: aggiunto shortcut per la creazione dei ticket. 2026-09-10 18:26:30 +02:00
23 changed files with 3676 additions and 487 deletions

No files matched your search

+4 -7
View File
@@ -40,6 +40,10 @@ if (dbType === 'mysql' || dbType === 'mariadb') {
// 2. ILIKE -> LIKE (MySQL LIKE is case-insensitive by default) // 2. ILIKE -> LIKE (MySQL LIKE is case-insensitive by default)
translatedSql = translatedSql.replace(/\bILIKE\b/gi, 'LIKE'); translatedSql = translatedSql.replace(/\bILIKE\b/gi, 'LIKE');
// 2b. PostgreSQL regex ~* / ~ -> REGEXP
translatedSql = translatedSql.replace(/~\*/g, 'REGEXP');
translatedSql = translatedSql.replace(/~/g, 'REGEXP');
// 3. PostgreSQL string concatenation '||' -> CONCAT(...) in ticket number generator // 3. PostgreSQL string concatenation '||' -> CONCAT(...) in ticket number generator
translatedSql = translatedSql.replace(/md5\(random\(\)::text\s*\|\|\s*clock_timestamp\(\)::text\)/gi, 'MD5(CONCAT(RAND(), NOW()))'); translatedSql = translatedSql.replace(/md5\(random\(\)::text\s*\|\|\s*clock_timestamp\(\)::text\)/gi, 'MD5(CONCAT(RAND(), NOW()))');
@@ -182,13 +186,6 @@ if (dbType === 'mysql' || dbType === 'mariadb') {
options: '-c timezone=UTC', // Ensure connection timezone is UTC options: '-c timezone=UTC', // Ensure connection timezone is UTC
}); });
// Ensure connection timezone is UTC via query fallback
pool.on('connect', (client) => {
client.query("SET TIME ZONE 'UTC'").catch(err => {
console.error('[DB] Errore nell\'impostazione della timezone UTC per Postgres:', err);
});
});
pool.on('error', (err) => { pool.on('error', (err) => {
console.error('Unexpected error on idle client', err); console.error('Unexpected error on idle client', err);
}); });
+343 -4
View File
@@ -950,6 +950,7 @@ body {
position: relative; position: relative;
overflow: visible !important; overflow: visible !important;
} }
.queue-tooltip { .queue-tooltip {
visibility: hidden; visibility: hidden;
opacity: 0; opacity: 0;
@@ -970,6 +971,7 @@ body {
transition: opacity 0.05s ease, visibility 0.05s ease; transition: opacity 0.05s ease, visibility 0.05s ease;
pointer-events: none; pointer-events: none;
} }
.queue-cell:hover .queue-tooltip { .queue-cell:hover .queue-tooltip {
visibility: visible; visibility: visible;
opacity: 1; opacity: 1;
@@ -1230,6 +1232,31 @@ body {
color: var(--accent-primary-hover); color: var(--accent-primary-hover);
} }
.batch-bar-left {
display: flex;
align-items: center;
gap: var(--space-sm);
flex-wrap: wrap;
flex: 1;
min-width: 280px;
}
.batch-bar-right {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 6px;
justify-content: center;
}
.batch-bar-right .btn svg {
transition: transform 0.15s ease;
}
.batch-bar-right .btn:not(:disabled):hover svg {
transform: scale(1.1);
}
/* ---- Pagination ---- */ /* ---- Pagination ---- */
.pagination { .pagination {
display: flex; display: flex;
@@ -2477,10 +2504,12 @@ body {
box-shadow: 0 0 15px rgba(239, 68, 68, 0.4), inset 0 0 15px rgba(239, 68, 68, 0.2); box-shadow: 0 0 15px rgba(239, 68, 68, 0.4), inset 0 0 15px rgba(239, 68, 68, 0.2);
border-color: rgba(239, 68, 68, 0.6); border-color: rgba(239, 68, 68, 0.6);
} }
50% { 50% {
box-shadow: 0 0 30px rgba(239, 68, 68, 0.8), inset 0 0 30px rgba(239, 68, 68, 0.4); box-shadow: 0 0 30px rgba(239, 68, 68, 0.8), inset 0 0 30px rgba(239, 68, 68, 0.4);
border-color: rgba(239, 68, 68, 1); border-color: rgba(239, 68, 68, 1);
} }
100% { 100% {
box-shadow: 0 0 15px rgba(239, 68, 68, 0.4), inset 0 0 15px rgba(239, 68, 68, 0.2); box-shadow: 0 0 15px rgba(239, 68, 68, 0.4), inset 0 0 15px rgba(239, 68, 68, 0.2);
border-color: rgba(239, 68, 68, 0.6); border-color: rgba(239, 68, 68, 0.6);
@@ -2502,11 +2531,13 @@ body {
box-shadow: 0 0 5px rgba(16, 112, 202, 0.4); box-shadow: 0 0 5px rgba(16, 112, 202, 0.4);
border-color: rgba(16, 112, 202, 0.5); border-color: rgba(16, 112, 202, 0.5);
} }
50% { 50% {
box-shadow: 0 0 15px rgba(16, 112, 202, 0.8), inset 0 0 5px rgba(16, 112, 202, 0.3); box-shadow: 0 0 15px rgba(16, 112, 202, 0.8), inset 0 0 5px rgba(16, 112, 202, 0.3);
border-color: rgba(16, 112, 202, 0.9); border-color: rgba(16, 112, 202, 0.9);
background: rgba(16, 112, 202, 0.15); background: rgba(16, 112, 202, 0.15);
} }
100% { 100% {
box-shadow: 0 0 5px rgba(16, 112, 202, 0.4); box-shadow: 0 0 5px rgba(16, 112, 202, 0.4);
border-color: rgba(16, 112, 202, 0.5); border-color: rgba(16, 112, 202, 0.5);
@@ -2548,11 +2579,13 @@ body {
box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); box-shadow: 0 0 5px rgba(239, 68, 68, 0.4);
border-color: rgba(239, 68, 68, 0.6); border-color: rgba(239, 68, 68, 0.6);
} }
50% { 50% {
box-shadow: 0 0 15px rgba(239, 68, 68, 0.8), inset 0 0 5px rgba(239, 68, 68, 0.3); box-shadow: 0 0 15px rgba(239, 68, 68, 0.8), inset 0 0 5px rgba(239, 68, 68, 0.3);
border-color: rgba(239, 68, 68, 0.9); border-color: rgba(239, 68, 68, 0.9);
background: rgba(239, 68, 68, 0.15) !important; background: rgba(239, 68, 68, 0.15) !important;
} }
100% { 100% {
box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); box-shadow: 0 0 5px rgba(239, 68, 68, 0.4);
border-color: rgba(239, 68, 68, 0.6); border-color: rgba(239, 68, 68, 0.6);
@@ -2571,11 +2604,13 @@ body {
/* ---- Ticket Tab Bar System ---- */ /* ---- Ticket Tab Bar System ---- */
.tabs-bar { .tabs-bar {
display: flex; display: flex;
flex-wrap: wrap; /* Wraps to new line if too many tabs */ flex-wrap: wrap;
/* Wraps to new line if too many tabs */
align-items: stretch; align-items: stretch;
background: var(--bg-secondary); background: var(--bg-secondary);
padding: 0; padding: 0;
} }
.tab-item { .tab-item {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -2584,7 +2619,8 @@ body {
background: transparent; background: transparent;
border: none; border: none;
border-right: 1px solid var(--border-subtle); border-right: 1px solid var(--border-subtle);
border-radius: 0 !important; /* Square corners */ border-radius: 0 !important;
/* Square corners */
font-size: 0.8rem; font-size: 0.8rem;
font-weight: 500; font-weight: 500;
color: var(--text-secondary); color: var(--text-secondary);
@@ -2593,15 +2629,19 @@ body {
transition: all var(--transition-fast); transition: all var(--transition-fast);
margin: 0 !important; margin: 0 !important;
} }
.tab-item:hover { .tab-item:hover {
background: var(--bg-tertiary); background: var(--bg-tertiary);
color: var(--text-primary); color: var(--text-primary);
} }
.tab-item.active { .tab-item.active {
background: var(--bg-primary); /* Blend with main content background */ background: var(--bg-primary);
/* Blend with main content background */
color: var(--accent-primary); color: var(--accent-primary);
border-bottom: 2px solid var(--accent-primary); border-bottom: 2px solid var(--accent-primary);
} }
.tab-item .tab-close { .tab-item .tab-close {
background: none; background: none;
border: none; border: none;
@@ -2613,6 +2653,7 @@ body {
opacity: 0.7; opacity: 0.7;
transition: all 0.15s; transition: all 0.15s;
} }
.tab-item .tab-close:hover { .tab-item .tab-close:hover {
opacity: 1; opacity: 1;
color: var(--error); color: var(--error);
@@ -2622,14 +2663,17 @@ body {
#view-container.ticket-view-active { #view-container.ticket-view-active {
padding: 0 !important; padding: 0 !important;
} }
#view-container.ticket-view-active .back-link { #view-container.ticket-view-active .back-link {
margin: var(--space-md) var(--space-xl) var(--space-xs); margin: var(--space-md) var(--space-xl) var(--space-xs);
display: inline-flex; display: inline-flex;
} }
#view-container.ticket-view-active .ticket-detail { #view-container.ticket-view-active .ticket-detail {
border-radius: 0 !important; border-radius: 0 !important;
border: none !important; border: none !important;
} }
#view-container.ticket-view-active .ticket-detail .card { #view-container.ticket-view-active .ticket-detail .card {
border-radius: 0 !important; border-radius: 0 !important;
border-left: none !important; border-left: none !important;
@@ -2651,6 +2695,7 @@ body {
gap: 2px; gap: 2px;
background: var(--bg-primary); background: var(--bg-primary);
} }
.multiselect-item { .multiselect-item {
padding: 6px 10px; padding: 6px 10px;
border-radius: var(--radius-sm); border-radius: var(--radius-sm);
@@ -2660,14 +2705,17 @@ body {
transition: background-color 0.15s, color 0.15s; transition: background-color 0.15s, color 0.15s;
user-select: none; user-select: none;
} }
.multiselect-item:hover { .multiselect-item:hover {
background-color: var(--bg-hover, rgba(0,0,0,0.05)); background-color: var(--bg-hover, rgba(0, 0, 0, 0.05));
color: var(--text-primary); color: var(--text-primary);
} }
.multiselect-item.selected { .multiselect-item.selected {
background-color: var(--accent-primary); background-color: var(--accent-primary);
color: white; color: white;
} }
.theme-dark .multiselect-item:hover, .theme-dark .multiselect-item:hover,
.theme-rosso .multiselect-item:hover, .theme-rosso .multiselect-item:hover,
.theme-naturale .multiselect-item:hover, .theme-naturale .multiselect-item:hover,
@@ -2676,6 +2724,7 @@ body {
.theme-fairytale .multiselect-item:hover { .theme-fairytale .multiselect-item:hover {
background-color: rgba(255, 255, 255, 0.08); background-color: rgba(255, 255, 255, 0.08);
} }
.line-config-row { .line-config-row {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@@ -2686,14 +2735,17 @@ body {
border-radius: var(--radius-md); border-radius: var(--radius-md);
transition: border-color var(--transition-fast); transition: border-color var(--transition-fast);
} }
.line-config-row:hover { .line-config-row:hover {
border-color: var(--border-light); border-color: var(--border-light);
} }
.line-config-row .line-name { .line-config-row .line-name {
font-weight: 500; font-weight: 500;
font-size: 0.9rem; font-size: 0.9rem;
color: var(--text-primary); color: var(--text-primary);
} }
.line-config-row .line-actions { .line-config-row .line-actions {
display: flex; display: flex;
gap: 6px; gap: 6px;
@@ -2752,3 +2804,290 @@ body {
color: transparent !important; color: transparent !important;
-webkit-text-fill-color: transparent !important; -webkit-text-fill-color: transparent !important;
} }
/* ---- Linux Terminal Console ---- */
.console-modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.75);
backdrop-filter: blur(6px);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
padding: var(--space-md);
animation: fadeIn 0.2s ease;
}
.console-window {
width: 900px;
max-width: 95vw;
height: 600px;
max-height: 85vh;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
display: flex;
flex-direction: column;
border: 1px solid rgba(255, 255, 255, 0.15);
font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
transition: all 0.2s ease;
}
.console-header {
height: 38px;
background: #1e1e2e;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 16px;
user-select: none;
}
.console-window-buttons {
display: flex;
align-items: center;
gap: 8px;
}
.console-btn {
width: 12px;
height: 12px;
border-radius: 50%;
display: inline-block;
cursor: pointer;
transition: opacity 0.15s ease;
}
.console-btn:hover {
opacity: 0.8;
}
.console-btn.btn-close { background: #ff5f56; border: 1px solid #e0443e; }
.console-btn.btn-minimize { background: #ffbd2e; border: 1px solid #dea123; }
.console-btn.btn-maximize { background: #27c93f; border: 1px solid #1aab29; }
.console-title {
font-size: 0.8rem;
color: #a6adc8;
font-weight: 600;
}
.console-badge {
font-size: 0.7rem;
background: rgba(255, 255, 255, 0.1);
padding: 2px 8px;
border-radius: 4px;
color: #cdd6f4;
}
.console-body {
flex: 1;
padding: 16px;
overflow-y: auto;
font-size: 0.88rem;
line-height: 1.45;
display: flex;
flex-direction: column;
}
/* Themes */
.theme-dark .console-window { background: #0f1419; color: #e6edf3; }
.theme-dark .console-prompt .user-part { color: #38bdf8; font-weight: bold; }
.theme-dark .console-prompt .path-part { color: #818cf8; }
.theme-dark .cmd-highlight { color: #38bdf8; font-weight: bold; }
.theme-dark .cmd-executed { color: #f43f5e; font-weight: bold; }
.theme-green .console-window { background: #051a05; color: #4ade80; }
.theme-green .console-prompt .user-part { color: #22c55e; font-weight: bold; }
.theme-green .console-prompt .path-part { color: #86efac; }
.theme-green .cmd-highlight { color: #4ade80; font-weight: bold; }
.theme-green .cmd-executed { color: #a7f3d0; font-weight: bold; }
.theme-green .console-header { background: #082808; }
.theme-amber .console-window { background: #1a1202; color: #fbbf24; }
.theme-amber .console-prompt .user-part { color: #f59e0b; font-weight: bold; }
.theme-amber .console-prompt .path-part { color: #fde68a; }
.theme-amber .cmd-highlight { color: #fbbf24; font-weight: bold; }
.theme-amber .cmd-executed { color: #fef08a; font-weight: bold; }
.theme-amber .console-header { background: #2a1d04; }
.theme-cyber .console-window { background: #0d0221; color: #00f5d4; }
.theme-cyber .console-prompt .user-part { color: #7b2cbf; font-weight: bold; }
.theme-cyber .console-prompt .path-part { color: #f72585; }
.theme-cyber .cmd-highlight { color: #7209b7; font-weight: bold; }
.theme-cyber .cmd-executed { color: #4cc9f0; font-weight: bold; }
.theme-cyber .console-header { background: #19053d; }
.console-banner {
font-size: 0.7rem;
line-height: 1.1;
color: var(--accent-primary);
margin-bottom: 12px;
font-weight: bold;
}
.console-welcome-text {
margin-bottom: 16px;
color: #94a3b8;
font-size: 0.85rem;
}
.console-line {
margin-bottom: 4px;
}
.console-output-line {
margin-bottom: 8px;
word-break: break-word;
white-space: pre-wrap;
}
.console-input-row {
display: flex;
align-items: center;
gap: 8px;
margin-top: 4px;
}
.console-input {
flex: 1;
background: transparent;
border: none;
outline: none;
color: inherit;
font-family: inherit;
font-size: 0.88rem;
padding: 0;
caret-color: var(--accent-primary);
}
.text-success { color: #22c55e; }
.text-danger { color: #ef4444; }
.text-warning { color: #f59e0b; }
.text-info { color: #3b82f6; }
.text-muted { color: #64748b; }
.text-accent { color: #38bdf8; font-weight: bold; }
.dir-item { color: #60a5fa; font-weight: bold; }
.file-item { color: #e2e8f0; }
.console-help-table {
display: flex;
flex-direction: column;
gap: 6px;
padding: 6px 0;
}
.console-help-table > div {
display: flex;
gap: 16px;
}
.cmd-name {
width: 220px;
flex-shrink: 0;
color: #38bdf8;
font-weight: bold;
}
.cmd-desc {
color: #94a3b8;
}
.neofetch-container {
display: flex;
gap: 24px;
align-items: flex-start;
padding: 8px 0;
flex-wrap: wrap;
}
.neofetch-logo {
color: #38bdf8;
font-size: 0.75rem;
line-height: 1.15;
font-weight: bold;
margin: 0;
}
.neofetch-info {
display: flex;
flex-direction: column;
gap: 3px;
font-size: 0.82rem;
}
.console-table {
width: 100%;
border-collapse: collapse;
font-size: 0.82rem;
margin: 8px 0;
}
.console-table th {
text-align: left;
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
padding: 4px 8px;
color: #94a3b8;
}
.console-table td {
padding: 4px 8px;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.badge-mini {
background: rgba(255, 255, 255, 0.1);
padding: 1px 6px;
border-radius: 3px;
font-size: 0.75rem;
}
.matrix-stream {
color: #22c55e;
font-size: 0.75rem;
line-height: 1.2;
margin: 0;
white-space: pre;
}
.sl-train-box {
color: #f59e0b;
font-size: 0.8rem;
line-height: 1.2;
margin: 0;
white-space: pre;
}
/* Ricerca Spudorata - Info Modal / Popover & Regex */
#spudorata-info-btn:hover {
background: var(--accent-primary) !important;
color: #ffffff !important;
box-shadow: 0 0 10px var(--accent-primary-glow);
transform: scale(1.08);
}
.spudorata-rules-popover {
animation: popoverFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popoverFadeIn {
from {
opacity: 0;
transform: translateY(-6px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
#spudorata-regex-toggle:hover {
border-color: var(--accent-primary) !important;
background: var(--bg-card-hover) !important;
}
+6 -5
View File
@@ -11,7 +11,7 @@
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap"
rel="stylesheet"> rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/quill@2.0.2/dist/quill.snow.css" rel="stylesheet"> <link href="/vendor/quill.snow.css" rel="stylesheet">
<link rel="stylesheet" href="/css/style.css"> <link rel="stylesheet" href="/css/style.css">
</head> </head>
@@ -258,10 +258,10 @@
<div class="toast-container" id="toast-container"></div> <div class="toast-container" id="toast-container"></div>
<!-- Scripts --> <!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.2/dist/quill.js"></script> <script src="/vendor/quill.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script src="/vendor/chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"></script> <script src="/vendor/pdf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdf-lib@1.17.1/dist/pdf-lib.min.js"></script> <script src="/vendor/pdf-lib.min.js"></script>
<script src="/js/components/toast.js"></script> <script src="/js/components/toast.js"></script>
<script src="/js/components/filters.js"></script> <script src="/js/components/filters.js"></script>
<script src="/js/views/dashboard.js"></script> <script src="/js/views/dashboard.js"></script>
@@ -279,6 +279,7 @@
<script src="/js/views/envConfig.js"></script> <script src="/js/views/envConfig.js"></script>
<script src="/js/views/userConfig.js"></script> <script src="/js/views/userConfig.js"></script>
<script src="/js/views/noteTemporanee.js"></script> <script src="/js/views/noteTemporanee.js"></script>
<script src="/js/views/consoleView.js"></script>
<script src="/js/app.js"></script> <script src="/js/app.js"></script>
</body> </body>
+100 -5
View File
@@ -64,7 +64,12 @@ const App = {
create_ticket_open: { ctrl: true, alt: true, shift: false, key: 'n', enabled: true }, create_ticket_open: { ctrl: true, alt: true, shift: false, key: 'n', enabled: true },
create_ticket_submit: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true }, create_ticket_submit: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true },
quick_edit_save: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true }, quick_edit_save: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true },
send_email_submit: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true },
pdf_save_edited: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true }, pdf_save_edited: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true },
ricerca_spudorata_open: { ctrl: true, alt: false, shift: true, key: 'f', enabled: true },
ticket_list_open: { ctrl: true, alt: false, shift: true, key: 'Backspace', enabled: true },
open_terminal_console: { ctrl: true, alt: true, shift: false, key: 't', enabled: true },
add_ticket_tab: { ctrl: true, alt: true, shift: false, key: 's', enabled: true },
}; };
return defaults[id] || { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true }; return defaults[id] || { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true };
}, },
@@ -89,13 +94,15 @@ const App = {
const isShift = sc.shift ? e.shiftKey : !e.shiftKey; const isShift = sc.shift ? e.shiftKey : !e.shiftKey;
let targetKey = sc.key.toLowerCase(); let targetKey = sc.key.toLowerCase();
let pressedKey = e.key.toLowerCase(); let pressedKey = (e.key || '').toLowerCase();
let codeKey = (e.code || '').replace(/^Key/, '').toLowerCase();
if (targetKey === 'space' && (pressedKey === ' ' || pressedKey === 'space')) { if (targetKey === 'space' && (pressedKey === ' ' || pressedKey === 'space' || codeKey === 'space')) {
return isCtrlOrCmd && isAlt && isShift; return isCtrlOrCmd && isAlt && isShift;
} }
return isCtrlOrCmd && isAlt && isShift && (pressedKey === targetKey); const matchesKey = (pressedKey === targetKey) || (codeKey === targetKey);
return isCtrlOrCmd && isAlt && isShift && matchesKey;
}, },
formatShortcutLabel(sc) { formatShortcutLabel(sc) {
@@ -117,12 +124,34 @@ const App = {
return text.replace(urlRegex, url => `<a href="${url}" target="_blank" rel="noopener noreferrer" style="color:var(--accent-primary); text-decoration:underline;">${url}</a>`); return text.replace(urlRegex, url => `<a href="${url}" target="_blank" rel="noopener noreferrer" style="color:var(--accent-primary); text-decoration:underline;">${url}</a>`);
}, },
openTab(id, tn, title) { openTab(id, tn, title, notify = false) {
const exists = this.tabs.find(t => String(t.id) === String(id)); const exists = this.tabs.find(t => String(t.id) === String(id));
if (!exists) { if (!exists) {
this.tabs.push({ id, tn, title }); this.tabs.push({ id, tn, title });
this.saveTabs(); this.saveTabs();
if (notify && typeof Toast !== 'undefined') {
Toast.success(`Ticket #${tn || id} aggiunto alle schede!`);
} }
} else {
if (notify && typeof Toast !== 'undefined') {
Toast.info(`Ticket #${tn || id} è già nelle schede`);
}
}
},
async assignAndOpenTab(id, tn, title) {
const activeAgentId = parseInt(localStorage.getItem('activeAgentId') || '1', 10);
try {
await this.api(`/api/tickets/${id}`, {
method: 'PATCH',
body: JSON.stringify({ user_id: activeAgentId }),
});
Toast.success('Ticket assegnato all\'agente attivo e aperto in scheda!');
} catch (err) {
console.error('Error assigning ticket:', err);
Toast.error('Errore durante l\'assegnazione del ticket: ' + err.message);
}
this.openTab(id, tn, title);
}, },
addTabWithoutRedirect(id, tn, title) { addTabWithoutRedirect(id, tn, title) {
@@ -261,15 +290,81 @@ const App = {
toggleClearBtn(); toggleClearBtn();
} }
// Global keyboard shortcuts (e.g. Crea Nuovo Ticket) // Global keyboard shortcuts (e.g. Crea Nuovo Ticket, Ricerca Spudorata, Torna a Elenco Ticket)
document.addEventListener('keydown', (e) => { document.addEventListener('keydown', (e) => {
if (this.isShortcutTriggered(e, 'create_ticket_open')) { if (this.isShortcutTriggered(e, 'create_ticket_open')) {
if (window.location.hash !== '#/tickets/new') { if (window.location.hash !== '#/tickets/new') {
e.preventDefault(); e.preventDefault();
window.location.hash = '#/tickets/new'; window.location.hash = '#/tickets/new';
} }
} else if (this.isShortcutTriggered(e, 'ricerca_spudorata_open')) {
e.preventDefault();
if (!window.location.hash.startsWith('#/ricerca-spudorata')) {
window.location.hash = '#/ricerca-spudorata';
} else {
const searchInput = document.getElementById('spudorata-search-input');
if (searchInput) {
searchInput.focus();
searchInput.select();
}
}
} else if (this.isShortcutTriggered(e, 'ticket_list_open')) {
if (window.location.hash !== '#/tickets' && window.location.hash !== '') {
e.preventDefault();
window.location.hash = '#/tickets';
}
} else if (this.isShortcutTriggered(e, 'open_terminal_console')) {
e.preventDefault();
const consoleObj = window.ConsoleView || (typeof ConsoleView !== 'undefined' ? ConsoleView : null);
if (consoleObj) {
consoleObj.toggle();
}
} else if (this.isShortcutTriggered(e, 'add_ticket_tab')) {
e.preventDefault();
// 1. Check if in ticket detail
const detailTabBtn = document.querySelector('.ticket-header .open-tab-btn, .ticket-detail .open-tab-btn');
if (detailTabBtn) {
detailTabBtn.click();
return;
}
// 2. Check if multiple tickets selected in list
const selectedRows = document.querySelectorAll('.ticket-table tbody tr.selected, .results-table tbody tr.selected');
if (selectedRows.length > 0) {
let count = 0;
selectedRows.forEach(row => {
const tabBtn = row.querySelector('.open-tab-btn');
if (tabBtn) {
const id = tabBtn.dataset.id;
const tn = tabBtn.dataset.tn;
const title = tabBtn.dataset.title || '';
if (id) {
this.openTab(parseInt(id, 10), tn, title);
count++;
}
} }
}); });
if (count > 0 && typeof Toast !== 'undefined') {
Toast.success(`${count} ticket aggiunti alle schede!`);
}
return;
}
// 3. Check hovered or focused row in any ticket table/list
const hoveredRow = document.querySelector('.ticket-table tbody tr:hover, .results-table tbody tr:hover, .ticket-table tbody tr:focus-within, .results-table tbody tr:focus-within');
if (hoveredRow) {
const tabBtn = hoveredRow.querySelector('.open-tab-btn');
if (tabBtn) {
tabBtn.click();
return;
}
}
if (typeof Toast !== 'undefined') {
Toast.info('Seleziona o apri un ticket per aggiungerlo in scheda');
}
}
}, true);
// Check DB connection // Check DB connection
this.checkConnection(); this.checkConnection();
+5 -5
View File
@@ -215,7 +215,7 @@ const Filters = {
<span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span> <span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span>
</div> </div>
<div class="multiselect-popover" id="state-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; width: 220px; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;"> <div class="multiselect-popover" id="state-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; width: 220px; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;">
<input type="text" class="form-input ms-search" placeholder="Cerca..." style="width:100%; padding:4px 8px; font-size:0.78rem; margin-bottom:6px; box-sizing:border-box;" autocomplete="off" /> <input type="text" id="state-ms-search-input" name="state_search" class="form-input ms-search" placeholder="Cerca..." style="width:100%; padding:4px 8px; font-size:0.78rem; margin-bottom:6px; box-sizing:border-box;" autocomplete="off" />
<div class="ms-items-container" style="display:flex; flex-direction:column; gap:2px; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);"> <div class="ms-items-container" style="display:flex; flex-direction:column; gap:2px; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);">
${(lookups.states || []).map(s => { ${(lookups.states || []).map(s => {
const selectedList = String(this.state.state_id || '').split(',').filter(Boolean); const selectedList = String(this.state.state_id || '').split(',').filter(Boolean);
@@ -243,7 +243,7 @@ const Filters = {
<span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span> <span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span>
</div> </div>
<div class="multiselect-popover" id="queue-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; min-width: 480px; width: max-content; max-width: 85vw; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;"> <div class="multiselect-popover" id="queue-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; min-width: 480px; width: max-content; max-width: 85vw; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;">
<input type="text" class="form-input ms-search" placeholder="Cerca coda..." style="width:100%; padding:4px 8px; font-size:0.78rem; margin-bottom:6px; box-sizing:border-box;" autocomplete="off" /> <input type="text" id="queue-ms-search-input" name="queue_search" class="form-input ms-search" placeholder="Cerca coda..." style="width:100%; padding:4px 8px; font-size:0.78rem; margin-bottom:6px; box-sizing:border-box;" autocomplete="off" />
<div class="ms-items-container" style="display:flex; flex-direction:column; gap:2px; max-height:300px; overflow-y:auto; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);"> <div class="ms-items-container" style="display:flex; flex-direction:column; gap:2px; max-height:300px; overflow-y:auto; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);">
${(lookups.queues || []).map(q => { ${(lookups.queues || []).map(q => {
const selectedList = String(this.state.queue_id || '').split(',').filter(Boolean); const selectedList = String(this.state.queue_id || '').split(',').filter(Boolean);
@@ -271,7 +271,7 @@ const Filters = {
<span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span> <span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span>
</div> </div>
<div class="multiselect-popover" id="priority-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; width: 200px; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;"> <div class="multiselect-popover" id="priority-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; width: 200px; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;">
<input type="text" class="form-input ms-search" placeholder="Cerca priorità..." style="width:100%; padding:4px 8px; font-size:0.78rem; margin-bottom:6px; box-sizing:border-box;" autocomplete="off" /> <input type="text" id="priority-ms-search-input" name="priority_search" class="form-input ms-search" placeholder="Cerca priorità..." style="width:100%; padding:4px 8px; font-size:0.78rem; margin-bottom:6px; box-sizing:border-box;" autocomplete="off" />
<div class="ms-items-container" style="display:flex; flex-direction:column; gap:2px; max-height:180px; overflow-y:auto; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);"> <div class="ms-items-container" style="display:flex; flex-direction:column; gap:2px; max-height:180px; overflow-y:auto; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);">
${(lookups.priorities || []).map(p => { ${(lookups.priorities || []).map(p => {
const selectedList = String(this.state.priority_id || '').split(',').filter(Boolean); const selectedList = String(this.state.priority_id || '').split(',').filter(Boolean);
@@ -299,7 +299,7 @@ const Filters = {
<span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span> <span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span>
</div> </div>
<div class="multiselect-popover" id="owner-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; width: 240px; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;"> <div class="multiselect-popover" id="owner-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; width: 240px; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;">
<input type="text" class="form-input ms-search" placeholder="Cerca owner..." style="width:100%; padding:4px 8px; font-size:0.78rem; margin-bottom:6px; box-sizing:border-box;" autocomplete="off" /> <input type="text" id="owner-ms-search-input" name="owner_search" class="form-input ms-search" placeholder="Cerca owner..." style="width:100%; padding:4px 8px; font-size:0.78rem; margin-bottom:6px; box-sizing:border-box;" autocomplete="off" />
<div class="ms-items-container" style="display:flex; flex-direction:column; gap:2px; max-height:180px; overflow-y:auto; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);"> <div class="ms-items-container" style="display:flex; flex-direction:column; gap:2px; max-height:180px; overflow-y:auto; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);">
${(lookups.users || []).map(u => { ${(lookups.users || []).map(u => {
const selectedList = String(this.state.user_id || '').split(',').filter(Boolean); const selectedList = String(this.state.user_id || '').split(',').filter(Boolean);
@@ -326,7 +326,7 @@ const Filters = {
<span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span> <span style="font-size:0.6rem; color:var(--text-muted); margin-left:6px;">▼</span>
</div> </div>
<div class="multiselect-popover" id="customer-user-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; width: 280px; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;"> <div class="multiselect-popover" id="customer-user-multiselect-popover" style="display:none; position:absolute; left:0; top:100%; width: 280px; background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); box-shadow:var(--shadow-md); z-index:1002; padding:var(--space-xs); margin-top:4px;">
<input type="text" id="customer-user-search-input" placeholder="Cerca utente..." style="width:100%; padding:6px 8px; font-size:0.8rem; background:var(--bg-tertiary); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); margin-bottom:6px; box-sizing:border-box; color:var(--text-primary); font-family:inherit;" autocomplete="off" /> <input type="text" id="customer-user-search-input" name="customer_user_search" placeholder="Cerca utente..." style="width:100%; padding:6px 8px; font-size:0.8rem; background:var(--bg-tertiary); border:1px solid var(--border-subtle); border-radius:var(--radius-sm); margin-bottom:6px; box-sizing:border-box; color:var(--text-primary); font-family:inherit;" autocomplete="off" />
<div id="customer-user-items-container" style="display:flex; flex-direction:column; gap:4px; max-height:220px; overflow-y:auto; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);"> <div id="customer-user-items-container" style="display:flex; flex-direction:column; gap:4px; max-height:220px; overflow-y:auto; padding-bottom:6px; border-bottom:1px solid var(--border-subtle);">
<!-- Populated dynamically --> <!-- Populated dynamically -->
</div> </div>
+500
View File
@@ -0,0 +1,500 @@
/**
* ConsoleView — Linux Terminal Simulation for OTRS Turbo
* Shortcut: Ctrl + Alt + T
*/
const ConsoleView = {
isOpen: false,
history: [],
historyIndex: -1,
currentTheme: 'dark', // dark, green, amber, cyber
activeAnimation: null,
toggle() {
if (this.isOpen) {
this.close();
} else {
this.open();
}
},
open() {
let modal = document.getElementById('linux-console-modal');
if (!modal) {
this.createModal();
modal = document.getElementById('linux-console-modal');
}
modal.style.display = 'flex';
this.isOpen = true;
const input = document.getElementById('console-input');
if (input) {
input.focus();
}
},
close() {
const modal = document.getElementById('linux-console-modal');
if (modal) {
modal.style.display = 'none';
}
this.stopAnimation();
this.isOpen = false;
},
createModal() {
const overlay = document.createElement('div');
overlay.id = 'linux-console-modal';
overlay.className = 'console-modal-overlay theme-dark';
overlay.innerHTML = `
<div class="console-window">
<div class="console-header">
<div class="console-window-buttons">
<span class="console-btn btn-close" id="console-btn-close" title="Chiudi (Esc)"></span>
<span class="console-btn btn-minimize" id="console-btn-min"></span>
<span class="console-btn btn-maximize" id="console-btn-max"></span>
</div>
<div class="console-title">otrs-turbo@linux-server:~</div>
<div class="console-header-right">
<span class="console-badge">BASH v5.2.15</span>
</div>
</div>
<div class="console-body" id="console-body">
<div class="console-welcome">
<pre class="console-banner">
____ _____ ____ ____ _____ _ _ ____ ____ ___
/ ___|_ _| _ \\/ ___| |_ _| | | | _ \\/ __ ) / _ \\
| | | | | |_) \\___ \\ | | | | | | |_) | _ \\| | | |
| |___ | | | _ < ___) | | | | |_| | _ <| |_) | |_| |
\\____| |_| |_| \\_\\____/ |_| \\___/|_| \\_\\____/ \\___/
</pre>
<div class="console-welcome-text">
Benvenuto nella console di simulazione Linux per <strong>OTRS Turbo</strong>.<br>
Digita <span class="cmd-highlight">help</span> per vedere l'elenco dei comandi disponibili.
</div>
</div>
<div id="console-output"></div>
<div class="console-input-row" id="console-input-row">
<span class="console-prompt"><span class="user-part">agent@otrs-turbo</span>:<span class="path-part">~</span>$</span>
<input type="text" id="console-input" class="console-input" autocomplete="off" spellcheck="false" autocorrect="off" autocapitalize="none" />
</div>
</div>
</div>
`;
document.body.appendChild(overlay);
// Event Bindings
overlay.querySelector('#console-btn-close').addEventListener('click', () => this.close());
overlay.addEventListener('click', (e) => {
if (e.target === overlay) this.close();
else {
const input = document.getElementById('console-input');
if (input && document.activeElement !== input) input.focus();
}
});
const input = overlay.querySelector('#console-input');
input.addEventListener('keydown', (e) => this.handleKeyDown(e));
},
stopAnimation() {
if (this.activeAnimation) {
clearInterval(this.activeAnimation);
this.activeAnimation = null;
}
},
handleKeyDown(e) {
if (e.key === 'Escape') {
e.preventDefault();
this.close();
return;
}
if (e.key === 'Enter') {
const input = e.target;
const cmdText = input.value.trim();
input.value = '';
if (cmdText) {
this.history.push(cmdText);
this.historyIndex = this.history.length;
this.executeCommand(cmdText);
} else {
this.printPrompt('');
}
return;
}
if (e.key === 'ArrowUp') {
e.preventDefault();
if (this.history.length > 0 && this.historyIndex > 0) {
this.historyIndex--;
e.target.value = this.history[this.historyIndex];
}
return;
}
if (e.key === 'ArrowDown') {
e.preventDefault();
if (this.historyIndex < this.history.length - 1) {
this.historyIndex++;
e.target.value = this.history[this.historyIndex];
} else {
this.historyIndex = this.history.length;
e.target.value = '';
}
return;
}
if (e.key === 'Tab') {
e.preventDefault();
this.autocomplete(e.target);
return;
}
if (e.ctrlKey && e.key.toLowerCase() === 'c') {
if (this.activeAnimation) {
e.preventDefault();
this.stopAnimation();
this.printOutput('<span class="text-warning">^C Animation interrupted</span>');
this.showInputRow();
}
}
},
autocomplete(inputEl) {
const val = inputEl.value.trim();
const commands = ['help', 'neofetch', 'otrsfetch', 'tickets', 'ls', 'cat', 'matrix', 'sl', 'sudo', 'whoami', 'theme', 'clear', 'history', 'exit'];
const matches = commands.filter(c => c.startsWith(val));
if (matches.length === 1) {
inputEl.value = matches[0] + ' ';
} else if (matches.length > 1) {
this.printOutput(`<span class="text-muted">${matches.join(' ')}</span>`);
}
},
printPrompt(cmdText) {
const outputDiv = document.getElementById('console-output');
const line = document.createElement('div');
line.className = 'console-line';
line.innerHTML = `<span class="console-prompt"><span class="user-part">agent@otrs-turbo</span>:<span class="path-part">~</span>$</span> <span class="cmd-executed">${App.escapeHtml(cmdText)}</span>`;
outputDiv.appendChild(line);
this.scrollToBottom();
},
printOutput(htmlContent) {
const outputDiv = document.getElementById('console-output');
const line = document.createElement('div');
line.className = 'console-output-line';
line.innerHTML = htmlContent;
outputDiv.appendChild(line);
this.scrollToBottom();
},
scrollToBottom() {
const body = document.getElementById('console-body');
if (body) {
body.scrollTop = body.scrollHeight;
}
},
showInputRow() {
const row = document.getElementById('console-input-row');
if (row) row.style.display = 'flex';
const input = document.getElementById('console-input');
if (input) input.focus();
},
hideInputRow() {
const row = document.getElementById('console-input-row');
if (row) row.style.display = 'none';
},
async executeCommand(rawCmd) {
this.stopAnimation();
this.printPrompt(rawCmd);
const parts = rawCmd.trim().split(/\s+/);
const mainCmd = parts[0].toLowerCase();
const args = parts.slice(1);
switch (mainCmd) {
case 'help':
this.cmdHelp();
break;
case 'clear':
document.getElementById('console-output').innerHTML = '';
break;
case 'whoami':
const agent = App.activeAgent || 'gabriele.cimaschi';
this.printOutput(`<span class="text-success">${App.escapeHtml(agent)}</span> (OTRS Turbo Operator)`);
break;
case 'sudo':
this.printOutput(`<span class="text-danger">agent is not in the sudoers file. This incident will be reported to OTRS Admins.</span>`);
break;
case 'ls':
this.cmdLs();
break;
case 'cat':
this.cmdCat(args[0]);
break;
case 'history':
this.cmdHistory();
break;
case 'neofetch':
case 'otrsfetch':
await this.cmdNeofetch();
break;
case 'tickets':
await this.cmdTickets();
break;
case 'theme':
this.cmdTheme(args[0]);
break;
case 'matrix':
this.cmdMatrix();
break;
case 'sl':
this.cmdSl();
break;
case 'exit':
this.close();
break;
default:
this.printOutput(`<span class="text-danger">bash: ${App.escapeHtml(mainCmd)}: command not found.</span> Digita <span class="cmd-highlight">help</span> per la lista dei comandi.`);
break;
}
},
cmdHelp() {
const helpHtml = `
<div class="console-help-table">
<div><span class="cmd-name">help</span><span class="cmd-desc">Mostra questo messaggio di aiuto</span></div>
<div><span class="cmd-name">neofetch</span> / <span class="cmd-name">otrsfetch</span><span class="cmd-desc">Visualizza informazioni ed ASCII art di OTRS Turbo</span></div>
<div><span class="cmd-name">tickets</span><span class="cmd-desc">Elenca i ticket recenti ed i conteggi direttamente dal DB</span></div>
<div><span class="cmd-name">ls</span><span class="cmd-desc">Elenca i file della directory corrente</span></div>
<div><span class="cmd-name">cat &lt;file&gt;</span><span class="cmd-desc">Legge il contenuto di un file virtuale</span></div>
<div><span class="cmd-name">whoami</span><span class="cmd-desc">Mostra l'agente attualmente autenticato</span></div>
<div><span class="cmd-name">theme &lt;dark|green|amber|cyber&gt;</span><span class="cmd-desc">Cambia il tema cromatico del terminale</span></div>
<div><span class="cmd-name">matrix</span><span class="cmd-desc">Avvia l'animazione della pioggia digitale Matrix (Ctrl+C per uscire)</span></div>
<div><span class="cmd-name">sl</span><span class="cmd-desc">Fai passare la locomotiva a vapore ASCII nel terminale</span></div>
<div><span class="cmd-name">sudo &lt;comando&gt;</span><span class="cmd-desc">Esegue un comando con privilegi di amministratore</span></div>
<div><span class="cmd-name">history</span><span class="cmd-desc">Mostra lo storico dei comandi usati</span></div>
<div><span class="cmd-name">clear</span><span class="cmd-desc">Pulisce lo schermo della console</span></div>
<div><span class="cmd-name">exit</span><span class="cmd-desc">Chiude la finestra del terminale</span></div>
</div>`;
this.printOutput(helpHtml);
},
cmdLs() {
this.printOutput(`
<span class="dir-item">drwxr-xr-x 2 agent otrs 4096 Sep 16 15:00 .</span>
<span class="dir-item">drwxr-xr-x 10 agent otrs 4096 Sep 16 15:00 ..</span>
<span class="file-item">-rw-r--r-- 1 agent otrs 2450 Sep 16 15:00 tickets.db</span>
<span class="file-item">-rw-r--r-- 1 agent otrs 777 Sep 16 15:00 motivational.txt</span>
<span class="file-item">-rw-r--r-- 1 agent otrs 1180 Sep 16 15:00 demotivational.txt</span>
<span class="file-item">-rw-r--r-- 1 agent otrs 512 Sep 16 15:00 secret.key</span>
<span class="file-item">-rwxr-xr-x 1 agent otrs 8192 Sep 16 15:00 system.log</span>
`);
},
cmdCat(fileName) {
if (!fileName) {
this.printOutput('<span class="text-danger">cat: specifica un nome file. Es: cat motivational.txt</span>');
return;
}
const name = fileName.toLowerCase();
if (name === 'motivational.txt') {
const phrases = App.motivationalPhrases || [
"Ogni ticket chiuso è una vittoria verso la fine della giornata!",
"La velocità è la nostra virtù con OTRS Turbo!",
"Mantieni la calma ed applica le macro."
];
const random = phrases[Math.floor(Math.random() * phrases.length)];
this.printOutput(`<span class="text-info">💡 ${App.escapeHtml(random)}</span>`);
} else if (name === 'demotivational.txt') {
const phrases = App.demotivationalPhrases || [
"Nessuna buona azione resta impunita: ogni ticket chiuso ne genera due nuovi.",
"Il weekend si avvicina, ma la coda di ticket non dorme mai.",
"Hai davvero controllato se il cavo di rete è collegato?"
];
const random = phrases[Math.floor(Math.random() * phrases.length)];
this.printOutput(`<span class="text-warning">💀 ${App.escapeHtml(random)}</span>`);
} else if (name === 'secret.key') {
this.printOutput('<span class="text-danger">🔒 Access Denied: 0x8840192A (Encryption key locked by OTRS Turbo core)</span>');
} else if (name === 'tickets.db') {
this.printOutput('<span class="text-muted">SQLite/PG Binary format header. Usare il comando "tickets" per consultare i dati.</span>');
} else if (name === 'system.log') {
this.printOutput('<span class="text-muted">[INFO] 2026-09-16 15:10:00 - OTRS Turbo Engine v1.0 running cleanly.\n[INFO] LDAP auto-sync skipped (within 24h window).\n[OK] Database query latency &lt; 4ms.</span>');
} else {
this.printOutput(`<span class="text-danger">cat: ${App.escapeHtml(fileName)}: No such file or directory</span>`);
}
},
cmdHistory() {
if (this.history.length === 0) {
this.printOutput('<span class="text-muted">Nessun comando nello storico.</span>');
return;
}
const lines = this.history.map((c, i) => ` ${i + 1} ${App.escapeHtml(c)}`).join('\n');
this.printOutput(`<pre class="text-muted">${lines}</pre>`);
},
async cmdNeofetch() {
let ticketStats = { total: 0, open: 0 };
try {
const data = await App.api('/api/tickets/stats');
if (data) {
ticketStats.total = data.total_tickets || data.total || 0;
ticketStats.open = data.open_tickets || data.open || 0;
}
} catch (e) {}
const agent = App.activeAgent || 'gabriele.cimaschi';
const html = `
<div class="neofetch-container">
<pre class="neofetch-logo">
██████╗ ████████╗██████╗ ██████╗
██╔═══██╗╚══██╔══╝██╔══██╗██╔════╝
██║ ██║ ██║ ██████╔╝╚█████╗
██║ ██║ ██║ ██╔══██╗ ╚═══██╗
╚██████╔╝ ██║ ██║ ██║██████╔╝
╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═════╝
⚡ T U R B O E N G I N E
</pre>
<div class="neofetch-info">
<div><strong style="color:var(--accent-primary);">${App.escapeHtml(agent)}</strong>@<strong style="color:var(--accent-primary);">otrs-turbo</strong></div>
<div style="color:var(--border-subtle)">----------------------------------</div>
<div><strong>OS:</strong> OTRS Turbo Linux Web Console</div>
<div><strong>Host:</strong> Enterprise Ticket Engine 1.0</div>
<div><strong>Uptime:</strong> 17 hours, 42 mins</div>
<div><strong>Shell:</strong> OTRS-Bash 5.2</div>
<div><strong>Engine:</strong> Express / PG SQL Node.js 18.x</div>
<div><strong>Tickets In DB:</strong> ${ticketStats.total} total (${ticketStats.open} aperti)</div>
<div><strong>Theme:</strong> ${this.currentTheme}</div>
<div class="color-palette" style="margin-top:6px;">
<span style="background:#ef4444; display:inline-block; width:12px; height:12px; border-radius:2px; margin-right:3px;"></span>
<span style="background:#f59e0b; display:inline-block; width:12px; height:12px; border-radius:2px; margin-right:3px;"></span>
<span style="background:#10b981; display:inline-block; width:12px; height:12px; border-radius:2px; margin-right:3px;"></span>
<span style="background:#3b82f6; display:inline-block; width:12px; height:12px; border-radius:2px; margin-right:3px;"></span>
<span style="background:#8b5cf6; display:inline-block; width:12px; height:12px; border-radius:2px; margin-right:3px;"></span>
<span style="background:#ec4899; display:inline-block; width:12px; height:12px; border-radius:2px; margin-right:3px;"></span>
</div>
</div>
</div>`;
this.printOutput(html);
},
async cmdTickets() {
this.printOutput('<span class="text-muted">Caricamento ultimi ticket dal database...</span>');
try {
const res = await App.api('/api/tickets?page=1&per_page=8');
const tickets = res.tickets || [];
if (tickets.length === 0) {
this.printOutput('<span class="text-warning">Nessun ticket trovato.</span>');
return;
}
let rows = `
<table class="console-table">
<thead>
<tr>
<th>TN</th>
<th>Titolo</th>
<th>Stato</th>
<th>Coda</th>
<th>Cliente</th>
</tr>
</thead>
<tbody>
`;
tickets.forEach(t => {
rows += `
<tr>
<td class="text-accent">#${App.escapeHtml(t.tn)}</td>
<td>${App.escapeHtml((t.title || '').substring(0, 35))}</td>
<td><span class="badge-mini">${App.escapeHtml(t.state_name || '')}</span></td>
<td>${App.escapeHtml(t.queue_name || '')}</td>
<td>${App.escapeHtml(t.customer_first ? `${t.customer_first} ${t.customer_last}` : (t.customer_user_id || '—'))}</td>
</tr>`;
});
rows += `</tbody></table>`;
this.printOutput(rows);
} catch (err) {
this.printOutput(`<span class="text-danger">Errore recupero ticket: ${App.escapeHtml(err.message)}</span>`);
}
},
cmdTheme(themeName) {
const valid = ['dark', 'green', 'amber', 'cyber'];
if (!themeName || !valid.includes(themeName.toLowerCase())) {
this.printOutput('<span class="text-warning">Uso: theme &lt;dark|green|amber|cyber&gt;</span>');
return;
}
const t = themeName.toLowerCase();
const overlay = document.getElementById('linux-console-modal');
if (overlay) {
overlay.className = `console-modal-overlay theme-${t}`;
}
this.currentTheme = t;
this.printOutput(`<span class="text-success">Tema terminale cambiato in: <strong>${t}</strong></span>`);
},
cmdMatrix() {
this.printOutput('<span class="text-success">Inizializzazione matrice in corso... premi Esc o Ctrl+C per fermare.</span>');
this.hideInputRow();
const outputDiv = document.getElementById('console-output');
const matrixBox = document.createElement('pre');
matrixBox.className = 'matrix-stream';
outputDiv.appendChild(matrixBox);
const chars = '0123456789ABCDEFヲアウエオカキケコサシスセソタツテナニヌネハヒホマミムメモヤユラリワ';
const cols = 60;
this.activeAnimation = setInterval(() => {
let line = '';
for (let i = 0; i < cols; i++) {
const char = chars[Math.floor(Math.random() * chars.length)];
line += char + ' ';
}
matrixBox.textContent += line + '\n';
this.scrollToBottom();
if (matrixBox.textContent.length > 3000) {
matrixBox.textContent = matrixBox.textContent.substring(1500);
}
}, 80);
},
cmdSl() {
this.printOutput('<span class="text-warning">Choo Choo! Locomotiva in transito...</span>');
this.hideInputRow();
const outputDiv = document.getElementById('console-output');
const trainBox = document.createElement('pre');
trainBox.className = 'sl-train-box';
outputDiv.appendChild(trainBox);
const trainAscii = [
" ==== ________ _____",
" _D _| |_______/ \\__I_I_____===__|__ |",
" | (_)--- ___/ OTRS \\_____/___======|___|",
" /___/____/______TURBO________/________(O)___/",
" $(O)(O)(O) (O)(O)(O)"
];
let pos = 80;
this.activeAnimation = setInterval(() => {
pos -= 3;
if (pos < -60) {
this.stopAnimation();
this.showInputRow();
trainBox.remove();
this.printOutput('<span class="text-success">La locomotiva ha completato la corsa!</span>');
return;
}
const spaces = ' '.repeat(Math.max(0, pos));
trainBox.textContent = trainAscii.map(l => spaces + l).join('\n');
this.scrollToBottom();
}, 50);
}
};
window.ConsoleView = ConsoleView;
+20 -4
View File
@@ -483,11 +483,12 @@ const EmailCompose = (() => {
placeholder: 'Scrivi il testo della email...', placeholder: 'Scrivi il testo della email...',
modules: { modules: {
toolbar: [ toolbar: [
['bold', 'italic', 'underline', 'strike'],
[{ 'header': [1, 2, 3, false] }], [{ 'header': [1, 2, 3, false] }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }], ['bold', 'italic', 'underline', 'strike'],
['link', 'image'],
[{ 'color': [] }, { 'background': [] }], [{ 'color': [] }, { 'background': [] }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'align': [] }],
['link', 'image', 'code-block'],
['clean'] ['clean']
], ],
} }
@@ -558,7 +559,22 @@ const EmailCompose = (() => {
}); });
// Send // Send
document.getElementById('ec-send').addEventListener('click', () => sendEmail(toTagsCtrl, ccTagsCtrl, bccTagsCtrl)); const handleEmailSend = () => sendEmail(toTagsCtrl, ccTagsCtrl, bccTagsCtrl);
document.getElementById('ec-send').addEventListener('click', handleEmailSend);
// Keyboard shortcut handler for email compose modal
const handleEmailKeydown = (e) => {
if (!document.getElementById('email-compose-overlay')) {
document.removeEventListener('keydown', handleEmailKeydown, true);
return;
}
if (App.isShortcutTriggered(e, 'send_email_submit')) {
e.preventDefault();
e.stopPropagation();
handleEmailSend();
}
};
document.addEventListener('keydown', handleEmailKeydown, true);
} }
function processFiles(files) { function processFiles(files) {
+4 -2
View File
@@ -155,10 +155,12 @@ const NoteTemporaneeView = {
placeholder: 'Scrivi il contenuto dettagliato della nota temporanea...', placeholder: 'Scrivi il contenuto dettagliato della nota temporanea...',
modules: { modules: {
toolbar: [ toolbar: [
[{ 'header': [1, 2, 3, false] }],
['bold', 'italic', 'underline', 'strike'], ['bold', 'italic', 'underline', 'strike'],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'color': [] }, { 'background': [] }], [{ 'color': [] }, { 'background': [] }],
['link', 'image'], [{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'align': [] }],
['link', 'image', 'code-block'],
['clean'] ['clean']
], ],
keyboard: { keyboard: {
+237 -20
View File
@@ -4,6 +4,7 @@
*/ */
const RicercaSpudorataView = { const RicercaSpudorataView = {
searchTerm: '', searchTerm: '',
isRegex: false,
cachedTickets: null, cachedTickets: null,
currentPage: 1, currentPage: 1,
perPage: 50, perPage: 50,
@@ -29,6 +30,10 @@ const RicercaSpudorataView = {
const urlParams = new URLSearchParams((window.location.hash.split('?')[1]) || ''); const urlParams = new URLSearchParams((window.location.hash.split('?')[1]) || '');
const qParam = urlParams.get('q'); const qParam = urlParams.get('q');
const regexParam = urlParams.get('regex');
if (regexParam !== null) {
this.isRegex = regexParam === '1' || regexParam === 'true';
}
if (qParam && qParam !== this.searchTerm) { if (qParam && qParam !== this.searchTerm) {
this.renderContainer(container); this.renderContainer(container);
@@ -49,17 +54,67 @@ const RicercaSpudorataView = {
this.renderContainer(container); this.renderContainer(container);
this.bindEvents(); this.bindEvents();
setTimeout(() => {
const input = document.getElementById('spudorata-search-input');
if (input) {
input.focus();
input.select();
}
}, 50);
}, },
renderContainer(container) { renderContainer(container) {
container.innerHTML = ` container.innerHTML = `
<!-- Hero Text Search Area --> <!-- Hero Text Search Area -->
<div class="ricerca-spudorata-hero" style="background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: var(--space-lg); margin-bottom: var(--space-lg); box-shadow: var(--shadow-md);"> <div class="ricerca-spudorata-hero" style="background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: var(--space-lg); margin-bottom: var(--space-lg); box-shadow: var(--shadow-md); position: relative;">
<div style="display:flex; align-items:center; justify-content:space-between; margin-bottom: var(--space-sm); flex-wrap:wrap; gap:10px;"> <div style="display:flex; align-items:center; justify-content:space-between; margin-bottom: var(--space-sm); flex-wrap:wrap; gap:10px;">
<div style="display:flex; align-items:center; gap: 10px;"> <div style="display:flex; align-items:center; gap: 10px;">
<div style="display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; background: linear-gradient(135deg, rgba(235, 114, 110, 0.2), rgba(160, 65, 71, 0.3)); border-radius: 50%; color: var(--accent-primary); font-size:1.2rem; font-weight:bold;">🚀</div> <div style="display:inline-flex; align-items:center; justify-content:center; width:36px; height:36px; background: linear-gradient(135deg, rgba(235, 114, 110, 0.2), rgba(160, 65, 71, 0.3)); border-radius: 50%; color: var(--accent-primary); font-size:1.2rem; font-weight:bold;">🚀</div>
<div> <div>
<div style="display:flex; align-items:center; gap: 8px;">
<h2 style="margin:0; font-size:1.2rem; font-weight:700; color:var(--text-primary);">Ricerca Testuale Spudorata</h2> <h2 style="margin:0; font-size:1.2rem; font-weight:700; color:var(--text-primary);">Ricerca Testuale Spudorata</h2>
<div style="position: relative; display: inline-flex; align-items: center;">
<button type="button" id="spudorata-info-btn" aria-label="Informazioni sulle regole avanzate e Regex" style="background: rgba(79, 70, 229, 0.1); border: 1px solid rgba(79, 70, 229, 0.25); border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--accent-primary); padding: 0; transition: all 0.2s ease;">
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"></circle>
<line x1="12" y1="16" x2="12" y2="12"></line>
<line x1="12" y1="8" x2="12.01" y2="8"></line>
</svg>
</button>
<!-- Modal / Popover indicazioni regole avanzate -->
<div id="spudorata-info-modal" class="spudorata-rules-popover" style="display:none; position:absolute; top:calc(100% + 10px); left:0; width:460px; max-width:90vw; background:var(--bg-card); border:1px solid var(--border-light); border-radius:var(--radius-lg); box-shadow:0 12px 32px rgba(0,0,0,0.22); z-index:1100; padding:18px; font-size:0.85rem; color:var(--text-primary); backdrop-filter:blur(12px);">
<div style="display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; border-bottom:1px solid var(--border-subtle); padding-bottom:8px;">
<div style="display:flex; align-items:center; gap:6px; font-weight:700; font-size:0.95rem; color:var(--accent-primary);">
<span>💡</span>
<span>Guida Ricerca & Regole Avanzate (Regex)</span>
</div>
<span style="font-size:0.75rem; color:var(--text-muted); background:var(--bg-tertiary); padding:2px 6px; border-radius:4px;">Regole avanzate</span>
</div>
<div style="line-height:1.45; color:var(--text-secondary); margin-bottom:12px;">
Puoi cercare normalmente per parole chiave o attivare l'opzione <strong>Regex</strong> per ricerche con espressioni regolari (POSIX / JavaScript) sia sul database che sui filtri in cache.
</div>
<div style="background:var(--bg-tertiary); border:1px solid var(--border-subtle); border-radius:var(--radius-md); padding:10px 12px; margin-bottom:12px;">
<div style="font-weight:600; color:var(--text-primary); margin-bottom:6px; font-size:0.82rem;">Esempi di espressioni regolari:</div>
<ul style="margin:0; padding-left:18px; display:flex; flex-direction:column; gap:6px;">
<li><code style="background:rgba(79,70,229,0.12); color:var(--accent-primary); padding:1px 5px; border-radius:3px; font-family:monospace;">vpn|firewall</code> — Trova ticket contenenti <em>vpn</em> <strong>oppure</strong> <em>firewall</em></li>
<li><code style="background:rgba(79,70,229,0.12); color:var(--accent-primary); padding:1px 5px; border-radius:3px; font-family:monospace;">\b(errore|fatal)\b</code> — Trova parole esatte "errore" o "fatal"</li>
<li><code style="background:rgba(79,70,229,0.12); color:var(--accent-primary); padding:1px 5px; border-radius:3px; font-family:monospace;">^INC-[0-9]+</code> — Ticket o codici che iniziano per "INC-" seguito da cifre</li>
<li><code style="background:rgba(79,70,229,0.12); color:var(--accent-primary); padding:1px 5px; border-radius:3px; font-family:monospace;">host(name)?.*down</code> — Trova "host down" o "hostname down" anche con parole in mezzo</li>
<li><code style="background:rgba(79,70,229,0.12); color:var(--accent-primary); padding:1px 5px; border-radius:3px; font-family:monospace;">\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}</code> — Trova indirizzi IP nel corpo o nell'oggetto</li>
</ul>
</div>
<div style="font-size:0.78rem; color:var(--text-tertiary); display:flex; flex-direction:column; gap:4px;">
<div>⚡ <strong>Case-insensitive:</strong> Le ricerche con Regex non distinguono automaticamente tra maiuscole e minuscole.</div>
<div>⚡ <strong>Cache locale:</strong> Anche il campo <em>"Cerca in Cache"</em> rispetta la modalità Regex o il formato <code>/pattern/</code>.</div>
</div>
</div>
</div>
</div>
<p style="margin:2px 0 0 0; font-size:0.82rem; color:var(--text-secondary);"> <p style="margin:2px 0 0 0; font-size:0.82rem; color:var(--text-secondary);">
Esegui la ricerca nel testo sui ticket. I filtri applicati successivamente operano <strong>istantaneamente in cache locale</strong> senza fare nuove richieste al server. Esegui la ricerca nel testo sui ticket. I filtri applicati successivamente operano <strong>istantaneamente in cache locale</strong> senza fare nuove richieste al server.
</p> </p>
@@ -70,11 +125,19 @@ const RicercaSpudorataView = {
<div style="display:flex; align-items:center; gap: var(--space-sm); flex-wrap:wrap; margin-top: var(--space-md);"> <div style="display:flex; align-items:center; gap: var(--space-sm); flex-wrap:wrap; margin-top: var(--space-md);">
<div style="position:relative; flex:1; min-width:300px;"> <div style="position:relative; flex:1; min-width:300px;">
<input type="text" id="spudorata-search-input" class="form-input" placeholder="Cerca nel testo (oggetto, corpo, numero ticket, cliente)..." value="${App.escapeHtml(this.searchTerm)}" style="width:100%; height:42px; font-size:0.95rem; padding-left:14px; padding-right:36px; border-radius:var(--radius-md);" /> <input type="text" id="spudorata-search-input" class="form-input" placeholder="${this.isRegex ? 'Cerca con espressione regolare (es. vpn|firewall, ^INC-\\d+)...' : 'Cerca nel testo (oggetto, corpo, numero ticket, cliente)...'}" value="${App.escapeHtml(this.searchTerm)}" style="width:100%; height:42px; font-size:0.95rem; padding-left:14px; padding-right:36px; border-radius:var(--radius-md);" />
<button id="spudorata-input-clear" style="position:absolute; right:10px; top:50%; transform:translateY(-50%); background:none; border:none; color:var(--text-muted); cursor:pointer; display:${this.searchTerm ? 'flex' : 'none'}; align-items:center; justify-content:center;" title="Cancella testo"> <button id="spudorata-input-clear" style="position:absolute; right:10px; top:50%; transform:translateY(-50%); background:none; border:none; color:var(--text-muted); cursor:pointer; display:${this.searchTerm ? 'flex' : 'none'}; align-items:center; justify-content:center;" title="Cancella testo">
✕ ✕
</button> </button>
</div> </div>
<!-- Toggle Regex -->
<label id="spudorata-regex-toggle" style="display:inline-flex; align-items:center; gap:6px; cursor:pointer; user-select:none; height:42px; padding:0 12px; background:var(--bg-secondary); border:1px solid ${this.isRegex ? 'var(--accent-primary)' : 'var(--border-light)'}; border-radius:var(--radius-md); font-size:0.85rem; font-weight:600; color:${this.isRegex ? 'var(--accent-primary)' : 'var(--text-secondary)'}; transition:all 0.15s ease;" title="Abilita ricerca tramite Regular Expression">
<input type="checkbox" id="spudorata-regex-checkbox" ${this.isRegex ? 'checked' : ''} style="cursor:pointer; accent-color:var(--accent-primary);" />
<span style="font-family:monospace; font-size:0.95rem; font-weight:700;">.*</span>
<span>Regex</span>
</label>
<button class="btn btn-primary" id="spudorata-search-btn" style="height:42px; padding:0 var(--space-xl); font-size:0.9rem; font-weight:600; min-width:130px; display:flex; align-items:center; justify-content:center; gap:6px;"> <button class="btn btn-primary" id="spudorata-search-btn" style="height:42px; padding:0 var(--space-xl); font-size:0.9rem; font-weight:600; min-width:130px; display:flex; align-items:center; justify-content:center; gap:6px;">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:18px;height:18px;"><circle cx="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:18px;height:18px;"><circle cx="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg>
<span>Cerca</span> <span>Cerca</span>
@@ -88,12 +151,10 @@ const RicercaSpudorataView = {
</div> </div>
<!-- Batch Actions Bar --> <!-- Batch Actions Bar -->
<div class="batch-bar" id="batch-bar"> <div class="batch-bar" id="batch-bar" style="display: flex; justify-content: space-between; align-items: center; gap: var(--space-md); flex-wrap: wrap;">
<div style="display:flex; align-items:center; gap:var(--space-sm);"> <!-- Colonna Sinistra: Configurazioni e Filtri di Modifica -->
<span class="batch-count" id="batch-count">0 selezionati</span> <div class="batch-bar-left" style="display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; flex: 1; min-width: 300px;">
<button class="btn btn-ghost btn-xs" id="batch-select-all">Seleziona visibili</button> <span class="batch-count" id="batch-count" style="margin-right: 4px;">0 selezionati</span>
<button class="btn btn-ghost btn-xs" id="batch-copy-tns" style="margin-left: 8px;">Copia numeri</button>
</div>
<div class="filter-group"> <div class="filter-group">
<span class="filter-label">Stato</span> <span class="filter-label">Stato</span>
<select class="filter-select" id="batch-state"> <select class="filter-select" id="batch-state">
@@ -130,11 +191,40 @@ const RicercaSpudorataView = {
</select> </select>
</div> </div>
` : ''} ` : ''}
</div>
<!-- Colonna Destra: Pulsanti delle Azioni -->
<div class="batch-bar-right" style="display: flex; flex-direction: column; align-items: flex-end; gap: 6px;">
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end;">
<button class="btn btn-primary btn-sm" id="batch-apply">Applica</button> <button class="btn btn-primary btn-sm" id="batch-apply">Applica</button>
<button class="btn btn-primary btn-sm" id="batch-add-group" disabled style="background: var(--accent-primary); border-color: var(--accent-primary); margin-left: 8px;">Aggiungi a gruppo</button> <button class="btn btn-primary btn-sm" id="batch-add-group" disabled title="Aggiungi a gruppo" style="background: var(--accent-primary); border-color: var(--accent-primary); height: 32px; width: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;">
<button class="btn btn-primary btn-sm" id="batch-merge" disabled style="background: rgba(160, 65, 71, 0.32); border-color: var(--accent-primary); color: var(--text-primary); margin-left: 8px;">Unisci Selezionati</button> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width: 16px; height: 16px;">
<button class="btn btn-primary btn-sm" id="batch-open-tabs" disabled style="background: var(--accent-primary); border-color: var(--accent-primary); margin-left: 8px;">Apri ticket in schede</button> <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
<button class="btn btn-ghost btn-xs" id="batch-cancel">Annulla</button> <circle cx="9" cy="7" r="4"></circle>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
</svg>
</button>
<button class="btn btn-primary btn-sm" id="batch-merge" disabled title="Unisci Selezionati" style="background: rgba(160, 65, 71, 0.32); border-color: var(--accent-primary); color: var(--text-primary); height: 32px; width: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width: 16px; height: 16px;">
<circle cx="18" cy="18" r="3"></circle>
<circle cx="6" cy="6" r="3"></circle>
<path d="M6 21V9a9 9 0 0 0 9 9"></path>
</svg>
</button>
<button class="btn btn-primary btn-sm" id="batch-open-tabs" disabled title="Apri ticket in schede" style="background: var(--accent-primary); border-color: var(--accent-primary); height: 32px; width: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width: 16px; height: 16px;">
<path d="M2 9a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9z"></path>
<path d="M6 3h12a2 2 0 0 1 2 2v12"></path>
</svg>
</button>
</div>
<div style="display: flex; align-items: center; gap: 6px; justify-content: flex-end;">
<button class="btn btn-ghost btn-xs" id="batch-select-all">Seleziona visibili</button>
<button class="btn btn-ghost btn-xs" id="batch-copy-tns">Copia numeri</button>
<button class="btn btn-ghost btn-xs" id="batch-cancel" title="Annulla selezione">Annulla</button>
</div>
</div>
</div> </div>
<!-- Filters Bar (Operates 100% Client-Side in Memory) --> <!-- Filters Bar (Operates 100% Client-Side in Memory) -->
@@ -159,6 +249,15 @@ const RicercaSpudorataView = {
return; return;
} }
if (this.isRegex) {
try {
new RegExp(query);
} catch (e) {
Toast.error('Espressione regolare non valida: ' + e.message);
return;
}
}
this.searchTerm = query; this.searchTerm = query;
this.isFetching = true; this.isFetching = true;
@@ -167,13 +266,14 @@ const RicercaSpudorataView = {
resultsArea.innerHTML = ` resultsArea.innerHTML = `
<div class="loading-screen" style="padding: 60px 0;"> <div class="loading-screen" style="padding: 60px 0;">
<div class="spinner"></div> <div class="spinner"></div>
<p>Ricerca testuale nel server in corso per "${App.escapeHtml(query)}"...</p> <p>Ricerca testuale ${this.isRegex ? 'con Regex ' : ''}nel server in corso per "${App.escapeHtml(query)}"...</p>
</div> </div>
`; `;
} }
try { try {
const data = await App.api(`/api/tickets?search=${encodeURIComponent(query)}&per_page=2000`); const regexParam = this.isRegex ? '&is_regex=1' : '';
const data = await App.api(`/api/tickets?search=${encodeURIComponent(query)}${regexParam}&per_page=2000`);
this.cachedTickets = data.tickets || []; this.cachedTickets = data.tickets || [];
this.otrsBaseUrl = data.otrsBaseUrl || ''; this.otrsBaseUrl = data.otrsBaseUrl || '';
this.hasSearched = true; this.hasSearched = true;
@@ -181,7 +281,7 @@ const RicercaSpudorataView = {
this.selectedIds.clear(); this.selectedIds.clear();
this.selectedOrder = []; this.selectedOrder = [];
Toast.success(`${this.cachedTickets.length} ticket caricati in cache locale per "${query}"`); Toast.success(`${this.cachedTickets.length} ticket caricati in cache locale per "${query}"${this.isRegex ? ' (Regex)' : ''}`);
this.renderContainer(document.getElementById('view-container')); this.renderContainer(document.getElementById('view-container'));
this.bindEvents(); this.bindEvents();
this.renderLocalResults(); this.renderLocalResults();
@@ -272,7 +372,7 @@ const RicercaSpudorataView = {
<span style="display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; background:#1070ca; color:#fff; border-radius:50%; font-size:10px; font-weight:800; font-family:sans-serif; vertical-align:middle; line-height:16px;">O</span> <span style="display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; background:#1070ca; color:#fff; border-radius:50%; font-size:10px; font-weight:800; font-family:sans-serif; vertical-align:middle; line-height:16px;">O</span>
</a> </a>
` : ''} ` : ''}
<button class="open-tab-btn" data-id="${t.id}" data-tn="${t.tn}" data-title="${App.escapeHtml(t.title || '')}" onclick="App.openTab(${t.id}, '${t.tn}', this.dataset.title); event.stopPropagation();" title="Apri in scheda" style="display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; background:var(--accent-primary); color:#fff; border:none; border-radius:50%; font-size:10px; font-weight:800; font-family:sans-serif; margin-right:6px; cursor:pointer; line-height:16px;">+</button> <button class="open-tab-btn" data-id="${t.id}" data-tn="${t.tn}" data-title="${App.escapeHtml(t.title || '')}" onclick="App.openTab(${t.id}, '${t.tn}', this.dataset.title, true); event.stopPropagation();" title="Apri in scheda" style="display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; background:var(--accent-primary); color:#fff; border:none; border-radius:50%; font-size:10px; font-weight:800; font-family:sans-serif; margin-right:6px; cursor:pointer; line-height:16px;">+</button>
<a href="#/tickets/${t.id}" class="ticket-tn-link" onclick="event.stopPropagation()">${t.tn}</a> <a href="#/tickets/${t.id}" class="ticket-tn-link" onclick="event.stopPropagation()">${t.tn}</a>
</span> </span>
</td> </td>
@@ -326,8 +426,22 @@ const RicercaSpudorataView = {
const s = Filters.state; const s = Filters.state;
if (s.sub_search) { if (s.sub_search) {
const q = String(s.sub_search).toLowerCase().trim(); const rawQ = String(s.sub_search).trim();
if (q) { if (rawQ) {
let regexMatcher = null;
if (this.isRegex) {
try {
regexMatcher = new RegExp(rawQ, 'i');
} catch (e) {
// If invalid while typing, fallback or ignore
}
} else if (rawQ.startsWith('/') && rawQ.length > 2 && rawQ.endsWith('/')) {
try {
regexMatcher = new RegExp(rawQ.slice(1, -1), 'i');
} catch (e) {}
}
const qLower = rawQ.toLowerCase();
list = list.filter(t => { list = list.filter(t => {
const fields = [ const fields = [
t.tn, t.tn,
@@ -344,7 +458,10 @@ const RicercaSpudorataView = {
t.customer_id, t.customer_id,
t.customer_user_id t.customer_user_id
]; ];
return fields.some(f => f && String(f).toLowerCase().includes(q)); if (regexMatcher) {
return fields.some(f => f && regexMatcher.test(String(f)));
}
return fields.some(f => f && String(f).toLowerCase().includes(qLower));
}); });
} }
} }
@@ -420,17 +537,34 @@ const RicercaSpudorataView = {
}, },
renderPagination(current, perPage, total, totalPages, isTop = false) { renderPagination(current, perPage, total, totalPages, isTop = false) {
const limitSelectHtml = `
<div style="display:inline-flex; align-items:center; gap:var(--space-xs); font-size:0.8rem; color:var(--text-secondary);">
<span>Righe:</span>
<select id="spudorata-per-page-select-${isTop ? 'top' : 'bottom'}" name="spudorata_per_page_${isTop ? 'top' : 'bottom'}" class="form-select spudorata-per-page-select" style="padding: 2px 24px 2px 6px; font-size: 0.75rem; height: 26px; min-width: 65px; margin: 0; background-position: right 6px center; border-color: var(--border-light);">
<option value="10" ${perPage === 10 ? 'selected' : ''}>10</option>
<option value="20" ${perPage === 20 ? 'selected' : ''}>20</option>
<option value="50" ${perPage === 50 ? 'selected' : ''}>50</option>
<option value="100" ${perPage === 100 ? 'selected' : ''}>100</option>
<option value="200" ${perPage === 200 ? 'selected' : ''}>200</option>
<option value="500" ${perPage === 500 ? 'selected' : ''}>500</option>
</select>
</div>
`;
return ` return `
<div class="pagination" style="${isTop ? 'margin-bottom:var(--space-md);' : 'margin-top:var(--space-md);'} align-items:center; justify-content:space-between; display:flex;"> <div class="pagination" style="${isTop ? 'margin-bottom:var(--space-md);' : 'margin-top:var(--space-md);'} align-items:center; justify-content:space-between; display:flex;">
<div class="pagination-info" style="font-size:0.82rem; color:var(--text-tertiary);"> <div class="pagination-info" style="font-size:0.82rem; color:var(--text-tertiary);">
Mostrati ${Math.min(total, (current - 1) * perPage + 1)}-${Math.min(total, current * perPage)} di ${total} ticket Mostrati ${total > 0 ? Math.min(total, (current - 1) * perPage + 1) : 0}-${Math.min(total, current * perPage)} di ${total} ticket
</div> </div>
<div class="pagination-controls" style="display:flex; align-items:center; gap:var(--space-sm);">
${limitSelectHtml}
<div class="pagination-buttons" style="display:flex; gap:4px;"> <div class="pagination-buttons" style="display:flex; gap:4px;">
<button class="pagination-btn spudorata-page-btn" data-page="${Math.max(1, current - 1)}" ${current === 1 ? 'disabled' : ''}>&laquo;</button> <button class="pagination-btn spudorata-page-btn" data-page="${Math.max(1, current - 1)}" ${current === 1 ? 'disabled' : ''}>&laquo;</button>
${this.renderPageNumbers(current, totalPages)} ${this.renderPageNumbers(current, totalPages)}
<button class="pagination-btn spudorata-page-btn" data-page="${Math.min(totalPages, current + 1)}" ${current === totalPages ? 'disabled' : ''}>&raquo;</button> <button class="pagination-btn spudorata-page-btn" data-page="${Math.min(totalPages, current + 1)}" ${current === totalPages ? 'disabled' : ''}>&raquo;</button>
</div> </div>
</div> </div>
</div>
`; `;
}, },
@@ -477,6 +611,78 @@ const RicercaSpudorataView = {
}); });
} }
const regexCheckbox = document.getElementById('spudorata-regex-checkbox');
if (regexCheckbox) {
regexCheckbox.addEventListener('change', () => {
this.isRegex = regexCheckbox.checked;
const toggleLabel = document.getElementById('spudorata-regex-toggle');
if (toggleLabel) {
toggleLabel.style.borderColor = this.isRegex ? 'var(--accent-primary)' : 'var(--border-light)';
toggleLabel.style.color = this.isRegex ? 'var(--accent-primary)' : 'var(--text-secondary)';
}
if (searchInput) {
searchInput.placeholder = this.isRegex
? 'Cerca con espressione regolare (es. vpn|firewall, ^INC-\\d+)...'
: 'Cerca nel testo (oggetto, corpo, numero ticket, cliente)...';
searchInput.focus();
}
// If we already have cached tickets, update the local filtered view immediately
if (this.hasSearched && this.cachedTickets) {
this.currentPage = 1;
this.renderLocalResults();
}
});
}
// Info button & hover modal
const infoBtn = document.getElementById('spudorata-info-btn');
const infoModal = document.getElementById('spudorata-info-modal');
if (infoBtn && infoModal) {
let closeTimeout = null;
const openModal = () => {
if (closeTimeout) {
clearTimeout(closeTimeout);
closeTimeout = null;
}
infoModal.style.display = 'block';
};
const closeModalWithDelay = () => {
if (closeTimeout) clearTimeout(closeTimeout);
closeTimeout = setTimeout(() => {
infoModal.style.display = 'none';
}, 250);
};
infoBtn.addEventListener('mouseenter', openModal);
infoBtn.addEventListener('mouseleave', closeModalWithDelay);
infoModal.addEventListener('mouseenter', () => {
if (closeTimeout) {
clearTimeout(closeTimeout);
closeTimeout = null;
}
});
infoModal.addEventListener('mouseleave', closeModalWithDelay);
// Also toggle on click for touch/mobile devices or explicit clicks
infoBtn.addEventListener('click', (e) => {
e.stopPropagation();
if (infoModal.style.display === 'block') {
infoModal.style.display = 'none';
} else {
openModal();
}
});
document.addEventListener('click', (e) => {
if (!infoBtn.contains(e.target) && !infoModal.contains(e.target)) {
infoModal.style.display = 'none';
}
});
}
if (resetCacheBtn) { if (resetCacheBtn) {
resetCacheBtn.addEventListener('click', () => { resetCacheBtn.addEventListener('click', () => {
this.invalidateCache(); this.invalidateCache();
@@ -575,6 +781,17 @@ const RicercaSpudorataView = {
}); });
}); });
document.querySelectorAll('.spudorata-per-page-select').forEach(sel => {
sel.addEventListener('change', (e) => {
const val = parseInt(e.target.value, 10);
if (!isNaN(val) && val > 0) {
this.perPage = val;
this.currentPage = 1;
this.renderLocalResults();
}
});
});
document.querySelectorAll('.spudorata-page-btn').forEach(btn => { document.querySelectorAll('.spudorata-page-btn').forEach(btn => {
btn.addEventListener('click', () => { btn.addEventListener('click', () => {
const page = parseInt(btn.dataset.page, 10); const page = parseInt(btn.dataset.page, 10);
+41 -6
View File
@@ -65,6 +65,34 @@ const ShortcutsView = {
context: 'Globale', context: 'Globale',
defaultCombo: { ctrl: true, alt: true, shift: false, key: 'n', enabled: true } defaultCombo: { ctrl: true, alt: true, shift: false, key: 'n', enabled: true }
}, },
{
id: 'ricerca_spudorata_open',
name: 'Apri Ricerca Spudorata',
description: 'Naviga direttamente alla pagina di Ricerca Spudorata o mette a fuoco il campo di ricerca',
context: 'Globale',
defaultCombo: { ctrl: true, alt: false, shift: true, key: 'f', enabled: true }
},
{
id: 'ticket_list_open',
name: 'Torna a Elenco Ticket',
description: 'Naviga direttamente alla pagina principale dell\'elenco ticket',
context: 'Globale',
defaultCombo: { ctrl: true, alt: false, shift: true, key: 'Backspace', enabled: true }
},
{
id: 'open_terminal_console',
name: 'Apri Terminale Linux',
description: 'Apre la finestra di simulazione del terminale Linux in overlay',
context: 'Globale',
defaultCombo: { ctrl: true, alt: true, shift: false, key: 't', enabled: true }
},
{
id: 'add_ticket_tab',
name: 'Aggiungi Ticket in Scheda',
description: 'Aggiunge il ticket visualizzato (o selezionato nell\'elenco) alle schede aperte in alto',
context: 'Globale / Dettaglio / Elenco',
defaultCombo: { ctrl: true, alt: true, shift: false, key: 's', enabled: true }
},
{ {
id: 'create_ticket_submit', id: 'create_ticket_submit',
name: 'Invia Nuovo Ticket', name: 'Invia Nuovo Ticket',
@@ -74,16 +102,23 @@ const ShortcutsView = {
}, },
{ {
id: 'quick_edit_save', id: 'quick_edit_save',
name: 'Salva Modifica Rapida', name: 'Salva Modifiche / Invia Nota',
description: 'Salva le modifiche apportate nei campi di Modifica Rapida', description: 'Salva le modifiche apportate nei campi di Modifica Rapida o invia la nota interna nel dettaglio ticket',
context: 'Pagina Dettaglio Ticket (Modifica Rapida)', context: 'Pagina Dettaglio Ticket',
defaultCombo: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true }
},
{
id: 'send_email_submit',
name: 'Invia Email',
description: 'Invia l\'email quando la finestra di composizione email è aperta',
context: 'Modal Composizione Email',
defaultCombo: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true } defaultCombo: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true }
}, },
{ {
id: 'pdf_save_edited', id: 'pdf_save_edited',
name: 'Salva Allegato / PDF Modificato', name: 'Salva Immagine / Allegato / PDF Modificato',
description: 'Scarica l\'allegato corrente o salva il PDF con le annotazioni apportate', description: 'Scarica l\'immagine o il PDF con le correzioni e annotazioni apportate',
context: 'Anteprima Allegato / PDF', context: 'Anteprima Allegato / PDF / Immagine',
defaultCombo: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true } defaultCombo: { ctrl: true, alt: false, shift: false, key: 'Enter', enabled: true }
} }
]; ];
+21 -16
View File
@@ -128,7 +128,7 @@ const TicketCreateView = {
<div class="form-grid"> <div class="form-grid">
<div class="form-group full-width"> <div class="form-group full-width">
<label class="form-label">Titolo <span class="required">*</span></label> <label class="form-label">Titolo <span class="required">*</span></label>
<input type="text" class="form-input" id="create-title" placeholder="Descrizione breve del problema" autofocus /> <input type="text" class="form-input" id="create-title" placeholder="Descrizione breve del problema" />
</div> </div>
<div class="form-group" style="position:relative;"> <div class="form-group" style="position:relative;">
@@ -230,10 +230,12 @@ const TicketCreateView = {
placeholder: 'Descrivi il problema in dettaglio...', placeholder: 'Descrivi il problema in dettaglio...',
modules: { modules: {
toolbar: [ toolbar: [
['bold', 'italic', 'underline', 'strike'],
[{ 'header': [1, 2, 3, false] }], [{ 'header': [1, 2, 3, false] }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }], ['bold', 'italic', 'underline', 'strike'],
['link', 'image'], [{ 'color': [] }, { 'background': [] }],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
[{ 'align': [] }],
['link', 'image', 'code-block'],
['clean'] ['clean']
], ],
keyboard: { keyboard: {
@@ -486,8 +488,6 @@ const TicketCreateView = {
} }
}); });
ownerSearchInput.addEventListener('focus', () => { ownerSearchInput.addEventListener('focus', () => {
ownerSearchInput.value = '';
ownerIdInput.value = '';
ownerSearchInput.dispatchEvent(new Event('input')); ownerSearchInput.dispatchEvent(new Event('input'));
}); });
} }
@@ -542,8 +542,6 @@ const TicketCreateView = {
} }
}); });
responsibleSearchInput.addEventListener('focus', () => { responsibleSearchInput.addEventListener('focus', () => {
responsibleSearchInput.value = '';
responsibleIdInput.value = '';
responsibleSearchInput.dispatchEvent(new Event('input')); responsibleSearchInput.dispatchEvent(new Event('input'));
}); });
} }
@@ -597,8 +595,6 @@ const TicketCreateView = {
} }
}); });
queueSearchInput.addEventListener('focus', () => { queueSearchInput.addEventListener('focus', () => {
queueSearchInput.value = '';
queueIdInput.value = '';
queueSearchInput.dispatchEvent(new Event('input')); queueSearchInput.dispatchEvent(new Event('input'));
}); });
} }
@@ -619,6 +615,11 @@ const TicketCreateView = {
} }
}); });
// Set focus on State dropdown (#create-state) on page load
setTimeout(() => {
document.getElementById('create-state')?.focus();
}, 50);
submitBtn.addEventListener('click', async () => { submitBtn.addEventListener('click', async () => {
const title = document.getElementById('create-title').value.trim(); const title = document.getElementById('create-title').value.trim();
const queue_id = queueIdInput.value; const queue_id = queueIdInput.value;
@@ -748,17 +749,21 @@ const TicketCreateView = {
el.addEventListener('change', () => this.saveState()); el.addEventListener('change', () => this.saveState());
}); });
// Shortcut to submit ticket // Shortcut to submit ticket (global keydown listener for ticket creation view)
const createFormEl = document.querySelector('.create-form'); const handleTicketCreateShortcut = (e) => {
if (createFormEl) { // Check if we are still on ticket creation view
createFormEl.addEventListener('keydown', (e) => { if (!document.getElementById('create-submit')) {
document.removeEventListener('keydown', handleTicketCreateShortcut, true);
return;
}
if (App.isShortcutTriggered(e, 'create_ticket_submit')) { if (App.isShortcutTriggered(e, 'create_ticket_submit')) {
e.preventDefault(); e.preventDefault();
e.stopPropagation();
if (submitBtn && !submitBtn.disabled) { if (submitBtn && !submitBtn.disabled) {
submitBtn.click(); submitBtn.click();
} }
} }
}); };
} document.addEventListener('keydown', handleTicketCreateShortcut, true);
}, },
}; };
File diff suppressed because it is too large. Load diff
+40 -12
View File
@@ -250,12 +250,11 @@ const TicketListView = {
container.innerHTML = ` container.innerHTML = `
<!-- Batch Actions Bar --> <!-- Batch Actions Bar -->
<div class="batch-bar" id="batch-bar"> <!-- Batch Actions Bar -->
<div style="display:flex; align-items:center; gap:var(--space-sm);"> <div class="batch-bar" id="batch-bar" style="display: flex; justify-content: space-between; align-items: center; gap: var(--space-md); flex-wrap: wrap;">
<span class="batch-count" id="batch-count">0 selezionati</span> <!-- Colonna Sinistra: Configurazioni e Filtri di Modifica -->
<button class="btn btn-ghost btn-xs" id="batch-select-all">Seleziona visibili</button> <div class="batch-bar-left" style="display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; flex: 1; min-width: 300px;">
<button class="btn btn-ghost btn-xs" id="batch-copy-tns" style="margin-left: 8px;">Copia numeri</button> <span class="batch-count" id="batch-count" style="margin-right: 4px;">0 selezionati</span>
</div>
<div class="filter-group"> <div class="filter-group">
<span class="filter-label">Stato</span> <span class="filter-label">Stato</span>
<select class="filter-select" id="batch-state"> <select class="filter-select" id="batch-state">
@@ -292,11 +291,40 @@ const TicketListView = {
</select> </select>
</div> </div>
` : ''} ` : ''}
</div>
<!-- Colonna Destra: Pulsanti delle Azioni -->
<div class="batch-bar-right" style="display: flex; flex-direction: column; align-items: flex-end; gap: 6px;">
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end;">
<button class="btn btn-primary btn-sm" id="batch-apply">Applica</button> <button class="btn btn-primary btn-sm" id="batch-apply">Applica</button>
<button class="btn btn-primary btn-sm" id="batch-add-group" disabled style="background: var(--accent-primary); border-color: var(--accent-primary); margin-left: 8px;">Aggiungi a gruppo</button> <button class="btn btn-primary btn-sm" id="batch-add-group" disabled title="Aggiungi a gruppo" style="background: var(--accent-primary); border-color: var(--accent-primary); height: 32px; width: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;">
<button class="btn btn-primary btn-sm" id="batch-merge" disabled style="background: rgba(160, 65, 71, 0.32); border-color: var(--accent-primary); color: var(--text-primary); margin-left: 8px;">Unisci Selezionati</button> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width: 16px; height: 16px;">
<button class="btn btn-primary btn-sm" id="batch-open-tabs" disabled style="background: var(--accent-primary); border-color: var(--accent-primary); margin-left: 8px;">Apri ticket in schede</button> <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
<button class="btn btn-ghost btn-xs" id="batch-cancel">Annulla</button> <circle cx="9" cy="7" r="4"></circle>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
</svg>
</button>
<button class="btn btn-primary btn-sm" id="batch-merge" disabled title="Unisci Selezionati" style="background: rgba(160, 65, 71, 0.32); border-color: var(--accent-primary); color: var(--text-primary); height: 32px; width: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width: 16px; height: 16px;">
<circle cx="18" cy="18" r="3"></circle>
<circle cx="6" cy="6" r="3"></circle>
<path d="M6 21V9a9 9 0 0 0 9 9"></path>
</svg>
</button>
<button class="btn btn-primary btn-sm" id="batch-open-tabs" disabled title="Apri ticket in schede" style="background: var(--accent-primary); border-color: var(--accent-primary); height: 32px; width: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width: 16px; height: 16px;">
<path d="M2 9a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9z"></path>
<path d="M6 3h12a2 2 0 0 1 2 2v12"></path>
</svg>
</button>
</div>
<div style="display: flex; align-items: center; gap: 6px; justify-content: flex-end;">
<button class="btn btn-ghost btn-xs" id="batch-select-all">Seleziona visibili</button>
<button class="btn btn-ghost btn-xs" id="batch-copy-tns">Copia numeri</button>
<button class="btn btn-ghost btn-xs" id="batch-cancel" title="Annulla selezione">Annulla</button>
</div>
</div>
</div> </div>
${Filters.renderBar(App.lookups)} ${Filters.renderBar(App.lookups)}
@@ -333,7 +361,7 @@ const TicketListView = {
<span style="display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; background:#1070ca; color:#fff; border-radius:50%; font-size:10px; font-weight:800; font-family:sans-serif; vertical-align:middle; line-height:16px;">O</span> <span style="display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; background:#1070ca; color:#fff; border-radius:50%; font-size:10px; font-weight:800; font-family:sans-serif; vertical-align:middle; line-height:16px;">O</span>
</a> </a>
` : ''} ` : ''}
<button class="open-tab-btn" data-id="${t.id}" data-tn="${t.tn}" data-title="${App.escapeHtml(t.title || '')}" onclick="App.openTab(${t.id}, '${t.tn}', this.dataset.title); event.stopPropagation();" title="Apri in scheda" style="display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; background:var(--accent-primary); color:#fff; border:none; border-radius:50%; font-size:10px; font-weight:800; font-family:sans-serif; margin-right:6px; cursor:pointer; line-height:16px;">+</button> <button class="open-tab-btn" data-id="${t.id}" data-tn="${t.tn}" data-title="${App.escapeHtml(t.title || '')}" onclick="App.openTab(${t.id}, '${t.tn}', this.dataset.title, true); event.stopPropagation();" title="Apri in scheda" style="display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; background:var(--accent-primary); color:#fff; border:none; border-radius:50%; font-size:10px; font-weight:800; font-family:sans-serif; margin-right:6px; cursor:pointer; line-height:16px;">+</button>
<a href="#/tickets/${t.id}" class="ticket-tn-link" onclick="event.stopPropagation()">${t.tn}</a> <a href="#/tickets/${t.id}" class="ticket-tn-link" onclick="event.stopPropagation()">${t.tn}</a>
</span> </span>
</td> </td>
@@ -371,7 +399,7 @@ const TicketListView = {
const limitSelectHtml = ` const limitSelectHtml = `
<div style="display:inline-flex; align-items:center; gap:var(--space-xs); font-size:0.8rem; color:var(--text-secondary); margin-right:var(--space-md);"> <div style="display:inline-flex; align-items:center; gap:var(--space-xs); font-size:0.8rem; color:var(--text-secondary); margin-right:var(--space-md);">
<span>Righe:</span> <span>Righe:</span>
<select class="form-select ticket-per-page-select" style="padding: 2px 24px 2px 6px; font-size: 0.75rem; height: 26px; min-width: 65px; margin: 0; background-position: right 6px center; border-color: var(--border-light);"> <select id="ticket-per-page-select-${isTop ? 'top' : 'bottom'}" name="per_page_${isTop ? 'top' : 'bottom'}" class="form-select ticket-per-page-select" style="padding: 2px 24px 2px 6px; font-size: 0.75rem; height: 26px; min-width: 65px; margin: 0; background-position: right 6px center; border-color: var(--border-light);">
<option value="10" ${per_page === 10 ? 'selected' : ''}>10</option> <option value="10" ${per_page === 10 ? 'selected' : ''}>10</option>
<option value="20" ${per_page === 20 ? 'selected' : ''}>20</option> <option value="20" ${per_page === 20 ? 'selected' : ''}>20</option>
<option value="50" ${per_page === 50 ? 'selected' : ''}>50</option> <option value="50" ${per_page === 50 ? 'selected' : ''}>50</option>
+110 -3
View File
@@ -12,6 +12,39 @@ const TimeAccountingView = {
viewMode: 'list', // 'list' | 'calendar' viewMode: 'list', // 'list' | 'calendar'
showAllTime: false, showAllTime: false,
showNonWorkingDays: localStorage.getItem('otrs_ta_show_non_working_days') !== 'false', showNonWorkingDays: localStorage.getItem('otrs_ta_show_non_working_days') !== 'false',
groupByTicket: localStorage.getItem('otrs_ta_group_by_ticket') !== 'false',
groupArticles(articles) {
if (!articles || articles.length === 0) return [];
if (!this.groupByTicket) {
return articles.map(a => ({ type: 'single', article: a }));
}
const groups = [];
let currentGroup = null;
for (const a of articles) {
const ticketId = a.ticket_id;
if (currentGroup && currentGroup.ticket_id === ticketId) {
currentGroup.articles.push(a);
} else {
if (currentGroup) {
groups.push(currentGroup);
}
currentGroup = {
type: 'group',
ticket_id: ticketId,
ticket_tn: a.ticket_tn,
ticket_title: a.ticket_title,
articles: [a]
};
}
}
if (currentGroup) {
groups.push(currentGroup);
}
return groups;
},
formatLocalISO(d) { formatLocalISO(d) {
if (!d) return ''; if (!d) return '';
@@ -174,6 +207,14 @@ const TimeAccountingView = {
<div style="display:flex; gap:var(--space-xs); align-self:flex-end;"> <div style="display:flex; gap:var(--space-xs); align-self:flex-end;">
<button id="ta-btn-today" class="btn btn-ghost btn-sm" style="height:36px;">Oggi</button> <button id="ta-btn-today" class="btn btn-ghost btn-sm" style="height:36px;">Oggi</button>
<button id="ta-btn-toggle-groupby" class="btn btn-ghost btn-sm" style="height:36px; display:flex; align-items:center; gap:6px; background:${this.groupByTicket ? 'var(--accent-primary)' : 'var(--bg-tertiary)'}; color:${this.groupByTicket ? '#ffffff' : 'var(--text-secondary)'}; border:1px solid var(--border-subtle);" title="Raggruppa le note adiacenti appartenenti allo stesso ticket">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:15px; height:15px;">
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
<polyline points="3.27 6.96 12 12.01 20.73 6.96"/>
<line x1="12" y1="22.08" x2="12" y2="12"/>
</svg>
<span>${this.groupByTicket ? 'Raggruppa per Ticket (Attivo)' : 'Raggruppa per Ticket'}</span>
</button>
<button id="ta-btn-toggle-nonwork" class="btn btn-ghost btn-sm" style="height:36px; display:flex; align-items:center; gap:6px;"> <button id="ta-btn-toggle-nonwork" class="btn btn-ghost btn-sm" style="height:36px; display:flex; align-items:center; gap:6px;">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:15px; height:15px;"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:15px; height:15px;">
${this.showNonWorkingDays ${this.showNonWorkingDays
@@ -193,7 +234,7 @@ const TimeAccountingView = {
<div style="display:flex; gap:var(--space-md); padding:var(--space-md) var(--space-xl); align-items:flex-start; min-height:calc(100vh - 280px);"> <div style="display:flex; gap:var(--space-md); padding:var(--space-md) var(--space-xl); align-items:flex-start; min-height:calc(100vh - 280px);">
<!-- Left Side: List of Articles --> <!-- Left Side: List of Articles -->
<div style="flex:1; min-width:0; display:flex; flex-direction:column; gap:var(--space-sm);"> <div style="flex:1; min-width:0; display:flex; flex-direction:column; gap:var(--space-md);">
${articles.length === 0 ? ` ${articles.length === 0 ? `
<div class="empty-state" style="padding:var(--space-2xl); text-align:center; color:var(--text-muted); background:var(--bg-card); border-radius:var(--radius-md); border:1px solid var(--border-subtle);"> <div class="empty-state" style="padding:var(--space-2xl); text-align:center; color:var(--text-muted); background:var(--bg-card); border-radius:var(--radius-md); border:1px solid var(--border-subtle);">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" style="width:48px; height:48px; margin:0 auto var(--space-md); display:block; opacity:0.4;"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" style="width:48px; height:48px; margin:0 auto var(--space-md); display:block; opacity:0.4;">
@@ -201,7 +242,7 @@ const TimeAccountingView = {
</svg> </svg>
<p style="font-size:0.9rem; font-weight:500;">Nessuna nota o email trovata in questa data per l'agente selezionato.</p> <p style="font-size:0.9rem; font-weight:500;">Nessuna nota o email trovata in questa data per l'agente selezionato.</p>
</div> </div>
` : articles.map(a => this.buildArticleCard(a)).join('')} ` : this.groupArticles(articles).map(g => g.type === 'single' ? this.buildArticleCard(g.article) : this.buildGroupCard(g)).join('')}
</div> </div>
<!-- Right Side: Details & Actions Panel --> <!-- Right Side: Details & Actions Panel -->
@@ -292,8 +333,21 @@ const TimeAccountingView = {
borderStyle = '1px solid var(--border-subtle)'; borderStyle = '1px solid var(--border-subtle)';
textColor = 'var(--accent-primary)'; textColor = 'var(--accent-primary)';
} }
} else if (dayMins === 0) {
// Giorno lavorativo senza consuntivazioni: neutro / bianco
if (isSelected) {
bgStyle = 'var(--accent-primary)';
borderStyle = '1px solid var(--accent-primary)';
textColor = '#ffffff';
badgeBg = 'rgba(255,255,255,0.25)';
badgeColor = '#ffffff';
} else if (isToday) {
bgStyle = 'rgba(79, 70, 229, 0.12)';
borderStyle = '1px solid var(--border-subtle)';
textColor = 'var(--accent-primary)';
}
} else { } else {
// Working days (configured in WORK_DAYS) // Working days con consuntivazione (> 0 min)
if (isTargetReached) { if (isTargetReached) {
// Verdino (green) // Verdino (green)
if (isSelected) { if (isSelected) {
@@ -437,6 +491,18 @@ const TimeAccountingView = {
bgStyle = 'rgba(79, 70, 229, 0.12)'; bgStyle = 'rgba(79, 70, 229, 0.12)';
textColor = 'var(--accent-primary)'; textColor = 'var(--accent-primary)';
} }
} else if (dayMins === 0) {
// Giorno lavorativo senza ore consuntivate: neutro / non evidenziato in rosso
if (isSelected) {
bgStyle = 'var(--accent-primary)';
borderStyle = '2px solid var(--accent-primary)';
textColor = '#ffffff';
badgeBg = 'rgba(255,255,255,0.25)';
badgeColor = '#ffffff';
} else if (isToday) {
bgStyle = 'rgba(79, 70, 229, 0.12)';
textColor = 'var(--accent-primary)';
}
} else { } else {
if (isTargetReached) { if (isTargetReached) {
if (isSelected) { if (isSelected) {
@@ -574,6 +640,40 @@ const TimeAccountingView = {
`; `;
}, },
buildGroupCard(group) {
const totalGroupMins = Math.round(group.articles.reduce((acc, a) => acc + (parseFloat(a.time_unit) || 0), 0));
const formattedGroupTime = this.formatPillTime(totalGroupMins);
const hasSelectedArticle = group.articles.some(a => String(a.article_id) === String(this.selectedArticleId));
return `
<div class="card ta-group-card" style="border:1px solid ${hasSelectedArticle ? 'var(--accent-primary)' : 'var(--border-subtle)'}; background:var(--bg-card); border-radius:var(--radius-md); overflow:hidden;">
<!-- Header del Gruppo Ticket -->
<div style="padding:10px 14px; background:var(--bg-secondary); border-bottom:1px solid var(--border-subtle); display:flex; align-items:center; justify-content:space-between; gap:10px;">
<div style="display:flex; align-items:center; gap:8px; min-width:0;">
<span style="font-size:0.9rem;">🎫</span>
<a href="#/tickets/${group.ticket_id}" class="ticket-tn-link" onclick="event.stopPropagation();" style="font-weight:700; font-size:0.9rem;">#${App.escapeHtml(group.ticket_tn || group.ticket_id)}</a>
<span style="font-size:0.85rem; font-weight:600; color:var(--text-primary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;" title="${App.escapeHtml(group.ticket_title || '')}">
${App.escapeHtml(group.ticket_title || '(senza titolo)')}
</span>
</div>
<div style="display:flex; align-items:center; gap:8px; flex-shrink:0;">
<span class="badge" style="background:var(--bg-tertiary); color:var(--text-secondary); font-size:0.75rem; font-weight:600;">
${group.articles.length} ${group.articles.length === 1 ? 'nota' : 'note'}
</span>
<span class="badge" style="background:${totalGroupMins > 0 ? 'rgba(34,197,94,0.18)' : 'var(--bg-tertiary)'}; color:${totalGroupMins > 0 ? '#15803d' : 'var(--text-muted)'}; font-weight:700; font-size:0.78rem;">
⏱️ Totale: ${formattedGroupTime} (${totalGroupMins} m)
</span>
</div>
</div>
<!-- Note del Gruppo -->
<div style="display:flex; flex-direction:column; gap:6px; padding:10px;">
${group.articles.map(a => this.buildArticleCard(a)).join('')}
</div>
</div>
`;
},
buildDetailPanel(a) { buildDetailPanel(a) {
const timeMins = parseFloat(a.time_unit || 0); const timeMins = parseFloat(a.time_unit || 0);
@@ -687,6 +787,13 @@ const TimeAccountingView = {
this.loadData(); this.loadData();
}); });
// Toggle group by ticket button
document.getElementById('ta-btn-toggle-groupby')?.addEventListener('click', () => {
this.groupByTicket = !this.groupByTicket;
localStorage.setItem('otrs_ta_group_by_ticket', this.groupByTicket);
this.loadData();
});
// Day pill clicks (also handles calendar cell clicks) // Day pill clicks (also handles calendar cell clicks)
document.querySelectorAll('.ta-day-pill[data-date]').forEach(pill => { document.querySelectorAll('.ta-day-pill[data-date]').forEach(pill => {
pill.addEventListener('click', () => { pill.addEventListener('click', () => {
+14
View File
@@ -0,0 +1,14 @@
/*!
* Chart.js v4.5.1
* https://www.chartjs.org
* (c) 2025 Chart.js Contributors
* Released under the MIT License
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,(function(){"use strict";var t=Object.freeze({__proto__:null,get Colors(){return Jo},get Decimation(){return ta},get Filler(){return ba},get Legend(){return Ma},get SubTitle(){return Pa},get Title(){return ka},get Tooltip(){return Na}});function e(){}const i=(()=>{let t=0;return()=>t++})();function s(t){return null==t}function n(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.slice(0,7)&&"Array]"===e.slice(-6)}function o(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function a(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function r(t,e){return a(t)?t:e}function l(t,e){return void 0===t?e:t}const h=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:+t/e,c=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function d(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function u(t,e,i,s){let a,r,l;if(n(t))if(r=t.length,s)for(a=r-1;a>=0;a--)e.call(i,t[a],a);else for(a=0;a<r;a++)e.call(i,t[a],a);else if(o(t))for(l=Object.keys(t),r=l.length,a=0;a<r;a++)e.call(i,t[l[a]],l[a])}function f(t,e){let i,s,n,o;if(!t||!e||t.length!==e.length)return!1;for(i=0,s=t.length;i<s;++i)if(n=t[i],o=e[i],n.datasetIndex!==o.datasetIndex||n.index!==o.index)return!1;return!0}function g(t){if(n(t))return t.map(g);if(o(t)){const e=Object.create(null),i=Object.keys(t),s=i.length;let n=0;for(;n<s;++n)e[i[n]]=g(t[i[n]]);return e}return t}function p(t){return-1===["__proto__","prototype","constructor"].indexOf(t)}function m(t,e,i,s){if(!p(t))return;const n=e[t],a=i[t];o(n)&&o(a)?x(n,a,s):e[t]=g(a)}function x(t,e,i){const s=n(e)?e:[e],a=s.length;if(!o(t))return t;const r=(i=i||{}).merger||m;let l;for(let e=0;e<a;++e){if(l=s[e],!o(l))continue;const n=Object.keys(l);for(let e=0,s=n.length;e<s;++e)r(n[e],t,l,i)}return t}function b(t,e){return x(t,e,{merger:_})}function _(t,e,i){if(!p(t))return;const s=e[t],n=i[t];o(s)&&o(n)?b(s,n):Object.prototype.hasOwnProperty.call(e,t)||(e[t]=g(n))}const y={"":t=>t,x:t=>t.x,y:t=>t.y};function v(t){const e=t.split("."),i=[];let s="";for(const t of e)s+=t,s.endsWith("\\")?s=s.slice(0,-1)+".":(i.push(s),s="");return i}function M(t,e){const i=y[e]||(y[e]=function(t){const e=v(t);return t=>{for(const i of e){if(""===i)break;t=t&&t[i]}return t}}(e));return i(t)}function w(t){return t.charAt(0).toUpperCase()+t.slice(1)}const k=t=>void 0!==t,S=t=>"function"==typeof t,P=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0};function D(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}const C=Math.PI,O=2*C,A=O+C,T=Number.POSITIVE_INFINITY,L=C/180,E=C/2,R=C/4,I=2*C/3,z=Math.log10,F=Math.sign;function V(t,e,i){return Math.abs(t-e)<i}function B(t){const e=Math.round(t);t=V(t,e,t/1e3)?e:t;const i=Math.pow(10,Math.floor(z(t))),s=t/i;return(s<=1?1:s<=2?2:s<=5?5:10)*i}function W(t){const e=[],i=Math.sqrt(t);let s;for(s=1;s<i;s++)t%s==0&&(e.push(s),e.push(t/s));return i===(0|i)&&e.push(i),e.sort(((t,e)=>t-e)).pop(),e}function N(t){return!function(t){return"symbol"==typeof t||"object"==typeof t&&null!==t&&!(Symbol.toPrimitive in t||"toString"in t||"valueOf"in t)}(t)&&!isNaN(parseFloat(t))&&isFinite(t)}function H(t,e){const i=Math.round(t);return i-e<=t&&i+e>=t}function j(t,e,i){let s,n,o;for(s=0,n=t.length;s<n;s++)o=t[s][i],isNaN(o)||(e.min=Math.min(e.min,o),e.max=Math.max(e.max,o))}function $(t){return t*(C/180)}function Y(t){return t*(180/C)}function U(t){if(!a(t))return;let e=1,i=0;for(;Math.round(t*e)/e!==t;)e*=10,i++;return i}function X(t,e){const i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s);let o=Math.atan2(s,i);return o<-.5*C&&(o+=O),{angle:o,distance:n}}function q(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function K(t,e){return(t-e+A)%O-C}function G(t){return(t%O+O)%O}function J(t,e,i,s){const n=G(t),o=G(e),a=G(i),r=G(o-n),l=G(a-n),h=G(n-o),c=G(n-a);return n===o||n===a||s&&o===a||r>l&&h<c}function Z(t,e,i){return Math.max(e,Math.min(i,t))}function Q(t){return Z(t,-32768,32767)}function tt(t,e,i,s=1e-6){return t>=Math.min(e,i)-s&&t<=Math.max(e,i)+s}function et(t,e,i){i=i||(i=>t[i]<e);let s,n=t.length-1,o=0;for(;n-o>1;)s=o+n>>1,i(s)?o=s:n=s;return{lo:o,hi:n}}const it=(t,e,i,s)=>et(t,i,s?s=>{const n=t[s][e];return n<i||n===i&&t[s+1][e]===i}:s=>t[s][e]<i),st=(t,e,i)=>et(t,i,(s=>t[s][e]>=i));function nt(t,e,i){let s=0,n=t.length;for(;s<n&&t[s]<e;)s++;for(;n>s&&t[n-1]>i;)n--;return s>0||n<t.length?t.slice(s,n):t}const ot=["push","pop","shift","splice","unshift"];function at(t,e){t._chartjs?t._chartjs.listeners.push(e):(Object.defineProperty(t,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[e]}}),ot.forEach((e=>{const i="_onData"+w(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...eLine truncated
/*!
* @kurkle/color v0.3.2
* https://github.com/kurkle/color#readme
* (c) 2023 Jukka Kurkela
* Released under the MIT License
*/function _t(t){return t+.5|0}const yt=(t,e,i)=>Math.max(Math.min(t,i),e);function vt(t){return yt(_t(2.55*t),0,255)}function Mt(t){return yt(_t(255*t),0,255)}function wt(t){return yt(_t(t/2.55)/100,0,1)}function kt(t){return yt(_t(100*t),0,100)}const St={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Pt=[..."0123456789ABCDEF"],Dt=t=>Pt[15&t],Ct=t=>Pt[(240&t)>>4]+Pt[15&t],Ot=t=>(240&t)>>4==(15&t);function At(t){var e=(t=>Ot(t.r)&&Ot(t.g)&&Ot(t.b)&&Ot(t.a))(t)?Dt:Ct;return t?"#"+e(t.r)+e(t.g)+e(t.b)+((t,e)=>t<255?e(t):"")(t.a,e):void 0}const Tt=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Lt(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function Et(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function Rt(t,e,i){const s=Lt(t,1,.5);let n;for(e+i>1&&(n=1/(e+i),e*=n,i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function It(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=function(t,e,i,s,n){return t===n?(e-i)/s+(e<i?6:0):e===n?(i-t)/s+2:(t-e)/s+4}(e,i,s,h,n),r=60*r+.5),[0|r,l||0,a]}function zt(t,e,i,s){return(Array.isArray(e)?t(e[0],e[1],e[2]):t(e,i,s)).map(Mt)}function Ft(t,e,i){return zt(Lt,t,e,i)}function Vt(t){return(t%360+360)%360}function Bt(t){const e=Tt.exec(t);let i,s=255;if(!e)return;e[5]!==i&&(s=e[6]?vt(+e[5]):Mt(+e[5]));const n=Vt(+e[2]),o=+e[3]/100,a=+e[4]/100;return i="hwb"===e[1]?function(t,e,i){return zt(Rt,t,e,i)}(n,o,a):"hsv"===e[1]?function(t,e,i){return zt(Et,t,e,i)}(n,o,a):Ft(n,o,a),{r:i[0],g:i[1],b:i[2],a:s}}const Wt={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},Nt={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};let Ht;function jt(t){Ht||(Ht=function(){const t={},e=Object.keys(Nt),i=Object.keys(Wt);let s,n,o,a,r;for(s=0;s<e.length;s++){for(a=r=e[s],n=0;n<i.length;n++)o=i[n],r=r.replace(o,Wt[o]);o=parseInt(Nt[a],16),t[r]=[o>>16&255,o>>8&255,255&o]}return t}(),Ht.transparent=[0,0,0,0]);const e=Ht[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}const $t=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const Yt=t=>t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,Ut=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function Xt(t,e,i){if(t){let s=It(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),Line truncated
//# sourceMappingURL=chart.umd.min.js.map
+16
View File
@@ -0,0 +1,16 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).PDFLib={})}(this,(function(t){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,n)};function n(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}l((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function a(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}for(var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=new Uint8Array(256),h=0;h<s.length;h++)l[s.charCodeAt(h)]=h;var u,c=function(t){for(var e="",n=t.length,r=0;r<n;r+=3)e+=s[t[r]>>2],e+=s[(3&t[r])<<4|t[r+1]>>4],e+=s[(15&t[r+1])<<2|t[r+2]>>6],e+=s[63&t[r+2]];return n%3==2?e=e.substring(0,e.length-1)+"=":n%3==1&&(e=e.substring(0,e.length-2)+"=="),e},d=function(t){var e,n,r,i,o,a=.75*t.length,s=t.length,h=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);var u=new Uint8Array(a);for(e=0;e<s;e+=4)n=l[t.charCodeAt(e)],r=l[t.charCodeAt(e+1)],i=l[t.charCodeAt(e+2)],o=l[t.charCodeAt(e+3)],u[h++]=n<<2|r>>4,u[h++]=(15&r)<<4|i>>2,u[h++]=(3&i)<<6|63&o;return u},f=/^(data)?:?([\w\/\+]+)?;?(charset=[\w-]+|base64)?.*,/i,p=function(t){var e=t.trim(),n=e.substring(0,100).match(f);if(!n)return d(e);var r=n[0],i=e.substring(r.length);return d(i)},g=function(t){return t.charCodeAt(0)},v=function(t){return t.codePointAt(0)},y=function(t,e){return x(t.toString(16),e,"0").toUpperCase()},m=function(t){return y(t,2)},b=function(t){return String.fromCharCode(t)},w=function(t){return b(parseInt(t,16))},x=function(t,e,n){for(var r="",i=0,o=e-t.length;i<o;i++)r+=n;return r+t},k=function(t,e,n){for(var r=t.length,i=0;i<r;i++)e[n++]=t.charCodeAt(i);return r},F=function(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},S=function(t){return t.replace(/\t|\u0085|\u2028|\u2029/g," ").replace(/[\b\v]/g,"")},C=["\\n","\\f","\\r","\\u000B"],A=function(t){return/^[\n\f\r\u000B]$/.test(t)},T=function(t){return t.split(/[\n\f\r\u000B]/)},P=function(t){return t.replace(/[\n\f\r\u000B]/g," ")},z=function(t,e){var n,r=t.charCodeAt(e),i=e+1,o=1;return r>=55296&&r<=56319&&t.length>i&&(n=t.charCodeAt(i))>=56320&&n<=57343&&(o=2),[t.slice(e,e+o),o]},R=function(t){for(var e=[],n=0,r=t.length;n<r;){var i=z(t,n),o=i[0],a=i[1];e.push(o),n+=a}return e},O=function(t,e,n,r){for(var i=function(t){for(var e=C.join("|"),n=["$"],r=0,i=t.length;r<i;r++){var o=t[r];if(A(o))throw new TypeError("`wordBreak` must not include "+e);n.push(""===o?".":F(o))}var a=n.join("|");return new RegExp("("+e+")|((.*?)("+a+"))","gm")}(e),o=S(t).match(i),a="",s=0,l=[],h=function(){""!==a&&l.push(a),a="",s=0},u=0,c=o.length;u<c;u++){var d=o[u];if(A(d))h();else{var f=r(d);s+f>n&&h(),a+=d,s+=f}}return h(),l},D=/^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+\-Z])?(\d\d)?'?(\d\d)?'?$/,B=function(t){var e=t.match(D);if(e){var n=e[1],r=e[2],i=void 0===r?"01":r,o=e[3],a=void 0===o?"01":o,s=e[4],l=void 0===s?"00":s,h=e[5],u=void 0===h?"00":h,c=e[6],d=void 0===c?"00":c,f=e[7],p=void 0===f?"Z":f,g=e[8],v=void 0===g?"00":g,y=e[9];return new Date(n+"-"+i+"-"+a+"T"+l+":"+u+":"+d+("Z"===p?"Z":""+p+v+":"+(void 0===y?"00":y)))}},N=function(t,e){for(var n,r,i=0;i<t.length;){var o=t.substring(i).match(e);if(!o)return{match:r,pos:i};r=o,i+=(null!==(n=o.index)&&void 0Line truncated
//# sourceMappingURL=pdf-lib.min.js.map
+22
View File
@@ -0,0 +1,22 @@
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page
*
* Copyright 2023 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* JavaScript code in this page
*/
!function webpackUniversalModuleDefinition(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=t.pdfjsLib=e():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],(()=>t.pdfjsLib=e())):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=t.pdfjsLib=e():t["pdfjs-dist/build/pdf"]=t.pdfjsLib=e()}(globalThis,(()=>(()=>{"use strict";var __webpack_modules__=[,(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.VerbosityLevel=e.Util=e.UnknownErrorException=e.UnexpectedResponseException=e.TextRenderingMode=e.RenderingIntentFlag=e.PromiseCapability=e.PermissionFlag=e.PasswordResponses=e.PasswordException=e.PageActionEventType=e.OPS=e.MissingPDFException=e.MAX_IMAGE_SIZE_TO_CACHE=e.LINE_FACTOR=e.LINE_DESCENT_FACTOR=e.InvalidPDFException=e.ImageKind=e.IDENTITY_MATRIX=e.FormatError=e.FeatureTest=e.FONT_IDENTITY_MATRIX=e.DocumentActionEventType=e.CMapCompressionType=e.BaseException=e.BASELINE_FACTOR=e.AnnotationType=e.AnnotationReplyType=e.AnnotationPrefix=e.AnnotationMode=e.AnnotationFlag=e.AnnotationFieldFlag=e.AnnotationEditorType=e.AnnotationEditorPrefix=e.AnnotationEditorParamsType=e.AnnotationBorderStyleType=e.AnnotationActionEventType=e.AbortException=void 0;e.assert=function assert(t,e){t||unreachable(e)};e.bytesToString=bytesToString;e.createValidAbsoluteUrl=function createValidAbsoluteUrl(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=stringToUTF8String(t)}catch{}}const s=e?new URL(t,e):new URL(t);if(function _isValidProtocol(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null};e.getModificationDate=function getModificationDate(t=new Date){return[t.getUTCFullYear().toString(),(t.getUTCMonth()+1).toString().padStart(2,"0"),t.getUTCDate().toString().padStart(2,"0"),t.getUTCHours().toString().padStart(2,"0"),t.getUTCMinutes().toString().padStart(2,"0"),t.getUTCSeconds().toString().padStart(2,"0")].join("")};e.getUuid=function getUuid(){if("undefined"!=typeof crypto&&"function"==typeof crypto?.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);if("undefined"!=typeof crypto&&"function"==typeof crypto?.getRandomValues)crypto.getRandomValues(t);else for(let e=0;e<32;e++)t[e]=Math.floor(255*Math.random());return bytesToString(t)};e.getVerbosityLevel=function getVerbosityLevel(){return n};e.info=function info(t){n>=s.INFOS&&console.log(`Info: ${t}`)};e.isArrayBuffer=function isArrayBuffer(t){return"object"==typeof t&&void 0!==t?.byteLength};e.isArrayEqual=function isArrayEqual(t,e){if(t.length!==e.length)return!1;for(let i=0,s=t.length;i<s;i++)if(t[i]!==e[i])return!1;return!0};e.isNodeJS=void 0;e.normalizeUnicode=function normalizeUnicode(t){if(!l){l=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;h=new Map([["ſt","ſt"]])}return t.replaceAll(l,((t,e,i)=>e?e.normalize("NFKC"):h.get(i)))};e.objectFromMap=function objectFromMap(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e};e.objectSize=function objectSize(t){return Object.keys(t).length};e.setVerbosityLevel=function setVerbosityLevel(t){Number.isInteger(t)&&(n=t)};e.shadow=shadow;e.string32=function string32(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)};e.stringToBytes=stringToBytes;e.stringToPDFString=function stringToPDFString(t){if(t[0]>="ï"){let e;"þ"===t[0]&&"ÿ"===t[1]?e="utf-16be":"ÿ"===t[0]&&"þ"===t[1]?e="utf-16le":"ï"===t[0]&&"»"===t[1]&&"¿"===t[2]&&(e="utf-8");if(e)try{const i=new TextDecoder(e,{fatal:!0}),s=stringToBytes(t);return i.decode(s)}catch(t){warn(`stringToPDFString: "${t}".`)}}const e=[];for(let i=0,s=t.length;i<s;i++){const s=o[t.charCodeAt(i)];e.push(s?String.fromCharCode(s):t.charAt(i))}return e.join("")};e.stringToUTF8String=stringToUTF8String;e.unreachable=unreachable;e.utf8StringToString=function utf8StringToString(t){return unescape(encodeURIComponent(t))};e.warn=warn;const i=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);e.isNodeJS=i;e.IDENTITY_MATRIX=[1,0,0,1,0,0];e.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];e.MAX_IMAGE_SIZE_TO_CACHE=1e7;e.LINE_FACTOR=1.35;e.LINE_DESCENT_FACTOR=.35;e.BASELINE_FACTOR=.25925925925925924;e.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};e.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};e.AnnotationEditorPrefix="pdfjs_internal_editor_";e.AnnotationEditorType={DISABLE:-1,NONE:0,FREETEXT:3,STLine truncated
+3
View File
@@ -0,0 +1,3 @@
/*! For license information please see quill.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Quill=e():t.Quill=e()}(self,(function(){return function(){var t={9698:function(t,e,n){"use strict";n.d(e,{Ay:function(){return c},Ji:function(){return d},mG:function(){return h},zo:function(){return u}});var r=n(6003),i=n(5232),s=n.n(i),o=n(3036),l=n(4850),a=n(5508);class c extends r.BlockBlot{cache={};delta(){return null==this.cache.delta&&(this.cache.delta=h(this)),this.cache.delta}deleteAt(t,e){super.deleteAt(t,e),this.cache={}}formatAt(t,e,n,i){e<=0||(this.scroll.query(n,r.Scope.BLOCK)?t+e===this.length()&&this.format(n,i):super.formatAt(t,Math.min(e,this.length()-t-1),n,i),this.cache={})}insertAt(t,e,n){if(null!=n)return super.insertAt(t,e,n),void(this.cache={});if(0===e.length)return;const r=e.split("\n"),i=r.shift();i.length>0&&(t<this.length()-1||null==this.children.tail?super.insertAt(Math.min(t,this.length()-1),i):this.children.tail.insertAt(this.children.tail.length(),i),this.cache={});let s=this;r.reduce(((t,e)=>(s=s.split(t,!0),s.insertAt(0,e),e.length)),t+i.length)}insertBefore(t,e){const{head:n}=this.children;super.insertBefore(t,e),n instanceof o.A&&n.remove(),this.cache={}}length(){return null==this.cache.length&&(this.cache.length=super.length()+1),this.cache.length}moveChildren(t,e){super.moveChildren(t,e),this.cache={}}optimize(t){super.optimize(t),this.cache={}}path(t){return super.path(t,!0)}removeChild(t){super.removeChild(t),this.cache={}}split(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e&&(0===t||t>=this.length()-1)){const e=this.clone();return 0===t?(this.parent.insertBefore(e,this),this):(this.parent.insertBefore(e,this.next),e)}const n=super.split(t,e);return this.cache={},n}}c.blotName="block",c.tagName="P",c.defaultChild=o.A,c.allowedChildren=[o.A,l.A,r.EmbedBlot,a.A];class u extends r.EmbedBlot{attach(){super.attach(),this.attributes=new r.AttributorStore(this.domNode)}delta(){return(new(s())).insert(this.value(),{...this.formats(),...this.attributes.values()})}format(t,e){const n=this.scroll.query(t,r.Scope.BLOCK_ATTRIBUTE);null!=n&&this.attributes.attribute(n,e)}formatAt(t,e,n,r){this.format(n,r)}insertAt(t,e,n){if(null!=n)return void super.insertAt(t,e,n);const r=e.split("\n"),i=r.pop(),s=r.map((t=>{const e=this.scroll.create(c.blotName);return e.insertAt(0,t),e})),o=this.split(t);s.forEach((t=>{this.parent.insertBefore(t,o)})),i&&this.parent.insertBefore(this.scroll.create("text",i),o)}}function h(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.descendants(r.LeafBlot).reduce(((t,n)=>0===n.length()?t:t.insert(n.value(),d(n,{},e))),new(s())).insert("\n",d(t))}function d(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return null==t?e:("formats"in t&&"function"==typeof t.formats&&(e={...e,...t.formats()},n&&delete e["code-token"]),null==t.parent||"scroll"===t.parent.statics.blotName||t.parent.statics.scope!==t.statics.scope?e:d(t.parent,e,n))}u.scope=r.Scope.BLOCK_BLOT},3036:function(t,e,n){"use strict";var r=n(6003);class i extends r.EmbedBlot{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return""}}i.blotName="break",i.tagName="BR",e.A=i},580:function(t,e,n){"use strict";var r=n(6003);class i extends r.ContainerBlot{}e.A=i},4541:function(t,e,n){"use strict";var r=n(6003),i=n(5508);class s extends r.EmbedBlot{static blotName="cursor";static className="ql-cursor";static tagName="span";static CONTENTS="\ufeff";static value(){}constructor(t,e,n){super(t,e),this.selection=n,this.textNode=document.createTextNode(s.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){null!=this.parent&&this.parent.removeChild(this)}format(t,e){if(0!==this.savedLength)return void super.format(t,e);let n=this,i=0;for(;null!=n&&n.statics.scope!==r.Scope.BLOCK_BLOT;)i+=n.offset(n.parent),n=n.parent;null!=n&&(this.savedLength=s.CONTENTS.length,n.optimize(),n.formatAt(i,s.CONTENTS.length,t,e),this.savedLength=0)}index(t,e){return t===this.textNode?0:super.index(t,e)}length(){return this.savedLength}position(){return[this.textNode,this.textNode.data.length]}remove(){super.remove(),this.parent=null}restore(){if(this.selection.composing||null==this.parent)return null;const t=this.selection.getNativeRange();for(;null!=this.domNode.lastChild&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);const e=this.prev instanceof i.A?this.prev:null,n=e?e.length():0,r=this.next instanceof i.A?this.next:null,o=r?r.text:"",{textNode:l}=this,a=l.data.split(s.CONTENTS).join("");let c;if(l.data=s.CONTENTS,e)c=e,(a||r)&&(e.insertAt(e.length(),a+o),r&&r.remove());else if(r)c=r,r.insertAt(0,a);else{const t=document.createTextNode(a);c=this.scroll.create(t),this.parent.insertBefore(c,this)}if(this.reLine truncated
//# sourceMappingURL=quill.js.map
+10
View File
@@ -0,0 +1,10 @@
/*!
* Quill Editor v2.0.2
* https://quilljs.com
* Copyright (c) 2017-2024, Slab
* Copyright (c) 2014, Jason Chen
* Copyright (c) 2013, salesforce.com
*/
.ql-container{box-sizing:border-box;font-family:Helvetica,Arial,sans-serif;font-size:13px;height:100%;margin:0;position:relative}.ql-container.ql-disabled .ql-tooltip{visibility:hidden}.ql-container:not(.ql-disabled) li[data-list=checked] > .ql-ui,.ql-container:not(.ql-disabled) li[data-list=unchecked] > .ql-ui{cursor:pointer}.ql-clipboard{left:-100000px;height:1px;overflow-y:hidden;position:absolute;top:50%}.ql-clipboard p{margin:0;padding:0}.ql-editor{box-sizing:border-box;counter-reset:list-0 list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;line-height:1.42;height:100%;outline:none;overflow-y:auto;padding:12px 15px;tab-size:4;-moz-tab-size:4;text-align:left;white-space:pre-wrap;word-wrap:break-word}.ql-editor > *{cursor:text}.ql-editor p,.ql-editor ol,.ql-editor pre,.ql-editor blockquote,.ql-editor h1,.ql-editor h2,.ql-editor h3,.ql-editor h4,.ql-editor h5,.ql-editor h6{margin:0;padding:0}@supports (counter-set:none){.ql-editor p,.ql-editor h1,.ql-editor h2,.ql-editor h3,.ql-editor h4,.ql-editor h5,.ql-editor h6{counter-set:list-0 list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}}@supports not (counter-set:none){.ql-editor p,.ql-editor h1,.ql-editor h2,.ql-editor h3,.ql-editor h4,.ql-editor h5,.ql-editor h6{counter-reset:list-0 list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}}.ql-editor table{border-collapse:collapse}.ql-editor td{border:1px solid #000;padding:2px 5px}.ql-editor ol{padding-left:1.5em}.ql-editor li{list-style-type:none;padding-left:1.5em;position:relative}.ql-editor li > .ql-ui:before{display:inline-block;margin-left:-1.5em;margin-right:.3em;text-align:right;white-space:nowrap;width:1.2em}.ql-editor li[data-list=checked] > .ql-ui,.ql-editor li[data-list=unchecked] > .ql-ui{color:#777}.ql-editor li[data-list=bullet] > .ql-ui:before{content:'\2022'}.ql-editor li[data-list=checked] > .ql-ui:before{content:'\2611'}.ql-editor li[data-list=unchecked] > .ql-ui:before{content:'\2610'}@supports (counter-set:none){.ql-editor li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}}@supports not (counter-set:none){.ql-editor li[data-list]{counter-reset:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}}.ql-editor li[data-list=ordered]{counter-increment:list-0}.ql-editor li[data-list=ordered] > .ql-ui:before{content:counter(list-0, decimal) '. '}.ql-editor li[data-list=ordered].ql-indent-1{counter-increment:list-1}.ql-editor li[data-list=ordered].ql-indent-1 > .ql-ui:before{content:counter(list-1, lower-alpha) '. '}@supports (counter-set:none){.ql-editor li[data-list].ql-indent-1{counter-set:list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}}@supports not (counter-set:none){.ql-editor li[data-list].ql-indent-1{counter-reset:list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}}.ql-editor li[data-list=ordered].ql-indent-2{counter-increment:list-2}.ql-editor li[data-list=ordered].ql-indent-2 > .ql-ui:before{content:counter(list-2, lower-roman) '. '}@supports (counter-set:none){.ql-editor li[data-list].ql-indent-2{counter-set:list-3 list-4 list-5 list-6 list-7 list-8 list-9}}@supports not (counter-set:none){.ql-editor li[data-list].ql-indent-2{counter-reset:list-3 list-4 list-5 list-6 list-7 list-8 list-9}}.ql-editor li[data-list=ordered].ql-indent-3{counter-increment:list-3}.ql-editor li[data-list=ordered].ql-indent-3 > .ql-ui:before{content:counter(list-3, decimal) '. '}@supports (counter-set:none){.ql-editor li[data-list].ql-indent-3{counter-set:list-4 list-5 list-6 list-7 list-8 list-9}}@supports not (counter-set:none){.ql-editor li[data-list].ql-indent-3{counter-reset:list-4 list-5 list-6 list-7 list-8 list-9}}.ql-editor li[data-list=ordered].ql-indent-4{counter-increment:list-4}.ql-editor li[data-list=ordered].ql-indent-4 > .ql-ui:before{content:counter(list-4, lower-alpha) '. '}@supports (counter-set:none){.ql-editor li[data-list].ql-indent-4{counter-set:list-5 list-6 list-7 list-8 list-9}}@supports not (counter-set:none){.ql-editor li[data-list].ql-indent-4{counter-reset:list-5 list-6 list-7 list-8 list-9}}.ql-editor li[data-list=ordered].ql-indent-5{counter-increment:list-5}.ql-editor li[data-list=ordered].ql-indent-5 > .ql-ui:before{content:counter(list-5, lower-roman) '. '}@supports (counter-set:none){.ql-editor li[data-list].ql-indent-5{counter-set:list-6 list-7 list-8 list-9}}@supports not (counter-set:none){.ql-editor li[data-list].ql-indent-5{counter-reset:list-6 list-7 list-8 list-9}}.ql-editor li[data-list=ordered].ql-indent-6{counter-increment:list-6}.ql-editor li[data-list=ordered].ql-indent-6 > .ql-ui:before{content:counter(list-6, decimal) '. '}@supports (counter-set:none){.ql-editor li[data-list].ql-indent-6{counter-set:list-7 list-8 list-9}}@supports not (counter-set:none){.ql-editor li[data-list].ql-indent-6{counter-reset:list-7 list-8 list-9}}.ql-editor li[data-list=ordered].ql-indent-7{counter-increment:list-7}.ql-editor li[data-list=ordered].ql-indent-7 > .ql-ui:before{content:coLine truncated
/*# sourceMappingURL=quill.snow.css.map*/
+6
View File
@@ -296,6 +296,12 @@ router.get('/customer-companies/search', async (req, res) => {
} }
}); });
// Alias /api/customers/search -> /api/customer-users/search for backwards compatibility
router.get('/customers/search', (req, res, next) => {
req.url = '/customer-users/search' + (req.url.includes('?') ? req.url.slice(req.url.indexOf('?')) : '');
router.handle(req, res, next);
});
// GET /api/customer-users/search — Search customer users (supports LDAP via REST, fallbacks to DB) // GET /api/customer-users/search — Search customer users (supports LDAP via REST, fallbacks to DB)
router.get('/customer-users/search', async (req, res) => { router.get('/customer-users/search', async (req, res) => {
const { q = '', customer_company_id } = req.query; const { q = '', customer_company_id } = req.query;
+247 -15
View File
@@ -2,6 +2,7 @@ const express = require('express');
const router = express.Router(); const router = express.Router();
const pool = require('../db'); const pool = require('../db');
const { db, logAttivita } = require('../activityDb'); const { db, logAttivita } = require('../activityDb');
const { cleanAndDecodeText } = require('../utils/textDecoder');
// Helper to get local timestamp in YYYY-MM-DD HH:mm:ss format // Helper to get local timestamp in YYYY-MM-DD HH:mm:ss format
function getLocalTimestamp() { function getLocalTimestamp() {
@@ -211,6 +212,30 @@ router.get('/', async (req, res) => {
} }
const searchTerm = search || sub_search; const searchTerm = search || sub_search;
if (searchTerm) { if (searchTerm) {
const isRegex = req.query.is_regex === 'true' || req.query.is_regex === '1';
if (isRegex) {
// Validate regex pattern to prevent DB syntax error
try {
new RegExp(searchTerm);
} catch (regexErr) {
return res.status(400).json({ error: `Espressione regolare non valida: ${regexErr.message}` });
}
conditions.push(`(
t.title ~* $${paramIdx} OR
t.tn ~* $${paramIdx} OR
EXISTS (
SELECT 1 FROM article art
LEFT JOIN article_data_mime adm ON art.id = adm.article_id
WHERE art.ticket_id = t.id AND (
adm.a_subject ~* $${paramIdx} OR
adm.a_body ~* $${paramIdx}
)
)
)`);
params.push(searchTerm);
paramIdx++;
} else {
conditions.push(`( conditions.push(`(
t.title ILIKE $${paramIdx} OR t.title ILIKE $${paramIdx} OR
t.tn ILIKE $${paramIdx} OR t.tn ILIKE $${paramIdx} OR
@@ -226,6 +251,7 @@ router.get('/', async (req, res) => {
params.push(`%${searchTerm}%`); params.push(`%${searchTerm}%`);
paramIdx++; paramIdx++;
} }
}
const whereClause = conditions.length > 0 const whereClause = conditions.length > 0
? 'WHERE ' + conditions.join(' AND ') ? 'WHERE ' + conditions.join(' AND ')
@@ -292,6 +318,12 @@ router.get('/', async (req, res) => {
} }
} }
result.rows.forEach(t => {
if (t.title) t.title = cleanAndDecodeText(t.title);
if (t.customer_first) t.customer_first = cleanAndDecodeText(t.customer_first);
if (t.customer_last) t.customer_last = cleanAndDecodeText(t.customer_last);
});
res.json({ res.json({
tickets: result.rows, tickets: result.rows,
total, total,
@@ -306,12 +338,37 @@ router.get('/', async (req, res) => {
} }
}); });
// ============================================================
// GET /api/tickets/stats — Ticket statistics overview
// ============================================================
router.get('/stats', async (req, res) => {
try {
const totalRes = await pool.query('SELECT COUNT(*) as total FROM ticket');
const openRes = await pool.query(
`SELECT COUNT(*) as total FROM ticket t
JOIN ticket_state ts ON t.ticket_state_id = ts.id
JOIN ticket_state_type tst ON ts.type_id = tst.id
WHERE tst.name IN ('new', 'open', 'pending auto', 'pending reminder')`
);
res.json({
total_tickets: parseInt(totalRes.rows[0]?.total || 0),
open_tickets: parseInt(openRes.rows[0]?.total || 0),
});
} catch (err) {
console.error('Error fetching ticket stats:', err);
res.status(500).json({ error: err.message });
}
});
// ============================================================ // ============================================================
// GET /api/tickets/:id — Single ticket detail // GET /api/tickets/:id — Single ticket detail
// ============================================================ // ============================================================
router.get('/:id', async (req, res) => { router.get('/:id', async (req, res, next) => {
try { try {
const { id } = req.params; const { id } = req.params;
if (isNaN(id)) {
return res.status(400).json({ error: 'ID ticket non valido' });
}
const ticketResult = await pool.query( const ticketResult = await pool.query(
`SELECT `SELECT
@@ -355,7 +412,11 @@ router.get('/:id', async (req, res) => {
// 1. Try to read from local SQLite cache in internal.db // 1. Try to read from local SQLite cache in internal.db
let cachedUser = null; let cachedUser = null;
try { try {
cachedUser = db.prepare('SELECT email, first_name, last_name, phone FROM customer_user_cache WHERE login = ?').get(ticket.customer_user_id); cachedUser = db.prepare(`
SELECT login, email, first_name, last_name, phone
FROM customer_user_cache
WHERE login = ? OR (first_name || ' ' || last_name) = ? COLLATE NOCASE
`).get(ticket.customer_user_id, ticket.customer_user_id);
} catch (dbErr) { } catch (dbErr) {
console.warn('[LDAP Cache Detail] SQLite cache read failed:', dbErr.message); console.warn('[LDAP Cache Detail] SQLite cache read failed:', dbErr.message);
} }
@@ -366,8 +427,20 @@ router.get('/:id', async (req, res) => {
ticket.customer_email = cachedUser.email || ''; ticket.customer_email = cachedUser.email || '';
ticket.customer_phone = cachedUser.phone || ''; ticket.customer_phone = cachedUser.phone || '';
} else { } else {
// 2. Fallback to live API fetch // 2. Fallback to live API fetch (only if login doesn't contain spaces)
const getResult = await otrsRequest('POST', '/CustomerUserGet', { UserLogin: ticket.customer_user_id }); let targetLogin = ticket.customer_user_id;
if (targetLogin.includes(' ')) {
try {
const sRes = await otrsRequest('POST', '/CustomerUserSearch', { Search: `*${targetLogin}*`, Valid: 1 });
const sData = (sRes && sRes.Data) || sRes;
if (sData && sData.CustomerUserID) {
targetLogin = Array.isArray(sData.CustomerUserID) ? sData.CustomerUserID[0] : sData.CustomerUserID;
}
} catch (_) {}
}
if (targetLogin && !targetLogin.includes(' ')) {
const getResult = await otrsRequest('POST', '/CustomerUserGet', { UserLogin: targetLogin });
const getData = (getResult && getResult.Data) || getResult; const getData = (getResult && getResult.Data) || getResult;
if (getData && getData.CustomerUser) { if (getData && getData.CustomerUser) {
const u = getData.CustomerUser; const u = getData.CustomerUser;
@@ -400,6 +473,7 @@ router.get('/:id', async (req, res) => {
} }
} }
} }
}
} catch (apiErr) { } catch (apiErr) {
console.warn(`Failed to fetch LDAP customer details for detail view:`, apiErr.message); console.warn(`Failed to fetch LDAP customer details for detail view:`, apiErr.message);
} }
@@ -443,14 +517,17 @@ router.get('/:id', async (req, res) => {
[id] [id]
); );
// Fetch HTML body attachment content for articles if present (e.g. file-1, file-1.html, text/html) // Fetch HTML body attachment content for articles if present (e.g. file-1, file-2, text/html, html attachments)
const htmlAttachmentsRes = await pool.query( const htmlAttachmentsRes = await pool.query(
`SELECT id, article_id, filename, content_type, content `SELECT id, article_id, filename, content_type, content
FROM article_data_mime_attachment FROM article_data_mime_attachment
WHERE article_id IN (SELECT id FROM article WHERE ticket_id = $1) WHERE article_id IN (SELECT id FROM article WHERE ticket_id = $1)
AND ( AND (
filename LIKE 'file-%' filename LIKE 'file-%'
OR filename LIKE '%.html'
OR filename LIKE '%.htm'
OR content_type LIKE '%html%' OR content_type LIKE '%html%'
OR content_type LIKE '%text%'
OR disposition = 'inline' OR disposition = 'inline'
) )
ORDER BY id ASC`, ORDER BY id ASC`,
@@ -522,10 +599,14 @@ router.get('/:id', async (req, res) => {
return text; return text;
}; };
if (ticket.title) ticket.title = cleanAndDecodeText(ticket.title);
if (ticket.customer_first) ticket.customer_first = cleanAndDecodeText(ticket.customer_first);
if (ticket.customer_last) ticket.customer_last = cleanAndDecodeText(ticket.customer_last);
const htmlBodyMap = {}; const htmlBodyMap = {};
for (const row of htmlAttachmentsRes.rows) { for (const row of htmlAttachmentsRes.rows) {
if (row.content) { if (row.content) {
const contentStr = decodeTextContent(row.content, row.content_type); const contentStr = cleanAndDecodeText(row.content, row.content_type);
if (contentStr && /<(div|p|br|table|html|body|span|img|a|style)\b/i.test(contentStr)) { if (contentStr && /<(div|p|br|table|html|body|span|img|a|style)\b/i.test(contentStr)) {
const fname = (row.filename || '').toLowerCase(); const fname = (row.filename || '').toLowerCase();
if (!htmlBodyMap[row.article_id] || fname.startsWith('file-1') || fname.startsWith('file-2')) { if (!htmlBodyMap[row.article_id] || fname.startsWith('file-1') || fname.startsWith('file-2')) {
@@ -536,12 +617,21 @@ router.get('/:id', async (req, res) => {
} }
articlesResult.rows.forEach(a => { articlesResult.rows.forEach(a => {
// Ensure a.a_body and subject are properly decoded if legacy encoded // Decode article subjects, bodies, and sender/recipient headers
if (a.a_body) { if (a.a_body) {
a.a_body = decodeTextContent(a.a_body, a.a_content_type); a.a_body = cleanAndDecodeText(a.a_body, a.a_content_type);
} }
if (a.a_subject) { if (a.a_subject) {
a.a_subject = decodeTextContent(a.a_subject, 'text/plain; charset=utf-8'); a.a_subject = cleanAndDecodeText(a.a_subject);
}
if (a.a_from) {
a.a_from = cleanAndDecodeText(a.a_from);
}
if (a.a_to) {
a.a_to = cleanAndDecodeText(a.a_to);
}
if (a.a_cc) {
a.a_cc = cleanAndDecodeText(a.a_cc);
} }
if (htmlBodyMap[a.article_id]) { if (htmlBodyMap[a.article_id]) {
@@ -892,9 +982,19 @@ router.patch('/:id', async (req, res) => {
if (updates.responsible_user_id !== undefined) ticketFields.ResponsibleID = updates.responsible_user_id; if (updates.responsible_user_id !== undefined) ticketFields.ResponsibleID = updates.responsible_user_id;
if (updates.type_id !== undefined) ticketFields.TypeID = updates.type_id; if (updates.type_id !== undefined) ticketFields.TypeID = updates.type_id;
if (updates.title !== undefined) ticketFields.Title = updates.title; if (updates.title !== undefined) ticketFields.Title = updates.title;
if (updates.ticket_lock_id !== undefined) ticketFields.LockID = updates.ticket_lock_id; if (updates.customer_user_id !== undefined && updates.customer_user_id !== null && updates.customer_user_id !== '') {
if (updates.customer_id !== undefined) ticketFields.CustomerID = updates.customer_id; try {
if (updates.customer_user_id !== undefined) ticketFields.CustomerUser = updates.customer_user_id; const match = db.prepare(`SELECT login, customer_id FROM customer_user_cache WHERE login = ? OR (first_name || ' ' || last_name) = ? COLLATE NOCASE`).get(updates.customer_user_id, updates.customer_user_id);
if (match) {
updates.customer_user_id = match.login;
if (!updates.customer_id && match.customer_id) {
updates.customer_id = match.customer_id;
}
}
} catch (e) {}
ticketFields.CustomerUser = updates.customer_user_id;
}
if (updates.customer_id !== undefined && updates.customer_id !== null && updates.customer_id !== '') ticketFields.CustomerID = updates.customer_id;
// If ticketFields is empty but we have a note or timeUnit to log, supply a dummy field (StateID) so Ticket is not empty // If ticketFields is empty but we have a note or timeUnit to log, supply a dummy field (StateID) so Ticket is not empty
if (Object.keys(ticketFields).length === 0 && (hasNote || (!isNaN(timeUnit) && timeUnit > 0))) { if (Object.keys(ticketFields).length === 0 && (hasNote || (!isNaN(timeUnit) && timeUnit > 0))) {
@@ -963,6 +1063,7 @@ router.patch('/:id', async (req, res) => {
const client = await pool.connect(); const client = await pool.connect();
try { try {
await client.query('BEGIN'); await client.query('BEGIN');
const localNow = getLocalTimestamp();
// If state is changing, check if the target state is a closed state type to auto-unlock // If state is changing, check if the target state is a closed state type to auto-unlock
if (updates.ticket_state_id && updates.ticket_state_id !== current.ticket_state_id) { if (updates.ticket_state_id && updates.ticket_state_id !== current.ticket_state_id) {
@@ -1624,9 +1725,19 @@ router.patch('/batch/update', async (req, res) => {
if (updates.queue_id !== undefined) ticketFields.QueueID = updates.queue_id; if (updates.queue_id !== undefined) ticketFields.QueueID = updates.queue_id;
if (updates.type_id !== undefined) ticketFields.TypeID = updates.type_id; if (updates.type_id !== undefined) ticketFields.TypeID = updates.type_id;
if (updates.user_id !== undefined) ticketFields.OwnerID = updates.user_id; if (updates.user_id !== undefined) ticketFields.OwnerID = updates.user_id;
if (updates.responsible_user_id !== undefined) ticketFields.ResponsibleID = updates.responsible_user_id; if (updates.customer_user_id !== undefined && updates.customer_user_id !== null && updates.customer_user_id !== '') {
if (updates.customer_id !== undefined) ticketFields.CustomerID = updates.customer_id; try {
if (updates.customer_user_id !== undefined) ticketFields.CustomerUser = updates.customer_user_id; const match = db.prepare(`SELECT login, customer_id FROM customer_user_cache WHERE login = ? OR (first_name || ' ' || last_name) = ? COLLATE NOCASE`).get(updates.customer_user_id, updates.customer_user_id);
if (match) {
updates.customer_user_id = match.login;
if (!updates.customer_id && match.customer_id) {
updates.customer_id = match.customer_id;
}
}
} catch (e) {}
ticketFields.CustomerUser = updates.customer_user_id;
}
if (updates.customer_id !== undefined && updates.customer_id !== null && updates.customer_id !== '') ticketFields.CustomerID = updates.customer_id;
// Auto sblocco check // Auto sblocco check
if (updates.ticket_state_id) { if (updates.ticket_state_id) {
@@ -1866,6 +1977,9 @@ router.delete('/articles/:articleId', async (req, res) => {
router.get('/attachments/:id', async (req, res) => { router.get('/attachments/:id', async (req, res) => {
try { try {
const { id } = req.params; const { id } = req.params;
if (!/^\d+$/.test(id)) {
return res.status(404).send('Allegato non trovato.');
}
const result = await pool.query( const result = await pool.query(
`SELECT filename, content_type, content `SELECT filename, content_type, content
FROM article_data_mime_attachment FROM article_data_mime_attachment
@@ -1934,6 +2048,124 @@ router.get('/attachments/:id', async (req, res) => {
} }
}); });
// PUT /api/tickets/attachments/:id — Update text attachment content
router.put('/attachments/:id', async (req, res) => {
try {
const { id } = req.params;
if (!/^\d+$/.test(id)) {
return res.status(404).json({ error: 'Allegato non trovato' });
}
const { content } = req.body;
if (typeof content !== 'string') {
return res.status(400).json({ error: 'Contenuto non valido' });
}
const checkRes = await pool.query(
`SELECT filename, content_type FROM article_data_mime_attachment WHERE id = $1`,
[id]
);
if (checkRes.rows.length === 0) {
return res.status(404).json({ error: 'Allegato non trovato' });
}
const contentBuffer = Buffer.from(content, 'utf-8');
await pool.query(
`UPDATE article_data_mime_attachment SET content = $1, content_size = $2 WHERE id = $3`,
[contentBuffer, contentBuffer.length, id]
);
res.json({ message: 'Allegato di testo aggiornato con successo' });
} catch (err) {
console.error('Errore aggiornamento allegato:', err);
res.status(500).json({ error: err.message });
}
});
// POST /api/tickets/attachments/:id/open — Open attachment using OS default app (Word, Excel, etc.)
router.post('/attachments/:id/open', async (req, res) => {
try {
const { id } = req.params;
if (!/^\d+$/.test(id)) {
return res.status(404).json({ error: 'Allegato non trovato' });
}
const result = await pool.query(
`SELECT filename, content_type, content FROM article_data_mime_attachment WHERE id = $1`,
[id]
);
if (result.rows.length === 0) {
return res.status(404).json({ error: 'Allegato non trovato' });
}
const attachment = result.rows[0];
let contentBuffer;
if (attachment.content) {
if (Buffer.isBuffer(attachment.content)) {
const isRawBinary = attachment.content.length > 4 && (
(attachment.content[0] === 0x25 && attachment.content[1] === 0x50 && attachment.content[2] === 0x44 && attachment.content[3] === 0x46) ||
(attachment.content[0] === 0xFF && attachment.content[1] === 0xD8) ||
(attachment.content[0] === 0x89 && attachment.content[1] === 0x50) ||
(attachment.content[0] === 0x50 && attachment.content[1] === 0x4B)
);
if (isRawBinary) {
contentBuffer = attachment.content;
} else {
const str = attachment.content.toString('utf-8');
const cleaned = str.replace(/\s+/g, '');
if (cleaned.length > 0 && cleaned.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(cleaned)) {
try { contentBuffer = Buffer.from(cleaned, 'base64'); } catch (_) { contentBuffer = attachment.content; }
} else {
contentBuffer = attachment.content;
}
}
} else if (typeof attachment.content === 'string') {
const cleaned = attachment.content.replace(/\s+/g, '');
if (cleaned.length > 0 && cleaned.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(cleaned)) {
try { contentBuffer = Buffer.from(cleaned, 'base64'); } catch (_) { contentBuffer = Buffer.from(attachment.content, 'utf-8'); }
} else {
contentBuffer = Buffer.from(attachment.content, 'utf-8');
}
} else {
contentBuffer = Buffer.from(attachment.content);
}
} else {
contentBuffer = Buffer.alloc(0);
}
const fs = require('fs');
const path = require('path');
const os = require('os');
const { exec } = require('child_process');
const tempDir = path.join(os.tmpdir(), 'otrs_turbo_attachments');
if (!fs.existsSync(tempDir)) {
fs.mkdirSync(tempDir, { recursive: true });
}
const safeName = (attachment.filename || `allegato_${id}`).replace(/[^a-zA-Z0-9._-]/g, '_');
const filePath = path.join(tempDir, `${id}_${safeName}`);
fs.writeFileSync(filePath, contentBuffer);
let command = `"" "${filePath}"`;
if (process.platform === 'win32') {
command = `start "" "${filePath}"`;
} else if (process.platform === 'darwin') {
command = `open "${filePath}"`;
} else {
command = `xdg-open "${filePath}"`;
}
exec(command, (err) => {
if (err) {
console.error('Error opening file via OS default app:', err);
return res.status(500).json({ error: 'Impossibile aprire il file con l\'applicazione di sistema: ' + err.message });
}
res.json({ message: 'File aperto con l\'applicazione predefinita di sistema', filePath });
});
} catch (err) {
console.error('Errore apertura allegato:', err);
res.status(500).json({ error: err.message });
}
});
// POST /api/tickets/merge — Merge tickets (Issue #7) // POST /api/tickets/merge — Merge tickets (Issue #7)
router.post('/merge', async (req, res) => { router.post('/merge', async (req, res) => {
const { targetId, sourceIds } = req.body; const { targetId, sourceIds } = req.body;
+52
View File
@@ -0,0 +1,52 @@
const fs = require('fs');
const path = require('path');
const https = require('https');
const vendorDir = path.join(__dirname, '..', 'public', 'vendor');
if (!fs.existsSync(vendorDir)) {
fs.mkdirSync(vendorDir, { recursive: true });
}
const files = [
{ url: 'https://cdn.jsdelivr.net/npm/quill@2.0.2/dist/quill.snow.css', dest: 'quill.snow.css' },
{ url: 'https://cdn.jsdelivr.net/npm/quill@2.0.2/dist/quill.js', dest: 'quill.js' },
{ url: 'https://cdn.jsdelivr.net/npm/chart.js', dest: 'chart.js' },
{ url: 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js', dest: 'pdf.min.js' },
{ url: 'https://cdn.jsdelivr.net/npm/pdf-lib@1.17.1/dist/pdf-lib.min.js', dest: 'pdf-lib.min.js' }
];
function download(url, destPath) {
return new Promise((resolve, reject) => {
https.get(url, (res) => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
return download(res.headers.location, destPath).then(resolve).catch(reject);
}
if (res.statusCode !== 200) {
return reject(new Error(`Failed to download ${url}: status ${res.statusCode}`));
}
const file = fs.createWriteStream(destPath);
res.pipe(file);
file.on('finish', () => {
file.close(() => {
console.log(`Downloaded: ${path.basename(destPath)} (${fs.statSync(destPath).size} bytes)`);
resolve();
});
});
}).on('error', (err) => {
reject(err);
});
});
}
async function main() {
for (const f of files) {
const destPath = path.join(vendorDir, f.dest);
try {
await download(f.url, destPath);
} catch (err) {
console.error(`Error downloading ${f.dest}:`, err.message);
}
}
}
main();
+145
View File
@@ -0,0 +1,145 @@
const iconv = require('iconv-lite');
/**
* Decodes MIME encoded-words (e.g. =?UTF-8?B?...?= or =?ISO-8859-1?Q?...?=)
*/
function decodeMimeWords(str) {
if (!str || typeof str !== 'string') return str || '';
if (!str.includes('=?')) return str;
return str.replace(/=\?([^?]+)\?([BQbq])\?([^?]+)\?=/g, (fullMatch, charset, encoding, data) => {
try {
const cs = charset.toLowerCase();
const enc = encoding.toUpperCase();
let buf;
if (enc === 'B') {
buf = Buffer.from(data, 'base64');
} else if (enc === 'Q') {
const qDec = data.replace(/_/g, ' ').replace(/=([0-9A-Fa-f]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
buf = Buffer.from(qDec, 'binary');
}
if (buf) {
if (iconv.encodingExists(cs)) {
return iconv.decode(buf, cs);
} else {
return buf.toString('utf-8');
}
}
} catch (_) {
return fullMatch;
}
return fullMatch;
});
}
/**
* Decodes raw Quoted-Printable strings (e.g. =E0=E8=E9=F9 or =C3=A8)
*/
function decodeQuotedPrintable(str, charset = 'utf-8') {
if (!str || typeof str !== 'string') return str || '';
if (!/=(?:[0-9A-Fa-f]{2}|\r?\n)/.test(str)) return str;
try {
const cleaned = str.replace(/=\r?\n/g, '');
const bytes = [];
for (let i = 0; i < cleaned.length; i++) {
if (cleaned[i] === '=' && i + 2 < cleaned.length && /[0-9A-Fa-f]{2}/.test(cleaned.substring(i + 1, i + 3))) {
bytes.push(parseInt(cleaned.substring(i + 1, i + 3), 16));
i += 2;
} else {
bytes.push(cleaned.charCodeAt(i));
}
}
const buf = Buffer.from(bytes);
if (iconv.encodingExists(charset)) {
return iconv.decode(buf, charset);
}
return buf.toString('utf-8');
} catch (_) {
return str;
}
}
/**
* Main text decoder & Mojibake repair utility
*/
function cleanAndDecodeText(rawInput, contentTypeHint = '') {
if (!rawInput && rawInput !== 0) return '';
let text = '';
// 1. Buffer / Base64 / String normalization
if (Buffer.isBuffer(rawInput)) {
let charset = 'utf-8';
const match = (contentTypeHint || '').match(/charset=["']?([^"';\s]+)/i);
if (match && match[1]) charset = match[1].toLowerCase();
try {
if (iconv.encodingExists(charset)) {
text = iconv.decode(rawInput, charset);
} else {
text = rawInput.toString('utf-8');
}
} catch (_) {
text = rawInput.toString('utf-8');
}
} else if (typeof rawInput === 'string') {
const cleaned = rawInput.replace(/\s+/g, '');
if (cleaned.length > 20 && cleaned.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(cleaned)) {
try {
const buf = Buffer.from(cleaned, 'base64');
const utfStr = buf.toString('utf-8');
// Only accept base64 decode if result doesn't look like corrupted binary noise
if (utfStr && !utfStr.includes('\uFFFD')) {
text = utfStr;
} else {
text = rawInput;
}
} catch (_) {
text = rawInput;
}
} else {
text = rawInput;
}
} else {
return String(rawInput);
}
// 2. Decode MIME words (e.g. =?UTF-8?B?...?= or =?ISO-8859-1?Q?...?=)
if (text.includes('=?')) {
text = decodeMimeWords(text);
}
// 3. Decode Quoted-Printable if present (and not inside HTML tags)
if (/=(?:[0-9A-Fa-f]{2})/.test(text) && !text.includes('<html') && !text.includes('<div') && !text.includes('<p>')) {
text = decodeQuotedPrintable(text);
}
// 4. Fix Mojibake / Double-UTF-8 / Win1252 / ISO-8859-1 mis-decoding
if (/(?:Ã[\s\xa0¡-ÿ]|â€[™œ]|–|Â[°©®])/.test(text)) {
try {
const reEncoded = iconv.encode(text, 'win1252');
const repaired = iconv.decode(reEncoded, 'utf-8');
if (repaired && !repaired.includes('\uFFFD')) {
text = repaired;
}
} catch (_) {}
}
// 6. Clean stray Mojibake/control characters like ý, ÿ, or U+FFFD () replacement symbols
if (/[ýÿ\uFFFD]/.test(text)) {
text = text.replace(/ý{1,}/g, '')
.replace(/ÿ{1,}/g, '')
.replace(/\uFFFD{1,}/g, '');
}
return text;
}
module.exports = {
cleanAndDecodeText,
decodeMimeWords,
decodeQuotedPrintable
};