E2: interfaccia delle copie esterne
Impostazioni → Esportazione (cartella generale, stesso post in due account, cartelle degli account), finestra della cartella delle copie (scelta nativa o sottocartelle di /esporta, tipi, nomi come la libreria o schema suo con anteprima), blocco «Copie esterne» nelle impostazioni dell'account con «Esporta questo account» e il conto dei file non ancora copiati. «Copia in…» con il riepilogo del piano e «Copia di nuovo anche i tolti o superati» (spento), dal menu dell'icona CSV, dalla barra della selezione, dall'account e dal visore; filtro «Copie» ricordato nell'indirizzo, segno sulle tessere, righe delle copie nel pannello File con «Copia di nuovo». Dashboard con la scheda Esportazione: avanzamento, Interrompi, Riprendi, lavori recenti e resoconto. Testi in it.json, stili in febe.css. Serve a usare dall'interfaccia il motore e le API delle copie esterne della tappa E2 (§4.10). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4a7925ad23
commit
2306f5a453
14 files changed
+1596
-33
No files matched your search
@@ -0,0 +1,191 @@
|
||||
// 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');
|
||||
const pendingBox = h('div');
|
||||
|
||||
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());
|
||||
}
|
||||
Reference in new issue
Block a user