Files
Febe/src/Febe.Web/wwwroot/js/pages/settings-export.js
T
Alby96andClaude Opus 5.5 28c7f814b1
verifica / controlli (push) Successful in 21s
verifica / prove (push) Failing after 25m17s
verifica / installatore (push) Skipped
verifica / immagine (push) Skipped
E2: schermate delle copie esterne e confronto con i mockup
Otto schermate nuove in docs/schermate (Impostazioni → Esportazione anche
in Docker, finestra della destinazione, blocco «Copie esterne» della scheda
account, «Copia in…», Libreria con il filtro «Copie» e il menu dell'icona
CSV, righe delle copie nel visualizzatore, scheda «Esportazione» della
Dashboard), con le voci e i passi del programma delle schermate, perché
§10.7 chiede di confrontare ogni schermata con i mockup da cui nasce.

Dal confronto, piccole correzioni dell'interfaccia: la riga dei tipi sotto
la cartella generale e le note in Docker non stanno più attaccate, la
scheda della Dashboard ha spazio sotto le linguette, il tipo di cartella
del blocco dell'account va sopra il campo così il percorso non si taglia,
«Copia di nuovo» è allineato ai valori e le icone dei pulsanti dentro un
avviso non prendono più il colore dell'avviso.

differenze.md elenca la composizione di ogni schermata e le differenze:
niente formati né conversione (E3), niente «Automatica» (E5), niente
«Fotogrammi…» né «È un video fermo?», il segno sulla tessera, le schede
«Motore» ed «Esportazione».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 15:59:39 +01:00

192 lines
8.1 KiB
JavaScript

