E3: interfaccia di formati, fotogrammi e conversione della libreria

Porta nell'interfaccia la tappa E3 sopra le API di WP3, così formati,
fotogrammi e conversione della libreria si usano senza toccare il server.

- Impostazioni › Esportazione: «Formati delle copie» (JPG dice «con
  perdita: qualità 92», MP4 «solo rimuxaggio») e «Conversione della
  libreria» con la domanda «Convertire anche i N file già in libreria?»
  («Solo i nuovi» per primo), stato, Interrompi, Riprendi, Riprova.
- Destinazione: sezione «Formati» con «Come le impostazioni generali»;
  «Copia in…»: riga «Formato: come la destinazione · Cambia», il
  riepilogo dice cosa si copia com'è e «con perdita».
- Nuova finestra «Fotogrammi…» (frames.js): dal visore parte all'istante
  del lettore, con anteprime; questo istante, uno ogni k secondi o N in
  tutto; formato; «Scarica» o «Nella cartella delle copie». Dalla
  selezione (Libreria e scheda account) le foto si saltano e lo dice.
- Visore: azione «Fotogramma», righe «· intero», «· PNG», «· fotogramma
  a 0:01,125 · PNG», righe «Convertito in …».
- Segno «Solo fotogrammi» sulle tessere, «Come sono» e «Note» nel
  resoconto, blocco «Conversione della libreria» nella Dashboard,
  conferma dell'eliminazione che conta i file convertiti.
- Il velo delle finestre sale sopra il visore (z-index 55).
- ExportInterfaceTests: elenchi dei titoli aggiornati alle due nuove
  sezioni delle impostazioni e al nuovo blocco della Dashboard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-28 01:33:11 +01:00
1 parent ab0d717424
commit 91f49cdbb9
11 files changed
+975 -39

No files matched your search

