From d32522bcbb6aeb6fa7151f055a8c97fb67405c56 Mon Sep 17 00:00:00 2001 From: Gabriele Cimaschi Date: Mon, 5 Oct 2026 18:00:34 +0200 Subject: [PATCH] feat: aggiunta ricerca tramite regex nella pagina ricerca supodrata con modal che fornisce rapide indicazioni. --- db.js | 4 + public/css/style.css | 28 +++++ public/js/views/ricercaSpudorata.js | 172 ++++++++++++++++++++++++++-- routes/tickets.js | 51 ++++++--- 4 files changed, 233 insertions(+), 22 deletions(-) diff --git a/db.js b/db.js index 988b26a..73d1e1a 100644 --- a/db.js +++ b/db.js @@ -40,6 +40,10 @@ if (dbType === 'mysql' || dbType === 'mariadb') { // 2. ILIKE -> LIKE (MySQL LIKE is case-insensitive by default) 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 translatedSql = translatedSql.replace(/md5\(random\(\)::text\s*\|\|\s*clock_timestamp\(\)::text\)/gi, 'MD5(CONCAT(RAND(), NOW()))'); diff --git a/public/css/style.css b/public/css/style.css index 5b1972c..353a582 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -3062,4 +3062,32 @@ body { 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; } \ No newline at end of file diff --git a/public/js/views/ricercaSpudorata.js b/public/js/views/ricercaSpudorata.js index 3f9740f..e131402 100644 --- a/public/js/views/ricercaSpudorata.js +++ b/public/js/views/ricercaSpudorata.js @@ -4,6 +4,7 @@ */ const RicercaSpudorataView = { searchTerm: '', + isRegex: false, cachedTickets: null, currentPage: 1, perPage: 50, @@ -29,6 +30,10 @@ const RicercaSpudorataView = { const urlParams = new URLSearchParams((window.location.hash.split('?')[1]) || ''); const qParam = urlParams.get('q'); + const regexParam = urlParams.get('regex'); + if (regexParam !== null) { + this.isRegex = regexParam === '1' || regexParam === 'true'; + } if (qParam && qParam !== this.searchTerm) { this.renderContainer(container); @@ -62,12 +67,54 @@ const RicercaSpudorataView = { renderContainer(container) { container.innerHTML = ` -
+
πŸš€
-

Ricerca Testuale Spudorata

+
+

Ricerca Testuale Spudorata

+
+ + + + +
+

Esegui la ricerca nel testo sui ticket. I filtri applicati successivamente operano istantaneamente in cache locale senza fare nuove richieste al server.

@@ -78,11 +125,19 @@ const RicercaSpudorataView = {
- +
+ + + +