// 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
// 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).
import { api, withCarried } from '../core/api.js';
import { h, icon, fill, later } from '../core/dom.js';
import { t } from '../core/text.js';
import { confirmDialog, label, segmented, showError, toast } from '../core/ui.js';
import { heading } from './settings.js';
import { countsText, describe, destinationDialog } from './export-dialogs.js';
export default async function exportSettings(page, box) {
let overview = await api('/api/export', { signal: page.signal });
const generalBox = h('div');
const ownBox = h('div');
const noteBox = h('div.nota-copie');
const pendingBox = h('div.nota-copie');
async function reload() {
try {
overview = await api('/api/export', { signal: page.signal });
draw();
} catch (error) {
if (error.name !== 'AbortError') showError(error);
}
}
// ------------------------------------------------------------------------------------------- general folder
function drawGeneral() {
const g = overview.general;
const root = overview.root;
const canChange = root.active;
const buttons = [];
if (!g) {
buttons.push(h('button.btn.primo', { type: 'button', disabled: !canChange, onclick: () => edit(null) }, icon('folder-open', 's'), t('esportazione.scegli')));
} else {
buttons.push(h('button.btn', { type: 'button', disabled: !canChange, onclick: () => edit(g) }, t('esportazione.modifica')));
buttons.push(h('button.btn.nudo', { type: 'button', onclick: () => retire(g) }, t('esportazione.togli')));
}
fill(generalBox, h('div.cartella-impostazioni',
h('div.riga-cartella',
h('div.campo.sola', { title: g ? g.display : null }, icon(g ? 'hard-drive' : 'folder', 's'),
g ? h('span.val.dati', g.display) : h('span.val.tenue', t('esportazione.nessunaCartella'))),
buttons),
g ? h('p.aiuto.descrizione-copie', describe(g)) : null,
g ? stateLine(g) : null));
}
/** «In pausa: …» with «Riprova», or the counts of the copies with «Controlla le copie». */
function stateLine(d) {
if (d.pausedAt || d.problem) {
return h('div.avviso.ambra.avviso-azione.stato-copie', icon('pause', 's'),
h('span', t('esportazione.pausa', { problema: d.problem || '' })),
h('button.btn.piccolo', { type: 'button', onclick: (e) => retry(d, e.currentTarget) }, icon('rotate-cw', 's'), t('esportazione.riprova')));
}
return h('div.stato-copie.riga-conteggi',
h('span.muto', countsText(d.counts)),
h('button.btn.piccolo', { type: 'button', title: t('esportazione.controllaAiuto'), onclick: (e) => check(d, e.currentTarget) }, icon('rotate-cw', 's'), t('esportazione.controlla')));
}
async function edit(destination) {
const saved = await destinationDialog({ scope: 'general', destination, overview });
if (saved) await reload();
}
async function retire(d) {
const ok = await confirmDialog({
title: t('esportazione.togliTitolo', { nome: d.label }),
text: t('esportazione.togliConferma'),
buttons: [
{ label: t('comune.annulla'), value: false, kind: 'nudo', autofocus: true },
{ label: t('esportazione.togliSi'), value: true, kind: 'pericolo' },
],
});
if (!ok) return;
try {
const result = await api(`/api/export/destinations/${d.id}`, { method: 'DELETE' });
toast(result.message);
await reload();
} catch (error) {
showError(error);
}
}
async function retry(d, button) {
button.disabled = true;
try {
const result = await api(`/api/export/destinations/${d.id}/resume`, { method: 'POST' });
toast(result.message);
await reload();
} catch (error) {
button.disabled = false;
showError(error);
}
}
async function check(d, button) {
button.disabled = true;
try {
const result = await api(`/api/export/destinations/${d.id}/check`, { method: 'POST' });
toast(result.message, '', { label: t('esportazione.apriEsportazione'), href: '/dashboard/esportazione' });
} catch (error) {
showError(error);
} finally {
button.disabled = false;
}
}
// ------------------------------------------------------------------------------------------- same post
const samePost = segmented({
label: t('esportazione.stessoPost'),
value: overview.samePost,
options: [
{ value: 'onePerAccount', label: t('esportazione.unaPerAccount') },
{ value: 'oneOnly', label: t('esportazione.unaSola') },
],
onchange: async (v) => {
try {
const result = await api('/api/export/settings', { method: 'PUT', body: { samePost: v } });
overview.samePost = v;
toast(result.message);
} catch (error) {
samePost.select(overview.samePost);
showError(error);
}
},
});
// ------------------------------------------------------------------------------------------- own folders
function drawOwn() {
const own = overview.own || [];
if (!own.length) {
fill(ownBox, h('p.vuoto-elenco.pannello', t('esportazione.nessunaPropria')));
return;
}
fill(ownBox, h('div.pannello.cartelle-copie', h('table.tab',
h('caption.vh', t('esportazione.cartelleAccount')),
h('thead', h('tr',
h('th', { scope: 'col' }, t('esportazione.colonne.account')),
h('th', { scope: 'col' }, t('esportazione.colonne.cartella')),
h('th', { scope: 'col' }, t('esportazione.colonne.stato')))),
h('tbody', own.map((d) => h('tr',
h('td', d.accountId && d.username
? h('a', { href: withCarried(`/account/${d.accountId}/impostazioni`) }, `@${d.username}`)
: h('span.muto', t('esportazione.eraDi', { nome: d.formerUsername || '?' }))),
h('td', h('span.dati', { title: d.display }, d.display), h('div.piccolo.muto', describe(d))),
h('td', d.pausedAt || d.problem
? label(t('esportazione.inPausa'), 'ambra', 'pause')
: h('span.muto.piccolo', countsText(d.counts)))))))));
}
// ------------------------------------------------------------------------------------------- notes
function drawNotes() {
const root = overview.root;
if (root.docker && !root.active) {
fill(noteBox, h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', root.problem || '')));
} else if (root.docker) {
fill(noteBox, h('div.avviso', icon('info', 's'), h('span', t('esportazione.dockerNota', { radice: root.root }))));
} else if (!root.active && root.problem) {
fill(noteBox, h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', root.problem)));
} else {
noteBox.replaceChildren();
}
const unfinished = overview.unfinishedRuns || 0;
fill(pendingBox, unfinished
? h('div.avviso.ambra.avviso-azione', icon('pause', 's'), h('span', t('esportazione.daRiprendere', { n: unfinished })),
h('a.btn.piccolo', { href: withCarried('/dashboard/esportazione') }, t('esportazione.apriEsportazione')))
: null);
}
function draw() {
drawGeneral();
drawOwn();
drawNotes();
}
draw();
fill(box,
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.stessoPost'), t('esportazione.stessoPostAiuto')), samePost),
h('div.sezione', heading(t('esportazione.cartelleAccount'), t('esportazione.cartelleAccountAiuto')), ownBox));
// Copies finished, a folder paused or changed elsewhere (another tab, an account card): the page follows.
const onChange = later(() => reload(), 500);
page.onLibrary((change) => {
if (change.reason === 'export') onChange();
});
page.onLeave(() => onChange.cancel());
}