diff --git a/src/Febe.Web/wwwroot/css/febe.css b/src/Febe.Web/wwwroot/css/febe.css index 51d9c86..5b97339 100644 --- a/src/Febe.Web/wwwroot/css/febe.css +++ b/src/Febe.Web/wwwroot/css/febe.css @@ -1160,6 +1160,55 @@ input[type=range].cursore.lungo::-webkit-slider-thumb{border-color:var(--accento .benvenuto{padding-top:40px} } +/* ---------- copie esterne (§4.10, tappa E2): impostazioni, finestre, scheda account, Dashboard ---------- */ +.breve-link{color:inherit;font-weight:650;white-space:nowrap;margin-left:4px} +.descrizione-copie{margin-top:8px} +.riga-conteggi{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-top:10px} +.riga-conteggi > span{flex:1;min-width:0} +.stato-copie.avviso{margin-top:10px} +.cartelle-copie .tab td{vertical-align:top} +.cartelle-copie .tab td .dati{display:block;overflow-wrap:anywhere} +.dialogo.destinazione{width:900px} +.dialogo.copia-in{width:600px} +.dialogo.resoconto-copia{width:700px} +.parte-dialogo{padding:12px 0 16px;border-bottom:1px solid var(--bordo)} +.parte-dialogo:first-child{padding-top:2px} +.parte-dialogo:last-child{border-bottom:0;padding-bottom:4px} +.parte-dialogo h3,.resoconto-copia h3{margin:0 0 4px;font-size:14px;font-weight:650} +.parte-dialogo .riga-cartella .campo input{flex:1;min-width:0;border:0;background:transparent;outline:none} +.controllo-cartella{margin-top:8px} +.controllo-cartella:empty{display:none} +.controllo-cartella .avviso{margin-top:2px} +.controllo-cartella p{margin:0} +.sfoglia-elenco li.scelta .sfoglia-voce{background:var(--accento-tinta);font-weight:600} +.sfoglia-elenco li.scelta .sfoglia-voce svg{color:var(--accento)} +.schemi-copie{margin-top:12px} +.destinazione .dialogo-tipi,.destinazione .tipi{margin-top:10px} +.riepilogo-copia{font-size:14px;margin:0 0 12px} +.riepilogo-copia b{font-weight:650} +.destinazioni-copia{list-style:none;margin:0 0 12px;padding:0} +.destinazioni-copia li{display:flex;align-items:flex-start;gap:10px;padding:11px 14px;border-bottom:1px solid var(--bordo)} +.destinazioni-copia li:last-child{border-bottom:0} +.destinazioni-copia li > svg{color:var(--testo-2);margin-top:2px} +.destinazioni-copia .chi-cosa{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px} +.destinazioni-copia .chi-cosa b{font-weight:600;overflow-wrap:anywhere} +.destinazioni-copia .chi-cosa > span{font-size:12.5px;color:var(--testo-2)} +.destinazioni-copia .avviso{margin-top:6px} +.di-nuovo{margin-top:4px} +.di-nuovo .aiuto{margin:4px 0 0 27px} +.copie-esterne .conteggio-copie{margin-top:12px} +.vis .scheda dd.riga-copia{display:flex;align-items:center;gap:4px 8px;flex-wrap:wrap} +.vis .scheda dd.riga-copia .btn{height:26px;padding:0 8px} +.tess .segno .copia.parte{font-variant-numeric:tabular-nums} +.esportazione-dashboard{display:flex;flex-direction:column;gap:22px;max-width:980px} +.avanzamento-copia{padding:16px 18px} +.avanzamento-copia .misura{margin:12px 0 8px} +.avanzamento-copia .fase-copia{margin:8px 0} +.riga-riprendi + .riga-riprendi{margin-top:8px} +.resoconto-account .num{text-align:right;width:96px} +.problemi-copia li{min-height:0;padding:8px 14px} +.problemi-copia .chi-cosa b{white-space:normal} + /* ---------- 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}} .dialogo,.menu,.breve{animation:febe-compare .14s ease-out} diff --git a/src/Febe.Web/wwwroot/js/core/ui.js b/src/Febe.Web/wwwroot/js/core/ui.js index 40f649c..18d9a24 100644 --- a/src/Febe.Web/wwwroot/js/core/ui.js +++ b/src/Febe.Web/wwwroot/js/core/ui.js @@ -1,21 +1,26 @@ // Components of the style sheet (appendix B, mockup 13) as functions: dialogs, menus, short notices, switches, // check boxes, avatars. Keyboard first: every control is a real button or input, focus is always visible. +import { withCarried } from './api.js'; import { h, icon, uid } from './dom.js'; import { t } from './text.js'; // ------------------------------------------------------------------------------------------------- short notices let toasts; -/** A short notice at the bottom («Impostazioni salvate.»); errors stay longer. */ -export function toast(message, kind = '') { +/** + * A short notice at the bottom («Impostazioni salvate.»); errors stay longer. link: { label, href } of an internal page + * to go to («Apri l'esportazione»); a notice with a link stays longer too. + */ +export function toast(message, kind = '', link = null) { if (!toasts) { toasts = h('div.brevi', { role: 'status', 'aria-live': 'polite' }); document.body.append(toasts); } - const item = h(`div.breve${kind ? '.' + kind : ''}`, kind === 'errore' ? icon('octagon-alert', 's') : icon('circle-check', 's'), h('span', message)); + const item = h(`div.breve${kind ? '.' + kind : ''}`, kind === 'errore' ? icon('octagon-alert', 's') : icon('circle-check', 's'), h('span', message), + link ? h('a.breve-link', { href: withCarried(link.href) }, link.label) : null); toasts.append(item); - setTimeout(() => item.remove(), kind === 'errore' ? 8000 : 4000); + setTimeout(() => item.remove(), kind === 'errore' || link ? 8000 : 4000); } /** Shows the message of an error (ApiError or anything else). */ diff --git a/src/Febe.Web/wwwroot/js/pages/account.js b/src/Febe.Web/wwwroot/js/pages/account.js index 91bb51e..51d75fd 100644 --- a/src/Febe.Web/wwwroot/js/pages/account.js +++ b/src/Febe.Web/wwwroot/js/pages/account.js @@ -2,6 +2,9 @@ // the link to the profile; tabs Contenuti (Post, Storie as a regular 9:16 grid, In evidenza grouped by collection, // Taggati, Profilo when there is more than one picture), Impostazioni (with «Con queste impostazioni» recomputed at // every change and the fixed save bar) and Cronologia (the checks with their outcome). +// 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 +// questo account» (on unless switched off), the folder of the copies and «312 su 1.204 non ancora copiati». import { api, download, withCarried } from '../core/api.js'; import { caps, serverNow } from '../core/context.js'; @@ -15,6 +18,7 @@ import { confirmDelete, selectionBar } from './library.js'; import { Mosaic, justify, tileElement, defaultDayLabel, filesDayLabel, modeSwitch, storedMode } from './mosaic.js'; import { kindName, orderEditor, orderOrDefault } from './download-order.js'; import { openViewer } from './viewer.js'; +import { copiesApi, copiesLabel, copiesMenu, copyDialog, destinationDialog, exportButton, exportMenu, separator } from './export-dialogs.js'; const KINDS = [ { key: 'post', api: 'posts', stat: 'posts', label: 'scheda.tipi.posts' }, @@ -108,6 +112,9 @@ async function contentsTab(page, route, detail) { const available = KINDS.filter((k) => k.key !== 'profilo' || s.profilePictures > 1); let kind = available.find((k) => k.key === route.query.get('tipo')) || available.find((k) => s[k.stat] > 0) || available[0]; let period = route.query.get('periodo') || ''; + let copies = copiesApi(route.query.get('copie')) ? route.query.get('copie') : ''; + // The «Copie» filter and «Copia in…» make sense once this account has a folder of the copies. + const hasDestination = Boolean(detail.export && detail.export.destination); let mosaic = null; // «Raggruppa i post» / «Tutte le foto» (spec §4.6): one choice for the views of every account, apart from the Libreria. let mode = storedMode('account'); @@ -121,8 +128,10 @@ async function contentsTab(page, route, detail) { let showToken = 0; const chips = h('div.filtri', { role: 'group', 'aria-label': t('scheda.linguette.contenuti') }); const periodButton = h('button.campo.scelta', { type: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false', style: { minWidth: '150px' } }); + const copiesButton = h('button.campo.scelta', { type: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false', hidden: !hasDestination && !copies, style: { minWidth: '96px' } }); const selectButton = h('button.btn', { type: 'button', 'aria-pressed': 'false' }, icon('circle-check'), h('span', t('libreria.seleziona'))); - page.tools(h('div', { style: { display: 'contents' } }, chips, periodButton, h('div.destra', modes, selectButton))); + const csvButton = exportButton(); + page.tools(h('div', { style: { display: 'contents' } }, chips, periodButton, copiesButton, h('div.destra', csvButton, modes, selectButton))); const host = h('div'); fill(page.body, host); @@ -136,6 +145,8 @@ async function contentsTab(page, route, detail) { }, }, t(k.label), h('i', number(s[k.stat]))))); fill(periodButton, h('span.val', period ? t(`libreria.periodi.${period}`) : t('libreria.periodi.qualsiasi')), icon('chevron-down', 's')); + fill(copiesButton, h('span.val', copiesLabel(copies)), icon('chevron-down', 's')); + copiesButton.classList.toggle('attivo', Boolean(copies)); selectButton.hidden = kind.key === 'evidenza'; // «In evidenza» is drawn by collection, one tile per item (almost always a single story): no switch there. modes.hidden = kind.key === 'evidenza'; @@ -149,8 +160,28 @@ async function contentsTab(page, route, detail) { show(); })); + copiesButton.addEventListener('click', () => copiesMenu(copiesButton, copies, (value) => { + copies = value; + setQuery({ copie: value || null }); + show(); + })); + csvButton.addEventListener('click', () => exportMenu(csvButton, { + hasDestinations: hasDestination, + csv: async () => { + try { + await download('/api/entries/export', { query: query() }, 'febe-elementi.csv'); + toast(t('libreria.esportatoFiltro')); + } catch (error) { + showError(error); + } + }, + copy: () => copyDialog({ query: query(), mode: mode === 'files' ? 'files' : 'grouped' }), + })); + function query() { const q = new URLSearchParams({ accounts: String(detail.account.id), kind: kind.api }); + const copiesFilter = copiesApi(copies); + if (copiesFilter) q.set('copies', copiesFilter); const today = caps().today; const add = (n) => new Date(Date.parse(`${today}T12:00:00Z`) + n * 86400000).toISOString().slice(0, 10); const year = Number(today.slice(0, 4)); @@ -177,6 +208,9 @@ async function contentsTab(page, route, detail) { showError(error); } }, + copySelected: hasDestination + ? () => copyDialog(mosaic.files ? { mediaIds: [...mosaic.selected] } : { entryIds: mosaic.selectedEntries().ids }) + : null, deleteSelected: async () => { const { ids, files } = mosaic.selectedEntries(); const removed = await confirmDelete(ids, mosaic.files ? { files: mosaic.selected.size, total: files } : null); @@ -234,11 +268,16 @@ async function contentsTab(page, route, detail) { } const onChange = later(() => mosaic && mosaic.refresh().catch(() => {}), 500); + const onMarks = later(() => mosaic && mosaic.refreshMarks().catch(() => {}), 600); page.onLibrary((change) => { - if (!change.accountId || change.accountId === detail.account.id) onChange(); + if (!change.accountId || change.accountId === detail.account.id) { + onChange(); + if (change.reason === 'export') onMarks(); + } }); page.onLeave(() => { onChange.cancel(); + onMarks.cancel(); if (mosaic) mosaic.destroy(); if (highlightCleanup) highlightCleanup(); }); @@ -467,7 +506,8 @@ function settingsTab(page, detail) { h('div.riga-campi', depthExtra), h('div', { style: { marginTop: '14px' } }, storyVideos)), h('div.sezione', h('h2.sez', t('impAccount.cartella')), h('p.aiuto', t(c.foldersReadOnly ? 'impAccount.cartellaDocker' : 'impAccount.cartellaAiuto')), - h('div.cartella', h('div.campo.sola', icon('folder', 's'), folderValue), folderActions))); + h('div.cartella', h('div.campo.sola', icon('folder', 's'), folderValue), folderActions)), + copiesBlock(page, detail)); function drawPlan() { const lines = plan.lines.map((l) => { @@ -540,6 +580,133 @@ function settingsTab(page, detail) { }); } +// --------------------------------------------------------------------------------------------- copie esterne + +/** + * «Copie esterne» (spec §4.10, mockup 05): «Esporta questo account», which acts at once and is not part of the form + * (decision D1: on unless switched off), where the copies go, how many files are still to copy and «Copia in…». + */ +function copiesBlock(page, detail) { + const account = detail.account; + const box = h('div.sezione.copie-esterne'); + let data = detail.export || { enabled: true, hasOwnFolder: false, destination: null, due: 0, notCopied: 0, removedOrSuperseded: 0, failed: 0 }; + const body = h('div.copie-corpo'); + const toggleBox = toggle({ + checked: data.enabled, + label: t('esportazione.account.interruttore'), + onchange: async (value, input) => { + input.disabled = true; + try { + const result = await api(`/api/accounts/${account.id}/export-enabled`, { method: 'POST', body: { value } }); + toast(result.message); + await reload(); + } catch (error) { + input.checked = !value; + showError(error); + } finally { + input.disabled = false; + } + }, + }); + + async function reload() { + try { + const fresh = await api(`/api/accounts/${account.id}`, { signal: page.signal }); + data = fresh.export || data; + toggleBox.input.checked = data.enabled; + draw(); + } catch (error) { + if (error.name !== 'AbortError') showError(error); + } + } + + async function chooseOwn() { + const saved = await destinationDialog({ scope: 'account', accountId: account.id, username: account.username, destination: data.hasOwnFolder ? data.destination : null }); + if (saved) await reload(); + } + + async function useGeneral() { + const general = data.hasOwnFolder && data.destination; + if (!general) return; + // Is there a general folder to fall back to? The overview says so. + let overview = null; + try { + overview = await api('/api/export'); + } catch (error) { + showError(error); + return; + } + const fallback = Boolean(overview.general); + const ok = await confirmDialog({ + title: t(fallback ? 'esportazione.account.usaGeneraleTitolo' : 'esportazione.account.togliTitolo', { nome: account.username }), + text: t(fallback ? 'esportazione.account.usaGeneraleTesto' : 'esportazione.account.togliTesto'), + buttons: [ + { label: t('comune.annulla'), value: false, kind: 'nudo', autofocus: true }, + { label: t(fallback ? 'esportazione.account.usaGenerale' : 'esportazione.togliSi'), value: true, kind: fallback ? 'primo' : 'pericolo' }, + ], + }); + if (!ok) return; + try { + const result = await api(`/api/export/destinations/${data.destination.id}`, { method: 'DELETE' }); + toast(result.message); + await reload(); + } catch (error) { + showError(error); + } + } + + function draw() { + const d = data.destination; + const rows = []; + if (d) { + const where = data.hasOwnFolder ? d.display : `${d.display}${separator(d.display)}${account.username}`; + rows.push(h('div.cartella', + h('div.campo.sola', { title: where }, icon('hard-drive', 's'), + h('span.val', h('span.muto', `${t(data.hasOwnFolder ? 'esportazione.account.sua' : 'esportazione.account.generale')}: `), h('span.dati', where))), + data.hasOwnFolder + ? [h('button.btn', { type: 'button', onclick: chooseOwn }, t('esportazione.modifica')), + h('button.btn.nudo', { type: 'button', onclick: useGeneral }, t('esportazione.account.usaGenerale'))] + : h('button.btn', { type: 'button', onclick: chooseOwn }, t('esportazione.account.scegliSua')))); + if (d.pausedAt || d.problem) { + rows.push(h('div.avviso.ambra', { style: { marginTop: '10px' } }, icon('pause', 's'), h('span', t('esportazione.pausa', { problema: d.problem || '' })))); + } + } else { + rows.push(h('div.cartella', + h('div.campo.sola', icon('folder', 's'), h('span.val.tenue', t('esportazione.nessunaCartella'))), + h('button.btn', { type: 'button', onclick: chooseOwn }, t('esportazione.account.scegliSua'))), + h('p.aiuto', { style: { marginTop: '8px' } }, t('esportazione.account.nessuna'))); + } + if (!data.enabled) { + rows.push(h('p.aiuto.conteggio-copie', icon('info', 'xs'), ' ', t('esportazione.account.spento'))); + } else if (d) { + let count; + if (!data.due) count = t('esportazione.account.nessunFile'); + else if (!data.notCopied) count = t('esportazione.account.tuttiCopiati', { n: data.due }); + else count = t('esportazione.account.conteggio', { n: data.notCopied, totale: data.due }); + const extra = []; + if (data.removedOrSuperseded) extra.push(t('esportazione.account.tolti', { n: data.removedOrSuperseded })); + if (data.failed) extra.push(t('esportazione.account.falliti', { n: data.failed })); + rows.push(h('div.riga-conteggi.conteggio-copie', + h('span', h('b', count), extra.length ? ` · ${extra.join(' · ')}` : ''), + h('button.btn', { type: 'button', onclick: () => copyDialog({ accountId: account.id }, { title: t('esportazione.copia.titolo') }) }, icon('copy'), t('esportazione.account.copiaIn')))); + } + fill(body, rows); + } + + draw(); + fill(box, + h('h2.sez', t('esportazione.account.titolo')), + h('p.aiuto', t('esportazione.account.aiuto')), + h('div', { style: { margin: '12px 0 4px' } }, toggleBox), + body); + const onChange = later(() => reload(), 600); + page.onLibrary((change) => { + if (change.reason === 'export' && (!change.accountId || change.accountId === account.id)) onChange(); + }); + page.onLeave(() => onChange.cancel()); + return box; +} + // --------------------------------------------------------------------------------------------- history async function historyTab(page, detail) { diff --git a/src/Febe.Web/wwwroot/js/pages/dashboard-export.js b/src/Febe.Web/wwwroot/js/pages/dashboard-export.js new file mode 100644 index 0000000..53222cf --- /dev/null +++ b/src/Febe.Web/wwwroot/js/pages/dashboard-export.js @@ -0,0 +1,270 @@ +// Dashboard, tab «Esportazione» (spec §7.9, §10.3, tappa E2; from mockup 06 and step 2 of mockup 09): the copy at +// work with its progress and «Interrompi»; the jobs to resume («Riprendi», «Annulla») and the folders in pause +// («Riprova»); the last jobs, each with its resoconto. The progress is asked every second while a copy works, every five +// seconds otherwise (decision D20), as the import does. A pause is an amber notice here, never the red strip. + +import { api } from '../core/api.js'; +import { h, icon, fill, later } from '../core/dom.js'; +import { t, at, bytes, capitalize, number } from '../core/text.js'; +import { confirmDialog, dialog, label, showError, toast } from '../core/ui.js'; + +const STATE_LOOK = { + running: ['accento', 'play'], + interrupted: ['ambra', 'pause'], + paused: ['ambra', 'pause'], + completed: ['verde', 'circle-check'], + cancelled: ['', 'x'], +}; + +const FILE_STATES = ['copied', 'adopted', 'alreadyCopied', 'skipped', 'missing', 'failed', 'pending']; + +export async function mountExport(page) { + page.title(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 pending = h('section.blocco', { hidden: true }); + const recent = h('section.blocco'); + fill(page.body, h('div.attivita.esportazione-dashboard', current, pending, recent)); + + let overview = null; + let runs = []; + let progress = null; + let wasRunning = null; + let timer = 0; + let ticks = 0; + let stopped = false; + page.onLeave(() => { + stopped = true; + clearTimeout(timer); + }); + + async function loadSide() { + try { + [overview, runs] = await Promise.all([ + api('/api/export', { signal: page.signal }), + api('/api/export/runs?limit=20', { signal: page.signal }), + ]); + drawPending(); + drawRecent(); + } catch (error) { + if (error.name !== 'AbortError') showError(error); + } + } + + async function poll() { + if (stopped) return; + try { + progress = await api('/api/export/progress', { signal: page.signal }); + } catch (error) { + if (error.name === 'AbortError') return; + progress = null; + } + drawCurrent(); + const running = Boolean(progress && progress.running); + ticks += 1; + // The jobs and the folders follow the copy: when it starts or ends, and every few seconds while it works. + if (running !== wasRunning || !running || ticks % 5 === 0) await loadSide(); + wasRunning = running; + if (stopped) return; + timer = setTimeout(poll, running ? 1000 : 5000); + } + + /** Asks again now (after a command), keeping one timer. */ + function again() { + clearTimeout(timer); + wasRunning = null; + poll(); + } + + // ------------------------------------------------------------------------------------------- in corso + function drawCurrent() { + const p = progress; + const head = h('div.testa-blocco', h('h2', t('esportazione.dashboard.inCorso'))); + if (!p || !p.running) { + fill(current, head, h('p.vuoto-elenco.pannello', t('esportazione.dashboard.nessunaInCorso'))); + return; + } + const percent = Math.round((p.fraction || 0) * 100); + const bar = h('div.misura.grande-misura', { role: 'progressbar', 'aria-valuemin': '0', 'aria-valuemax': '100', 'aria-valuenow': String(percent), 'aria-label': t('esportazione.dashboard.copio', { cartella: p.destination || '' }) }, + h('i', { style: { width: `${percent}%` } })); + const phase = p.phase && p.phase !== 'copying' && p.phase !== 'finished' ? t(`esportazione.dashboard.fasi.${p.phase}`) : ''; + const count = [t('esportazione.dashboard.fatti', { fatti: number(p.filesDone), totale: number(p.filesTotal) })]; + if (p.bytesTotal) count.push(t('esportazione.dashboard.byte', { fatti: bytes(p.bytesDone), totale: bytes(p.bytesTotal) })); + fill(current, head, h('div.pannello.avanzamento-import.avanzamento-copia', + h('h2.sez', t('esportazione.dashboard.copio', { cartella: p.destination || '' })), + bar, + h('p.conteggio.dati', count.join(' · ')), + phase ? h('p.avviso.ambra.fase-copia', icon(p.phase === 'waitingForSession' ? 'hourglass' : 'info', 's'), h('span', phase)) : null, + h('p.aiuto.piccolo.file-corrente', p.currentFile ? t('esportazione.dashboard.ora', { file: p.currentFile }) : ''), + h('div.riga-azione', h('button.btn', { type: 'button', onclick: interrupt }, icon('pause', 's'), t('esportazione.dashboard.interrompi'))))); + } + + async function interrupt(e) { + e.currentTarget.disabled = true; + try { + const result = await api('/api/export/interrupt', { method: 'POST' }); + toast(result.message); + } catch (error) { + showError(error); + } + again(); + } + + // ------------------------------------------------------------------------------------------- da riprendere + function drawPending() { + const waiting = runs.filter((r) => !r.running && (r.state === 'interrupted' || r.state === 'paused')); + const folders = overview ? [overview.general, ...(overview.own || [])].filter((d) => d && (d.pausedAt || d.problem)) : []; + pending.hidden = !waiting.length && !folders.length; + if (pending.hidden) { + pending.replaceChildren(); + return; + } + const busy = Boolean(progress && progress.running); + fill(pending, + h('div.testa-blocco', h('h2', t('esportazione.dashboard.daRiprendere')), + waiting.length > 1 ? h('div.destra', h('button.btn.piccolo', { type: 'button', disabled: busy, onclick: resumeAll }, icon('play', 's'), t('esportazione.dashboard.riprendiTutte'))) : null), + folders.map((d) => h('div.avviso.ambra.avviso-azione.riga-riprendi', icon('pause', 's'), + h('span', t('esportazione.dashboard.cartellaInPausa', { cartella: d.label, problema: d.problem || t('esportazione.inPausa') })), + h('button.btn.piccolo', { type: 'button', onclick: (e) => retry(d, e.currentTarget) }, icon('rotate-cw', 's'), t('esportazione.riprova')))), + waiting.map((r) => h('div.avviso.ambra.avviso-azione.riga-riprendi', icon('pause', 's'), + h('span', r.state === 'paused' + ? t('esportazione.dashboard.ferma', { cartella: r.destination, problema: r.error || t('esportazione.inPausa') }) + : t('esportazione.dashboard.interrotta', { cartella: r.destination, fatti: number(r.done), totale: number(r.total) })), + h('button.btn.primo.piccolo', { type: 'button', disabled: busy, onclick: (e) => resume(r, e.currentTarget) }, icon('play', 's'), t('esportazione.dashboard.riprendi')), + h('button.btn.nudo.piccolo', { type: 'button', onclick: () => discard(r) }, t('esportazione.dashboard.annulla'))))); + } + + async function resume(run, button) { + button.disabled = true; + try { + const result = await api(`/api/export/runs/${run.id}/resume`, { method: 'POST' }); + toast(result.message); + } catch (error) { + button.disabled = false; + showError(error); + } + again(); + } + + async function resumeAll(e) { + e.currentTarget.disabled = true; + try { + const result = await api('/api/export/resume', { method: 'POST' }); + toast(result.message); + } catch (error) { + showError(error); + } + again(); + } + + async function retry(d, button) { + button.disabled = true; + try { + const result = await api(`/api/export/destinations/${d.id}/resume`, { method: 'POST' }); + toast(result.message); + } catch (error) { + button.disabled = false; + showError(error); + } + again(); + } + + async function discard(run) { + const ok = await confirmDialog({ + title: t('esportazione.dashboard.annullaTitolo', { cartella: run.destination }), + text: t('esportazione.dashboard.annullaTesto'), + buttons: [ + { label: t('comune.annulla'), value: false, kind: 'nudo', autofocus: true }, + { label: t('esportazione.dashboard.annullaSi'), value: true, kind: 'pericolo' }, + ], + }); + if (!ok) return; + try { + const result = await api(`/api/export/runs/${run.id}/discard`, { method: 'POST' }); + toast(result.message); + } catch (error) { + showError(error); + } + again(); + } + + // ------------------------------------------------------------------------------------------- ultimi lavori + function drawRecent() { + const head = h('div.testa-blocco', h('h2', t('esportazione.dashboard.ultimi'))); + if (!runs.length) { + fill(recent, head, h('p.vuoto-elenco.pannello', t('esportazione.dashboard.vuoto'))); + return; + } + fill(recent, head, h('div.pannello', h('ul.elenco-attivita.largo', runs.map((r) => { + const state = r.running ? 'running' : r.state; + const [kind, look] = STATE_LOOK[state] || STATE_LOOK.cancelled; + return h('li', + h('span.quando.dati', capitalize(at(r.startedAt))), + h('div.chi-cosa', + h('b', jobName(r)), + h('span', [t('esportazione.dashboard.fatti', { fatti: number(r.done), totale: number(r.total) }), r.error].filter(Boolean).join(' · '))), + label(t(`esportazione.dashboard.stati.${state}`), kind, look), + h('button.btn.piccolo', { type: 'button', onclick: () => openReport(r) }, t('esportazione.dashboard.resoconto'))); + })))); + } + + const onChange = later(() => again(), 400); + page.onLibrary((change) => { + if (change.reason === 'export') onChange(); + }); + page.onLeave(() => onChange.cancel()); + await poll(); +} + +function jobName(run) { + return t(run.kind === 'recognize' ? 'esportazione.dashboard.lavoroControllo' : 'esportazione.dashboard.lavoroCopia', { cartella: run.destination }); +} + +/** The resoconto of a job: files per state, per account, and the files that need a look (at most 200). */ +async function openReport(run) { + let report; + try { + report = await api(`/api/export/runs/${run.id}/report`); + } catch (error) { + showError(error); + return; + } + const r = report.run; + const when = [t('esportazione.dashboard.iniziata', { quando: at(r.startedAt) })]; + if (r.completedAt) when.push(t('esportazione.dashboard.finita', { quando: at(r.completedAt) })); + const states = FILE_STATES.filter((s) => report.byState[s]).map((s) => t(`esportazione.dashboard.statiFile.${s}`, { n: report.byState[s] })); + if (report.bytesCopied) states.push(t('esportazione.dashboard.copiatiByte', { spazio: bytes(report.bytesCopied) })); + const accounts = report.accounts.length + ? h('div.pannello', h('table.tab.resoconto-account', + h('thead', h('tr', + h('th', { scope: 'col' }, t('esportazione.dashboard.colonne.account')), + h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.copiati')), + h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.gia')), + h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.saltati')), + h('th.num', { scope: 'col' }, t('esportazione.dashboard.colonne.falliti')))), + h('tbody', report.accounts.map((a) => h('tr', + h('td', `@${a.username}`), + h('td.num.dati', number(a.copied)), + h('td.num.dati', number(a.alreadyCopied)), + h('td.num.dati', number(a.skipped)), + h('td.num.dati', number(a.failed))))))) + : null; + const problems = report.problems.length + ? h('div.pannello', h('ul.elenco-attivita.problemi-copia', report.problems.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)))))) + : h('p.aiuto', t('esportazione.dashboard.nessunProblema')); + await dialog({ + title: t('esportazione.dashboard.resocontoTitolo', { lavoro: jobName(r) }), + className: 'resoconto-copia', + build: (close) => ({ + body: h('div.contenuto', + h('p.aiuto', `${when.join(', ')} · ${t(`esportazione.dashboard.stati.${r.running ? 'running' : r.state}`)}`), + h('p.riepilogo-copia', states.join(' · ')), + accounts ? h('h3', t('esportazione.dashboard.perAccount')) : null, + accounts, + h('h3', t('esportazione.dashboard.problemi')), + problems), + footer: h('footer', h('div.destra', h('button.btn', { type: 'button', autofocus: true, onclick: () => close() }, t('comune.chiudi')))), + }), + }); +} diff --git a/src/Febe.Web/wwwroot/js/pages/dashboard.js b/src/Febe.Web/wwwroot/js/pages/dashboard.js index 8602f18..5e333e7 100644 --- a/src/Febe.Web/wwwroot/js/pages/dashboard.js +++ b/src/Febe.Web/wwwroot/js/pages/dashboard.js @@ -23,9 +23,17 @@ const QUEUE_ROWS = 5; const THUMBS = 8; export default { - async mount(page) { + async mount(page, route) { page.title(t('attivita.titolo')); + const tab = route && route.params && route.params.scheda === 'esportazione' ? 'esportazione' : 'motore'; + page.tabs(dashboardTabs(tab)); + // The tab «Esportazione» (spec §7.9, §10.3, tappa E2): the copies to external folders, not the engine. + if (tab === 'esportazione') { + const module = await import('./dashboard-export.js'); + return module.mountExport(page); + } const notice = h('div'); + const exportNotice = h('div'); const now = h('div.ora-testo'); const preview = previewBox(page); const today = h('section.blocco.oggi-basso'); @@ -43,7 +51,7 @@ export default { h('section.cruscotto.pannello', preview.element, h('div.cruscotto-lato', now, budgets)), suspended, today, h('div.due-colonne.storia-coda', history.element, queue.element), - notice, incidents, alerts)); + exportNotice, notice, incidents, alerts)); let latest = null; page.onEngine((state) => { @@ -62,11 +70,17 @@ export default { async function loadSide() { first.check(); try { - const [counts, history, recent] = await Promise.all([ + const [counts, history, recent, exports] = await Promise.all([ api('/api/duplicates/count', { signal: page.signal }), api('/api/engine/incidents', { signal: page.signal }), api('/api/alerts', { signal: page.signal }), + // The copies are not the engine: without an answer the notice is simply not there. + api('/api/export', { signal: page.signal }).catch((error) => { + if (error.name === 'AbortError') throw error; + return null; + }), ]); + drawExportNotice(exportNotice, exports); drawNotice(notice, counts); drawIncidents(incidents, history); drawAlerts(alerts, recent); @@ -84,6 +98,15 @@ export default { }, }; +// ------------------------------------------------------------------------------------------------- tabs + +/** «Motore» and «Esportazione» under the title (spec §7.9: the export has its own tab, never the red strip). */ +function dashboardTabs(tab) { + const link = (key, href) => h(`a${tab === key ? '.qui' : ''}`, { href: withCarried(href), 'aria-current': tab === key ? 'page' : null }, t(`esportazione.dashboard.${key}`)); + return h('nav.linguette.linguette-dashboard', { 'aria-label': t('esportazione.dashboard.linguette') }, + link('motore', '/dashboard'), link('esportazione', '/dashboard/esportazione')); +} + // ------------------------------------------------------------------------------------------------- first start /** @@ -661,6 +684,23 @@ function drawNotice(box, counts) { h('a.btn.piccolo', { href: withCarried('/doppioni') }, t('attivita.decidi')))); } +/** + * A destination of the copies in pause, or copies left to resume (spec §4.10): an amber notice with the way to the tab + * «Esportazione». Never the red strip, which stays the engine's. + */ +function drawExportNotice(box, overview) { + if (!overview) { + box.replaceChildren(); + return; + } + const paused = [overview.general, ...(overview.own || [])].filter((d) => d && (d.pausedAt || d.problem)); + const items = paused.map((d) => t('esportazione.dashboard.cartellaInPausa', { cartella: d.label, problema: d.problem || t('esportazione.inPausa') })); + if (!paused.length && overview.unfinishedRuns) items.push(t('esportazione.dashboard.avvisoDaRiprendere', { n: overview.unfinishedRuns })); + fill(box, items.map((text) => h('div.avviso.ambra.avviso-azione', { style: { marginBottom: '10px' } }, icon('pause', 's'), + h('span', text), + h('a.btn.piccolo', { href: withCarried('/dashboard/esportazione') }, t('esportazione.apriEsportazione'))))); +} + /** Recipes suspended after three problems in a row (unknown formats, targets not found): what to do, «Riattiva». */ function drawSuspended(box, state) { const items = state.snapshot.suspendedRecipes || []; diff --git a/src/Febe.Web/wwwroot/js/pages/export-dialogs.js b/src/Febe.Web/wwwroot/js/pages/export-dialogs.js new file mode 100644 index 0000000..4dbebe5 --- /dev/null +++ b/src/Febe.Web/wwwroot/js/pages/export-dialogs.js @@ -0,0 +1,495 @@ +// Copies to external folders (spec §4.10, §10.3, tappa E2): the pieces shared by the pages. The destination dialog +// (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 +// 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). + +import { api } from '../core/api.js'; +import { h, icon, fill, later } from '../core/dom.js'; +import { t, bytes } from '../core/text.js'; +import { checkbox, dialog, menu, radio, showError, toast } from '../core/ui.js'; + +/** Content types of a destination, as the API names them, in the order of the dialog. */ +export const TYPES = [ + { key: 'postFoto', icon: 'image' }, + { key: 'postVideo', icon: 'clapperboard' }, + { key: 'storie', icon: 'circle-dashed' }, + { key: 'evidenza', icon: 'star' }, + { key: 'taggati', icon: 'square-user' }, + { key: 'profilo', icon: 'circle-user' }, +]; + +/** The «Copie» filter: the value in the page address (Italian) and in the API query. */ +export const COPIES = [ + { key: 'non-copiati', api: 'notCopied', label: 'esportazione.filtro.nonCopiati' }, + { key: 'copiati', api: 'copied', label: 'esportazione.filtro.copiati' }, + { key: 'tolti', api: 'removedOrSuperseded', label: 'esportazione.filtro.tolti' }, +]; + +/** The API value of the «Copie» filter of the address, or null. */ +export function copiesApi(value) { + const found = COPIES.find((c) => c.key === value); + return found ? found.api : null; +} + +/** The label of the «Copie» menu: its name until a value is chosen (spec §10.3). */ +export function copiesLabel(value) { + const found = COPIES.find((c) => c.key === value); + return found ? t(found.label) : t('esportazione.filtro.titolo'); +} + +/** The radio menu of the «Copie» filter; onPick('' | 'non-copiati' | 'copiati' | 'tolti'). */ +export function copiesMenu(anchor, value, onPick) { + return menu(anchor, [ + { label: t('esportazione.filtro.tutti'), value: '', checked: !value, radio: true }, + ...COPIES.map((c) => ({ label: t(c.label), value: c.key, checked: value === c.key, radio: true })), + ], onPick); +} + +/** + * The menu of the CSV icon (spec §10.3): «Esporta l'elenco (CSV)» and «Copia i file in…», the second only usable + * when a destination exists. + */ +export function exportMenu(anchor, { hasDestinations, csv, copy }) { + return menu(anchor, [ + { label: t('esportazione.libreria.menuCsv'), icon: 'file-down', value: 'csv' }, + { label: t('esportazione.libreria.menuCopia'), icon: 'copy', value: 'copy', disabled: !hasDestinations }, + ], (value) => { + if (value === 'csv') csv(); + if (value === 'copy') copy(); + }, { align: 'right' }); +} + +/** The CSV icon of the tools row, a menu anchor. */ +export function exportButton() { + return h('button.btn.nudo.piccolo.solo-icona', { + type: 'button', title: t('esportazione.libreria.menu'), 'aria-label': t('esportazione.libreria.menu'), 'aria-haspopup': 'menu', 'aria-expanded': 'false', + }, icon('file-down')); +} + +/** «54 copiati · 1 tolto · 1 superato · 1 non riuscito» of a destination (zeros left out, «copiati» always). */ +export function countsText(counts) { + const c = counts || {}; + const parts = [t('esportazione.conteggi.copiati', { n: c.copied || 0 })]; + if (c.removed) parts.push(t('esportazione.conteggi.tolti', { n: c.removed })); + if (c.superseded) parts.push(t('esportazione.conteggi.superati', { n: c.superseded })); + if (c.failed) parts.push(t('esportazione.conteggi.falliti', { n: c.failed })); + return parts.join(' · '); +} + +/** «Tipi: post foto, storie · nomi come la libreria». */ +export function describe(destination) { + const types = destination.types.length === TYPES.length + ? t('esportazione.tuttiITipi') + : destination.types.map((k) => t(`esportazione.tipi.${k}`).toLowerCase()).join(', '); + const own = destination.namingScheme || destination.highlightNamingScheme || destination.profileNamingScheme; + return `${t('esportazione.tipiScelti', { elenco: types })} · ${t(own ? 'esportazione.nomiSuoi' : 'esportazione.nomiLibreria')}`; +} + +/** The separator of the folders of a path as shown («/» in Docker, «\» on Windows). */ +export function separator(display) { + return String(display || '').startsWith('/') ? '/' : '\\'; +} + +// ------------------------------------------------------------------------------------------------- destination + +/** + * The dialog of a destination: the general folder, or the own folder of an account. overview: GET /api/export (asked + * when missing). destination: the one being changed, or null for a new one. Resolves with the saved destination, or + * undefined when closed. + */ +export async function destinationDialog({ scope, accountId = null, username = '', destination = null, overview = null }) { + let info = overview; + if (!info) { + try { + info = await api('/api/export'); + } catch (error) { + showError(error); + return undefined; + } + } + const root = info.root; + const docker = root.docker; + const general = scope === 'general'; + const original = destination ? (docker ? relativeOf(destination.display, root.root) : destination.rootPath) : ''; + const state = { + path: original, + check: null, + checking: false, + types: new Set(destination ? destination.types : TYPES.map((x) => x.key)), + own: Boolean(destination && (destination.namingScheme || destination.highlightNamingScheme || destination.profileNamingScheme)), + naming: (destination && destination.namingScheme) || info.library.general, + highlight: (destination && destination.highlightNamingScheme) || info.library.highlight, + profile: (destination && destination.profileNamingScheme) || info.library.profile, + errors: [], + saving: false, + }; + + return dialog({ + title: general ? t('esportazione.dialogo.titoloGenerale') : t('esportazione.dialogo.titoloAccount', { nome: username }), + className: 'destinazione', + build: (close) => { + const save = h('button.btn.primo', { type: 'button', disabled: true, onclick: () => submit(close) }, icon('check'), t('esportazione.dialogo.salva')); + + // ------------------------------------------------------------------------------- folder + const checkLine = h('div.controllo-cartella', { 'aria-live': 'polite' }); + const changedNote = h('p.avviso-testo', { hidden: true }, icon('triangle-alert', 'xs'), ' ', t('esportazione.dialogo.cambiata')); + let folderPart; + const pathInput = h('input.dati', { type: 'text', value: state.path, id: 'cartella-copie', spellcheck: 'false', autocomplete: 'off', 'aria-describedby': 'cartella-copie-aiuto' }); + if (!docker) { + const pick = root.pickFolder ? h('button.btn', { type: 'button', onclick: pickFolder }, icon('folder-open', 's'), t('esportazione.dialogo.sfoglia')) : null; + folderPart = h('div', + h('label.etichetta', { for: 'cartella-copie' }, t('esportazione.dialogo.percorso')), + h('div.riga-cartella', h('label.campo', icon('folder', 's'), pathInput), pick)); + const typed = later(() => checkFolder(pathInput.value.trim()), 500); + pathInput.addEventListener('input', () => { + state.path = pathInput.value.trim(); + state.check = null; + drawCheck(); + typed(); + }); + } else { + folderPart = h('div.sfoglia-copie'); + browse(parentOf(state.path)); + } + + async function pickFolder() { + try { + const result = await api('/api/export/pick-folder', { method: 'POST', body: { destinationId: destination ? destination.id : null } }); + if (!result.path) return; + pathInput.value = result.path; + state.path = result.path; + checkFolder(result.path); + } catch (error) { + showError(error); + } + } + + async function browse(path) { + try { + const list = await api(`/api/export/folders${path ? `?path=${encodeURIComponent(path)}` : ''}`); + fill(folderPart, h('div.pannello.sfoglia', + h('div.sfoglia-testa', icon('folder-open', 's'), h('span.dati', list.display), + list.parent != null ? h('button.btn.nudo.piccolo.destra', { type: 'button', onclick: () => browse(list.parent || null) }, icon('arrow-left', 's'), t('esportazione.dialogo.su')) : null), + list.folders.length + ? h('ul.sfoglia-elenco', list.folders.map((f) => h(`li${f.path === state.path ? '.scelta' : ''}`, + h('button.sfoglia-voce', { type: 'button', 'aria-pressed': String(f.path === state.path), onclick: () => { state.path = f.path; checkFolder(f.path); browse(list.relative || null); } }, + icon(f.path === state.path ? 'circle-check' : 'folder', 's'), h('span', f.name)), + f.hasSubfolders ? h('button.btn.nudo.solo', { type: 'button', 'aria-label': t('esportazione.dialogo.apri', { nome: f.name }), onclick: () => browse(f.path) }, icon('chevron-right', 's')) : null))) + : h('p.vuoto-elenco', t('esportazione.dialogo.vuota')))); + } catch (error) { + fill(folderPart, h('div.avviso.ambra', icon('triangle-alert', 's'), h('span', error.message))); + } + } + + let checkToken = 0; + async function checkFolder(path) { + const mine = ++checkToken; + if (!path) { + state.check = null; + drawCheck(); + return; + } + state.checking = true; + drawCheck(); + try { + const result = await api('/api/export/check-folder', { method: 'POST', body: { path } }); + if (mine !== checkToken) return; + state.check = result; + } catch (error) { + if (mine !== checkToken) return; + state.check = { accepted: false, problem: error.message }; + } + state.checking = false; + drawCheck(); + } + + function drawCheck() { + const c = state.check; + if (state.checking) fill(checkLine, h('p.aiuto', t('esportazione.dialogo.controllo'))); + else if (!c) fill(checkLine, docker && !state.path ? h('p.aiuto', t('esportazione.dialogo.scegliDocker')) : null); + else if (!c.accepted) fill(checkLine, h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', c.problem || t('comune.errore')))); + else { + const name = c.display.split(/[\\/]/).filter(Boolean).pop() || c.display; + fill(checkLine, + h('p.aiuto', icon('circle-check', 'xs'), ' ', docker ? h('span.dati', c.display) : null, docker ? ' · ' : null, + c.freeBytes != null ? t('esportazione.dialogo.liberi', { nome: name, spazio: bytes(c.freeBytes) }) : name), + c.fat32 ? h('p.avviso-testo', icon('triangle-alert', 'xs'), ' ', t('esportazione.dialogo.fat32')) : null); + } + changedNote.hidden = !destination || !state.path || samePath(state.path, original); + drawSave(); + refresh(); + } + + // ------------------------------------------------------------------------------- types + const typesNote = h('p.errore-testo', { hidden: state.types.size > 0 }, t('esportazione.dialogo.nessunTipo')); + const types = h('div.tipi', TYPES.map((x) => { + const box = checkbox({ + checked: state.types.has(x.key), + labelNode: h('span.testo', t(`esportazione.tipi.${x.key}`)), + onchange: (v) => { + if (v) state.types.add(x.key); + else state.types.delete(x.key); + typesNote.hidden = state.types.size > 0; + drawSave(); + }, + }); + box.classList.add('tipo'); + box.append(icon(x.icon, 's')); + return box; + })); + + // ------------------------------------------------------------------------------- naming + const naming = h('input.dati', { type: 'text', value: state.naming, id: 'schema-copie', spellcheck: 'false', autocomplete: 'off' }); + const highlight = h('input.dati', { type: 'text', value: state.highlight, id: 'schema-copie-evidenza', spellcheck: 'false', autocomplete: 'off' }); + const profile = h('input.dati', { type: 'text', value: state.profile, id: 'schema-copie-profilo', spellcheck: 'false', autocomplete: 'off' }); + const namingField = h('label.campo', naming); + const highlightField = h('label.campo', highlight); + const profileField = h('label.campo', profile); + const fields = h('div.schemi-copie', + h('label.etichetta', { for: 'schema-copie' }, t('esportazione.dialogo.schema')), namingField, + h('label.etichetta', { for: 'schema-copie-evidenza' }, t('esportazione.dialogo.schemaEvidenza')), highlightField, + h('label.etichetta', { for: 'schema-copie-profilo' }, t('esportazione.dialogo.schemaProfilo')), profileField, + h('p.aiuto.segnaposto', t('esportazione.dialogo.segnaposto', { elenco: info.library.placeholders.join(', ') }))); + fields.hidden = !state.own; + const problems = h('div.problemi-schema', { 'aria-live': 'polite' }); + const tree = h('div.albero.pannello', { 'aria-label': t('esportazione.dialogo.risultato') }); + const choose = (value) => { + state.own = value === 'suo'; + fields.hidden = !state.own; + refresh(); + }; + const namingChoice = h('div.scelte', { role: 'radiogroup', 'aria-label': t('esportazione.dialogo.nomi') }, + radio({ name: 'nomi-copie', value: 'libreria', checked: !state.own, onchange: choose, labelNode: h('span', h('b', t('esportazione.dialogo.comeLibreria')), h('small', t('esportazione.dialogo.comeLibreriaAiuto'))) }), + radio({ name: 'nomi-copie', value: 'suo', checked: state.own, onchange: choose, labelNode: h('span', h('b', t('esportazione.dialogo.suo')), h('small', t('esportazione.dialogo.suoAiuto'))) })); + for (const [input, key] of [[naming, 'naming'], [highlight, 'highlight'], [profile, 'profile']]) { + input.addEventListener('input', () => { + state[key] = input.value; + refresh(); + }); + } + + function drawTree(preview) { + const errors = preview.errors || []; + state.errors = state.own ? errors : []; + namingField.classList.toggle('errore', state.own && errors.some((e) => e.startsWith('Schema:'))); + highlightField.classList.toggle('errore', state.own && errors.some((e) => e.startsWith('Schema per le raccolte in evidenza:'))); + profileField.classList.toggle('errore', state.own && errors.some((e) => e.startsWith('Schema per le foto del profilo:'))); + fill(problems, + errors.map((e) => h('p.errore-testo', icon('octagon-alert', 'xs'), ' ', e)), + (preview.warnings || []).map((w) => h('p.aiuto', icon('info', 'xs'), ' ', w))); + const c = state.check; + const shown = c && c.accepted ? c.display : destination ? destination.display : (docker ? root.root : t('esportazione.dialogo.cartella')); + const sep = separator(shown); + const top = String(shown).split(/[\\/]/).filter(Boolean).pop() || shown; + fill(tree, + h('div.ramo.radice', icon('hard-drive', 's'), h('b', top)), + preview.folders.map((f) => [ + f.path.length ? h('div.ramo.livello-1', icon('folder', 's'), h('span', f.path.join(` ${sep} `))) : null, + f.files.map((file) => h(`div.ramo.${f.path.length ? 'livello-2' : 'livello-1'}`, icon(file.kind === 'video' ? 'clapperboard' : 'image', 's'), h('span.dati', file.name))), + ])); + drawSave(); + } + + let previewToken = 0; + const refresh = later(async () => { + const mine = ++previewToken; + try { + const preview = await api('/api/export/naming-preview', { + method: 'POST', + body: { scope, general: state.own ? state.naming : null, highlight: state.own ? state.highlight : null, profile: state.own ? state.profile : null }, + }); + if (mine === previewToken) drawTree(preview); + } catch (error) { + showError(error); + } + }, 150); + + // ------------------------------------------------------------------------------- save + function ready() { + if (state.saving || !state.path || state.types.size === 0 || state.errors.length) return false; + // The folder of a destination being changed is not checked again when it stays the same: an unplugged disk + // must not stop a change of types or names. + if (destination && samePath(state.path, original)) return true; + return Boolean(state.check && state.check.accepted && !state.checking); + } + + function drawSave() { + save.disabled = !ready(); + } + + async function submit(done) { + if (!ready()) return; + state.saving = true; + drawSave(); + const body = { + scope, + accountId: general ? null : accountId, + path: state.path, + label: null, + types: TYPES.map((x) => x.key).filter((k) => state.types.has(k)), + namingScheme: state.own ? state.naming : null, + highlightNamingScheme: state.own ? state.highlight : null, + profileNamingScheme: state.own ? state.profile : null, + // «Automatica» is kept as stored: tappa E5 acts on it (decision D8). + automatic: destination ? destination.automatic : false, + onlyNew: true, + }; + try { + const saved = await api(destination ? `/api/export/destinations/${destination.id}` : '/api/export/destinations', { method: destination ? 'PUT' : 'POST', body }); + toast(t('esportazione.salvata')); + for (const w of saved.warnings || []) toast(w); + done(saved.destination); + } catch (error) { + state.saving = false; + drawSave(); + showError(error); + } + } + + const body = h('div.contenuto', + h('section.parte-dialogo', + h('h3', t('esportazione.dialogo.cartella')), + h('p.aiuto', { id: 'cartella-copie-aiuto' }, docker ? t('esportazione.dialogo.cartellaAiutoDocker', { radice: root.root }) : t('esportazione.dialogo.cartellaAiuto')), + folderPart, checkLine, changedNote), + h('section.parte-dialogo', + h('h3', t('esportazione.dialogo.tipi')), + h('p.aiuto', t('esportazione.dialogo.tipiAiuto')), + types, typesNote), + h('section.parte-dialogo', + h('h3', t('esportazione.dialogo.nomi')), + general ? h('p.aiuto', t('esportazione.dialogo.notaAccount')) : null, + h('div.nomi-file', + h('div.colonna-nomi', namingChoice, fields, problems), + h('div.colonna-albero', h('span.etichetta', t('esportazione.dialogo.risultato')), tree)))); + const footer = h('footer', h('div.destra', + h('button.btn.nudo', { type: 'button', onclick: () => close(undefined) }, t('comune.annulla')), + save)); + if (state.path) checkFolder(state.path); + else drawCheck(); + return { body, footer, onClose: () => refresh.cancel() }; + }, + }); +} + +function relativeOf(display, rootDisplay) { + const value = String(display || ''); + const base = String(rootDisplay || '').replace(/\/+$/, ''); + if (value === base) return ''; + return value.startsWith(`${base}/`) ? value.slice(base.length + 1) : value; +} + +function parentOf(relative) { + if (!relative) return null; + const i = relative.lastIndexOf('/'); + return i > 0 ? relative.slice(0, i) : null; +} + +function samePath(a, b) { + const norm = (p) => String(p || '').trim().replace(/[\\/]+$/, '').toLowerCase(); + return norm(a) === norm(b); +} + +// ------------------------------------------------------------------------------------------------- «Copia in…» + +/** + * «Copia in…» (spec §10.3, mockups 13 and 09). selection: exactly one of { mediaIds }, { entryIds }, + * { query, mode } (the filter of a page) or { accountId }. Each file goes to the folder of its account (decision D5): + * the dialog does not choose a destination, it says where the files go. Resolves with the started job, or undefined. + */ +export function copyDialog(selection, { title } = {}) { + let copyAgain = false; + return dialog({ + title: title || t('esportazione.copia.titolo'), + className: 'copia-in', + build: (close) => { + const content = h('div.contenuto', { 'aria-live': 'polite' }, h('p.aiuto', t('esportazione.copia.conto'))); + const start = h('button.btn.primo', { type: 'button', disabled: true, onclick: () => go() }, icon('copy'), t('esportazione.copia.pulsante', { n: 0 })); + const footer = h('footer', h('div.destra', h('button.btn.nudo', { type: 'button', onclick: () => close(undefined) }, t('comune.annulla')), start)); + let plan = null; + let token = 0; + let busy = false; + + async function load() { + const mine = ++token; + start.disabled = true; + try { + const result = await api('/api/export/plan', { method: 'POST', body: { ...selection, copyAgain } }); + if (mine !== token) return; + plan = result; + draw(); + } catch (error) { + if (mine !== token) return; + fill(content, h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', error.message))); + } + } + + function draw() { + const p = plan; + const parts = [h('b', t('esportazione.copia.file', { n: p.files }))]; + if (p.alreadyCopied) parts.push(t('esportazione.copia.giaCopiati', { n: p.alreadyCopied })); + 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.missing) parts.push(t('esportazione.copia.mancanti', { n: p.missing })); + if (p.files) parts.push(t('esportazione.copia.circa', { spazio: bytes(p.bytes) })); + 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', + 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.copia.file', { n: d.files }), + bytes(d.bytes), + 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))); + let empty = null; + if (!p.files) { + empty = p.destinations.length === 0 && p.notExported && !p.alreadyCopied && !p.removedOrSuperseded + ? h('p.aiuto', t('esportazione.copia.nessunaCartella')) + : h('p.aiuto', t('esportazione.copia.niente')); + } + const again = p.removedOrSuperseded + ? h('div.di-nuovo', + checkbox({ checked: copyAgain, label: t('esportazione.copia.diNuovo', { n: p.removedOrSuperseded }), onchange: (v) => { copyAgain = v; load(); } }), + h('p.aiuto', t('esportazione.copia.diNuovoAiuto'))) + : null; + fill(content, summary, rows.length ? h('ul.destinazioni-copia.pannello', rows) : null, empty, again); + fill(start, icon('copy'), t('esportazione.copia.pulsante', { n: p.files })); + start.disabled = busy || !p.files; + } + + async function go() { + if (!plan || !plan.files || busy) return; + busy = true; + start.disabled = true; + try { + const job = await api('/api/export/start', { method: 'POST', body: { ...selection, copyAgain } }); + toast(job.message, '', job.runIds.length ? { label: t('esportazione.copia.vediAvanzamento'), href: '/dashboard/esportazione' } : null); + close(job); + } catch (error) { + busy = false; + if (plan) draw(); + showError(error); + } + } + + load(); + return { body: content, footer }; + }, + }); +} + +/** «Copia di nuovo» of a copy «Tolto» or «Superato» (the viewer). Resolves with the job, or null. */ +export async function copyAgain(copyId) { + try { + const job = await api('/api/export/copy-again', { method: 'POST', body: { copyId } }); + toast(job.message, '', job.runIds.length ? { label: t('esportazione.copia.vediAvanzamento'), href: '/dashboard/esportazione' } : null); + return job; + } catch (error) { + showError(error); + return null; + } +} + diff --git a/src/Febe.Web/wwwroot/js/pages/library.js b/src/Febe.Web/wwwroot/js/pages/library.js index 042c821..d2bda5b 100644 --- a/src/Febe.Web/wwwroot/js/pages/library.js +++ b/src/Febe.Web/wwwroot/js/pages/library.js @@ -3,6 +3,8 @@ // «Esporta l'elenco» in the tools row exports what the filter shows (spec §4.8: CSV with «;», UTF-8 with BOM). // «Raggruppa i post» / «Tutte le foto» (spec §4.6): one tile per entry or per file, remembered in this browser. With // «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 +// in…»), «Copia in…» in the selection bar and the «Copie» filter, these two only once a folder of the copies exists. import { api, download, withCarried } from '../core/api.js'; import { caps } from '../core/context.js'; @@ -14,6 +16,7 @@ import { engineState } from '../core/engine.js'; import { Mosaic, modeSwitch, storedMode } from './mosaic.js'; import { welcome } from './welcome.js'; import { openViewer } from './viewer.js'; +import { copiesApi, copiesLabel, copiesMenu, copyDialog, exportButton as exportMenuButton, exportMenu } from './export-dialogs.js'; const KINDS = [ { key: 'tutto', api: 'all', label: 'libreria.tipi.all' }, @@ -38,6 +41,8 @@ export function apiQuery(state, today) { if (state.provenienza === 'importati') q.set('provenance', 'imported'); if (state.provenienza === 'scaricati') q.set('provenance', 'downloaded'); if (state.q) q.set('q', state.q); + const copies = copiesApi(state.copie); + if (copies) q.set('copies', copies); return q.toString(); } @@ -66,6 +71,7 @@ function readState(query) { al: query.get('al') || '', provenienza: query.get('provenienza') || '', q: query.get('q') || '', + copie: copiesApi(query.get('copie')) ? query.get('copie') : '', }; } @@ -76,6 +82,8 @@ export default { let accounts = null; let mosaic = null; let mode = storedMode('libreria'); + // A folder of the copies exists (told by the days of the mosaic): the «Copie» filter, «Copia in…» and the marks. + let hasDestinations = false; page.title(t('libreria.titolo'), ''); const search = h('input', { type: 'search', placeholder: t('libreria.cerca'), 'aria-label': t('libreria.cerca'), value: state.q }); @@ -91,6 +99,7 @@ export default { const accountButton = h('button.campo.scelta', { type: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false', style: { minWidth: '118px' } }); const periodButton = h('button.campo.scelta', { type: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false', style: { minWidth: '111px' } }); const provenanceButton = h('button.campo.scelta', { type: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false', style: { minWidth: '141px' } }); + const copiesButton = h('button.campo.scelta', { type: 'button', 'aria-haspopup': 'true', 'aria-expanded': 'false', hidden: true, style: { minWidth: '96px' } }); const filtersButton = h('button.btn.solo-stretto', { type: 'button', 'aria-haspopup': 'true' }, icon('list-filter'), t('libreria.filtri')); const size = local.get('libreria.tessere', 160); const slider = h('input.cursore', { type: 'range', min: '96', max: '300', step: '4', value: String(size), 'aria-label': t('libreria.grandezza') }); @@ -100,7 +109,8 @@ export default { mode = value; apply(); }, { compact: true }); - const exportButton = h('button.btn.nudo.piccolo.solo-icona.solo-largo', { type: 'button', title: t('libreria.esportaAiuto'), 'aria-label': t('libreria.esporta') }, icon('file-down')); + const exportButton = exportMenuButton(); + exportButton.classList.add('solo-largo'); // Probable duplicates after a download wait for Alberto (spec §9.5): a short link to their review. const duplicates = h('a.btn.nudo.piccolo.doppioni-link', { href: withCarried('/doppioni'), hidden: true }); api('/api/duplicates/count', { signal: page.signal }).then((counts) => { @@ -110,7 +120,7 @@ export default { }).catch(() => {}); page.tools(h('div', { style: { display: 'contents' } }, chips, - h('div.scelte-menu.solo-largo', accountButton, periodButton, provenanceButton), + h('div.scelte-menu.solo-largo', accountButton, periodButton, provenanceButton, copiesButton), filtersButton, h('div.destra', duplicates, @@ -123,7 +133,7 @@ export default { fill(page.body, host); function filtersActive() { - return state.tipo !== 'tutto' || state.account || state.periodo || state.dal || state.al || state.provenienza || state.q; + return state.tipo !== 'tutto' || state.account || state.periodo || state.dal || state.al || state.provenienza || state.q || state.copie; } function drawChips() { @@ -156,7 +166,9 @@ export default { else if (state.periodo) periodText = t(`libreria.periodi.${state.periodo}`); menuLabel(periodButton, periodText, state.periodo || state.dal || state.al); menuLabel(provenanceButton, state.provenienza ? t(`libreria.provenienze.${state.provenienza === 'importati' ? 'imported' : 'downloaded'}`) : t('libreria.menuProvenienza'), state.provenienza); - filtersButton.classList.toggle('primo', Boolean(state.account || state.periodo || state.dal || state.al || state.provenienza)); + menuLabel(copiesButton, copiesLabel(state.copie), state.copie); + copiesButton.hidden = !hasDestinations && !state.copie; + filtersButton.classList.toggle('primo', Boolean(state.account || state.periodo || state.dal || state.al || state.provenienza || state.copie)); } async function loadAccounts() { @@ -246,22 +258,32 @@ export default { }); } + function openCopies(anchor) { + copiesMenu(anchor, state.copie, (value) => { + state.copie = value; + apply(); + }); + } + function openFilters(anchor) { - // Narrow window: the three menus behind one button. + // Narrow window: the menus behind one button. menu(anchor, [ { label: accountButton.textContent, value: 'account', icon: 'users' }, { label: periodButton.textContent, value: 'periodo', icon: 'calendar' }, { label: provenanceButton.textContent, value: 'provenienza', icon: 'folder-input' }, - ], (value) => { + copiesButton.hidden ? null : { label: copiesButton.textContent, value: 'copie', icon: 'copy' }, + ].filter(Boolean), (value) => { if (value === 'account') openAccounts(anchor); if (value === 'periodo') openPeriod(anchor); if (value === 'provenienza') openProvenance(anchor); + if (value === 'copie') openCopies(anchor); }); } accountButton.addEventListener('click', () => openAccounts(accountButton)); periodButton.addEventListener('click', () => openPeriod(periodButton)); provenanceButton.addEventListener('click', () => openProvenance(provenanceButton)); + copiesButton.addEventListener('click', () => openCopies(copiesButton)); filtersButton.addEventListener('click', () => openFilters(filtersButton)); slider.addEventListener('input', () => { const value = Number(slider.value); @@ -281,7 +303,7 @@ export default { page.saveBar(null); return; } - page.saveBar(selectionBar(mosaic, selected, { cancel: () => setSelecting(false), exportSelected, deleteSelected })); + page.saveBar(selectionBar(mosaic, selected, { cancel: () => setSelecting(false), exportSelected, deleteSelected, copySelected: hasDestinations ? copySelected : null })); } function setSelecting(on) { @@ -293,7 +315,16 @@ export default { } selectButton.addEventListener('click', () => setSelecting(!mosaic.selecting)); - exportButton.addEventListener('click', () => exportFiltered()); + exportButton.addEventListener('click', () => exportMenu(exportButton, { + hasDestinations, + csv: exportFiltered, + copy: () => copyDialog({ query: apiQuery(state, today()), mode: mode === 'files' ? 'files' : 'grouped' }), + })); + + function copySelected() { + // «Tutte le foto»: the chosen files (spec §4.6); otherwise the chosen entries. + return copyDialog(mosaic.files ? { mediaIds: [...mosaic.selected] } : { entryIds: mosaic.selectedEntries().ids }); + } async function exportSelected() { try { @@ -361,6 +392,7 @@ export default { al: state.al || null, provenienza: state.provenienza || null, q: state.q || null, + copie: state.copie || null, }); drawChips(); drawMenus(); @@ -375,9 +407,16 @@ export default { signal: page.signal, onOpen: (tile) => openViewer({ tile, source: mosaic, origin: t('libreria.titolo'), onDeleted: (ids) => mosaic.removeTiles(ids) }), onSelection: drawSelection, - onTotals: ({ entries, accounts: n, files }) => page.count(files == null - ? t('libreria.quanti', { elementi: t('comune.elementi', { n: entries }), account: t('comune.account', { n }) }) - : t('libreria.quantiFile', { file: t('comune.file', { n: files }), elementi: t('comune.elementi', { n: entries }), account: t('comune.account', { n }) })), + onTotals: ({ entries, accounts: n, files, hasDestinations: any }) => { + page.count(files == null + ? t('libreria.quanti', { elementi: t('comune.elementi', { n: entries }), account: t('comune.account', { n }) }) + : t('libreria.quantiFile', { file: t('comune.file', { n: files }), elementi: t('comune.elementi', { n: entries }), account: t('comune.account', { n }) })); + if (any !== hasDestinations) { + hasDestinations = any; + drawMenus(); + if (mosaic) drawSelection(mosaic.selected); + } + }, onEmpty: drawEmpty, }); try { @@ -389,9 +428,15 @@ export default { } const onLibraryChange = later(() => mosaic && mosaic.refresh().catch(() => {}), 400); - page.onLibrary(onLibraryChange); + // Copies done or a folder changed: the counts may stay the same, the marks of the tiles do not. + const onExportChange = later(() => mosaic && mosaic.refreshMarks().catch(() => {}), 600); + page.onLibrary((change) => { + onLibraryChange(); + if (change && change.reason === 'export') onExportChange(); + }); page.onLeave(() => { onLibraryChange.cancel(); + onExportChange.cancel(); if (mosaic) mosaic.destroy(); }); loadAccounts().then(drawMenus).catch(() => {}); @@ -401,10 +446,11 @@ export default { }; /** - * The bar of the selection (Libreria and account view): how many are chosen, «Esporta l'elenco» and «Elimina». With - * «Tutte le foto» it counts the files and says how many entries they belong to: those are what the actions work on. + * 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 + * says how many entries they belong to: the CSV list and «Elimina» work on those, «Copia in…» on the chosen files. */ -export function selectionBar(mosaic, selected, { cancel, exportSelected, deleteSelected }) { +export function selectionBar(mosaic, selected, { cancel, exportSelected, deleteSelected, copySelected = null }) { const n = selected.size; const entries = mosaic.selectedEntries().ids.length; let note = t('selezione.nessuno'); @@ -415,6 +461,7 @@ export function selectionBar(mosaic, selected, { cancel, exportSelected, deleteS h('div.destra', 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')), + copySelected ? h('button.btn', { type: 'button', disabled: !n, onclick: copySelected }, icon('copy'), t('esportazione.selezione.copia')) : null, h('button.btn.pericolo', { type: 'button', disabled: !n, onclick: deleteSelected }, icon('trash-2'), t('selezione.elimina', { n: entries })))); } diff --git a/src/Febe.Web/wwwroot/js/pages/mosaic.js b/src/Febe.Web/wwwroot/js/pages/mosaic.js index a532a5c..be8677e 100644 --- a/src/Febe.Web/wwwroot/js/pages/mosaic.js +++ b/src/Febe.Web/wwwroot/js/pages/mosaic.js @@ -134,6 +134,16 @@ export function tileElement(tile, width, height, { selected = false, today = '', if (file && tile.files > 1) description.push(t('libreria.tesseraPosizione', { n: tile.position, totale: tile.files })); else if (!file && tile.files > 1) description.push(t('libreria.tesseraFile', { n: tile.files })); if (cover && cover.kind === 'video') description.push(t('libreria.tesseraDurata', { durata: duration(cover.duration || 0) })); + // The copies to external folders (spec §4.10): only when a destination exists does the server send a mark. Last, so + // that the place in the series stays the first mark; never colour only. + if (tile.copies === 'copied') { + marks.push(h('span.copia', { title: t('esportazione.segno.copiato') }, icon('copy'))); + description.push(t('esportazione.segno.copiato')); + } else if (tile.copies === 'partly') { + 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}`)); + description.push(parte); + } const el = h(`button.tess${selected ? '.scelta' : ''}`, { type: 'button', style: { width: `${width}px`, height: `${height}px` }, @@ -172,7 +182,8 @@ export class Mosaic { /** * scroller: the scrolling element (.corpo); host: where the groups go; query: filter as a query string; * mode: 'justified' or 'grid' (9:16 stories); files: «Tutte le foto» (one tile per file); rowHeight: target height; - * onOpen(tile), onSelection(set), onTotals({ entries, accounts, files, today }) (files only with «Tutte le foto»), + * onOpen(tile), onSelection(set), onTotals({ entries, accounts, files, today, hasDestinations }) (files only with + * «Tutte le foto»; hasDestinations: a folder of the copies exists, so the «Copie» filter and the marks make sense), * onEmpty(), dayLabel(day, count, today). */ constructor(options) { @@ -230,7 +241,7 @@ export class Mosaic { const data = await api(`/api/library/days?${this.query}`, { signal: this.signal }); if (this.destroyed) return; this.today = data.today; - this.onTotals({ entries: data.entries, accounts: data.accounts, files: data.files, today: data.today }); + this.onTotals({ entries: data.entries, accounts: data.accounts, files: data.files, today: data.today, hasDestinations: Boolean(data.hasDestinations) }); this.width = this.root.clientWidth || this.host.clientWidth || 800; for (const section of this.sections) this.unobserve(section); this.sections = []; @@ -559,7 +570,7 @@ export class Mosaic { async refresh() { const data = await api(`/api/library/days?${this.query}`, { signal: this.signal }); if (this.destroyed) return; - this.onTotals({ entries: data.entries, accounts: data.accounts, files: data.files, today: data.today }); + this.onTotals({ entries: data.entries, accounts: data.accounts, files: data.files, today: data.today, hasDestinations: Boolean(data.hasDestinations) }); // The empty state of the page took the place of the mosaic: the first new entries bring it back. if (data.days.length && !this.root.isConnected) { this.pendingNew = 0; @@ -602,6 +613,41 @@ export class Mosaic { if (!this.sections.length) this.onEmpty(); } + /** + * The copies changed (spec §4.10: a copy finished, a folder was added or taken away) and the counts did not: the + * marks of the tiles on screen are asked again and the tiles redrawn in place (the same sizes, so nothing moves); the + * days far from the view forget their tiles and load them again when they come near. + */ + async refreshMarks() { + for (const s of this.sections) { + if (!s.tiles.length || s.loading) continue; + if (!s.rendered) { + s.tiles = []; + s.complete = false; + continue; + } + try { + const page = await api(`/api/library?${this.query}${this.query ? '&' : ''}cursor=${encodeURIComponent(s.cursor)}&limit=${Math.min(600, s.tiles.length + 1)}`, { signal: this.signal }); + if (this.destroyed) return; + const fresh = new Map(page.tiles.map((x) => [this.files && x.cover ? x.cover.mediaId : x.id, x])); + let changed = false; + for (const tile of s.tiles) { + const now = fresh.get(keyOf(tile)); + if (!now) continue; + if (now.copies !== tile.copies || now.copiesDone !== tile.copiesDone || now.copiesDue !== tile.copiesDue) { + tile.copies = now.copies; + tile.copiesDone = now.copiesDone; + tile.copiesDue = now.copiesDue; + changed = true; + } + } + if (changed && s.rendered) this.render(s); + } catch (error) { + if (error.name === 'AbortError') return; + } + } + } + reset(s, day) { s.count = day.count; s.cursor = day.cursor; diff --git a/src/Febe.Web/wwwroot/js/pages/settings-export.js b/src/Febe.Web/wwwroot/js/pages/settings-export.js new file mode 100644 index 0000000..b31d56d --- /dev/null +++ b/src/Febe.Web/wwwroot/js/pages/settings-export.js @@ -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()); +} diff --git a/src/Febe.Web/wwwroot/js/pages/settings.js b/src/Febe.Web/wwwroot/js/pages/settings.js index 3384535..a827941 100644 --- a/src/Febe.Web/wwwroot/js/pages/settings.js +++ b/src/Febe.Web/wwwroot/js/pages/settings.js @@ -1,5 +1,5 @@ // Impostazioni (spec §10.3; mockups 07, 08, 10): the left sub-menu (Generali, Limiti e comportamento, Collegamento a -// Instagram, Notifiche, Dati e copie di sicurezza, Informazioni) and the section on the right. «Collegamento a +// Instagram, Notifiche, Dati e copie di sicurezza, Esportazione, Informazioni) and the section on the right. «Collegamento a // Instagram» is a page of its own (mockup 10: back link, no sub-menu). import { withCarried } from '../core/api.js'; @@ -13,6 +13,7 @@ export const SECTIONS = [ { key: 'collegamento', icon: 'key-round', load: null }, { key: 'notifiche', icon: 'bell', load: () => import('./settings-notifications.js') }, { key: 'dati', icon: 'database', load: () => import('./settings-data.js') }, + { key: 'esportazione', icon: 'hard-drive', load: () => import('./settings-export.js') }, { key: 'informazioni', icon: 'info', load: () => import('./settings-about.js') }, ]; diff --git a/src/Febe.Web/wwwroot/js/pages/viewer.js b/src/Febe.Web/wwwroot/js/pages/viewer.js index 4a98446..0488c80 100644 --- a/src/Febe.Web/wwwroot/js/pages/viewer.js +++ b/src/Febe.Web/wwwroot/js/pages/viewer.js @@ -9,6 +9,7 @@ import { h, icon, fill } from '../core/dom.js'; import { t, dayName, capitalize, bytes, duration, number, ago, shortDay } from '../core/text.js'; import { avatar, label, showError, toast } from '../core/ui.js'; import { confirmDelete } from './library.js'; +import { copyAgain, copyDialog } from './export-dialogs.js'; const KIND_ICON = { post: 'image', story: 'circle-dashed', highlight: 'star', tagged: 'square-user', profile: 'circle-user' }; @@ -248,7 +249,8 @@ export function openViewer({ tile, source, origin, onDeleted }) { row(t('vis.codice'), entry.code || entry.instagramId), 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.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)), h('section', h('h3', t('vis.provenienza')), h('dl', row(t('vis.origine'), t(entry.provenance === 'imported' ? 'vis.importato' : 'vis.scaricato')), row(t('vis.quando'), downloaded)))); @@ -265,12 +267,40 @@ export function openViewer({ tile, source, origin, onDeleted }) { ? h('button.btn', { type: 'button', onclick: () => openNative(entry.id) }, icon('external-link'), t('vis.apri')) : h('a.btn', { href: entry.instagramUrl, target: '_blank', rel: 'noopener noreferrer' }, icon('external-link'), t('vis.apri'))); } + // «Copia in…» (spec §4.6, §4.10): the file on screen goes to the folder of the copies of its account. + if (entry.canCopy && media && media.available) { + actions.push(h('button.btn', { type: 'button', onclick: () => copyDialog({ mediaIds: [media.id] }) }, icon('copy'), t('esportazione.vis.copiaIn'))); + } if (entry.state !== 'deleted') { actions.push(h('button.btn.nudo.pericolo', { type: 'button', onclick: remove }, icon('trash-2'), t('vis.elimina'))); } fill(panelBottom, actions); } + /** + * A copy of the file in an external folder (spec §4.10): «Copiato in Disco USB il 3 novembre · intero», «Tolto da + * Disco USB il 4 novembre» with «Copia di nuovo», «Superato in…», «Non riuscito in…». + */ + function copyRow(copy, media) { + const today = caps().today; + 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 text = t(`esportazione.vis.${key}`, vars) + (copy.destinationRetired ? ` (${t('esportazione.vis.tolta')})` : ''); + const again = copy.canCopyAgain + ? h('button.btn.nudo.piccolo.copia-di-nuovo', { + type: 'button', + onclick: async (e) => { + const button = e.currentTarget; + button.disabled = true; + const job = await copyAgain(copy.copyId); + if (job) await load(entry.id, fileIndex, media.id); + else button.disabled = false; + }, + }, icon('rotate-cw', 's'), t('esportazione.vis.diNuovo')) + : null; + return [h('dt', t('esportazione.vis.copia')), h('dd.riga-copia', h('span', text), again)]; + } + async function showInFolder(mediaId) { try { const result = await api('/api/media/show-in-folder', { method: 'POST', body: { mediaId } }); diff --git a/src/Febe.Web/wwwroot/js/routes.js b/src/Febe.Web/wwwroot/js/routes.js index 4628b28..a15740b 100644 --- a/src/Febe.Web/wwwroot/js/routes.js +++ b/src/Febe.Web/wwwroot/js/routes.js @@ -5,7 +5,7 @@ export const routes = [ // The Dashboard is the start page (spec §7.9, §10.2, tappa D1); the old address of Attività leads there too. { pattern: /^\/$/, redirect: '/dashboard' }, - { pattern: /^\/dashboard\/?$/, nav: 'dashboard', page: () => import('./pages/dashboard.js') }, + { pattern: /^\/dashboard(?:\/(?esportazione))?\/?$/, nav: 'dashboard', page: () => import('./pages/dashboard.js') }, { pattern: /^\/attivita\/?$/, redirect: '/dashboard' }, { pattern: /^\/libreria\/?$/, nav: 'libreria', page: () => import('./pages/library.js') }, { pattern: /^\/account\/?$/, nav: 'account', page: () => import('./pages/accounts.js') }, @@ -14,7 +14,7 @@ export const routes = [ { pattern: /^\/doppioni\/?$/, nav: 'dashboard', page: () => import('./pages/duplicates.js') }, { pattern: /^\/impostazioni\/?$/, redirect: '/impostazioni/generali' }, { - pattern: /^\/impostazioni\/(?
generali|limiti|collegamento|notifiche|dati|informazioni)\/?$/, + pattern: /^\/impostazioni\/(?
generali|limiti|collegamento|notifiche|dati|esportazione|informazioni)\/?$/, nav: 'impostazioni', page: () => import('./pages/settings.js'), }, diff --git a/src/Febe.Web/wwwroot/testi/it.json b/src/Febe.Web/wwwroot/testi/it.json index 1267699..bfe6151 100644 --- a/src/Febe.Web/wwwroot/testi/it.json +++ b/src/Febe.Web/wwwroot/testi/it.json @@ -527,6 +527,7 @@ "collegamento": "Collegamento a Instagram", "notifiche": "Notifiche", "dati": "Dati e copie di sicurezza", + "esportazione": "Esportazione", "informazioni": "Informazioni" }, "prossimamente": "Questa pagina arriva con la seconda parte dell'interfaccia.", @@ -1078,5 +1079,226 @@ "rimedio": "Che cosa fare", "ricarica": "Ricarica la pagina", "guida": "Altri problemi comuni sono spiegati nella guida." + }, + "esportazione": { + "titolo": "Esportazione", + "aiuto": "Copie dei file della libreria in cartelle fuori da Febe: un disco esterno, una chiavetta, una cartella di rete. La libreria non cambia, e nelle cartelle delle copie Febe non cancella e non sovrascrive mai nulla.", + "generale": "Cartella generale", + "generaleAiuto": "Qui vanno le copie degli account che non hanno una cartella loro, ognuno nella sottocartella con il suo nome.", + "nessunaCartella": "Nessuna cartella scelta", + "scegli": "Scegli una cartella…", + "modifica": "Modifica…", + "togli": "Togli la cartella", + "togliTitolo": "Togliere la cartella {nome}?", + "togliConferma": "I file già copiati restano dove sono.", + "togliSi": "Togli la cartella", + "pausa": "In pausa: {problema}", + "inPausa": "In pausa", + "riprova": "Riprova", + "controlla": "Controlla le copie", + "controllaAiuto": "Guarda se i file copiati sono ancora nella cartella. Nessun file viene toccato.", + "conteggi": { + "copiati": "1 copiato|{n} copiati", + "tolti": "1 tolto|{n} tolti", + "superati": "1 superato|{n} superati", + "falliti": "1 non riuscito|{n} non riusciti" + }, + "tipiScelti": "Tipi: {elenco}", + "tuttiITipi": "tutti", + "nomiLibreria": "nomi come la libreria", + "nomiSuoi": "nomi con uno schema suo", + "salvata": "Cartella delle copie salvata.", + "stessoPost": "Lo stesso post in due account", + "stessoPostAiuto": "Quando lo stesso file è il post di un account e il taggato di un altro: una copia per ciascun account, ognuna nella sua cartella, oppure una copia sola, nel primo account che la copia; l'altro la mostra «Copiato» con la cartella dove sta.", + "unaPerAccount": "Una copia per account", + "unaSola": "Una copia sola", + "cartelleAccount": "Cartelle degli account", + "cartelleAccountAiuto": "Un account può avere una cartella sua al posto di quella generale: si sceglie nella scheda dell'account, Impostazioni, blocco «Copie esterne».", + "nessunaPropria": "Nessun account ha una cartella sua.", + "colonne": { + "account": "Account", + "cartella": "Cartella", + "stato": "Copie" + }, + "eraDi": "era di @{nome}", + "daRiprendere": "1 copia da riprendere.|{n} copie da riprendere.", + "apriEsportazione": "Apri l'esportazione", + "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": { + "titoloGenerale": "Cartella generale delle copie", + "titoloAccount": "Cartella delle copie di @{nome}", + "cartella": "Cartella", + "cartellaAiuto": "Una cartella che esiste già, fuori da Dati, Libreria e dalle cartelle degli account; non la radice di un disco. Va bene anche una cartella di rete.", + "cartellaAiutoDocker": "Una sottocartella di {radice} che esiste già: scegli il suo nome, la freccia apre le cartelle che contiene.", + "scegliDocker": "Nessuna cartella scelta.", + "percorso": "Percorso della cartella", + "sfoglia": "Scegli…", + "su": "Su", + "apri": "Apri {nome}", + "vuota": "Nessuna sottocartella qui.", + "controllo": "Controllo la cartella…", + "liberi": "{nome} · liberi {spazio}", + "fat32": "Disco FAT32: i file oltre 4 GB non si copiano.", + "cambiata": "Le copie già fatte restano nella cartella di prima; qui si ricomincia, e i file già presenti si riconoscono.", + "tipi": "Che cosa copiare", + "tipiAiuto": "Una storia entrata in una raccolta in evidenza conta anche come evidenza.", + "nessunTipo": "Scegli almeno un tipo.", + "nomi": "Nomi dei file", + "comeLibreria": "Come la libreria", + "comeLibreriaAiuto": "Gli schemi di Impostazioni → Generali, anche quando cambiano.", + "suo": "Uno schema suo", + "suoAiuto": "Schemi solo per questa cartella, con le regole di quelli della libreria.", + "notaAccount": "Febe mette sempre per primo il nome dell'account, perché gli account non si scontrino.", + "schema": "Schema", + "schemaEvidenza": "Schema per le raccolte in evidenza", + "schemaProfilo": "Schema per le foto del profilo", + "segnaposto": "Segnaposto: {elenco}.", + "risultato": "Risultato", + "salva": "Salva la cartella" + }, + "tipi": { + "postFoto": "Post foto", + "postVideo": "Post video", + "storie": "Storie", + "evidenza": "In evidenza", + "taggati": "Taggati", + "profilo": "Foto del profilo" + }, + "copia": { + "titolo": "Copia in…", + "conto": "Conto i file…", + "file": "1 file|{n} file", + "giaCopiati": "1 già copiato, saltato|{n} già copiati, saltati", + "tolti": "1 tolto o superato, saltato|{n} tolti o superati, saltati", + "toltiDiNuovo": "1 tolto o superato, copiato di nuovo|{n} tolti o superati, copiati di nuovo", + "nonEsportati": "1 di un account che non si esporta|{n} di account che non si esportano", + "mancanti": "1 non presente in libreria|{n} non presenti in libreria", + "circa": "circa {spazio}", + "verso": "In {nome}", + "versoGenerale": "cartella generale", + "versoAccount": "cartella di @{nome}", + "liberi": "liberi {spazio}", + "inAttesa": "{problema} I file restano in attesa: la copia riparte con «Riprendi» nella Dashboard, scheda Esportazione.", + "diNuovo": "Copia di nuovo anche 1 tolto o superato|Copia di nuovo anche i {n} tolti o superati", + "diNuovoAiuto": "Scrive un file nuovo; la copia di prima resta dov'è.", + "niente": "Niente da copiare: i file scelti sono già copiati, non si esportano o non sono in libreria.", + "nessunaCartella": "Nessuna cartella delle copie: scegline una in Impostazioni → Esportazione.", + "pulsante": "Copia 1 file|Copia {n} file", + "vediAvanzamento": "Apri l'esportazione" + }, + "filtro": { + "titolo": "Copie", + "tutti": "Tutti", + "nonCopiati": "Non ancora copiati", + "copiati": "Copiati", + "tolti": "Tolti o superati" + }, + "segno": { + "copiato": "copiato", + "parte": "copiato in parte, {n} file di {totale}" + }, + "vis": { + "copia": "Copia", + "copiato": "Copiato in {cartella} il {giorno} · intero", + "copiatoPer": "Copiato per @{nome} in {cartella} il {giorno} · intero", + "tolto": "Tolto da {cartella} il {giorno}", + "superato": "Superato in {cartella} il {giorno}", + "fallito": "Non riuscito in {cartella} il {giorno}", + "tolta": "cartella tolta", + "diNuovo": "Copia di nuovo", + "copiaIn": "Copia in…" + }, + "account": { + "titolo": "Copie esterne", + "aiuto": "Copie dei file di questo account in una cartella fuori da Febe, con «Copia in…». I file già copiati si saltano.", + "interruttore": "Esporta questo account", + "spento": "Questo account non si esporta: «Copia in…» lo salta. Le copie già fatte restano dove sono.", + "generale": "Nella cartella generale", + "sua": "Nella sua cartella", + "nessuna": "Nessuna cartella delle copie: scegline una qui o in Impostazioni → Esportazione.", + "scegliSua": "Scegli una cartella sua…", + "usaGenerale": "Usa la cartella generale", + "usaGeneraleTitolo": "Usare la cartella generale per @{nome}?", + "usaGeneraleTesto": "La cartella sua si toglie: i file già copiati restano dove sono, le copie nuove vanno nella cartella generale.", + "togliTitolo": "Togliere la cartella di @{nome}?", + "togliTesto": "I file già copiati restano dove sono. Senza una cartella generale l'account non ha più dove copiare.", + "conteggio": "{n} su {totale} non ancora copiati", + "tuttiCopiati": "1 file, già copiato|Tutti i {n} file sono copiati", + "nessunFile": "Nessun file da copiare con i tipi di questa cartella", + "tolti": "1 tolto o superato|{n} tolti o superati", + "falliti": "1 non riuscito|{n} non riusciti", + "copiaIn": "Copia in…" + }, + "selezione": { + "copia": "Copia in…" + }, + "libreria": { + "menu": "Esporta", + "menuCsv": "Esporta l'elenco (CSV)", + "menuCopia": "Copia i file in…" + }, + "dashboard": { + "linguette": "Sezioni della Dashboard", + "motore": "Motore", + "esportazione": "Esportazione", + "inCorso": "In corso", + "nessunaInCorso": "Nessuna copia al lavoro.", + "copio": "Copio in {cartella}", + "fatti": "{fatti} di {totale} file", + "byte": "{fatti} di {totale}", + "ora": "Ora: {file}", + "fasi": { + "preparing": "Preparo la copia…", + "checking": "Controllo la cartella…", + "waitingForSession": "Aspetto la fine della sessione del motore: durante una sessione non si copia." + }, + "interrompi": "Interrompi", + "daRiprendere": "Da riprendere", + "interrotta": "Copia in {cartella} interrotta: {fatti} di {totale} file fatti.", + "ferma": "Copia in {cartella} in pausa: {problema}", + "cartellaInPausa": "{cartella} è in pausa: {problema}", + "riprendi": "Riprendi", + "riprendiTutte": "Riprendi tutte", + "annulla": "Annulla", + "annullaTitolo": "Annullare la copia in {cartella}?", + "annullaTesto": "I file già copiati restano dove sono; quelli che mancano non si copiano.", + "annullaSi": "Annulla la copia", + "ultimi": "Ultimi lavori", + "vuoto": "Nessuna copia ancora. Le copie partono da «Copia in…» nella Libreria, nel visualizzatore o nella scheda di un account.", + "lavoroCopia": "Copia in {cartella}", + "lavoroControllo": "Controllo delle copie in {cartella}", + "stati": { + "running": "In corso", + "interrupted": "Interrotta", + "paused": "In pausa", + "completed": "Completata", + "cancelled": "Annullata" + }, + "resoconto": "Resoconto", + "resocontoTitolo": "Resoconto: {lavoro}", + "iniziata": "Iniziata {quando}", + "finita": "finita {quando}", + "copiatiByte": "{spazio} scritti", + "statiFile": { + "pending": "1 in attesa|{n} in attesa", + "copied": "1 copiato|{n} copiati", + "adopted": "1 già presente, riconosciuto|{n} già presenti, riconosciuti", + "alreadyCopied": "1 già copiato|{n} già copiati", + "skipped": "1 saltato|{n} saltati", + "missing": "1 non presente in libreria|{n} non presenti in libreria", + "failed": "1 non riuscito|{n} non riusciti" + }, + "perAccount": "Per account", + "colonne": { + "account": "Account", + "copiati": "Copiati", + "gia": "Già copiati", + "saltati": "Saltati", + "falliti": "Non riusciti" + }, + "problemi": "File da guardare", + "nessunProblema": "Nessun file da guardare.", + "avvisoDaRiprendere": "1 copia da riprendere.|{n} copie da riprendere." + } } } diff --git a/tests/Febe.Tests/Web/HostingAndSecurityTests.cs b/tests/Febe.Tests/Web/HostingAndSecurityTests.cs index fa11106..d6da58c 100644 --- a/tests/Febe.Tests/Web/HostingAndSecurityTests.cs +++ b/tests/Febe.Tests/Web/HostingAndSecurityTests.cs @@ -17,7 +17,7 @@ public sealed class HostingAndSecurityTests [ "/", "/libreria", "/account", "/account/12", "/account/12/impostazioni", "/attivita", "/importa", "/impostazioni/generali", "/impostazioni/limiti", "/impostazioni/collegamento", "/impostazioni/notifiche", - "/impostazioni/dati", "/impostazioni/informazioni", "/browser", + "/impostazioni/dati", "/impostazioni/esportazione", "/impostazioni/informazioni", "/browser", "/dashboard/esportazione", ]; [TestMethod]