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

+44 -1
View File
@@ -367,7 +367,7 @@ input[type=range].cursore:focus-visible{outline:2px solid var(--accento);outline
.breve svg{flex:none;margin-top:1px} .breve svg{flex:none;margin-top:1px}
/* dialoghi */ /* dialoghi */
.velo.finestra{position:fixed;z-index:40;padding:16px} .velo.finestra{position:fixed;z-index:55;padding:16px}
.dialogo{max-height:calc(100vh - 32px);max-width:calc(100vw - 32px)} .dialogo{max-height:calc(100vh - 32px);max-width:calc(100vw - 32px)}
.dialogo header .btn.solo{margin-left:auto} .dialogo header .btn.solo{margin-left:auto}
.dialogo .contenuto{padding:10px 22px 18px;overflow:auto} .dialogo .contenuto{padding:10px 22px 18px;overflow:auto}
@@ -1213,6 +1213,49 @@ p.aiuto.descrizione-copie{margin-top:8px}
.problemi-copia li{min-height:0;padding:8px 14px} .problemi-copia li{min-height:0;padding:8px 14px}
.problemi-copia .chi-cosa b{white-space:normal} .problemi-copia .chi-cosa b{white-space:normal}
/* ---------- formati e fotogrammi (§4.10, tappa E3) ---------- */
.formati-copie{display:flex;flex-direction:column;gap:12px}
.scelta-formato{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px}
.scelta-formato > .etichetta{width:56px;margin:0}
.scelta-formato .nota-formato{flex-basis:100%;margin-left:68px}
.scelta-formato .gruppo{flex-wrap:wrap}
.parte-formati .formati-copie{margin-top:10px}
.sezione-conversione .stato-conversione{margin-top:6px}
.sezione-conversione .stato-conversione .avviso{margin-top:10px}
.riga-formato{margin-top:4px;padding-top:12px;border-top:1px solid var(--bordo)}
.riga-formato-testa{display:flex;align-items:center;gap:8px;font-size:13.5px}
.riga-formato-testa > svg{color:var(--testo-2)}
.riga-formato .formati-copie{margin-top:12px}
.riepilogo-copia .con-perdita{color:var(--ambra);font-weight:600}
.vis .scheda dd.riga-copia .nota-copia{flex-basis:100%;font-size:12.5px;color:var(--testo-2)}
.vis .scheda .basso .nota-fotogramma{text-align:center;font-size:12.5px}
.tess .segno .solo-fotogrammi{padding:0 5px}
.tess .segno .solo-fotogrammi .cornice{display:block;width:11px;height:9px;border:1.6px solid currentColor;border-radius:2px;box-shadow:inset 0 0 0 1.4px rgba(0,0,0,.58),inset 0 0 0 3px currentColor}
.dialogo.fotogrammi{width:640px}
.dialogo.fotogrammi .gruppo{flex-wrap:wrap}
.modo-fotogrammi{margin-top:12px;display:flex;flex-direction:column;gap:8px}
.anteprima-fotogramma{display:flex;justify-content:center;align-items:center;min-height:120px;background:#141414;border-radius:var(--r-pannello);overflow:hidden}
.anteprima-fotogramma img{display:block;max-width:100%;max-height:320px;object-fit:contain}
input[type=range].cursore.scorri-fotogramma{width:100%}
.riga-tempo{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.riga-tempo > .etichetta{margin:0}
.riga-tempo .aiuto{margin:0}
.campo-tempo{width:auto}
.campo-tempo input{border:0;background:transparent;outline:none;width:9ch;font:inherit;color:inherit}
.striscia-fotogrammi{display:flex;flex-wrap:wrap;gap:8px;align-items:flex-end}
.striscia-fotogrammi:empty{display:none}
.fotogramma-piccolo{margin:0;display:flex;flex-direction:column;align-items:center;gap:3px}
.fotogramma-piccolo img{display:block;height:72px;width:auto;max-width:128px;object-fit:cover;border-radius:var(--r-tessera);background:var(--barra)}
.fotogramma-piccolo figcaption{font-size:12px;color:var(--testo-2)}
.altri-fotogrammi{font-size:12.5px;padding-bottom:20px}
.dialogo.fotogrammi .nota-perdita,.dialogo.fotogrammi .nota-audio{margin-top:8px}
.dialogo.fotogrammi .dati-video{margin-bottom:4px}
.riepilogo-fotogrammi{margin-top:12px}
.riepilogo-fotogrammi .avviso{margin-top:6px}
.scheda-conversione{padding:14px 16px}
.scheda-conversione .riga-conteggi{margin-top:0}
.scheda-conversione .avviso{margin:10px 0 0}
/* ---------- animazioni: solo in risposta a un gesto, e mai con le animazioni ridotte ---------- */ /* ---------- animazioni: solo in risposta a un gesto, e mai con le animazioni ridotte ---------- */
@keyframes febe-compare{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}} @keyframes febe-compare{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.dialogo,.menu,.breve{animation:febe-compare .14s ease-out} .dialogo,.menu,.breve{animation:febe-compare .14s ease-out}
+6
View File
@@ -5,6 +5,7 @@
// Copies to external folders (spec §4.10, tappa E2): in Contenuti the menu of the CSV icon, «Copia in…» in the // Copies to external folders (spec §4.10, tappa E2): in Contenuti the menu of the CSV icon, «Copia in…» in the
// selection bar and the «Copie» filter; in Impostazioni the block «Copie esterne» under «Cartella», with «Esporta // selection bar and the «Copie» filter; in Impostazioni the block «Copie esterne» under «Cartella», with «Esporta
// questo account» (on unless switched off), the folder of the copies and «312 su 1.204 non ancora copiati». // questo account» (on unless switched off), the folder of the copies and «312 su 1.204 non ancora copiati».
// Tappa E3: «Fotogrammi…» in the selection bar of Contenuti, as in the Libreria.
import { api, download, withCarried } from '../core/api.js'; import { api, download, withCarried } from '../core/api.js';
import { caps, serverNow } from '../core/context.js'; import { caps, serverNow } from '../core/context.js';
@@ -19,6 +20,7 @@ import { Mosaic, justify, tileElement, defaultDayLabel, filesDayLabel, modeSwitc
import { kindName, orderEditor, orderOrDefault } from './download-order.js'; import { kindName, orderEditor, orderOrDefault } from './download-order.js';
import { openViewer } from './viewer.js'; import { openViewer } from './viewer.js';
import { copiesApi, copiesLabel, copiesMenu, copyDialog, destinationDialog, exportButton, exportMenu, separator } from './export-dialogs.js'; import { copiesApi, copiesLabel, copiesMenu, copyDialog, destinationDialog, exportButton, exportMenu, separator } from './export-dialogs.js';
import { framesDialog } from './frames.js';
const KINDS = [ const KINDS = [
{ key: 'post', api: 'posts', stat: 'posts', label: 'scheda.tipi.posts' }, { key: 'post', api: 'posts', stat: 'posts', label: 'scheda.tipi.posts' },
@@ -211,6 +213,10 @@ async function contentsTab(page, route, detail) {
copySelected: hasDestination copySelected: hasDestination
? () => copyDialog(mosaic.files ? { mediaIds: [...mosaic.selected] } : { entryIds: mosaic.selectedEntries().ids }) ? () => copyDialog(mosaic.files ? { mediaIds: [...mosaic.selected] } : { entryIds: mosaic.selectedEntries().ids })
: null, : null,
framesSelected: () => framesDialog({
selection: mosaic.files ? { mediaIds: [...mosaic.selected] } : { entryIds: mosaic.selectedEntries().ids },
hasDestination,
}),
deleteSelected: async () => { deleteSelected: async () => {
const { ids, files } = mosaic.selectedEntries(); const { ids, files } = mosaic.selectedEntries();
const removed = await confirmDelete(ids, mosaic.files ? { files: mosaic.selected.size, total: files } : null); const removed = await confirmDelete(ids, mosaic.files ? { files: mosaic.selected.size, total: files } : null);
@@ -2,8 +2,10 @@
// work with its progress and «Interrompi»; the jobs to resume («Riprendi», «Annulla») and the folders in pause // 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 // («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. // 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 { h, icon, fill, later } from '../core/dom.js';
import { t, at, bytes, capitalize, number } from '../core/text.js'; import { t, at, bytes, capitalize, number } from '../core/text.js';
import { confirmDialog, dialog, label, showError, toast } from '../core/ui.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')}` }); document.title = t('app.titoloPagina', { pagina: `${t('esportazione.dashboard.esportazione')} · ${t('attivita.titolo')}` });
const current = h('section.blocco.copia-in-corso'); const current = h('section.blocco.copia-in-corso');
const pending = h('section.blocco', { hidden: true }); const pending = h('section.blocco', { hidden: true });
const conversion = h('section.blocco.conversione-libreria', { hidden: true });
const recent = h('section.blocco'); 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 overview = null;
let runs = []; let runs = [];
@@ -48,6 +51,7 @@ export async function mountExport(page) {
api('/api/export/runs?limit=20', { signal: page.signal }), api('/api/export/runs?limit=20', { signal: page.signal }),
]); ]);
drawPending(); drawPending();
drawConversion();
drawRecent(); drawRecent();
} catch (error) { } catch (error) {
if (error.name !== 'AbortError') showError(error); if (error.name !== 'AbortError') showError(error);
@@ -212,6 +216,38 @@ export async function mountExport(page) {
again(); 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 // ------------------------------------------------------------------------------------------- ultimi lavori
function drawRecent() { function drawRecent() {
const head = h('div.testa-blocco', h('h2', t('esportazione.dashboard.ultimi'))); 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) })); 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] })); 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) })); 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 const accounts = report.accounts.length
? h('div.pannello', h('table.tab.resoconto-account', ? h('div.pannello', h('table.tab.resoconto-account',
h('thead', h('tr', 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.copiati')),
h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.gia')), 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.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('tbody', report.accounts.map((a) => h('tr',
h('td', `@${a.username}`), h('td', `@${a.username}`),
h('td.num.dati', number(a.copied)), h('td.num.dati', number(a.copied)),
h('td.num.dati', number(a.alreadyCopied)), h('td.num.dati', number(a.alreadyCopied)),
h('td.num.dati', number(a.skipped)), 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; : null;
const problems = report.problems.length const problems = report.problems.length
? h('div.pannello', h('ul.elenco-attivita.problemi-copia', report.problems.map((p) => h('li', ? 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.perAccount')) : null,
accounts, accounts,
h('h3', t('esportazione.dashboard.problemi')), 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')))), footer: h('footer', h('div.destra', h('button.btn', { type: 'button', autofocus: true, onclick: () => close() }, t('comune.chiudi')))),
}), }),
}); });
+103 -6
View File
@@ -2,12 +2,51 @@
// (folder: native picker on the desktop, the subfolders of /esporta in Docker; content types; «Come la libreria» or a // (folder: native picker on the desktop, the subfolders of /esporta in Docker; content types; «Come la libreria» or a
// scheme of its own with the «Risultato» tree), «Copia in…» (the summary of what would be copied, one row per // scheme of its own with the «Risultato» tree), «Copia in…» (the summary of what would be copied, one row per
// destination, «Copia di nuovo anche i N tolti o superati» unchecked), the menu of the CSV icon and the «Copie» filter. // destination, «Copia di nuovo anche i N tolti o superati» unchecked), the menu of the CSV icon and the «Copie» filter.
// «Automatica» and the formats are not shown in this tappa: there is nothing behind them yet (decisions D7, D8). // Tappa E3: the formats (the destination's «Formati» with «Come le impostazioni generali» first; the row «Formato: come
// la destinazione · Cambia» of «Copia in…», whose summary says what is copied as it is and «con perdita»).
// «Automatica» is not shown: tappa E5 acts on it (decision D8 of E2).
import { api } from '../core/api.js'; import { api } from '../core/api.js';
import { h, icon, fill, later } from '../core/dom.js'; import { h, icon, fill, later } from '../core/dom.js';
import { t, bytes } from '../core/text.js'; import { t, bytes } from '../core/text.js';
import { checkbox, dialog, menu, radio, showError, toast } from '../core/ui.js'; import { checkbox, dialog, menu, radio, segmented, showError, toast } from '../core/ui.js';
import { formatLabel } from './frames.js';
/** The formats of the copies by kind (wire names, decision D21), «Originale» first. */
export const FORMATS = { photo: ['original', 'jpg', 'png', 'webplossless'], video: ['original', 'mp4'] };
/**
* The control of one format («Foto» or «Video»): a segmented choice with what it means under it («con perdita: qualità
* 92» for JPG, «solo rimuxaggio, mai ricodifica» for MP4). first: an option before the formats ({ value, label }:
* «Come le impostazioni generali», «Come la destinazione»). onchange(value) after a choice; the returned node has
* select(value) to set it back.
*/
export function formatChoice({ kind, value, first = null, onchange }) {
const name = t(`esportazione.formati.${kind === 'photo' ? 'foto' : 'video'}`);
const note = h('p.aiuto.nota-formato');
const options = [...(first ? [first] : []), ...FORMATS[kind].map((f) => ({ value: f, label: formatLabel(f) }))];
const drawNote = (v) => {
const key = v === 'jpg' ? 'conPerdita' : v === 'mp4' ? 'soloRimux' : null;
fill(note, key ? t(`esportazione.formati.${key}`) : null);
note.hidden = !key;
};
const control = segmented({
label: name,
value,
options,
onchange: (v) => {
drawNote(v);
if (onchange) onchange(v);
},
});
drawNote(value);
const box = h('div.scelta-formato', { dataset: { tipo: kind } }, h('span.etichetta', name), control, note);
box.select = (v) => {
control.select(v);
drawNote(v);
};
return box;
}
/** Content types of a destination, as the API names them, in the order of the dialog. */ /** Content types of a destination, as the API names them, in the order of the dialog. */
export const TYPES = [ export const TYPES = [
@@ -123,6 +162,8 @@ export async function destinationDialog({ scope, accountId = null, username = ''
profile: (destination && destination.profileNamingScheme) || info.library.profile, profile: (destination && destination.profileNamingScheme) || info.library.profile,
errors: [], errors: [],
saving: false, saving: false,
photoFormat: (destination && destination.photoFormat) || 'general',
videoFormat: (destination && destination.videoFormat) || 'general',
}; };
return dialog({ return dialog({
@@ -345,6 +386,9 @@ export async function destinationDialog({ scope, accountId = null, username = ''
// «Automatica» is kept as stored: tappa E5 acts on it (decision D8). // «Automatica» is kept as stored: tappa E5 acts on it (decision D8).
automatic: destination ? destination.automatic : false, automatic: destination ? destination.automatic : false,
onlyNew: true, onlyNew: true,
// Tappa E3: «general» is «Come le impostazioni generali».
photoFormat: state.photoFormat,
videoFormat: state.videoFormat,
}; };
try { try {
const saved = await api(destination ? `/api/export/destinations/${destination.id}` : '/api/export/destinations', { method: destination ? 'PUT' : 'POST', body }); const saved = await api(destination ? `/api/export/destinations/${destination.id}` : '/api/export/destinations', { method: destination ? 'PUT' : 'POST', body });
@@ -358,6 +402,12 @@ export async function destinationDialog({ scope, accountId = null, username = ''
} }
} }
// ------------------------------------------------------------------------------- formats (tappa E3)
const asGeneral = { value: 'general', label: t('esportazione.formati.generali') };
const formatsPart = h('div.formati-copie',
formatChoice({ kind: 'photo', value: state.photoFormat, first: asGeneral, onchange: (v) => { state.photoFormat = v; } }),
formatChoice({ kind: 'video', value: state.videoFormat, first: asGeneral, onchange: (v) => { state.videoFormat = v; } }));
const body = h('div.contenuto', const body = h('div.contenuto',
h('section.parte-dialogo', h('section.parte-dialogo',
h('h3', t('esportazione.dialogo.cartella')), h('h3', t('esportazione.dialogo.cartella')),
@@ -367,6 +417,10 @@ export async function destinationDialog({ scope, accountId = null, username = ''
h('h3', t('esportazione.dialogo.tipi')), h('h3', t('esportazione.dialogo.tipi')),
h('p.aiuto', t('esportazione.dialogo.tipiAiuto')), h('p.aiuto', t('esportazione.dialogo.tipiAiuto')),
types, typesNote), types, typesNote),
h('section.parte-dialogo.parte-formati',
h('h3', t('esportazione.dialogo.formati')),
h('p.aiuto', t('esportazione.dialogo.formatiAiuto')),
formatsPart),
h('section.parte-dialogo', h('section.parte-dialogo',
h('h3', t('esportazione.dialogo.nomi')), h('h3', t('esportazione.dialogo.nomi')),
general ? h('p.aiuto', t('esportazione.dialogo.notaAccount')) : null, general ? h('p.aiuto', t('esportazione.dialogo.notaAccount')) : null,
@@ -410,6 +464,8 @@ function samePath(a, b) {
*/ */
export function copyDialog(selection, { title } = {}) { export function copyDialog(selection, { title } = {}) {
let copyAgain = false; let copyAgain = false;
// Tappa E3: the formats of this request only; null is «Come la destinazione».
const formats = { photo: null, video: null };
return dialog({ return dialog({
title: title || t('esportazione.copia.titolo'), title: title || t('esportazione.copia.titolo'),
className: 'copia-in', className: 'copia-in',
@@ -425,18 +481,55 @@ export function copyDialog(selection, { title } = {}) {
let againCount = 0; let againCount = 0;
let refocusAgain = false; let refocusAgain = false;
// «Formato: come la destinazione · Cambia»: the two controls open under the row, and a change asks the plan again.
const formatText = h('span.testo-formato');
const asDestination = { value: 'destination', label: t('esportazione.formati.comeDestinazione') };
const pick = (kind) => (v) => {
formats[kind] = v === 'destination' ? null : v;
drawFormat();
load();
};
const formatControls = h('div.formati-copie', { hidden: true },
formatChoice({ kind: 'photo', value: 'destination', first: asDestination, onchange: pick('photo') }),
formatChoice({ kind: 'video', value: 'destination', first: asDestination, onchange: pick('video') }));
const change = h('button.btn.nudo.piccolo', {
type: 'button',
'aria-expanded': 'false',
onclick: () => {
formatControls.hidden = !formatControls.hidden;
change.setAttribute('aria-expanded', String(!formatControls.hidden));
},
}, t('esportazione.copia.cambia'));
const formatRow = h('div.riga-formato', h('div.riga-formato-testa', icon('sliders-horizontal', 's'), formatText, change), formatControls);
function drawFormat() {
const same = t('esportazione.formati.comeDestinazione').toLowerCase();
fill(formatText, formats.photo || formats.video
? t('esportazione.copia.formatoScelto', { foto: formats.photo ? formatLabel(formats.photo) : same, video: formats.video ? formatLabel(formats.video) : same })
: t('esportazione.copia.formatoCome'));
}
drawFormat();
const planBox = h('div.piano-copia', { 'aria-live': 'polite' }, h('p.aiuto', t('esportazione.copia.conto')));
content.replaceChildren(planBox, formatRow);
function request() {
const b = { ...selection, copyAgain };
if (formats.photo) b.photoFormat = formats.photo;
if (formats.video) b.videoFormat = formats.video;
return b;
}
async function load() { async function load() {
const mine = ++token; const mine = ++token;
start.disabled = true; start.disabled = true;
try { try {
const result = await api('/api/export/plan', { method: 'POST', body: { ...selection, copyAgain } }); const result = await api('/api/export/plan', { method: 'POST', body: request() });
if (mine !== token) return; if (mine !== token) return;
plan = result; plan = result;
if (!copyAgain) againCount = result.removedOrSuperseded || 0; if (!copyAgain) againCount = result.removedOrSuperseded || 0;
draw(); draw();
} catch (error) { } catch (error) {
if (mine !== token) return; if (mine !== token) return;
fill(content, h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', error.message))); fill(planBox, h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', error.message)));
} }
} }
@@ -447,7 +540,11 @@ export function copyDialog(selection, { title } = {}) {
if (p.removedOrSuperseded) parts.push(t(copyAgain ? 'esportazione.copia.toltiDiNuovo' : 'esportazione.copia.tolti', { n: p.removedOrSuperseded })); if (p.removedOrSuperseded) parts.push(t(copyAgain ? 'esportazione.copia.toltiDiNuovo' : 'esportazione.copia.tolti', { n: p.removedOrSuperseded }));
if (p.notExported) parts.push(t('esportazione.copia.nonEsportati', { n: p.notExported })); if (p.notExported) parts.push(t('esportazione.copia.nonEsportati', { n: p.notExported }));
if (p.missing) parts.push(t('esportazione.copia.mancanti', { n: p.missing })); if (p.missing) parts.push(t('esportazione.copia.mancanti', { n: p.missing }));
for (const a of p.asIs || []) {
if (a.files) parts.push(t('esportazione.copia.comeSono', { n: a.files, tipo: a.label }));
}
if (p.files) parts.push(t('esportazione.copia.circa', { spazio: bytes(p.bytes) })); if (p.files) parts.push(t('esportazione.copia.circa', { spazio: bytes(p.bytes) }));
if (p.lossy) parts.push(h('span.con-perdita', t('esportazione.copia.conPerdita')));
const summary = h('p.riepilogo-copia', parts.flatMap((x, i) => (i ? [' · ', x] : [x]))); const summary = h('p.riepilogo-copia', parts.flatMap((x, i) => (i ? [' · ', x] : [x])));
const rows = p.destinations.filter((d) => d.files > 0 || d.problem).map((d) => h('li', const rows = p.destinations.filter((d) => d.files > 0 || d.problem).map((d) => h('li',
icon('hard-drive', 's'), icon('hard-drive', 's'),
@@ -479,7 +576,7 @@ export function copyDialog(selection, { title } = {}) {
const again = choice const again = choice
? h('div.di-nuovo', choice, h('p.aiuto', t('esportazione.copia.diNuovoAiuto'))) ? h('div.di-nuovo', choice, h('p.aiuto', t('esportazione.copia.diNuovoAiuto')))
: null; : null;
fill(content, summary, rows.length ? h('ul.destinazioni-copia.pannello', rows) : null, empty, again); fill(planBox, summary, rows.length ? h('ul.destinazioni-copia.pannello', rows) : null, empty, again);
if (refocusAgain && choice) choice.input.focus(); if (refocusAgain && choice) choice.input.focus();
refocusAgain = false; refocusAgain = false;
fill(start, icon('copy'), t('esportazione.copia.pulsante', { n: p.files })); fill(start, icon('copy'), t('esportazione.copia.pulsante', { n: p.files }));
@@ -491,7 +588,7 @@ export function copyDialog(selection, { title } = {}) {
busy = true; busy = true;
start.disabled = true; start.disabled = true;
try { try {
const job = await api('/api/export/start', { method: 'POST', body: { ...selection, copyAgain } }); const job = await api('/api/export/start', { method: 'POST', body: request() });
toast(job.message, '', job.runIds.length ? { label: t('esportazione.copia.vediAvanzamento'), href: '/dashboard/esportazione' } : null); toast(job.message, '', job.runIds.length ? { label: t('esportazione.copia.vediAvanzamento'), href: '/dashboard/esportazione' } : null);
close(job); close(job);
} catch (error) { } catch (error) {
+454
View File
@@ -0,0 +1,454 @@
// «Fotogrammi…» (spec §4.10, §10.3, tappa E3; composed from the dialogs of mockup 13 and mockup 09): frames of a video
// from the viewer, opened at the player's time, or of the videos of a selection (Libreria and account tab; the photos
// are skipped and the dialog says so). Three ways to choose them: «Questo istante» (scrubber and time field with a
// preview), «Uno ogni k secondi», «N in tutto» (with a strip of the first previews); the format (JPG, PNG, WEBP senza
// perdita; PNG by default, JPG says «con perdita»); and where they go: «Scarica» (one image, or a zip) or «Nella
// cartella delle copie» (an export job to the folder of each account, only when one exists). «Il fotogramma non ha
// l'audio» is always said. The dialog never writes a file itself: the server does, through its usual addresses.
import { api, withCarried } from '../core/api.js';
import { h, icon, fill, later, uid } from '../core/dom.js';
import { t, number, bytes } from '../core/text.js';
import { dialog, radio, segmented, showError, toast } from '../core/ui.js';
/** Frame formats as the API names them (decision D21), with PNG first: the default (§16 domanda 35). */
export const FRAME_FORMATS = ['png', 'jpg', 'webplossless'];
/** How many previews the strip shows before «e altri N». */
const STRIP = 6;
/** The label of a format («JPG», «WEBP senza perdita», «Originale»). */
export function formatLabel(format) {
return t(`esportazione.formati.${format || 'original'}`);
}
/** «0:01», «0:01,25», «1:02:03» (decision D13): milliseconds only when the instant is not a whole second. */
export function instantLabel(ms) {
const total = Math.max(0, Math.round(Number(ms) || 0));
const whole = Math.floor(total / 1000);
const rest = total % 1000;
const hours = Math.floor(whole / 3600);
const minutes = Math.floor((whole % 3600) / 60);
const seconds = String(whole % 60).padStart(2, '0');
const base = hours > 0 ? `${hours}:${String(minutes).padStart(2, '0')}:${seconds}` : `${minutes}:${seconds}`;
return rest ? `${base},${String(rest).padStart(3, '0').replace(/0+$/, '')}` : base;
}
/** «0:12», «0:12,5», «12», «1:02:03,25» as milliseconds; null when it is not a time. */
export function parseInstant(text) {
const value = String(text || '').trim().replace(',', '.');
if (!/^(\d+:){0,2}\d+(\.\d{1,3})?$/.test(value)) return null;
const parts = value.split(':');
let seconds = 0;
for (const part of parts) seconds = seconds * 60 + Number(part);
return Number.isFinite(seconds) ? Math.round(seconds * 1000) : null;
}
/** «2», «0,5», «1.5» seconds as milliseconds; null when it is not a number. */
function parseSeconds(text) {
const value = String(text || '').trim().replace(',', '.');
if (!/^\d+(\.\d{1,3})?$/.test(value) && !/^\.\d{1,3}$/.test(value)) return null;
return Math.round(Number(value) * 1000);
}
/**
* Opens «Fotogrammi…». From the viewer: { mediaId, atMs, hasDestination } (one video, at the player's time). From a
* selection: { selection: { mediaIds } | { entryIds } | { query, mode }, hasDestination }. hasDestination: a folder of
* the copies exists for the files, so «Nella cartella delle copie» can be chosen. Resolves when the dialog closes.
*/
export function framesDialog({ mediaId = null, atMs = 0, selection = null, hasDestination = false }) {
const single = mediaId != null;
const chosen = single ? { mediaIds: [mediaId] } : selection;
const state = {
mode: 'istante',
atMs: Math.max(0, Math.round(atMs || 0)),
every: '2',
count: '6',
format: 'png',
output: 'scarica',
info: null,
};
return dialog({
title: t(single ? 'esportazione.fotogrammi.titolo' : 'esportazione.fotogrammi.titoloSelezione'),
className: 'fotogrammi',
build: (close) => {
const body = h('div.contenuto', h('p.aiuto', t('esportazione.fotogrammi.apro')));
const start = h('button.btn.primo', { type: 'button', disabled: true, onclick: () => go() }, icon('download'), t('esportazione.fotogrammi.pulsanteScarica', { n: 0 }));
const footer = h('footer', h('div.destra', h('button.btn.nudo', { type: 'button', onclick: () => close(undefined) }, t('comune.annulla')), start));
let busy = false;
let plan = null;
let planToken = 0;
let stripToken = 0;
let closed = false;
// ------------------------------------------------------------------------------- which frames
const modeBox = h('div.modo-fotogrammi');
const modes = segmented({
label: t('esportazione.fotogrammi.quali'),
value: state.mode,
options: [
{ value: 'istante', label: t('esportazione.fotogrammi.istante') },
{ value: 'ogni', label: t('esportazione.fotogrammi.ogni') },
{ value: 'numero', label: t('esportazione.fotogrammi.numero') },
],
onchange: (v) => {
state.mode = v;
drawMode();
changed();
},
});
const timeId = uid('istante');
const timeField = h('input.dati', { type: 'text', id: timeId, value: instantLabel(state.atMs), inputmode: 'decimal', spellcheck: 'false', autocomplete: 'off', size: '9' });
const timeBox = h('label.campo.campo-tempo', timeField);
const timeError = h('p.errore-testo', { hidden: true }, t('esportazione.fotogrammi.tempoErrato'));
const scrubber = h('input.cursore.scorri-fotogramma', { type: 'range', min: '0', max: '0', step: '1', value: String(state.atMs), 'aria-label': t('esportazione.fotogrammi.tempo') });
const preview = h('div.anteprima-fotogramma', { 'aria-live': 'polite' });
const shownLabel = h('p.aiuto.istante-mostrato', { 'aria-live': 'polite' });
const everyId = uid('ogni');
const everyField = h('input.dati', { type: 'text', id: everyId, value: state.every, inputmode: 'decimal', spellcheck: 'false', autocomplete: 'off', size: '5' });
const everyBox = h('label.campo.campo-tempo', everyField);
const everyError = h('p.errore-testo', { hidden: true }, t('esportazione.fotogrammi.ogniErrato'));
const countId = uid('numero');
const countField = h('input.dati', { type: 'number', id: countId, value: state.count, min: '1', max: '1000', step: '1' });
const countBox = h('label.campo.campo-tempo', countField);
const countError = h('p.errore-testo', { hidden: true }, t('esportazione.fotogrammi.numeroErrato'));
const strip = h('div.striscia-fotogrammi', { 'aria-live': 'polite' });
const typedTime = later(() => changed(), 250);
timeField.addEventListener('input', () => {
const ms = parseInstant(timeField.value);
timeError.hidden = ms != null;
timeBox.classList.toggle('errore', ms == null);
if (ms == null) {
drawStart();
return;
}
state.atMs = clampToVideo(ms);
scrubber.value = String(state.atMs);
typedTime();
});
const scrubbed = later(() => changed(), 120);
scrubber.addEventListener('input', () => {
state.atMs = Number(scrubber.value);
timeField.value = instantLabel(state.atMs);
timeError.hidden = true;
timeBox.classList.remove('errore');
scrubbed();
});
const typed = later(() => changed(), 300);
everyField.addEventListener('input', () => {
state.every = everyField.value;
typed();
drawErrors();
});
countField.addEventListener('input', () => {
state.count = countField.value;
typed();
drawErrors();
});
function clampToVideo(ms) {
return state.info && state.info.durationMs ? Math.min(ms, state.info.durationMs) : ms;
}
function everyMs() {
const ms = parseSeconds(state.every);
return ms != null && ms >= 100 ? ms : null;
}
function countValue() {
const n = Number(state.count);
return Number.isInteger(n) && n >= 1 && n <= 1000 ? n : null;
}
function drawErrors() {
everyError.hidden = state.mode !== 'ogni' || everyMs() != null;
everyBox.classList.toggle('errore', !everyError.hidden);
countError.hidden = state.mode !== 'numero' || countValue() != null;
countBox.classList.toggle('errore', !countError.hidden);
drawStart();
}
/** The request of the frames chosen, or null while a field is not valid. */
function request() {
const base = { mode: state.mode, format: state.format };
if (state.mode === 'istante') return parseInstant(timeField.value) == null ? null : { ...base, atMs: state.atMs };
if (state.mode === 'ogni') return everyMs() == null ? null : { ...base, everyMs: everyMs() };
return countValue() == null ? null : { ...base, count: countValue() };
}
function drawMode() {
if (state.mode === 'istante') {
fill(modeBox,
single ? preview : null,
single ? scrubber : null,
h('div.riga-tempo',
h('label.etichetta', { for: timeId }, t('esportazione.fotogrammi.tempo')), timeBox,
single ? shownLabel : h('p.aiuto', t('esportazione.fotogrammi.istanteSelezione'))),
timeError);
} else if (state.mode === 'ogni') {
fill(modeBox,
h('div.riga-tempo',
h('label.etichetta', { for: everyId }, t('esportazione.fotogrammi.ogniCampo')),
everyBox, h('span.muto', t('esportazione.fotogrammi.secondi'))),
everyError,
h('p.aiuto', t('esportazione.fotogrammi.ogniAiuto')),
single ? strip : null);
} else {
fill(modeBox,
h('div.riga-tempo',
h('label.etichetta', { for: countId }, t('esportazione.fotogrammi.numeroCampo')),
countBox),
countError,
h('p.aiuto', t('esportazione.fotogrammi.numeroAiuto')),
single ? strip : null);
}
drawErrors();
}
// ------------------------------------------------------------------------------- previews (one video)
function previewSrc(ms, max) {
return withCarried(`/api/media/${mediaId}/frame?at=${Math.max(0, Math.round(ms))}&max=${max}`);
}
async function drawPreviews() {
if (!single) return;
const wanted = request();
const mine = ++stripToken;
if (!wanted) return;
const q = new URLSearchParams({ mode: wanted.mode });
if (wanted.atMs != null) q.set('at', String(wanted.atMs));
if (wanted.everyMs != null) q.set('every', String(wanted.everyMs));
if (wanted.count != null) q.set('count', String(wanted.count));
if (state.mode === 'istante') {
// The picture follows the scrubber at once; the instant really shown comes with the list.
const img = preview.querySelector('img') || h('img', { alt: t('esportazione.fotogrammi.anteprima') });
img.src = previewSrc(state.atMs, 480);
if (!img.isConnected) fill(preview, img);
}
let list;
try {
list = await api(`/api/media/${mediaId}/frames/instants?${q}`);
} catch (error) {
if (mine !== stripToken || closed) return;
fill(strip, h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', error.message)));
return;
}
if (mine !== stripToken || closed) return;
if (state.mode === 'istante') {
const first = list.instants[0];
fill(shownLabel, first ? t('esportazione.fotogrammi.mostrato', { istante: first.label }) : '');
return;
}
if (list.problem) {
fill(strip, h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', list.problem)));
return;
}
const shown = list.instants.slice(0, STRIP);
const others = Math.max(0, list.total - shown.length);
fill(strip,
shown.map((x) => h('figure.fotogramma-piccolo',
h('img', { src: previewSrc(x.actualMs, 160), alt: '', loading: 'lazy' }),
h('figcaption.dati', x.label))),
others ? h('span.altri-fotogrammi.muto', t('esportazione.fotogrammi.altri', { n: others })) : null);
}
// ------------------------------------------------------------------------------- format and output
const lossyNote = h('p.aiuto.nota-perdita', { hidden: state.format !== 'jpg' }, icon('info', 'xs'), ' ', t('esportazione.formati.conPerdita'));
const formats = segmented({
label: t('esportazione.fotogrammi.formato'),
value: state.format,
options: FRAME_FORMATS.map((f) => ({ value: f, label: formatLabel(f) })),
onchange: (v) => {
state.format = v;
lossyNote.hidden = v !== 'jpg';
loadPlan();
},
});
const outputName = uid('uscita');
const pickOutput = (v) => {
state.output = v;
drawStart();
loadPlan();
};
const outputs = h('div.scelte', { role: 'radiogroup', 'aria-label': t('esportazione.fotogrammi.uscita') },
radio({ name: outputName, value: 'scarica', checked: true, onchange: pickOutput, labelNode: h('span', h('b', t('esportazione.fotogrammi.scarica')), h('small', t('esportazione.fotogrammi.scaricaAiuto'))) }),
(() => {
const r = radio({
name: outputName, value: 'cartella', checked: false, onchange: pickOutput,
labelNode: h('span', h('b', t('esportazione.fotogrammi.cartella')), h('small', t(hasDestination ? 'esportazione.fotogrammi.cartellaAiuto' : 'esportazione.fotogrammi.nessunaCartella'))),
});
if (!hasDestination) {
r.input.disabled = true;
r.classList.add('spenta');
}
return r;
})());
const summary = h('div.riepilogo-fotogrammi', { 'aria-live': 'polite' });
// ------------------------------------------------------------------------------- plan
const loadPlan = later(async () => {
const mine = ++planToken;
plan = null;
drawStart();
const frames = request();
if (!frames) {
summary.replaceChildren();
return;
}
fill(summary, h('p.aiuto', t('esportazione.fotogrammi.conto')));
try {
const result = state.output === 'cartella'
? await api('/api/export/plan', { method: 'POST', body: { ...chosen, frames } })
: await api('/api/frames/plan', { method: 'POST', body: { ...chosen, frames } });
if (mine !== planToken || closed) return;
plan = { kind: state.output, ...result };
drawSummary();
} catch (error) {
if (mine !== planToken || closed) return;
fill(summary, h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', error.message)));
}
drawStart();
}, 200);
function drawSummary() {
const p = plan;
if (p.kind === 'cartella') {
const parts = [h('b', p.summary || t('esportazione.fotogrammi.quanti', { n: p.frames }))];
if (p.notExported) parts.push(t('esportazione.copia.nonEsportati', { n: p.notExported }));
if (p.missing) parts.push(t('esportazione.copia.mancanti', { n: p.missing }));
const rows = (p.destinations || []).filter((d) => d.files > 0 || d.problem).map((d) => h('li',
icon('hard-drive', 's'),
h('div.chi-cosa',
h('b', t('esportazione.copia.verso', { nome: d.label }), ' ', h('span.dati.muto', `(${d.display})`)),
h('span', [
d.scope === 'account' && d.username ? t('esportazione.copia.versoAccount', { nome: d.username }) : t('esportazione.copia.versoGenerale'),
t('esportazione.fotogrammi.quanti', { n: d.files }),
d.freeBytes != null ? t('esportazione.copia.liberi', { spazio: bytes(d.freeBytes) }) : null,
].filter(Boolean).join(' · ')),
d.problem || d.paused ? h('div.avviso.ambra', icon('pause', 's'), h('span', t('esportazione.copia.inAttesa', { problema: d.problem || t('esportazione.inPausa') }))) : null)));
fill(summary,
h('p.riepilogo-copia', parts.flatMap((x, i) => (i ? [' · ', x] : [x]))),
rows.length ? h('ul.destinazioni-copia.pannello', rows) : null,
p.overCap ? h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', t('esportazione.fotogrammi.oltre'))) : null,
!p.frames && !p.overCap ? h('p.aiuto', t(p.hasDestination === false ? 'esportazione.copia.nessunaCartella' : 'esportazione.fotogrammi.nienteCartella')) : null);
} else {
fill(summary,
h('p.riepilogo-copia', h('b', p.summary)),
p.problem ? h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', p.problem)) : null,
!p.problem && p.needsQuiet ? h('p.aiuto', t('esportazione.fotogrammi.zipLungo')) : null);
}
}
function count() {
if (!plan) return 0;
return plan.frames || 0;
}
function drawStart() {
const n = count();
const download = state.output === 'scarica';
fill(start, icon(download ? 'download' : 'copy'), t(download ? 'esportazione.fotogrammi.pulsanteScarica' : 'esportazione.fotogrammi.pulsanteCopia', { n }));
const blocked = !plan || plan.kind !== state.output || !n || (download && plan.problem) || (!download && plan.overCap);
start.disabled = busy || Boolean(blocked) || !request();
}
function changed() {
drawPreviews();
loadPlan();
}
// ------------------------------------------------------------------------------- go
async function go() {
const frames = request();
if (!frames || busy || !plan) return;
busy = true;
drawStart();
try {
if (state.output === 'cartella') {
const job = await api('/api/export/start', { method: 'POST', body: { ...chosen, frames } });
toast(job.message, '', job.runIds.length ? { label: t('esportazione.copia.vediAvanzamento'), href: '/dashboard/esportazione' } : null);
close(job);
} else {
const ready = await api('/api/frames/download-token', { method: 'POST', body: { ...chosen, frames } });
const a = h('a', { href: withCarried(ready.url), download: '' });
a.hidden = true;
document.body.append(a);
a.click();
a.remove();
toast(t('esportazione.fotogrammi.scaricati', { n: ready.frames }));
close(ready);
}
} catch (error) {
busy = false;
drawStart();
showError(error);
}
}
// ------------------------------------------------------------------------------- layout
function drawAll() {
fill(body,
h('section.parte-dialogo',
h('h3', t('esportazione.fotogrammi.quali')),
modes, modeBox),
h('section.parte-dialogo',
h('h3', t('esportazione.fotogrammi.formato')),
formats, lossyNote,
h('p.aiuto.nota-audio', icon('volume-x', 'xs'), ' ', t('esportazione.fotogrammi.audio'))),
h('section.parte-dialogo',
h('h3', t('esportazione.fotogrammi.uscita')),
outputs, summary));
drawMode();
changed();
}
async function begin() {
if (!single) {
drawAll();
return;
}
try {
state.info = await api(`/api/media/${mediaId}/frames/info`);
} catch (error) {
if (closed) return;
fill(body, h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', error.message)));
return;
}
if (closed) return;
if (!state.info.available) {
fill(body, h('div.avviso.ambra', icon('info', 's'), h('span', state.info.unavailable || t('esportazione.fotogrammi.nonDisponibile'))));
return;
}
scrubber.max = String(Math.max(0, state.info.durationMs));
state.atMs = clampToVideo(state.atMs);
scrubber.value = String(state.atMs);
timeField.value = instantLabel(state.atMs);
drawAll();
body.prepend(h('p.aiuto.dati-video', t('esportazione.fotogrammi.video', {
durata: instantLabel(state.info.durationMs),
l: number(state.info.width),
a: number(state.info.height),
})));
}
begin();
return {
body,
footer,
onClose: () => {
closed = true;
planToken++;
stripToken++;
loadPlan.cancel();
typed.cancel();
typedTime.cancel();
scrubbed.cancel();
},
};
},
});
}
+32 -9
View File
@@ -5,6 +5,8 @@
// «Tutte le foto» the selection is of files; the CSV list and «Elimina» work on the entries they belong to. // «Tutte le foto» the selection is of files; the CSV list and «Elimina» work on the entries they belong to.
// Copies to external folders (spec §4.10, tappa E2): the CSV icon is a menu («Esporta l'elenco (CSV)», «Copia i file // Copies to external folders (spec §4.10, tappa E2): the CSV icon is a menu («Esporta l'elenco (CSV)», «Copia i file
// in…»), «Copia in…» in the selection bar and the «Copie» filter, these two only once a folder of the copies exists. // in…»), «Copia in…» in the selection bar and the «Copie» filter, these two only once a folder of the copies exists.
// Tappa E3: «Fotogrammi…» in the selection bar (always: the photos are skipped and the dialog says so), and the
// confirmation of «Elimina» counts the converted files of the library that go with the entries.
import { api, download, withCarried } from '../core/api.js'; import { api, download, withCarried } from '../core/api.js';
import { caps } from '../core/context.js'; import { caps } from '../core/context.js';
@@ -17,6 +19,7 @@ import { Mosaic, modeSwitch, storedMode } from './mosaic.js';
import { welcome } from './welcome.js'; import { welcome } from './welcome.js';
import { openViewer } from './viewer.js'; import { openViewer } from './viewer.js';
import { copiesApi, copiesLabel, copiesMenu, copyDialog, exportButton as exportMenuButton, exportMenu } from './export-dialogs.js'; import { copiesApi, copiesLabel, copiesMenu, copyDialog, exportButton as exportMenuButton, exportMenu } from './export-dialogs.js';
import { framesDialog } from './frames.js';
const KINDS = [ const KINDS = [
{ key: 'tutto', api: 'all', label: 'libreria.tipi.all' }, { key: 'tutto', api: 'all', label: 'libreria.tipi.all' },
@@ -303,7 +306,7 @@ export default {
page.saveBar(null); page.saveBar(null);
return; return;
} }
page.saveBar(selectionBar(mosaic, selected, { cancel: () => setSelecting(false), exportSelected, deleteSelected, copySelected: hasDestinations ? copySelected : null })); page.saveBar(selectionBar(mosaic, selected, { cancel: () => setSelecting(false), exportSelected, deleteSelected, copySelected: hasDestinations ? copySelected : null, framesSelected }));
} }
function setSelecting(on) { function setSelecting(on) {
@@ -326,6 +329,10 @@ export default {
return copyDialog(mosaic.files ? { mediaIds: [...mosaic.selected] } : { entryIds: mosaic.selectedEntries().ids }); return copyDialog(mosaic.files ? { mediaIds: [...mosaic.selected] } : { entryIds: mosaic.selectedEntries().ids });
} }
function framesSelected() {
return framesDialog({ selection: mosaic.files ? { mediaIds: [...mosaic.selected] } : { entryIds: mosaic.selectedEntries().ids }, hasDestination: hasDestinations });
}
async function exportSelected() { async function exportSelected() {
try { try {
await download('/api/entries/export', { ids: mosaic.selectedEntries().ids }, 'febe-elementi.csv'); await download('/api/entries/export', { ids: mosaic.selectedEntries().ids }, 'febe-elementi.csv');
@@ -447,10 +454,11 @@ export default {
/** /**
* The bar of the selection (Libreria and account view): how many are chosen, «Esporta l'elenco», «Copia in…» (only * The bar of the selection (Libreria and account view): how many are chosen, «Esporta l'elenco», «Copia in…» (only
* with copySelected, when a folder of the copies exists) and «Elimina». With «Tutte le foto» it counts the files and * with copySelected, when a folder of the copies exists), «Fotogrammi…» (with framesSelected) and «Elimina». With
* says how many entries they belong to: the CSV list and «Elimina» work on those, «Copia in…» on the chosen files. * «Tutte le foto» it counts the files and says how many entries they belong to: the CSV list and «Elimina» work on
* those, «Copia in…» and «Fotogrammi…» on the chosen files.
*/ */
export function selectionBar(mosaic, selected, { cancel, exportSelected, deleteSelected, copySelected = null }) { export function selectionBar(mosaic, selected, { cancel, exportSelected, deleteSelected, copySelected = null, framesSelected = null }) {
const n = selected.size; const n = selected.size;
const entries = mosaic.selectedEntries().ids.length; const entries = mosaic.selectedEntries().ids.length;
let note = t('selezione.nessuno'); let note = t('selezione.nessuno');
@@ -462,6 +470,7 @@ export function selectionBar(mosaic, selected, { cancel, exportSelected, deleteS
h('button.btn.nudo', { type: 'button', onclick: cancel }, t('selezione.annulla')), h('button.btn.nudo', { type: 'button', onclick: cancel }, t('selezione.annulla')),
h('button.btn', { type: 'button', disabled: !n, onclick: exportSelected }, icon('file-down'), t('selezione.esporta')), h('button.btn', { type: 'button', disabled: !n, onclick: exportSelected }, icon('file-down'), t('selezione.esporta')),
copySelected ? h('button.btn', { type: 'button', disabled: !n, onclick: copySelected }, icon('copy'), t('esportazione.selezione.copia')) : null, copySelected ? h('button.btn', { type: 'button', disabled: !n, onclick: copySelected }, icon('copy'), t('esportazione.selezione.copia')) : null,
framesSelected ? h('button.btn.fotogrammi-selezione', { type: 'button', disabled: !n, onclick: framesSelected }, icon('image'), t('esportazione.selezione.fotogrammi')) : null,
h('button.btn.pericolo', { type: 'button', disabled: !n, onclick: deleteSelected }, icon('trash-2'), t('selezione.elimina', { n: entries })))); h('button.btn.pericolo', { type: 'button', disabled: !n, onclick: deleteSelected }, icon('trash-2'), t('selezione.elimina', { n: entries }))));
} }
@@ -469,17 +478,31 @@ export function selectionBar(mosaic, selected, { cancel, exportSelected, deleteS
* «Elimina dalla libreria» with the confirmation of spec §4.6: by default the choice is remembered (state «eliminato», * «Elimina dalla libreria» with the confirmation of spec §4.6: by default the choice is remembered (state «eliminato»,
* never downloaded again); «Eliminalo e lascia che torni» forgets the entry. Returns the deleted keys, or null. * never downloaded again); «Eliminalo e lascia che torni» forgets the entry. Returns the deleted keys, or null.
* files: with «Tutte le foto», { files: chosen files, total: files of their entries }: the confirmation says that the * files: with «Tutte le foto», { files: chosen files, total: files of their entries }: the confirmation says that the
* whole entries go («3 file scelti appartengono a 2 elementi: elimino gli elementi interi, 9 file»). * whole entries go («3 file scelti appartengono a 2 elementi: elimino gli elementi interi, 9 file»). Tappa E3: the
* converted files of the library made from those entries go too, and the confirmation counts them («… 9 file e 2 file
* convertiti»), asked of the server before it opens.
*/ */
export async function confirmDelete(ids, files = null) { export async function confirmDelete(ids, files = null) {
const n = ids.length; const n = ids.length;
const whole = files let converted = 0;
? h('p', `${t('elimina.fileDi', { n: files.files, elementi: t('comune.elementi', { n }) })}: ${t('elimina.interi', { n, file: t('comune.file', { n: files.total }) })}`) if (n && n <= 5000) {
: null; try {
converted = (await api('/api/entries/delete-preview', { method: 'POST', body: { ids, mode: null } })).convertedFiles || 0;
} catch {
// the count is a courtesy: the deletion itself says what it removed
}
}
const convertedText = converted ? t('elimina.convertiti', { n: converted }) : '';
let whole = null;
if (files) {
const filesText = t('comune.file', { n: files.total });
const tail = converted ? t('elimina.interiConvertiti', { n, file: filesText, convertiti: convertedText }) : t('elimina.interi', { n, file: filesText });
whole = h('p', `${t('elimina.fileDi', { n: files.files, elementi: t('comune.elementi', { n }) })}: ${tail}`);
}
const mode = await confirmDialog({ const mode = await confirmDialog({
title: t('elimina.titolo', { n }), title: t('elimina.titolo', { n }),
text: t('elimina.testo', { n }), text: t('elimina.testo', { n }),
extra: h('div', whole, h('p.aiuto', t('elimina.tornaSpiega'))), extra: h('div', whole, !files && converted ? h('p.conta-convertiti', t('elimina.ancheConvertiti', { n: converted })) : null, h('p.aiuto', t('elimina.tornaSpiega'))),
buttons: [ buttons: [
{ label: t('comune.annulla'), value: undefined, kind: 'nudo' }, { label: t('comune.annulla'), value: undefined, kind: 'nudo' },
{ label: t('elimina.torna', { n }), value: 'allowReturn' }, { label: t('elimina.torna', { n }), value: 'allowReturn' },
+4
View File
@@ -143,6 +143,10 @@ export function tileElement(tile, width, height, { selected = false, today = '',
const parte = t('esportazione.segno.parte', { n: tile.copiesDone || 0, totale: tile.copiesDue || 0 }); const parte = t('esportazione.segno.parte', { n: tile.copiesDone || 0, totale: tile.copiesDue || 0 });
marks.push(h('span.copia.parte', { title: parte }, icon('copy'), `${tile.copiesDone || 0}/${tile.copiesDue || 0}`)); marks.push(h('span.copia.parte', { title: parte }, icon('copy'), `${tile.copiesDone || 0}/${tile.copiesDue || 0}`));
description.push(parte); description.push(parte);
} else if (tile.copies === 'frameOnly') {
// Tappa E3 (decision D4): only frames of it were copied, never the file. A frame drawn in CSS, no icon file.
marks.push(h('span.solo-fotogrammi', { title: t('esportazione.segno.fotogrammi') }, h('i.cornice', { 'aria-hidden': 'true' })));
description.push(t('esportazione.segno.fotogrammi'));
} }
const el = h(`button.tess${selected ? '.scelta' : ''}`, { const el = h(`button.tess${selected ? '.scelta' : ''}`, {
type: 'button', type: 'button',
@@ -1,14 +1,17 @@
// Impostazioni → Esportazione (spec §4.10, §10.3, tappa E2; composed from mockups 08 and 07): the general folder of // Impostazioni → Esportazione (spec §4.10, §10.3, tappa E2; composed from mockups 08 and 07): the general folder of
// the copies with its state («In pausa» with «Riprova», or the counts with «Controlla le copie»), «Lo stesso post in // the copies with its state («In pausa» with «Riprova», or the counts with «Controlla le copie»), «Lo stesso post in
// due account», the folders of the accounts, and in Docker the note on /esporta. Everything acts at once: there is no // due account», the folders of the accounts, and in Docker the note on /esporta. Everything acts at once: there is no
// save bar. The formats, the conversion of the library and «Automatica» come with later tappe (decisions D7, D8). // save bar. Tappa E3: «Formati delle copie» (Foto and Video, JPG says «con perdita: qualità 92», MP4 «solo
// rimuxaggio, mai ricodifica») and «Conversione della libreria» (the same two controls; turning one on asks «Convertire
// anche i N file già in libreria?» with «Solo i nuovi» first; the status line with «Interrompi», «Riprendi» and
// «Riprova i non riusciti»). «Automatica» comes with tappa E5 (decision D8 of E2).
import { api, withCarried } from '../core/api.js'; import { api, withCarried } from '../core/api.js';
import { h, icon, fill, later } from '../core/dom.js'; import { h, icon, fill, later } from '../core/dom.js';
import { t } from '../core/text.js'; import { t, bytes } from '../core/text.js';
import { confirmDialog, label, segmented, showError, toast } from '../core/ui.js'; import { confirmDialog, label, segmented, showError, toast } from '../core/ui.js';
import { heading } from './settings.js'; import { heading } from './settings.js';
import { countsText, describe, destinationDialog } from './export-dialogs.js'; import { countsText, describe, destinationDialog, formatChoice } from './export-dialogs.js';
export default async function exportSettings(page, box) { export default async function exportSettings(page, box) {
let overview = await api('/api/export', { signal: page.signal }); let overview = await api('/api/export', { signal: page.signal });
@@ -127,6 +130,110 @@ export default async function exportSettings(page, box) {
}, },
}); });
// ------------------------------------------------------------------------------------------- formats (tappa E3)
/** PUT /api/export/settings with some fields; the overview that comes back is the page's. */
async function saveSettings(fields) {
const result = await api('/api/export/settings', { method: 'PUT', body: fields });
if (result.overview) overview = result.overview;
toast(result.message);
return result;
}
function copyFormat(kind) {
const key = kind === 'photo' ? 'photoFormat' : 'videoFormat';
const control = formatChoice({
kind,
value: overview[key] || 'original',
onchange: async (v) => {
const before = overview[key];
try {
await saveSettings({ [key]: v });
} catch (error) {
control.select(before || 'original');
showError(error);
}
},
});
return control;
}
const formatsBox = h('div.formati-copie', copyFormat('photo'), copyFormat('video'));
// ------------------------------------------------------------------------------------------- library conversion
const conversionStatus = h('div.stato-conversione', { 'aria-live': 'polite' });
function libraryFormat(kind) {
const key = kind === 'photo' ? 'libraryPhotoFormat' : 'libraryVideoFormat';
const control = formatChoice({
kind,
value: overview[key] || 'original',
onchange: async (v) => {
const before = overview[key] || 'original';
try {
let convertExisting = false;
if (v !== 'original') {
// «Convertire anche i N file già in libreria?» (§16 domanda 29): «Solo i nuovi» first; closed, nothing changes.
const q = new URLSearchParams({ [kind]: v });
const preview = await api(`/api/export/library-conversion/preview?${q}`);
if (preview.files > 0) {
const answer = await confirmDialog({
title: t('esportazione.conversione.domanda', { n: preview.files }),
text: t('esportazione.conversione.domandaTesto'),
extra: h('p.aiuto.spazio-conversione', t('esportazione.conversione.spazio', { n: preview.files, spazio: bytes(preview.bytes) })),
buttons: [
{ label: t('esportazione.conversione.anche', { n: preview.files }), value: 'all', kind: '' },
{ label: t('esportazione.conversione.soloNuovi'), value: 'new', kind: 'primo', autofocus: true },
],
});
if (!answer) {
control.select(before);
return;
}
convertExisting = answer === 'all';
}
}
await saveSettings({ [key]: v, convertExisting });
drawConversion();
} catch (error) {
control.select(before);
showError(error);
}
},
});
return control;
}
const libraryBox = h('div.formati-copie', libraryFormat('photo'), libraryFormat('video'));
/** «In coda 12 · convertiti 340 · non riusciti 2 · non si convertono 3», why it waits, and its commands. */
function drawConversion() {
const c = overview.libraryConversion;
if (!c) {
conversionStatus.replaceChildren();
return;
}
const busy = c.pending > 0 || c.on;
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 (busy) buttons.push(h('button.btn.piccolo', { type: 'button', onclick: (e) => conversionCommand('pause', e.currentTarget) }, icon('pause', 's'), t('esportazione.conversione.interrompi')));
if (c.failed > 0) buttons.push(h('button.btn.piccolo', { type: 'button', onclick: (e) => conversionCommand('retry', e.currentTarget) }, icon('rotate-cw', 's'), t('esportazione.conversione.riprova')));
fill(conversionStatus,
h('div.riga-conteggi',
h('span.muto', c.on || c.pending || c.converted || c.failed || c.asIs ? c.text : t('esportazione.conversione.spenta')),
buttons),
c.waiting && !c.paused ? h('div.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);
await reload();
} catch (error) {
button.disabled = false;
showError(error);
}
}
// ------------------------------------------------------------------------------------------- own folders // ------------------------------------------------------------------------------------------- own folders
function drawOwn() { function drawOwn() {
const own = overview.own || []; const own = overview.own || [];
@@ -173,14 +280,17 @@ export default async function exportSettings(page, box) {
drawGeneral(); drawGeneral();
drawOwn(); drawOwn();
drawNotes(); drawNotes();
drawConversion();
} }
draw(); draw();
fill(box, fill(box,
h('div.sezione', heading(t('esportazione.titolo'), t('esportazione.aiuto')), noteBox, pendingBox), h('div.sezione', heading(t('esportazione.titolo'), t('esportazione.aiuto')), noteBox, pendingBox),
h('div.sezione', heading(t('esportazione.generale'), t('esportazione.generaleAiuto')), generalBox), h('div.sezione', heading(t('esportazione.generale'), t('esportazione.generaleAiuto')), generalBox),
h('div.sezione.sezione-formati', heading(t('esportazione.formati.titolo'), t('esportazione.formati.aiuto')), formatsBox),
h('div.sezione', heading(t('esportazione.stessoPost'), t('esportazione.stessoPostAiuto')), samePost), h('div.sezione', heading(t('esportazione.stessoPost'), t('esportazione.stessoPostAiuto')), samePost),
h('div.sezione', heading(t('esportazione.cartelleAccount'), t('esportazione.cartelleAccountAiuto')), ownBox)); h('div.sezione', heading(t('esportazione.cartelleAccount'), t('esportazione.cartelleAccountAiuto')), ownBox),
h('div.sezione.sezione-conversione', heading(t('esportazione.conversione.titolo'), t('esportazione.conversione.aiuto')), libraryBox, conversionStatus));
// Copies finished, a folder paused or changed elsewhere (another tab, an account card): the page follows. // Copies finished, a folder paused or changed elsewhere (another tab, an account card): the page follows.
const onChange = later(() => reload(), 500); const onChange = later(() => reload(), 500);
+56 -5
View File
@@ -1,7 +1,9 @@
// Visualizzatore (mockup 02, spec §4.6): covers the whole window; arrows and arrow keys move through the files of the // Visualizzatore (mockup 02, spec §4.6): covers the whole window; arrows and arrow keys move through the files of the
// series and then to the next entry; Esc closes; videos start muted. The side panel shows the data, the files and the // series and then to the next entry; Esc closes; videos start muted. The side panel shows the data, the files and the
// provenance, and the actions: «Mostra nella cartella» (desktop) or «Scarica» (browser), «Apri su Instagram» (in // provenance, and the actions: «Mostra nella cartella» (desktop) or «Scarica» (browser), «Apri su Instagram» (in
// Alberto's own browser, never in Febe's), «Elimina dalla libreria». // Alberto's own browser, never in Febe's), «Elimina dalla libreria». Tappa E3: «Fotogramma» on a video whose frames
// can be taken (the dialog «Fotogrammi…» opens at the player's time), the copy rows with their form («· intero», «· JPG»,
// «· fotogramma a 0:01 · PNG») and the converted files of the library next to the original («Convertito in PNG»).
import { api, withCarried } from '../core/api.js'; import { api, withCarried } from '../core/api.js';
import { caps, serverNow } from '../core/context.js'; import { caps, serverNow } from '../core/context.js';
@@ -11,6 +13,7 @@ import { t, dayName, capitalize, bytes, duration, number, ago, shortDay } from '
import { avatar, label, showError, toast } from '../core/ui.js'; import { avatar, label, showError, toast } from '../core/ui.js';
import { confirmDelete } from './library.js'; import { confirmDelete } from './library.js';
import { copyAgain, copyDialog } from './export-dialogs.js'; import { copyAgain, copyDialog } from './export-dialogs.js';
import { formatLabel, framesDialog } from './frames.js';
const KIND_ICON = { post: 'image', story: 'circle-dashed', highlight: 'star', tagged: 'square-user', profile: 'circle-user' }; const KIND_ICON = { post: 'image', story: 'circle-dashed', highlight: 'star', tagged: 'square-user', profile: 'circle-user' };
@@ -255,7 +258,8 @@ export function openViewer({ tile, source, origin, onDeleted }) {
entry.author ? row(t('vis.autore'), `@${entry.author}`) : null, entry.author ? row(t('vis.autore'), `@${entry.author}`) : null,
entry.media.length > 1 ? row(t('vis.posizione'), t('vis.posizioneDi', { n: fileIndex + 1, totale: entry.media.length })) : null, entry.media.length > 1 ? row(t('vis.posizione'), t('vis.posizioneDi', { n: fileIndex + 1, totale: entry.media.length })) : null,
entry.highlights.length ? row(t('vis.raccolte'), entry.highlights.join(', ')) : null, entry.highlights.length ? row(t('vis.raccolte'), entry.highlights.join(', ')) : null,
media && media.copies ? media.copies.map((c) => copyRow(c, media)) : null)), media && media.copies ? media.copies.map((c) => copyRow(c, media)) : null,
media && media.conversions ? media.conversions.map((c) => conversionRow(c)) : null)),
h('section', h('h3', t('vis.provenienza')), h('dl', h('section', h('h3', t('vis.provenienza')), h('dl',
row(t('vis.origine'), t(entry.provenance === 'imported' ? 'vis.importato' : 'vis.scaricato')), row(t('vis.origine'), t(entry.provenance === 'imported' ? 'vis.importato' : 'vis.scaricato')),
row(t('vis.quando'), downloaded)))); row(t('vis.quando'), downloaded))));
@@ -276,6 +280,14 @@ export function openViewer({ tile, source, origin, onDeleted }) {
if (entry.canCopy && media && media.available) { if (entry.canCopy && media && media.available) {
actions.push(h('button.btn', { type: 'button', onclick: () => copyDialog({ mediaIds: [media.id] }) }, icon('copy'), t('esportazione.vis.copiaIn'))); actions.push(h('button.btn', { type: 'button', onclick: () => copyDialog({ mediaIds: [media.id] }) }, icon('copy'), t('esportazione.vis.copiaIn')));
} }
// «Fotogramma» (spec §4.6, §4.10): only on a video whose frames can be taken; the others say why not.
if (media && media.kind === 'video' && media.available && !media.damaged) {
if (media.framesAvailable === false) {
actions.push(h('p.aiuto.nota-fotogramma', icon('info', 'xs'), ' ', t('esportazione.vis.fotogrammaNo')));
} else {
actions.push(h('button.btn.azione-fotogramma', { type: 'button', onclick: () => openFrames(media) }, icon('image'), t('esportazione.vis.fotogrammaAzione')));
}
}
if (entry.state !== 'deleted') { if (entry.state !== 'deleted') {
actions.push(h('button.btn.nudo.pericolo', { type: 'button', onclick: remove }, icon('trash-2'), t('vis.elimina'))); actions.push(h('button.btn.nudo.pericolo', { type: 'button', onclick: remove }, icon('trash-2'), t('vis.elimina')));
} }
@@ -290,7 +302,7 @@ export function openViewer({ tile, source, origin, onDeleted }) {
const today = caps().today; const today = caps().today;
const vars = { cartella: copy.destination, giorno: shortDay(copy.at.day, today), nome: copy.forAccount || '' }; const vars = { cartella: copy.destination, giorno: shortDay(copy.at.day, today), nome: copy.forAccount || '' };
const key = { copied: copy.forAccount ? 'copiatoPer' : 'copiato', removed: 'tolto', superseded: 'superato' }[copy.state] || 'fallito'; const key = { copied: copy.forAccount ? 'copiatoPer' : 'copiato', removed: 'tolto', superseded: 'superato' }[copy.state] || 'fallito';
const text = t(`esportazione.vis.${key}`, vars) + (copy.destinationRetired ? ` (${t('esportazione.vis.tolta')})` : ''); const text = t(`esportazione.vis.${key}`, vars) + copyForm(copy) + (copy.destinationRetired ? ` (${t('esportazione.vis.tolta')})` : '');
const busy = copying.has(copy.copyId); const busy = copying.has(copy.copyId);
const again = copy.canCopyAgain const again = copy.canCopyAgain
? h('button.btn.nudo.piccolo.copia-di-nuovo', { ? h('button.btn.nudo.piccolo.copia-di-nuovo', {
@@ -310,7 +322,47 @@ export function openViewer({ tile, source, origin, onDeleted }) {
}, },
}, icon('rotate-cw', 's'), t(busy ? 'esportazione.vis.inCopia' : 'esportazione.vis.diNuovo')) }, icon('rotate-cw', 's'), t(busy ? 'esportazione.vis.inCopia' : 'esportazione.vis.diNuovo'))
: null; : null;
return [h('dt', t('esportazione.vis.copia')), h('dd.riga-copia', h('span', text), again)]; return [h('dt', t('esportazione.vis.copia')), h('dd.riga-copia', h('span', text), again, copy.notes ? h('span.nota-copia', copy.notes) : null)];
}
/** «· intero», «· JPG», «· fotogramma a 0:01 · PNG» (decision D13 for the label of the instant). */
function copyForm(copy) {
if (copy.variant === 'frame') return t('esportazione.vis.fotogramma', { istante: copy.frameLabel || '', formato: formatLabel(copy.format) });
if (copy.variant === 'converted') return t('esportazione.vis.formato', { formato: formatLabel(copy.format) });
return t('esportazione.vis.intero');
}
/**
* A converted file of the library next to its original (§16 domanda 30): «Convertito in PNG · 2,1 MB» with «Scarica»
* or «Mostra nella cartella», and what was not kept (or why it does not convert) as a second line.
*/
function conversionRow(c) {
const vars = { formato: formatLabel(c.format), spazio: bytes(c.bytes || 0) };
const text = t(`esportazione.vis.conversioni.${c.state}`, vars);
let action = null;
if (c.available && (c.state === 'converted' || c.state === 'superseded')) {
action = caps().showInFolder
? h('button.btn.nudo.piccolo', { type: 'button', onclick: () => showConversion(c.id) }, icon('folder-open', 's'), t('esportazione.vis.mostraConvertito'))
: h('a.btn.nudo.piccolo', { href: withCarried(`/api/conversions/${c.id}/file?download=1`), download: c.fileName || '' }, icon('download', 's'), t('esportazione.vis.scaricaConvertito'));
}
return [h('dt', t('esportazione.vis.conversione')), h('dd.riga-copia.riga-conversione', h('span', text), action, c.notes ? h('span.nota-copia', c.notes) : null)];
}
async function showConversion(conversionId) {
try {
const result = await api('/api/conversions/show-in-folder', { method: 'POST', body: { conversionId } });
toast(result.message);
} catch (error) {
showError(error);
}
}
/** «Fotogrammi…» at the instant the player shows; the video waits while the dialog is open. */
function openFrames(media) {
const video = stage.querySelector('video');
const atMs = video && Number.isFinite(video.currentTime) ? Math.round(video.currentTime * 1000) : 0;
if (video) video.pause();
framesDialog({ mediaId: media.id, atMs, hasDestination: Boolean(entry.canCopy) });
} }
async function showInFolder(mediaId) { async function showInFolder(mediaId) {
@@ -358,5 +410,4 @@ export function openViewer({ tile, source, origin, onDeleted }) {
document.body.append(box); document.body.append(box);
closeButton.focus(); closeButton.focus();
load(tile.id, 0, files && tile.cover ? tile.cover.mediaId : null); load(tile.id, 0, files && tile.cover ? tile.cover.mediaId : null);
void withCarried;
} }
+108 -7
View File
@@ -178,7 +178,10 @@
"torna": "Eliminalo e lascia che torni|Eliminali e lascia che tornino", "torna": "Eliminalo e lascia che torni|Eliminali e lascia che tornino",
"tornaSpiega": "Con «lascia che torni» Febe dimentica l'elemento: se è ancora su Instagram, al prossimo controllo lo scarica di nuovo.", "tornaSpiega": "Con «lascia che torni» Febe dimentica l'elemento: se è ancora su Instagram, al prossimo controllo lo scarica di nuovo.",
"fileDi": "1 file scelto appartiene a {elementi}|{n} file scelti appartengono a {elementi}", "fileDi": "1 file scelto appartiene a {elementi}|{n} file scelti appartengono a {elementi}",
"interi": "elimino l'elemento intero, {file}.|elimino gli elementi interi, {file}." "interi": "elimino l'elemento intero, {file}.|elimino gli elementi interi, {file}.",
"interiConvertiti": "elimino l'elemento intero, {file} e {convertiti}.|elimino gli elementi interi, {file} e {convertiti}.",
"convertiti": "1 file convertito|{n} file convertiti",
"ancheConvertiti": "Si cancella anche 1 file convertito della libreria, fatto da questi file.|Si cancellano anche {n} file convertiti della libreria, fatti da questi file."
}, },
"vis": { "vis": {
"etichetta": "Visualizzatore", "etichetta": "Visualizzatore",
@@ -1123,6 +1126,35 @@
"eraDi": "era di @{nome}", "eraDi": "era di @{nome}",
"daRiprendere": "1 copia da riprendere.|{n} copie da riprendere.", "daRiprendere": "1 copia da riprendere.|{n} copie da riprendere.",
"apriEsportazione": "Apri l'esportazione", "apriEsportazione": "Apri l'esportazione",
"formati": {
"titolo": "Formati delle copie",
"aiuto": "Il formato dei file nelle cartelle delle copie. Un file già in quel formato si copia byte per byte; HEIC, AVIF, raw, immagini animate e ciò che non si converte si copiano come sono, e il resoconto lo dice. Un formato nuovo vale per i file non ancora copiati.",
"foto": "Foto",
"video": "Video",
"original": "Originale",
"jpg": "JPG",
"png": "PNG",
"webplossless": "WEBP senza perdita",
"mp4": "MP4",
"generali": "Come le impostazioni generali",
"comeDestinazione": "Come la destinazione",
"conPerdita": "con perdita: qualità 92",
"soloRimux": "solo rimuxaggio, mai ricodifica",
"originale": "i file si copiano come sono"
},
"conversione": {
"titolo": "Conversione della libreria",
"aiuto": "Febe può aggiungere nella libreria, accanto a ogni foto o video, il file convertito nel formato scelto. Il file convertito si aggiunge: l'originale resta, con il suo nome, e resta lui il file che si copia e da cui si prendono i fotogrammi. Lavora in sottofondo, mai durante una sessione del motore, e lascia il passo a importazioni, copie e ricostruzioni.",
"domanda": "Convertire anche il file già in libreria?|Convertire anche i {n} file già in libreria?",
"domandaTesto": "Da adesso ogni file nuovo si converte dopo lo scaricamento o l'importazione. Quelli già in libreria si convertono solo se lo chiedi.",
"spazio": "L'originale occupa circa {spazio}; il convertito può occupare di più.|Gli originali occupano circa {spazio}; i convertiti possono occupare di più.",
"soloNuovi": "Solo i nuovi",
"anche": "Anche quello già in libreria|Anche i {n} già in libreria",
"spenta": "Spenta: nessun file della libreria si converte.",
"interrompi": "Interrompi",
"riprendi": "Riprendi",
"riprova": "Riprova i non riusciti"
},
"dockerNota": "Le cartelle delle copie sono sottocartelle di {radice}, il disco o la condivisione montata nel contenitore. Febe non crea mai la cartella scelta: deve esistere già.", "dockerNota": "Le cartelle delle copie sono sottocartelle di {radice}, il disco o la condivisione montata nel contenitore. Febe non crea mai la cartella scelta: deve esistere già.",
"dialogo": { "dialogo": {
"titoloGenerale": "Cartella generale delle copie", "titoloGenerale": "Cartella generale delle copie",
@@ -1154,6 +1186,8 @@
"schemaProfilo": "Schema per le foto del profilo", "schemaProfilo": "Schema per le foto del profilo",
"segnaposto": "Segnaposto: {elenco}.", "segnaposto": "Segnaposto: {elenco}.",
"risultato": "Risultato", "risultato": "Risultato",
"formati": "Formati",
"formatiAiuto": "Il formato dei file copiati in questa cartella. «Come le impostazioni generali» segue Impostazioni → Esportazione, anche quando cambia.",
"salva": "Salva la cartella" "salva": "Salva la cartella"
}, },
"tipi": { "tipi": {
@@ -1185,7 +1219,12 @@
"nessunaCartella": "Nessuna cartella delle copie: scegline una in Impostazioni → Esportazione.", "nessunaCartella": "Nessuna cartella delle copie: scegline una in Impostazioni → Esportazione.",
"nienteNonEsportati": "Niente da copiare: questi file sono di account che non si esportano o di tipi che la cartella non copia.", "nienteNonEsportati": "Niente da copiare: questi file sono di account che non si esportano o di tipi che la cartella non copia.",
"pulsante": "Copia 1 file|Copia {n} file", "pulsante": "Copia 1 file|Copia {n} file",
"vediAvanzamento": "Apri l'esportazione" "vediAvanzamento": "Apri l'esportazione",
"formatoCome": "Formato: come la destinazione",
"formatoScelto": "Formato: foto {foto} · video {video}",
"cambia": "Cambia",
"comeSono": "circa 1 {tipo} copiato com'è|circa {n} {tipo} copiati come sono",
"conPerdita": "con perdita"
}, },
"filtro": { "filtro": {
"titolo": "Copie", "titolo": "Copie",
@@ -1196,19 +1235,35 @@
}, },
"segno": { "segno": {
"copiato": "copiato", "copiato": "copiato",
"parte": "copiato in parte, {n} file di {totale}" "parte": "copiato in parte, {n} file di {totale}",
"fotogrammi": "Solo fotogrammi"
}, },
"vis": { "vis": {
"copia": "Copia", "copia": "Copia",
"copiato": "Copiato in {cartella} il {giorno} · intero", "copiato": "Copiato in {cartella} il {giorno}",
"copiatoPer": "Copiato per @{nome} in {cartella} il {giorno} · intero", "copiatoPer": "Copiato per @{nome} in {cartella} il {giorno}",
"intero": " · intero",
"formato": " · {formato}",
"fotogramma": " · fotogramma a {istante} · {formato}",
"tolto": "Tolto da {cartella} il {giorno}", "tolto": "Tolto da {cartella} il {giorno}",
"superato": "Superato in {cartella} il {giorno}", "superato": "Superato in {cartella} il {giorno}",
"fallito": "Non riuscito in {cartella} il {giorno}", "fallito": "Non riuscito in {cartella} il {giorno}",
"tolta": "cartella tolta", "tolta": "cartella tolta",
"diNuovo": "Copia di nuovo", "diNuovo": "Copia di nuovo",
"inCopia": "In copia…", "inCopia": "In copia…",
"copiaIn": "Copia in…" "copiaIn": "Copia in…",
"fotogrammaAzione": "Fotogramma",
"fotogrammaNo": "Fotogramma non disponibile per questo video",
"conversione": "Convertito",
"conversioni": {
"converted": "Convertito in {formato} · {spazio}",
"superseded": "Convertito in {formato}, da una versione di prima · {spazio}",
"pending": "In coda per la conversione in {formato}",
"failed": "Conversione in {formato} non riuscita",
"asIs": "Non si converte in {formato}"
},
"scaricaConvertito": "Scarica",
"mostraConvertito": "Mostra nella cartella"
}, },
"account": { "account": {
"titolo": "Copie esterne", "titolo": "Copie esterne",
@@ -1232,7 +1287,48 @@
"copiaIn": "Copia in…" "copiaIn": "Copia in…"
}, },
"selezione": { "selezione": {
"copia": "Copia in…" "copia": "Copia in…",
"fotogrammi": "Fotogrammi…"
},
"fotogrammi": {
"titolo": "Fotogrammi",
"titoloSelezione": "Fotogrammi dei video scelti",
"apro": "Apro il video…",
"video": "Video di {durata}, {l} × {a} pixel.",
"quali": "Quali fotogrammi",
"istante": "Questo istante",
"ogni": "Uno ogni k secondi",
"numero": "N in tutto",
"tempo": "Istante",
"tempoErrato": "Scrivi l'istante come 0:12 o 0:12,5.",
"istanteSelezione": "Lo stesso istante in ogni video; oltre la fine, l'ultimo fotogramma.",
"mostrato": "Fotogramma a {istante}",
"anteprima": "Anteprima del fotogramma",
"ogniCampo": "Uno ogni",
"secondi": "secondi",
"ogniErrato": "Almeno 0,1 secondi.",
"ogniAiuto": "Dall'inizio del video: 0:00, poi ogni k secondi fino alla fine.",
"numeroCampo": "Fotogrammi in tutto",
"numeroErrato": "Da 1 a 1.000.",
"numeroAiuto": "Distribuiti in parti uguali, ognuno al centro della sua parte.",
"altri": "e altro 1|e altri {n}",
"formato": "Formato",
"audio": "Il fotogramma non ha l'audio.",
"uscita": "Dove",
"scarica": "Scarica",
"scaricaAiuto": "Un fotogramma si scarica com'è; più fotogrammi in uno zip.",
"cartella": "Nella cartella delle copie",
"cartellaAiuto": "Nella cartella delle copie di ogni account, accanto alle copie, con l'istante nel nome.",
"nessunaCartella": "Serve una cartella delle copie: scegline una in Impostazioni → Esportazione.",
"nonDisponibile": "Fotogramma non disponibile per questo video",
"conto": "Conto i fotogrammi…",
"quanti": "1 fotogramma|{n} fotogrammi",
"oltre": "Più di 1.000 fotogrammi per un video: scegli un intervallo più lungo",
"nienteCartella": "Niente da copiare: i video scelti non hanno fotogrammi, non si esportano o non sono in libreria.",
"zipLungo": "Più di 20 fotogrammi: lo zip si prepara solo fuori dalle sessioni del motore e quando nessun altro lavoro lungo è in corso.",
"pulsanteScarica": "Scarica 1 fotogramma|Scarica {n} fotogrammi",
"pulsanteCopia": "Copia 1 fotogramma|Copia {n} fotogrammi",
"scaricati": "Scaricamento del fotogramma avviato.|Scaricamento dei {n} fotogrammi avviato."
}, },
"libreria": { "libreria": {
"menu": "Esporta", "menu": "Esporta",
@@ -1299,6 +1395,11 @@
"falliti": "Non riusciti" "falliti": "Non riusciti"
}, },
"problemi": "File da guardare", "problemi": "File da guardare",
"note": "Note",
"comeSono": "Come sono",
"conversione": "Conversione della libreria",
"conversioneSpenta": "Spenta: si accende in Impostazioni → Esportazione.",
"conversioneImpostazioni": "Apri le impostazioni",
"nessunProblema": "Nessun file da guardare.", "nessunProblema": "Nessun file da guardare.",
"avvisoDaRiprendere": "1 copia da riprendere.|{n} copie da riprendere." "avvisoDaRiprendere": "1 copia da riprendere.|{n} copie da riprendere."
} }
+2 -2
View File
@@ -80,7 +80,7 @@ public sealed class ExportInterfaceTests
StringAssert.Contains(notes, "sottocartelle di /esporta", "la nota di Docker"); StringAssert.Contains(notes, "sottocartelle di /esporta", "la nota di Docker");
StringAssert.Contains(notes, "da riprendere", "il lavoro interrotto della demo"); StringAssert.Contains(notes, "da riprendere", "il lavoro interrotto della demo");
CollectionAssert.AreEqual( CollectionAssert.AreEqual(
new[] { "Esportazione", "Cartella generale", "Lo stesso post in due account", "Cartelle degli account" }, new[] { "Esportazione", "Cartella generale", "Formati delle copie", "Lo stesso post in due account", "Cartelle degli account", "Conversione della libreria" },
(await ui.EvalAsync<string[]>("[...document.querySelectorAll('.sezione h2')].map((x) => x.textContent)"))); (await ui.EvalAsync<string[]>("[...document.querySelectorAll('.sezione h2')].map((x) => x.textContent)")));
StringAssert.Contains((await ui.EvalAsync("document.querySelector('.stato-copie')?.textContent || ''")).GetString(), "copiati", "i conteggi della cartella"); StringAssert.Contains((await ui.EvalAsync("document.querySelector('.stato-copie')?.textContent || ''")).GetString(), "copiati", "i conteggi della cartella");
Assert.IsTrue((await ui.EvalAsync("[...document.querySelectorAll('.stato-copie button')].some((b) => b.textContent.includes('Controlla le copie'))")).GetBoolean(), "«Controlla le copie»"); Assert.IsTrue((await ui.EvalAsync("[...document.querySelectorAll('.stato-copie button')].some((b) => b.textContent.includes('Controlla le copie'))")).GetBoolean(), "«Controlla le copie»");
@@ -340,7 +340,7 @@ public sealed class ExportInterfaceTests
await ui.WaitAsync("location.pathname === '/dashboard/esportazione' && document.querySelector('.esportazione-dashboard .riga-riprendi') !== null", "la linguetta «Esportazione»"); await ui.WaitAsync("location.pathname === '/dashboard/esportazione' && document.querySelector('.esportazione-dashboard .riga-riprendi') !== null", "la linguetta «Esportazione»");
Assert.AreEqual("Esportazione", (await ui.EvalAsync("document.querySelector('.linguette-dashboard a.qui').textContent")).GetString()); Assert.AreEqual("Esportazione", (await ui.EvalAsync("document.querySelector('.linguette-dashboard a.qui').textContent")).GetString());
CollectionAssert.AreEqual(new[] { "In corso", "Da riprendere", "Ultimi lavori" }, await ui.EvalAsync<string[]>("[...document.querySelectorAll('.esportazione-dashboard h2')].map((x) => x.textContent)")); CollectionAssert.AreEqual(new[] { "In corso", "Da riprendere", "Conversione della libreria", "Ultimi lavori" }, await ui.EvalAsync<string[]>("[...document.querySelectorAll('.esportazione-dashboard h2')].map((x) => x.textContent)"));
StringAssert.Contains((await ui.EvalAsync("document.querySelector('.copia-in-corso').textContent")).GetString(), "Nessuna copia al lavoro"); StringAssert.Contains((await ui.EvalAsync("document.querySelector('.copia-in-corso').textContent")).GetString(), "Nessuna copia al lavoro");
StringAssert.Contains((await ui.EvalAsync("document.querySelector('.riga-riprendi').textContent")).GetString(), "interrotta"); StringAssert.Contains((await ui.EvalAsync("document.querySelector('.riga-riprendi').textContent")).GetString(), "interrotta");