@@ -2,8 +2,10 @@
// work with its progress and «Interrompi»; the jobs to resume («Riprendi», «Annulla») and the folders in pause
// («Riprova»); the last jobs, each with its resoconto. The progress is asked every second while a copy works, every five
// seconds otherwise (decision D20), as the import does. A pause is an amber notice here, never the red strip.
// Tappa E3: the card «Conversione della libreria» (shown once it is on or has rows) and, in the resoconto, the files
// copied as they are per account and the «Note» (what a conversion could not keep, a file copied as it is).
import { api } from '../core/api.js';
import { api, withCarried } from '../core/api.js';
import { h, icon, fill, later } from '../core/dom.js';
import { t, at, bytes, capitalize, number } from '../core/text.js';
import { confirmDialog, dialog, label, showError, toast } from '../core/ui.js';
@@ -23,8 +25,9 @@ export async function mountExport(page) {
document.title = t('app.titoloPagina', { pagina: `${t('esportazione.dashboard.esportazione')} · ${t('attivita.titolo')}` });
const current = h('section.blocco.copia-in-corso');
const pending = h('section.blocco', { hidden: true });
const conversion = h('section.blocco.conversione-libreria', { hidden: true });
const recent = h('section.blocco');
fill(page.body, h('div.attivita.esportazione-dashboard', current, pending, recent));
fill(page.body, h('div.attivita.esportazione-dashboard', current, pending, conversion, recent));
let overview = null;
let runs = [];
@@ -48,6 +51,7 @@ export async function mountExport(page) {
api('/api/export/runs?limit=20', { signal: page.signal }),
]);
drawPending();
drawConversion();
drawRecent();
} catch (error) {
if (error.name !== 'AbortError') showError(error);
@@ -212,6 +216,38 @@ export async function mountExport(page) {
again();
}
// ------------------------------------------------------------------------------------------- library conversion
function drawConversion() {
const c = overview && overview.libraryConversion;
conversion.hidden = !c || !(c.on || c.pending || c.converted || c.failed || c.asIs);
if (conversion.hidden) {
conversion.replaceChildren();
return;
}
const buttons = [];
if (c.paused) buttons.push(h('button.btn.piccolo', { type: 'button', onclick: (e) => conversionCommand('resume', e.currentTarget) }, icon('play', 's'), t('esportazione.conversione.riprendi')));
else if (c.on || c.pending) buttons.push(h('button.btn.piccolo', { type: 'button', onclick: (e) => conversionCommand('pause', e.currentTarget) }, icon('pause', 's'), t('esportazione.conversione.interrompi')));
if (c.failed) buttons.push(h('button.btn.piccolo', { type: 'button', onclick: (e) => conversionCommand('retry', e.currentTarget) }, icon('rotate-cw', 's'), t('esportazione.conversione.riprova')));
buttons.push(h('a.btn.nudo.piccolo', { href: withCarried('/impostazioni/esportazione') }, t('esportazione.dashboard.conversioneImpostazioni')));
fill(conversion,
h('div.testa-blocco', h('h2', t('esportazione.dashboard.conversione'))),
h('div.pannello.scheda-conversione',
h('div.riga-conteggi', h('span', c.on ? c.text : `${c.text} · ${t('esportazione.dashboard.conversioneSpenta')}`), buttons),
c.waiting && !c.paused ? h('p.avviso.ambra', icon('hourglass', 's'), h('span', c.waiting)) : null));
}
async function conversionCommand(command, button) {
button.disabled = true;
try {
const result = await api(`/api/export/library-conversion/${command}`, { method: 'POST' });
toast(result.message);
} catch (error) {
button.disabled = false;
showError(error);
}
again();
}
// ------------------------------------------------------------------------------------------- ultimi lavori
function drawRecent() {
const head = h('div.testa-blocco', h('h2', t('esportazione.dashboard.ultimi')));
@@ -258,6 +294,9 @@ async function openReport(run) {
if (r.completedAt) when.push(t('esportazione.dashboard.finita', { quando: at(r.completedAt) }));
const states = FILE_STATES.filter((s) => report.byState[s]).map((s) => t(`esportazione.dashboard.statiFile.${s}`, { n: report.byState[s] }));
if (report.bytesCopied) states.push(t('esportazione.dashboard.copiatiByte', { spazio: bytes(report.bytesCopied) }));
// Tappa E3: the files copied as they are, per kind («3 HEIC»), in a column only when some job file was.
const asIsText = (a) => Object.entries(a.asIs || {}).filter(([, n]) => n).map(([kind, n]) => `${number(n)} ${kind}`).join(', ');
const withAsIs = report.accounts.some((a) => asIsText(a));
const accounts = report.accounts.length
? h('div.pannello', h('table.tab.resoconto-account',
h('thead', h('tr',
@@ -265,13 +304,19 @@ async function openReport(run) {
h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.copiati')),
h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.gia')),
h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.saltati')),
h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.falliti')))),
h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.falliti')),
withAsIs ? h('th', { scope: 'col' }, t('esportazione.dashboard.comeSono')) : null)),
h('tbody', report.accounts.map((a) => h('tr',
h('td', `@${a.username}`),
h('td.num.dati', number(a.copied)),
h('td.num.dati', number(a.alreadyCopied)),
h('td.num.dati', number(a.skipped)),
h('td.num.dati', number(a.failed)))))))
h('td.num.dati', number(a.failed)),
withAsIs ? h('td.dati', asIsText(a)) : null)))))
: null;
const notes = report.notes && report.notes.length
? h('div.pannello', h('ul.elenco-attivita.problemi-copia.note-copia', report.notes.map((p) => h('li',
h('div.chi-cosa', h('b', `@${p.username}`, p.path ? h('span.codice.dati', p.path) : null), h('span', p.text))))))
: null;
const problems = report.problems.length
? h('div.pannello', h('ul.elenco-attivita.problemi-copia', report.problems.map((p) => h('li',
@@ -287,7 +332,9 @@ async function openReport(run) {
accounts ? h('h3', t('esportazione.dashboard.perAccount')) : null,
accounts,
h('h3', t('esportazione.dashboard.problemi')),
problems),
problems,
notes ? h('h3', t('esportazione.dashboard.note')) : null,
notes),
footer: h('footer', h('div.destra', h('button.btn', { type: 'button', autofocus: true, onclick: () => close() }, t('comune.chiudi')))),
}),
});