Interfaccia: niente notifiche laterali, messaggio al centro solo per ciò che conta
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
0e3ad6c867
commit
9624832cc8
14 files changed
+95
-49
No files matched your search
@@ -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
|
||||
|
||||
+4
-1
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
<div class="bottom-log" id="bottom-log" aria-live="polite"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toasts" id="toasts"></div>
|
||||
<noscript>L'interfaccia di Bidoo BidBot ha bisogno di JavaScript.</noscript>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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);
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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; } },
|
||||
|
||||
@@ -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); }
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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' } });
|
||||
|
||||
@@ -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
|
||||
* <c>important</c>, 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();
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user