From 9624832cc8ec6e79e43aae7c65dcc627b47f6ce5 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Mon, 28 Sep 2026 11:14:50 +0200 Subject: [PATCH] =?UTF-8?q?Interfaccia:=20niente=20notifiche=20laterali,?= =?UTF-8?q?=20messaggio=20al=20centro=20solo=20per=20ci=C3=B2=20che=20cont?= =?UTF-8?q?a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le notifiche che comparivano in basso a destra a ogni azione finivano in mezzo all'interfaccia mentre la si usava. Ora una conferma di routine (seguire un prodotto, cambiare modo, salvare paletti o impostazioni, copiare) si vede solo da ciò che cambia nella pagina: la stella, il bottone acceso, la riga, il bottone che dice «Salvato» o «Copiato». Un messaggio al centro, da chiudere con OK, resta per gli errori e per le informazioni importanti: esito di una puntata vera, accesso a Bidoo e cookie incollati, verifica della connessione, studio, correzione, recupero e statistiche dei prodotti, limiti consigliati applicati, messaggio di prova Telegram, manutenzione. L'avviso che un'asta Attiva non punta in modalità OSSERVA compare una volta sola. Corretto anche il testo «null» che compariva in Impostazioni prima della prima manutenzione e nella barra di Apprendimento fuori dal simulatore. tools/Screenshots con --messaggio verifica che il messaggio a schermo compaia. Co-Authored-By: Claude Opus 5.5 --- Mimante/CHANGELOG.md | 5 ++- Mimante/CLAUDE.md | 5 ++- Mimante/src/BidooBidBot/wwwroot/css/app.css | 10 ++--- Mimante/src/BidooBidBot/wwwroot/index.html | 1 - Mimante/src/BidooBidBot/wwwroot/js/app.js | 7 +-- .../BidooBidBot/wwwroot/js/pages/accesso.js | 6 +-- .../wwwroot/js/pages/apprendimento.js | 8 ++-- .../src/BidooBidBot/wwwroot/js/pages/aste.js | 19 +++++--- .../src/BidooBidBot/wwwroot/js/pages/cerca.js | 8 ++-- .../wwwroot/js/pages/impostazioni.js | 10 +++-- .../BidooBidBot/wwwroot/js/pages/prodotti.js | 10 ++--- .../BidooBidBot/wwwroot/js/pages/registro.js | 2 +- Mimante/src/BidooBidBot/wwwroot/js/util.js | 44 ++++++++++++++----- Mimante/tools/Screenshots/Program.cs | 9 ++++ 14 files changed, 95 insertions(+), 49 deletions(-) diff --git a/Mimante/CHANGELOG.md b/Mimante/CHANGELOG.md index 73e8496..4af8d70 100644 --- a/Mimante/CHANGELOG.md +++ b/Mimante/CHANGELOG.md @@ -22,7 +22,10 @@ Prima versione di **Bidoo BidBot**, la riscrittura di AutoBidder come servizio D vincitore, durata, «se entrassi ora»; confronto con la realtà alla chiusura. - **Interfaccia web** senza framework: Aste, Cerca, Prodotti, Storico, Apprendimento, Accesso a Bidoo, Impostazioni, Registro; countdown animati dal browser, aggiornamenti a delta via WebSocket, pannelli - ridimensionabili, tema chiaro e scuro, finestra stretta. + ridimensionabili, tema chiaro e scuro, finestra stretta. Nessuna notifica che compare ai lati mentre + si lavora: le conferme di routine si vedono nell'interfaccia stessa, e solo errori e informazioni + importanti (puntate, sessione, risultati di studio, verifica, manutenzione) aprono un messaggio al + centro da chiudere con OK. - **Accesso assistito** a Bidoo con il browser del bot in streaming nell'interfaccia (CDP scritto a mano); sessione cifrata AES-256-GCM; ripiego «incolla i cookie». - **Simulatore interno** con lo stesso formato del sito: primo avvio senza sessione, riscaldamento del diff --git a/Mimante/CLAUDE.md b/Mimante/CLAUDE.md index ae781b2..d417f67 100644 --- a/Mimante/CLAUDE.md +++ b/Mimante/CLAUDE.md @@ -47,7 +47,10 @@ da password e avvisa su Telegram. C# / .NET 10, interfaccia HTML/CSS/JS senza fr PostgreSQL usano `[Collection("Database")]` e saltano se manca `TEST_DB_HOST`. - **Interfaccia:** ogni numero, campo e intestazione ha un `title` che dice esattamente cos'è; aggiornamento chirurgico del DOM (mai ri-renderizzare la griglia, vedi `wwwroot/js/grid.js`); - layout fluido con maniglie; token di colore solo da `wwwroot/css/tokens.css`. Dopo ogni + layout fluido con maniglie; token di colore solo da `wwwroot/css/tokens.css`. **Niente + notifiche che compaiono ai lati**: una conferma di routine si vede già nell'interfaccia + (stella, bottone del modo, riga); un messaggio al centro (`notice`, `report(ack, { important: true })` + in `wwwroot/js/util.js`) solo per errori e informazioni importanti. Dopo ogni modifica all'interfaccia: `tools/Screenshots` contro il bot in locale deve finire con «Nessun errore JavaScript», e le schermate vanno guardate. - **Due mondi separati:** sito vero e simulatore (`Host/BotWorld`). I dati del simulatore hanno diff --git a/Mimante/src/BidooBidBot/wwwroot/css/app.css b/Mimante/src/BidooBidBot/wwwroot/css/app.css index 34f30e3..6c4681b 100644 --- a/Mimante/src/BidooBidBot/wwwroot/css/app.css +++ b/Mimante/src/BidooBidBot/wwwroot/css/app.css @@ -315,11 +315,11 @@ table.grid .spacer-row td { padding: 0; border: 0; } .modal .content { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; } .modal footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; } .modal .field { grid-template-columns: minmax(0, 1fr) minmax(0, 220px); } -.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); } -.toast { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); padding: 10px 12px; box-shadow: 0 6px 24px var(--shadow); } -.toast.ok { border-left-color: var(--ok); } -.toast.warn { border-left-color: var(--warn); } -.toast.bad { border-left-color: var(--bad); } +/* messaggio importante al centro (util.notice): la barra a sinistra dice il tipo */ +.notice { margin: 0; padding: 2px 0 2px 12px; border-left: 4px solid var(--accent); white-space: pre-line; overflow-wrap: anywhere; } +.notice.ok { border-left-color: var(--ok); color: var(--text); } +.notice.warn { border-left-color: var(--warn); color: var(--text); } +.notice.bad { border-left-color: var(--bad); color: var(--text); } .conn-lost { position: fixed; top: calc(var(--topbar-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 40; } /* catalogo: categorie a sinistra */ diff --git a/Mimante/src/BidooBidBot/wwwroot/index.html b/Mimante/src/BidooBidBot/wwwroot/index.html index fa548d3..cdb2662 100644 --- a/Mimante/src/BidooBidBot/wwwroot/index.html +++ b/Mimante/src/BidooBidBot/wwwroot/index.html @@ -19,7 +19,6 @@
-
diff --git a/Mimante/src/BidooBidBot/wwwroot/js/app.js b/Mimante/src/BidooBidBot/wwwroot/js/app.js index 192f589..99ce479 100644 --- a/Mimante/src/BidooBidBot/wwwroot/js/app.js +++ b/Mimante/src/BidooBidBot/wwwroot/js/app.js @@ -1,6 +1,6 @@ // Avvio dell'interfaccia: barra in alto, menu, pagine (#/aste, #/cerca…), registro in basso. -import { el, $, num, euro, bytes, time, store, toast, confirmDialog, report } from './util.js'; +import { el, $, num, euro, bytes, time, store, notice, confirmDialog, report } from './util.js'; import { conn, state, subscribe, send, post } from './state.js'; import { horizontalSplit } from './split.js'; @@ -229,8 +229,9 @@ function start() { subscribe('risk', renderRisk); subscribe('db', renderDb); subscribe('login.state', m => { - if (m.state === 'riuscito') toast(m.detail || 'Accesso a Bidoo riuscito', 'ok', 7000); - if (m.state === 'errore') toast(m.detail || 'Accesso non riuscito', 'bad', 7000); + // L'esito dell'accesso a Bidoo conta: cambia il mondo in cui lavora il bot. + if (m.state === 'riuscito' && m.detail && !m.detail.startsWith('Accesso riuscito: salvo')) notice(m.detail, 'ok', 'Accesso a Bidoo'); + if (m.state === 'errore') notice(m.detail || 'Accesso a Bidoo non riuscito.', 'bad', 'Accesso a Bidoo'); }); renderMode(); renderSession(); renderAccount(); renderNet(); renderRisk(); renderDb(); window.addEventListener('hashchange', route); diff --git a/Mimante/src/BidooBidBot/wwwroot/js/pages/accesso.js b/Mimante/src/BidooBidBot/wwwroot/js/pages/accesso.js index f6e649f..734d70b 100644 --- a/Mimante/src/BidooBidBot/wwwroot/js/pages/accesso.js +++ b/Mimante/src/BidooBidBot/wwwroot/js/pages/accesso.js @@ -40,7 +40,7 @@ function build() { const ua = el('input', { class: 'txt', placeholder: 'User-Agent del tuo browser', style: { width: '100%' }, value: navigator.userAgent, title: 'Lo User-Agent del browser da cui hai copiato i cookie: Bidoo lo lega alla sessione' }); const paste = el('button', { class: 'btn primary', type: 'button', onclick: async () => { const ack = await send({ t: 'session.paste', cookie: cookie.value, userAgent: ua.value }, 60000); - report(ack); + report(ack, { important: true }); if (ack.ok) cookie.value = ''; } }, 'Usa questi cookie'); @@ -68,7 +68,7 @@ function renderSession() { if (!bar) return; const pill = { ok: ['ok', 'Sessione valida'], verifica: ['warn', 'Verifica in corso'], scaduta: ['bad', 'Sessione scaduta'], simulatore: ['warn', 'Simulatore'], assente: ['muted', 'Nessuna sessione'] }[s.state] || ['muted', s.state || '—']; bar.replaceChildren(el('h1', null, 'Accesso a Bidoo'), el('span', { class: 'pill ' + pill[0] }, pill[1]), el('span', { class: 'spacer' }), - el('button', { class: 'btn', type: 'button', title: 'Chiede a Bidoo la pagina del conto: utente, saldo, credito', onclick: async () => report(await send({ t: 'session.verify' }, 30000)) }, 'Verifica connessione'), + el('button', { class: 'btn', type: 'button', title: 'Chiede a Bidoo la pagina del conto: utente, saldo, credito', onclick: async () => report(await send({ t: 'session.verify' }, 30000), { important: true }) }, 'Verifica connessione'), el('button', { class: 'btn', type: 'button', title: 'Cancella la sessione salvata e torna al simulatore', onclick: logout }, 'Disconnetti')); const banner = document.getElementById('session-banner'); @@ -98,7 +98,7 @@ async function logout() { async function openBrowser() { idle.replaceChildren(el('p', null, 'Avvio il browser del bot…')); const ack = await send({ t: 'login.open' }, 60000); - report(ack); + // L'esito si vede nel riquadro stesso (il browser compare, o il motivo per cui non parte). if (!ack.ok) { idle.replaceChildren(el('p', null, ack.msg || 'Browser non avviato.'), el('button', { class: 'btn primary', type: 'button', onclick: openBrowser }, 'Riprova'), diff --git a/Mimante/src/BidooBidBot/wwwroot/js/pages/apprendimento.js b/Mimante/src/BidooBidBot/wwwroot/js/pages/apprendimento.js index d759965..8254512 100644 --- a/Mimante/src/BidooBidBot/wwwroot/js/pages/apprendimento.js +++ b/Mimante/src/BidooBidBot/wwwroot/js/pages/apprendimento.js @@ -46,7 +46,7 @@ function renderToolbar(live) { el('h1', null, 'Apprendimento'), el('span', { class: 'pill ' + cls, title: s.detail }, label), el('span', { class: 'sub grow', title: s.detail }, `${s.detail} · campione: ${m.champion === 'rete' ? 'rete ' + m.network : 'regressione logistica'}`), - data.simulator ? el('span', { class: 'pill warn', title: 'Il modello del simulatore è separato da quello del sito vero (ml-sim)' }, 'simulatore') : null, + data.simulator ? el('span', { class: 'pill warn', title: 'Il modello del simulatore è separato da quello del sito vero (ml-sim)' }, 'simulatore') : '', el('span', { class: 'spacer' }), el('button', { class: 'btn', type: 'button', onclick: studyNow, title: 'Studia subito le aste chiuse che aspettano (di solito succede da sé)' }, 'Studia adesso'), el('button', { class: 'btn', type: 'button', onclick: recalc, title: 'Ricalcola la correzione sulle tue puntate vere da tutte quelle con esito' }, 'Ricalcola correzione'), @@ -145,12 +145,12 @@ async function studyNow() { const ack = await send({ t: 'learning.study_now' }, 30 * 60 * 1000); busy = false; progressBox?.remove(); progressBox = null; - report(ack); + report(ack, { important: true }); load(); } async function recalc() { - report(await send({ t: 'learning.recalc' }, 120000)); + report(await send({ t: 'learning.recalc' }, 120000), { important: true }); load(); } @@ -168,6 +168,6 @@ async function forget() { okText: 'Dimentica', danger: true, requireWord: 'DIMENTICA' }); if (!word) return; - report(await send({ t: 'learning.forget', confirm: word }, 120000)); + report(await send({ t: 'learning.forget', confirm: word }, 120000), { important: true }); load(); } diff --git a/Mimante/src/BidooBidBot/wwwroot/js/pages/aste.js b/Mimante/src/BidooBidBot/wwwroot/js/pages/aste.js index 94abdb7..e146451 100644 --- a/Mimante/src/BidooBidBot/wwwroot/js/pages/aste.js +++ b/Mimante/src/BidooBidBot/wwwroot/js/pages/aste.js @@ -1,7 +1,7 @@ // Aste (mockup 01, 07, 08): griglia per data-id con countdown animati dal client, azioni // per riga, pannello dettagli dell'asta selezionata con cinque schede. -import { el, $, num, euro, signedEuro, pct, time, timer, parseNum, store, toast, report, confirmDialog, modal, field, kv, badge, modeLabel, imageUrl, getJson, copyText } from '../util.js'; +import { el, $, num, euro, signedEuro, pct, time, timer, parseNum, store, notice, report, confirmDialog, modal, field, kv, badge, modeLabel, imageUrl, getJson, copyText } from '../util.js'; import { state, subscribe, send, post, remainingMs } from '../state.js'; import { Grid } from '../grid.js'; import { verticalSplit } from '../split.js'; @@ -178,9 +178,17 @@ function renderCounters() { // ── azioni ────────────────────────────────────────────────────────────── +let osservaExplained = false; + async function setMode(id, mode) { const ack = await send({ t: 'auction.set_mode', id, mode }); - if (!ack.ok || (ack.msg && ack.msg.includes('OSSERVA'))) report(ack); + if (!ack.ok) { report(ack); return; } + // Attiva con la modalità globale OSSERVA non punta: lo si spiega la prima volta, poi basta + // il chip OSSERVA in alto (e la riga nel registro dell'asta). + if (ack.msg && ack.msg.includes('OSSERVA') && !osservaExplained) { + osservaExplained = true; + notice(ack.msg, 'warn'); + } } async function setAll(mode) { @@ -195,7 +203,7 @@ async function bidNow(id) { const r = state.auctions.get(id); if (!r) return; if (!state.mode.live && !state.mode.simulator) { - toast('Modalità OSSERVA: nessuna puntata parte. Passa a DAL VIVO dalle Impostazioni per puntare davvero', 'warn', 6000); + notice('Modalità OSSERVA: nessuna puntata parte. Passa a DAL VIVO dalle Impostazioni per puntare davvero.', 'warn'); return; } const ok = await confirmDialog({ @@ -204,7 +212,8 @@ async function bidNow(id) { okText: 'Punta', danger: true }); if (!ok) return; - report(await send({ t: 'auction.bid_now', id, confirm: true })); + // Una puntata vera: l'esito si dice sempre. + report(await send({ t: 'auction.bid_now', id, confirm: true }), { important: true }); } async function removeAuction(id) { @@ -392,7 +401,7 @@ async function renderProduct(body) { advice, el('div', { class: 'row' }, el('a', { class: 'btn', href: d.url, target: '_blank', rel: 'noopener noreferrer', title: 'Apre l\'asta su Bidoo in una scheda nuova' }, 'Apri su Bidoo'), - el('button', { class: 'btn', type: 'button', onclick: () => copyText(d.url), title: 'Copia l\'indirizzo dell\'asta' }, 'Copia indirizzo'), + el('button', { class: 'btn', type: 'button', onclick: ev => copyText(d.url, ev.currentTarget), title: 'Copia l\'indirizzo dell\'asta' }, 'Copia indirizzo'), el('button', { class: 'btn', type: 'button', title: 'Rilegge la pagina dell\'asta: Compralo Ora, spedizione, foto', onclick: async () => { report(await send({ t: 'auction.refresh_product', id: d.id })); formFor = null; } }, 'Rileggi pagina'), el('button', { class: 'btn', type: 'button', title: d.followed ? 'Smetti di seguire il prodotto: le sue aste nuove non entreranno più da sole' : 'Segui il prodotto: le sue aste nuove entrano da sole in elenco', onclick: async () => { report(await send({ t: 'product.follow', key: d.productKey, name: d.name, productId: p.bidooProductId, followed: !d.followed })); formFor = null; } }, diff --git a/Mimante/src/BidooBidBot/wwwroot/js/pages/cerca.js b/Mimante/src/BidooBidBot/wwwroot/js/pages/cerca.js index a1e2067..ce44d7d 100644 --- a/Mimante/src/BidooBidBot/wwwroot/js/pages/cerca.js +++ b/Mimante/src/BidooBidBot/wwwroot/js/pages/cerca.js @@ -1,6 +1,6 @@ // Cerca: il catalogo di Bidoo per categoria, con ricerca, filtri e aggiunta in un clic. -import { el, num, euro, timer, store, report, getJson, imageUrl, toast } from '../util.js'; +import { el, num, euro, timer, store, report, getJson, imageUrl } from '../util.js'; import { send } from '../state.js'; import { Grid } from '../grid.js'; @@ -134,8 +134,6 @@ async function follow(r) { const next = !r.followed; const ack = await send({ t: 'product.follow', key: r.productKey, name: r.name, productId: r.productId, followed: next }); report(ack); - if (ack.ok) { - for (const x of grid.rows.values()) if (x.productKey === r.productKey) { x.followed = next; grid.update(x.id, null); } - if (next) toast('Le aste nuove del prodotto entreranno da sole al prossimo giro della sorveglianza', 'info'); - } + // La stella che diventa oro basta come conferma: nessun messaggio. + if (ack.ok) for (const x of grid.rows.values()) if (x.productKey === r.productKey) { x.followed = next; grid.update(x.id, null); } } diff --git a/Mimante/src/BidooBidBot/wwwroot/js/pages/impostazioni.js b/Mimante/src/BidooBidBot/wwwroot/js/pages/impostazioni.js index af2d6cc..07d342e 100644 --- a/Mimante/src/BidooBidBot/wwwroot/js/pages/impostazioni.js +++ b/Mimante/src/BidooBidBot/wwwroot/js/pages/impostazioni.js @@ -168,7 +168,7 @@ function render() { body.append(row); } if (sec.risk) body.append(el('div', { id: 'risk-box' })); - if (sec.telegram) body.append(el('div', { class: 'row' }, el('button', { class: 'btn', type: 'button', title: 'Manda un messaggio di prova con token e chat salvati', onclick: async () => report(await send({ t: 'telegram.test' }, 30000)) }, 'Invia messaggio di prova'), + if (sec.telegram) body.append(el('div', { class: 'row' }, el('button', { class: 'btn', type: 'button', title: 'Manda un messaggio di prova con token e chat salvati', onclick: async () => report(await send({ t: 'telegram.test' }, 30000), { important: true }) }, 'Invia messaggio di prova'), el('span', { class: 'help' }, system.telegramReady ? 'token e chat impostati' : 'token o chat mancanti'))); if (sec.data) body.append(el('div', { id: 'data-box' })); if (sec.net) body.append(el('div', { id: 'net-box' })); @@ -195,14 +195,15 @@ function renderData() { const box = document.getElementById('data-box'); if (!box) return; const d = state.db; - box.replaceChildren( + box.replaceChildren(...[ el('dl', { class: 'kv' }, el('dt', null, 'Usato adesso'), el('dd', null, `${bytes(d.sizeBytes)} su ${bytes(d.capBytes)}`), el('dt', null, 'Oltre il tetto si cancella prima'), el('dd', { style: { textAlign: 'right' } }, 'decisioni e puntate altrui più vecchie, poi i reset'), el('dt', null, 'Mai cancellato'), el('dd', { style: { textAlign: 'right' } }, 'aste, tue puntate, previsioni, prodotti, rischio'), el('dt', null, 'Ultima manutenzione'), el('dd', null, d.maintenanceAt ? dateTime(d.maintenanceAt) : '—')), d.maintenance ? el('p', { class: 'help', style: { margin: '6px 0' } }, d.maintenance) : null, - el('div', { class: 'row' }, el('button', { class: 'btn', type: 'button', title: 'Partizioni, rotazione dei dati, registri e backup adesso (di solito alle 04:30)', onclick: async () => report(await send({ t: 'maintenance.run', full: true }, 30 * 60 * 1000)) }, 'Esegui manutenzione adesso'))); + el('div', { class: 'row' }, el('button', { class: 'btn', type: 'button', title: 'Partizioni, rotazione dei dati, registri e backup adesso (di solito alle 04:30)', onclick: async () => report(await send({ t: 'maintenance.run', full: true }, 30 * 60 * 1000), { important: true }) }, 'Esegui manutenzione adesso')) + ].filter(Boolean)); } function renderNet() { @@ -251,4 +252,7 @@ async function save() { dirty.clear(); mark('', undefined); render(); + // La conferma sta nel bottone stesso, senza altri avvisi. + saveBtn.textContent = 'Salvato'; + setTimeout(() => { if (dirty.size === 0) saveBtn.textContent = 'Salva'; }, 1500); } diff --git a/Mimante/src/BidooBidBot/wwwroot/js/pages/prodotti.js b/Mimante/src/BidooBidBot/wwwroot/js/pages/prodotti.js index 58298f5..3ccc1f5 100644 --- a/Mimante/src/BidooBidBot/wwwroot/js/pages/prodotti.js +++ b/Mimante/src/BidooBidBot/wwwroot/js/pages/prodotti.js @@ -1,7 +1,7 @@ // Prodotti (mockup 04): schede con paletti e valore reale, prodotti seguiti, statistiche, // limiti consigliati (solo consigli, applicati su richiesta), aste del prodotto. -import { el, num, euro, when, store, report, getJson, imageUrl, confirmDialog, field, kv, parseNum, modeLabel } from '../util.js'; +import { el, num, euro, when, store, report, notice, getJson, imageUrl, confirmDialog, field, kv, parseNum, modeLabel } from '../util.js'; import { send, subscribe } from '../state.js'; import { Grid } from '../grid.js'; import { verticalSplit } from '../split.js'; @@ -73,10 +73,10 @@ async function follow(r) { async function applySuggested() { const n = rows.filter(r => r.adviceChanges).length; - if (n === 0) { report({ ok: true, msg: 'Nessuna scheda cambierebbe: i limiti sono già quelli consigliati (o mancano dati)' }); return; } + if (n === 0) { notice('Nessuna scheda cambierebbe: i limiti sono già quelli consigliati (o mancano dati).', 'info'); return; } const ok = await confirmDialog({ title: 'Usare i limiti consigliati?', body: `Cambiano prezzo massimo e puntate massime di ${n} prodotti. Sono consigli ricavati dalle chiusure passate: le aste già in elenco tengono i loro paletti.`, okText: `Applica a ${n} prodotti` }); if (!ok) return; - report(await send({ t: 'products.apply_suggested', confirm: true })); + report(await send({ t: 'products.apply_suggested', confirm: true }), { important: true }); await load(); } @@ -84,12 +84,12 @@ async function backfill() { const stop = subscribe('progress', m => { if (m.op === 'backfill') counts.textContent = `Recupero puntate dei vincitori: ${num(m.done)} su ${num(m.total)} (${m.detail || ''})`; }); const ack = await send({ t: 'products.backfill_winners' }, 60 * 60 * 1000); stop(); - report(ack); + report(ack, { important: true }); await load(); } async function refreshStats() { - report(await send({ t: 'products.refresh_stats' }, 120000)); + report(await send({ t: 'products.refresh_stats' }, 120000), { important: true }); await load(); } diff --git a/Mimante/src/BidooBidBot/wwwroot/js/pages/registro.js b/Mimante/src/BidooBidBot/wwwroot/js/pages/registro.js index 4e224fb..8fd46a7 100644 --- a/Mimante/src/BidooBidBot/wwwroot/js/pages/registro.js +++ b/Mimante/src/BidooBidBot/wwwroot/js/pages/registro.js @@ -11,7 +11,7 @@ export async function mount(host) { el('option', { value: 'error' }, 'Solo errori'), el('option', { value: 'ok' }, 'Riusciti'), el('option', { value: 'info' }, 'Informazioni')); tag = el('select', { class: 'txt', title: 'Categoria (il tag fra parentesi quadre)' }, el('option', { value: '' }, 'Tutte le categorie')); text = el('input', { class: 'txt', type: 'search', placeholder: 'Cerca nel registro…', style: { width: '240px' } }); - const copy = el('button', { class: 'btn', type: 'button', title: 'Copia le righe mostrate', onclick: () => copyText(entries.map(e => `${time(e.ts)} ${e.msg}`).join('\n')) }, 'Copia'); + const copy = el('button', { class: 'btn', type: 'button', title: 'Copia le righe mostrate', onclick: ev => copyText(entries.map(e => `${time(e.ts)} ${e.msg}`).join('\n'), ev.currentTarget) }, 'Copia'); host.append(el('div', { class: 'toolbar' }, el('h1', null, 'Registro'), level, tag, text, copy, el('span', { class: 'spacer' }), el('span', { class: 'sub' }, 'Una riga per evento. Le interrogazioni a Bidoo non si registrano; il registro di ogni asta è nel suo pannello e nel file aste-AAAA-MM-GG.log'))); list = el('div', { class: 'log', style: { fontFamily: 'var(--mono)', lineHeight: '1.55' } }); diff --git a/Mimante/src/BidooBidBot/wwwroot/js/util.js b/Mimante/src/BidooBidBot/wwwroot/js/util.js index 4662f55..f3330b0 100644 --- a/Mimante/src/BidooBidBot/wwwroot/js/util.js +++ b/Mimante/src/BidooBidBot/wwwroot/js/util.js @@ -126,19 +126,32 @@ export const store = { }; // ── avvisi ────────────────────────────────────────────────────────────── +// +// Niente notifiche che compaiono ai lati mentre si lavora: una conferma di routine si vede già +// nell'interfaccia (la stella diventa oro, il bottone del modo si accende, la riga compare). +// Un messaggio a schermo solo quando conta: errori, puntate, sessione, risultati di operazioni +// lunghe o chieste apposta (verifica, studio, esportazione, manutenzione). -export function toast(message, kind = 'info', ms = 4500) { - const host = document.getElementById('toasts'); - if (!host || !message) return; - const t = el('div', { class: 'toast ' + kind, role: 'status' }, message); - host.append(t); - setTimeout(() => t.remove(), ms); +const noticeTitles = { ok: 'Fatto', bad: 'Operazione non riuscita', warn: 'Attenzione', info: 'Informazione' }; +const openNotices = new Set(); + +/** Un messaggio importante al centro dello schermo, da chiudere con OK (o Invio, o Esc). */ +export function notice(message, kind = 'info', title) { + if (!message || openNotices.has(message)) return Promise.resolve(); + openNotices.add(message); + const content = el('p', { class: 'notice ' + kind }, message); + return modal({ title: title || noticeTitles[kind] || noticeTitles.info, content, buttons: [{ text: 'OK', kind: 'primary', value: null }] }) + .finally(() => openNotices.delete(message)); } -/** L'esito di un comando: verde o rosso con il messaggio del bot. */ -export function report(ack, okText) { +/** + * L'esito di un comando. Un errore si mostra sempre; un esito riuscito solo se + * important, altrimenti basta ciò che cambia nell'interfaccia. + */ +export function report(ack, { important = false } = {}) { if (!ack) return; - toast(ack.msg || (ack.ok ? okText || 'Fatto' : 'Non riuscito'), ack.ok ? 'ok' : 'bad'); + if (!ack.ok) notice(ack.msg || 'Il bot non ha eseguito il comando.', 'bad'); + else if (important && ack.msg) notice(ack.msg, 'ok'); } // ── dialoghi ──────────────────────────────────────────────────────────── @@ -231,9 +244,16 @@ export async function getJson(url) { return data; } -export function copyText(text) { - if (navigator.clipboard?.writeText) return navigator.clipboard.writeText(text).then(() => toast('Copiato', 'ok')); +/** Copia negli appunti; il bottone premuto dice «Copiato» per un momento, senza altri avvisi. */ +export function copyText(text, button) { + const done = () => { + if (!button) return; + const before = button.textContent; + button.textContent = 'Copiato'; + setTimeout(() => { button.textContent = before; }, 1500); + }; + if (navigator.clipboard?.writeText) return navigator.clipboard.writeText(text).then(done, () => notice('Il browser non ha permesso di copiare negli appunti.', 'bad')); const ta = el('textarea', { style: { position: 'fixed', opacity: 0 } }, text); - document.body.append(ta); ta.select(); document.execCommand('copy'); ta.remove(); toast('Copiato', 'ok'); + document.body.append(ta); ta.select(); document.execCommand('copy'); ta.remove(); done(); return Promise.resolve(); } diff --git a/Mimante/tools/Screenshots/Program.cs b/Mimante/tools/Screenshots/Program.cs index c156993..a906014 100644 --- a/Mimante/tools/Screenshots/Program.cs +++ b/Mimante/tools/Screenshots/Program.cs @@ -113,6 +113,15 @@ if (args.Contains("--accesso-assistito")) if (!frame) errors.Add("accesso assistito: nessun fotogramma dal browser del bot"); await Eval("document.querySelector('.browser .url button[title^=\"Chiudi\"]')?.click()"); } +if (args.Contains("--messaggio")) +{ + // Il messaggio a schermo per un'informazione importante: nel simulatore «Verifica + // connessione» risponde che non c'è una sessione. + await Shot("11-messaggio", "#/accesso", "[...document.querySelectorAll('#login-toolbar button')].find(b => b.textContent.startsWith('Verifica'))?.click()"); + if ((await Eval("!!document.querySelector('.modal .notice')")).ValueKind != JsonValueKind.True) + errors.Add("messaggio a schermo: nessun avviso dopo «Verifica connessione»"); + await Eval("document.querySelector('.modal footer .btn')?.click()"); +} await Shot("04-prodotti", "#/prodotti", clickFirst); await Shot("05-impostazioni", "#/impostazioni"); await Shot("06-storico", "#/storico", clickFirst);