@cardinali-studio/adminkit 2.2.49 → 2.2.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/App.js +6 -6
- package/dist/app/app.css +110 -1
- package/dist/app/delivery.js +7 -7
- package/dist/app/guide/TransferGuide.js +1 -1
- package/dist/app/lib/deliveries.d.ts +6 -0
- package/dist/app/lib/delivery-capabilities.d.ts +31 -0
- package/dist/app/lib/delivery-capabilities.js +115 -0
- package/dist/app/lib/delivery-checkpoint-pipeline.d.ts +81 -0
- package/dist/app/lib/delivery-checkpoint-pipeline.js +195 -0
- package/dist/app/lib/delivery-finalize.d.ts +21 -0
- package/dist/app/lib/delivery-finalize.js +42 -0
- package/dist/app/lib/delivery-multipart-large.d.ts +18 -0
- package/dist/app/lib/delivery-multipart-large.js +28 -0
- package/dist/app/lib/delivery-network.d.ts +7 -1
- package/dist/app/lib/delivery-network.js +85 -18
- package/dist/app/lib/delivery-part-pipeline.d.ts +79 -0
- package/dist/app/lib/delivery-part-pipeline.js +270 -0
- package/dist/app/lib/delivery-upload-coordinator.d.ts +112 -0
- package/dist/app/lib/delivery-upload-coordinator.js +229 -0
- package/dist/app/lib/delivery-upload.d.ts +19 -3
- package/dist/app/lib/delivery-upload.js +226 -29
- package/dist/app/lib/upload-queue.d.ts +5 -0
- package/dist/app/lib/upload-queue.js +54 -29
- package/dist/app/routes/Deliveries.d.ts +9 -3
- package/dist/app/routes/Deliveries.js +318 -189
- package/dist/app/routes/DeliveryDashboard.js +1 -1
- package/dist/app/routes/DeliveryEmail.d.ts +8 -1
- package/dist/app/routes/DeliveryEmail.js +63 -23
- package/dist/app/routes/DeliveryRecipientPreview.d.ts +14 -0
- package/dist/app/routes/DeliveryRecipientPreview.js +49 -0
- package/dist/app/routes/Overview.js +5 -5
- package/dist/app/routes/UploadDock.js +4 -3
- package/dist/form/media/MediaGrid.js +1 -1
- package/dist/functions/_shared/b2.js +98 -19
- package/dist/functions/_shared/delivery-activation.js +98 -0
- package/dist/functions/_shared/delivery-download-bundle.js +280 -0
- package/dist/functions/_shared/delivery-email.js +92 -13
- package/dist/functions/_shared/delivery-file-names.js +19 -0
- package/dist/functions/_shared/delivery-finalization-paid.js +31 -0
- package/dist/functions/_shared/delivery-finalization-storage.js +64 -0
- package/dist/functions/_shared/delivery-manifest-free.js +74 -0
- package/dist/functions/_shared/delivery-manifest.js +277 -20
- package/dist/functions/_shared/delivery-multipart-verification.js +68 -0
- package/dist/functions/_shared/delivery-request.js +74 -0
- package/dist/functions/_shared/delivery-storage-access.js +14 -0
- package/dist/functions/_shared/delivery-upload-admission.js +221 -0
- package/dist/functions/_shared/delivery-upload-contract.js +44 -0
- package/dist/functions/_shared/delivery-upload-free.js +80 -0
- package/dist/functions/_shared/delivery-upload-policy.js +64 -0
- package/dist/functions/_shared/delivery-upload-session.js +365 -0
- package/dist/functions/_shared/delivery-work-budget.js +49 -0
- package/dist/functions/api/deliveries.js +58 -17
- package/dist/functions/api/delivery/multipart.js +152 -15
- package/dist/functions/delivery-public/assets/client.js +59 -54
- package/dist/functions/delivery-public/assets/delivery.css +6 -2
- package/dist/functions/delivery-public/index.js +43 -15
- package/dist/functions/delivery-public/migrations/0015_delivery_activation_intents.sql +12 -0
- package/dist/functions/delivery-public/migrations/0016_delivery_multipart_verification.sql +16 -0
- package/dist/functions/delivery-public/migrations/0017_delivery_upload_admission.sql +38 -0
- package/dist/functions/delivery-public/migrations/0018_delivery_upload_sessions.sql +26 -0
- package/dist/functions/delivery-public/migrations/0019_delivery_manifest_fragments.sql +27 -0
- package/dist/functions/delivery-public/migrations/0020_delivery_email_reply_to.sql +1 -0
- package/dist/functions/index.js +3 -1
- package/dist/theme.css +2 -1
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@ export function DeliveryDashboard({ onCreate, onOpen }) {
|
|
|
46
46
|
const running = checking || data?.storage.status === "running";
|
|
47
47
|
useEffect(() => { const timer = setTimeout(() => void load(), running || (data?.storage.enabled && !data.storage.checkedAt) ? 3000 : 60_000); return () => clearTimeout(timer); }, [data, running, load]);
|
|
48
48
|
const storage = data?.storage, snapshot = storage?.snapshot;
|
|
49
|
-
return _jsxs("section", { className: "dd-dashboard", "aria-label": "Dashboard consegne", children: [_jsxs("header", { className: "dd-heading", children: [_jsxs("div", { children: [_jsx("p", { className: "dd-eyebrow", children: "Consegne" }), _jsx("h2", { children: "Panoramica transfer" }), _jsx("p", { children: "Disponibilit\u00E0, richieste di download e spazio realmente occupato." })] }), _jsxs("div", { className: "dd-heading-actions", children: [_jsxs("a", { className: "ak-btn", href: typeof window === "undefined" ? "?adminkit-guide=transfer" : transferGuideHref(window.location.href), target: "_blank", rel: "noopener noreferrer", "aria-label": "Guida ai Transfer (si apre in una nuova scheda)", children: ["Guida ai Transfer ", _jsx(Icon.out, {})] }), _jsx("button", { className: "ak-btn ak-btn-primary", onClick: onCreate, children: "Nuovo transfer" })] })] }), error && _jsxs("div", { className: "dd-error", role: "alert", children: [error, " ", _jsx("button", { className: "ak-btn", onClick: () => void load(), children: "Riprova" })] }), _jsxs("div", { className: "dd-metrics", children: [_jsx(Metric, { label: "Transfer attivi", value: data?.active, note: "Pubblicati, disponibili e con un link valido" }), _jsx(Metric, { label: "Spazio transfer attivi", value: bytes(storage?.activeBytes), note: storage?.checkedAt ? "
|
|
49
|
+
return _jsxs("section", { className: "dd-dashboard", "aria-label": "Dashboard consegne", children: [_jsxs("header", { className: "dd-heading", children: [_jsxs("div", { children: [_jsx("p", { className: "dd-eyebrow", children: "Consegne" }), _jsx("h2", { children: "Panoramica transfer" }), _jsx("p", { children: "Disponibilit\u00E0, richieste di download e spazio realmente occupato." })] }), _jsxs("div", { className: "dd-heading-actions", children: [_jsxs("a", { className: "ak-btn", href: typeof window === "undefined" ? "?adminkit-guide=transfer" : transferGuideHref(window.location.href), target: "_blank", rel: "noopener noreferrer", "aria-label": "Guida ai Transfer (si apre in una nuova scheda)", children: ["Guida ai Transfer ", _jsx(Icon.out, {})] }), _jsx("button", { className: "ak-btn ak-btn-primary", onClick: onCreate, children: "Nuovo transfer" })] })] }), error && _jsxs("div", { className: "dd-error", role: "alert", children: [error, " ", _jsx("button", { className: "ak-btn", onClick: () => void load(), children: "Riprova" })] }), _jsxs("div", { className: "dd-metrics", children: [_jsx(Metric, { label: "Transfer attivi", value: data?.active, note: "Pubblicati, disponibili e con un link valido" }), _jsx(Metric, { label: "Spazio transfer attivi", value: bytes(storage?.activeBytes), note: storage?.checkedAt ? "Aggiornato il " + date(storage.checkedAt) : storage?.enabled ? "In attesa della prima verifica" : "Dato non disponibile" }), _jsx(Metric, { label: "Con download richiesto", value: data?.withRequests, note: "Almeno una richiesta di download" }), _jsx(Metric, { label: "Senza richieste", value: data?.withoutRequests, note: "Nessuna richiesta di download registrata" })] }), site().deliveryPricing && _jsx(DeliveryCostEstimate, { totalBytes: snapshot?.totalBytes, pricing: site().deliveryPricing }), (storage?.enabled || snapshot) && _jsxs("section", { className: "dd-storage", "aria-label": "Spazio utilizzato", children: [_jsxs("div", { className: "dd-storage-head", children: [_jsxs("div", { children: [_jsxs("div", { className: "dd-title-row", children: [_jsx("h3", { children: "Spazio utilizzato" }), _jsx("span", { className: "dd-status" + (running ? " is-running" : storage?.error ? " is-error" : ""), children: running ? "Verifica in corso" : storage?.error ? "Verifica non riuscita" : storage?.checkedAt ? "Verificato" : "Da verificare" })] }), _jsx("p", { children: storage?.checkedAt ? `Ultima verifica completata: ${date(storage.checkedAt)}. Controllo automatico ogni ora.` : "Verifica quanto spazio occupano i tuoi transfer." })] }), _jsx("button", { className: "ak-btn", disabled: running || !storage?.enabled, onClick: () => void load(true), children: running ? "Verifica in corso…" : "Verifica ora" })] }), storage?.error && _jsxs("p", { className: "dd-notice", role: "status", children: ["Non \u00E8 stato possibile verificare lo spazio. ", snapshot ? "I valori si riferiscono all’ultima verifica." : "Riprova tra poco."] }), _jsxs("div", { className: "dd-storage-grid", children: [_jsx(Metric, { label: "Spazio totale", value: bytes(snapshot?.totalBytes), note: snapshot ? `${snapshot.currentObjects} ${snapshot.currentObjects === 1 ? "elemento archiviato" : "elementi archiviati"} · ${snapshot.objectVersions} ${snapshot.objectVersions === 1 ? "versione" : "versioni"}` : "Nessun risultato ancora disponibile" }), _jsx(Metric, { label: "Versioni nascoste", value: bytes(snapshot?.hiddenBytes), note: "Byte conservati nelle versioni precedenti" }), _jsx(Metric, { label: "Upload incompleti", value: bytes(snapshot?.incompleteBytes), note: snapshot ? `${snapshot.incompleteUploads} caricamenti da completare` : "File in attesa di completamento" }), _jsx(Metric, { label: "Senza consegna associata", value: bytes(snapshot?.unassignedBytes), note: "Dati senza un riferimento nei transfer" })] }), _jsx("p", { className: "dd-footnote", children: "Versioni nascoste e upload incompleti sono inclusi nel totale. I dati senza consegna possono includerli." })] }), _jsxs("section", { className: "dd-transfers", children: [_jsxs("div", { className: "dd-title-row", children: [_jsx("h3", { children: "Transfer attivi" }), _jsxs("span", { children: [data?.requestedDownloads ?? "—", " richieste di download complessive"] })] }), _jsx("p", { className: "dd-footnote", children: "Una richiesta indica l\u2019uso del pulsante di download; non conferma che il file sia stato ricevuto per intero." }), !data ? _jsx("p", { className: "ak-hint", role: "status", children: "Carico la panoramica\u2026" }) : !data.transfers.length ? _jsx("p", { className: "dd-empty", children: "Nessun transfer attivo. Crea un nuovo transfer per iniziare." }) :
|
|
50
50
|
_jsx("div", { className: "dd-table-wrap", children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Transfer" }), _jsx("th", { children: "Spazio occupato" }), _jsx("th", { children: "Download richiesti" }), _jsx("th", { children: "Scadenza file" })] }) }), _jsx("tbody", { children: data.transfers.map(t => _jsxs("tr", { children: [_jsx("td", { children: _jsxs("button", { className: "dd-transfer-link", onClick: () => onOpen(t.id), children: [_jsx("strong", { children: t.clientName || t.title }), t.clientName && _jsx("span", { children: t.title })] }) }), _jsx("td", { children: bytes(t.storedBytes) }), _jsx("td", { children: _jsx("span", { className: "dd-request" + (!t.downloadCount ? " is-pending" : ""), children: t.downloadCount ? `${t.downloadCount} ${t.downloadCount === 1 ? "richiesta" : "richieste"}` : "Nessuna richiesta" }) }), _jsx("td", { children: t.expiresAt ? new Intl.DateTimeFormat("it-IT", { dateStyle: "medium" }).format(new Date(t.expiresAt)) : "Senza scadenza" })] }, t.id)) })] }) })] })] });
|
|
51
51
|
}
|
|
52
52
|
function Metric({ label, value, note }) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface EmailPreferences {
|
|
2
2
|
recipientEmail: string;
|
|
3
|
+
replyToEmail?: string;
|
|
3
4
|
notifyOwner: boolean;
|
|
4
5
|
sendRecipient: boolean;
|
|
5
6
|
}
|
|
@@ -8,6 +9,8 @@ interface EmailState {
|
|
|
8
9
|
enabled: boolean;
|
|
9
10
|
ownerEnabled: boolean;
|
|
10
11
|
ownerEmail: string;
|
|
12
|
+
fromEmail?: string;
|
|
13
|
+
replyToEditable?: boolean;
|
|
11
14
|
settingsVersion?: number;
|
|
12
15
|
settingsEditable?: boolean;
|
|
13
16
|
notifyDownloads?: boolean;
|
|
@@ -20,12 +23,16 @@ interface EmailState {
|
|
|
20
23
|
recipient: string;
|
|
21
24
|
state: string;
|
|
22
25
|
sentAt: string | null;
|
|
26
|
+
createdAt?: string;
|
|
23
27
|
reason?: 'ready' | 'download';
|
|
24
28
|
}>;
|
|
25
29
|
migrationRequired?: boolean;
|
|
26
30
|
}
|
|
27
31
|
export declare function saveTransferEmailPreferences(id: string, p: EmailPreferences): Promise<EmailState>;
|
|
28
|
-
export declare function DeliveryEmail({ id, value, onChange, busy, onState, unsaved }: {
|
|
32
|
+
export declare function DeliveryEmail({ id, value, onChange, busy, onState, unsaved, hydratePreferences, canResend, activityTarget }: {
|
|
33
|
+
activityTarget?: HTMLElement | null;
|
|
34
|
+
canResend?: boolean;
|
|
35
|
+
hydratePreferences?: boolean;
|
|
29
36
|
id?: string;
|
|
30
37
|
value: EmailPreferences;
|
|
31
38
|
onChange: (v: EmailPreferences) => void;
|
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
async function request(url, body) {
|
|
5
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
async function request(url, body) {
|
|
5
|
+
const unavailable = 'Email momentaneamente non disponibile. Riprova tra poco.';
|
|
6
|
+
let response;
|
|
7
|
+
try {
|
|
8
|
+
response = await fetch(url, { credentials: 'same-origin', ...(body ? { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : {}) });
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
throw Error('Controlla la connessione e riprova.');
|
|
12
|
+
}
|
|
13
|
+
const value = await response.json().catch(() => null);
|
|
14
|
+
if (!response.ok || !value?.ok)
|
|
15
|
+
throw Error(response.status < 500 && value?.error ? value.error : unavailable);
|
|
16
|
+
return value.email;
|
|
17
|
+
}
|
|
6
18
|
export async function saveTransferEmailPreferences(id, p) { return request('/admin/api/deliveries', { action: 'emailPreferences', id, ...p }); }
|
|
7
|
-
export function DeliveryEmail({ id, value, onChange, busy, onState, unsaved = false }) {
|
|
8
|
-
const [state, setState] = useState(null), [error, setError] = useState(''), [working, setWorking] = useState(false), [confirm, setConfirm] = useState(null);
|
|
19
|
+
export function DeliveryEmail({ id, value, onChange, busy, onState, unsaved = false, hydratePreferences = true, canResend = true, activityTarget }) {
|
|
20
|
+
const [state, setState] = useState(null), [error, setError] = useState(''), [working, setWorking] = useState(false), [resendError, setResendError] = useState(''), [confirm, setConfirm] = useState(null);
|
|
9
21
|
useEffect(() => {
|
|
10
22
|
let alive = true;
|
|
11
23
|
setState(null);
|
|
12
24
|
setError('');
|
|
25
|
+
setResendError('');
|
|
26
|
+
setConfirm(null);
|
|
13
27
|
// Configuration is readable without a transfer; no recipient data is returned.
|
|
14
28
|
request('/admin/api/deliveries?email=1' + (id ? '&id=' + encodeURIComponent(id) : ''))
|
|
15
29
|
.then(v => { if (alive) {
|
|
16
30
|
setState(v);
|
|
17
|
-
if (id)
|
|
31
|
+
if (id && hydratePreferences)
|
|
18
32
|
onState?.(v.preferences);
|
|
19
33
|
} }).catch(e => { if (alive)
|
|
20
34
|
setError(e.message); });
|
|
21
35
|
return () => { alive = false; };
|
|
22
36
|
}, [id]);
|
|
37
|
+
const previouslyBusy = useRef(busy);
|
|
23
38
|
const pending = state?.messages.some(m => m.state === 'pending' || m.state === 'sending') || false;
|
|
24
39
|
useEffect(() => {
|
|
25
40
|
if (!id)
|
|
@@ -27,24 +42,49 @@ export function DeliveryEmail({ id, value, onChange, busy, onState, unsaved = fa
|
|
|
27
42
|
let active = true;
|
|
28
43
|
const refresh = () => request('/admin/api/deliveries?email=1&id=' + encodeURIComponent(id)).then(v => { if (active)
|
|
29
44
|
setState(v); }).catch(() => { });
|
|
30
|
-
if (!busy)
|
|
45
|
+
if (previouslyBusy.current && !busy)
|
|
31
46
|
void refresh();
|
|
47
|
+
previouslyBusy.current = busy;
|
|
32
48
|
const timer = busy || pending ? setInterval(refresh, 5000) : null;
|
|
33
49
|
return () => { active = false; if (timer)
|
|
34
50
|
clearInterval(timer); };
|
|
35
51
|
}, [id, busy, pending]);
|
|
36
|
-
const labels = { pending: 'In attesa
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
const labels = { pending: 'In attesa', sending: 'Invio in corso', sent: 'Inviata', failed: 'Invio non riuscito', review: 'Verifica con chi doveva riceverla prima di reinviare.', cancelled: 'Annullata' };
|
|
53
|
+
const config = state?.configuration;
|
|
54
|
+
const sender = config?.ownerEmail || config?.fromEmail || '';
|
|
55
|
+
const history = state?.messages || [];
|
|
56
|
+
const targets = new Set();
|
|
57
|
+
const issues = history.filter(message => {
|
|
58
|
+
const target = [message.kind, message.reason || 'ready', message.recipient].join('|');
|
|
59
|
+
if (targets.has(target))
|
|
60
|
+
return false;
|
|
61
|
+
targets.add(target);
|
|
62
|
+
return message.state === 'failed' || message.state === 'review';
|
|
63
|
+
});
|
|
64
|
+
const messages = history.filter(message => message.kind === 'recipient' || issues.includes(message));
|
|
65
|
+
const resendKinds = ['owner', 'recipient'].filter(kind => kind === 'owner' ? config?.ownerEnabled && config?.notifyReady !== false : value.sendRecipient && value.recipientEmail);
|
|
66
|
+
const showResend = canResend && config?.enabled && resendKinds.length > 0;
|
|
67
|
+
const activity = id && (messages.length > 0 || showResend) ? (_jsxs("details", { className: "dl-email-activity", children: [_jsxs("summary", { children: [messages.length ? 'Cronologia email' : 'Opzioni email', issues.length > 0 && _jsx("span", { className: "dl-email-attention", children: "Invio da verificare" })] }), messages.length > 0 && _jsx("ul", { className: "dl-email-log", "aria-label": "Stato delle email", children: messages.map(message => {
|
|
68
|
+
const label = message.kind === 'recipient' ? 'Link al destinatario'
|
|
69
|
+
: message.reason === 'download' ? 'Avviso di download al titolare' : 'Conferma di caricamento al titolare';
|
|
70
|
+
const at = message.sentAt || message.createdAt;
|
|
71
|
+
return _jsxs("li", { children: [_jsx("strong", { children: label }), _jsx("span", { children: message.recipient }), _jsxs("span", { children: [labels[message.state] || 'Stato non disponibile', at && _jsxs(_Fragment, { children: [" \u00B7 ", _jsx("time", { dateTime: at, children: new Date(at).toLocaleString('it-IT', { dateStyle: 'short', timeStyle: 'short' }) })] })] })] }, message.id);
|
|
72
|
+
}) }), showResend && _jsx("div", { className: "dl-link-actions", children: resendKinds.map(kind => _jsxs("button", { type: "button", className: "ak-btn", disabled: busy || working || unsaved, title: unsaved ? "Salva prima le modifiche del transfer" : undefined, onClick: () => { setResendError(''); setConfirm(kind); }, children: ["Reinvia ", kind === 'owner' ? 'notifica al titolare' : 'email al destinatario'] }, kind)) }), confirm && _jsxs("div", { className: "dl-email-confirm", children: [_jsxs("p", { children: ["Reinviare l\u2019email a ", confirm === 'owner' ? config?.ownerEmail : value.recipientEmail, "?"] }), _jsx("button", { type: "button", className: "ak-btn ak-btn-primary", disabled: working || busy, onClick: async () => {
|
|
73
|
+
setWorking(true);
|
|
74
|
+
setResendError('');
|
|
75
|
+
try {
|
|
76
|
+
await saveTransferEmailPreferences(id, value);
|
|
77
|
+
setState(await request('/admin/api/deliveries', { action: 'emailSend', id, kind: confirm }));
|
|
78
|
+
setConfirm(null);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
setResendError(e instanceof Error ? e.message : 'Invio non riuscito');
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
setWorking(false);
|
|
85
|
+
}
|
|
86
|
+
}, children: "Conferma invio" }), _jsx("button", { className: "ak-btn", type: "button", disabled: working, onClick: () => setConfirm(null), children: "Annulla" })] }), resendError && _jsx("p", { className: "ak-error", role: "alert", children: resendError })] })) : null;
|
|
87
|
+
return _jsxs("section", { className: "dl-email dl-quick-email", "aria-label": "Indirizzi email", children: [_jsxs("label", { className: "dl-field", children: [_jsx("span", { children: "Email del destinatario" }), _jsx("input", { type: "email", autoComplete: "off", pattern: "[^ @]+@[^ @]+[.][^ @]+", maxLength: 254, value: value.sendRecipient ? value.recipientEmail : '', placeholder: "cliente@esempio.it", disabled: busy || !config?.enabled, onChange: event => onChange({ ...value, recipientEmail: event.target.value, sendRecipient: !!event.target.value.trim() }) }), _jsx("small", { children: error || (state && !config?.enabled ? 'Puoi condividere questo transfer tramite link.' : 'Lascia vuoto per ottenere solo il link.') })] }), _jsxs("label", { className: "dl-field", children: [_jsx("span", { children: "Email del mittente" }), _jsx("input", { type: "email", autoComplete: "email", pattern: "[^ @]+@[^ @]+[.][^ @]+", maxLength: 254, value: value.replyToEmail ?? sender, readOnly: !config?.replyToEditable, disabled: busy || !config?.enabled, placeholder: sender || 'Indirizzo del sito', onChange: event => onChange({ ...value, replyToEmail: event.target.value }) }), config?.enabled && _jsx("small", { children: "Le risposte arrivano a questo indirizzo." })] }), activityTarget ? createPortal(activity, activityTarget) : activityTarget === undefined ? activity : null] });
|
|
48
88
|
}
|
|
49
89
|
export function DeliveryEmailConfiguration() {
|
|
50
90
|
const [config, setConfig] = useState(null), [owner, setOwner] = useState(''), [downloads, setDownloads] = useState(true), [ready, setReady] = useState(true), [busy, setBusy] = useState(false), [error, setError] = useState(''), [notice, setNotice] = useState('');
|
|
@@ -59,7 +99,7 @@ export function DeliveryEmailConfiguration() {
|
|
|
59
99
|
setError(e instanceof Error ? e.message : 'Impostazioni non disponibili');
|
|
60
100
|
} };
|
|
61
101
|
useEffect(() => { void load(); }, []);
|
|
62
|
-
return _jsxs("section", { className: "dl-card dl-email-config", "aria-labelledby": "dl-email-settings-title", children: [_jsxs("div", { className: "dl-section-head", children: [_jsx("h3", { id: "dl-email-settings-title", children: "Email dei Transfer" }), _jsx("p", { children: "Notifiche al titolare e invio automatico del link ai destinatari." })] }), _jsx("p", { children:
|
|
102
|
+
return _jsxs("section", { className: "dl-card dl-email-config", "aria-labelledby": "dl-email-settings-title", children: [_jsxs("div", { className: "dl-section-head", children: [_jsx("h3", { id: "dl-email-settings-title", children: "Email dei Transfer" }), _jsx("p", { children: "Notifiche al titolare e invio automatico del link ai destinatari." })] }), config && !config.enabled && _jsx("p", { children: "L\u2019invio email \u00E8 disattivato. Puoi condividere i transfer tramite link." }), _jsxs("form", { onSubmit: async (e) => { e.preventDefault(); setBusy(true); setError(''); setNotice(''); try {
|
|
63
103
|
const v = await request('/admin/api/deliveries', { action: 'emailSettings', ownerEmail: owner, notifyDownloads: downloads, notifyReady: ready, settingsVersion: config?.settingsVersion ?? 0 });
|
|
64
104
|
setConfig(v.configuration);
|
|
65
105
|
setOwner(v.configuration.ownerEmail);
|
|
@@ -70,5 +110,5 @@ export function DeliveryEmailConfiguration() {
|
|
|
70
110
|
}
|
|
71
111
|
finally {
|
|
72
112
|
setBusy(false);
|
|
73
|
-
} }, children: [_jsxs("label", { className: "dl-field", children: [_jsx("span", { children: "Email del titolare" }), _jsx("input", { type: "email", autoComplete: "email", maxLength: 254, value: owner, disabled: busy || !config?.settingsEditable, onChange: e => { setOwner(e.target.value); setNotice(''); }, placeholder: "titolare@esempio.it" }), _jsx("small", { children: "Riceve gli avvisi dei Transfer ed \u00E8 l\u2019indirizzo a cui i destinatari possono rispondere. Lascia vuoto per disattivare gli avvisi al titolare." })] }), _jsxs("label", { className: "dl-check", children: [_jsx("input", { type: "checkbox", checked: ready, disabled: busy || !config?.settingsEditable, onChange: e => { setReady(e.target.checked); setNotice(''); } }), _jsxs("span", { children: [_jsx("strong", { children: "Avvisami quando il transfer \u00E8 pronto" }), _jsx("small", { children: "
|
|
113
|
+
} }, children: [_jsxs("label", { className: "dl-field", children: [_jsx("span", { children: "Email del titolare" }), _jsx("input", { type: "email", autoComplete: "email", maxLength: 254, value: owner, disabled: busy || !config?.settingsEditable, onChange: e => { setOwner(e.target.value); setNotice(''); }, placeholder: "titolare@esempio.it" }), _jsx("small", { children: "Riceve gli avvisi dei Transfer ed \u00E8 l\u2019indirizzo a cui i destinatari possono rispondere. Lascia vuoto per disattivare gli avvisi al titolare." })] }), _jsxs("label", { className: "dl-check", children: [_jsx("input", { type: "checkbox", checked: ready, disabled: busy || !config?.settingsEditable, onChange: e => { setReady(e.target.checked); setNotice(''); } }), _jsxs("span", { children: [_jsx("strong", { children: "Avvisami quando il transfer \u00E8 pronto" }), _jsx("small", { children: "Ricevi una conferma quando i file sono pronti, anche dopo un\u2019aggiunta al transfer." })] })] }), _jsxs("label", { className: "dl-check", children: [_jsx("input", { type: "checkbox", checked: downloads, disabled: busy || !config?.settingsEditable, onChange: e => { setDownloads(e.target.checked); setNotice(''); } }), _jsxs("span", { children: [_jsx("strong", { children: "Avvisami quando viene avviato un download" }), _jsx("small", { children: "Ricevi una notifica quando qualcuno avvia il download." })] })] }), _jsxs("div", { className: "dl-link-actions", children: [_jsx("button", { className: "ak-btn ak-btn-primary", type: "submit", disabled: busy || !config?.settingsEditable, children: busy ? 'Salvo…' : 'Salva impostazioni email' }), _jsx("button", { className: "ak-btn", type: "button", disabled: busy, onClick: () => void load(), children: "Ricarica" })] })] }), error && _jsx("p", { role: "alert", className: "ak-error", children: error }), notice && _jsx("p", { role: "status", children: notice })] });
|
|
74
114
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
title: string;
|
|
3
|
+
clientName: string;
|
|
4
|
+
message: string;
|
|
5
|
+
covers: (string | File)[];
|
|
6
|
+
locked: boolean;
|
|
7
|
+
fileCount: number;
|
|
8
|
+
downloadLabel: string;
|
|
9
|
+
expiryLabel: string;
|
|
10
|
+
notice: string;
|
|
11
|
+
finalLabel: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function DeliveryRecipientPreview(props: Props): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
// Keep file previews local to the editor, including covers awaiting their first save.
|
|
4
|
+
function usePreviewCovers(sources) {
|
|
5
|
+
const [images, setImages] = useState([]);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const localUrls = [];
|
|
8
|
+
const loaded = sources.map(() => null);
|
|
9
|
+
setImages([]);
|
|
10
|
+
const probes = sources.map((source, i) => {
|
|
11
|
+
const image = new Image();
|
|
12
|
+
const url = typeof source === "string" ? source : URL.createObjectURL(source);
|
|
13
|
+
if (typeof source !== "string")
|
|
14
|
+
localUrls.push(url);
|
|
15
|
+
image.onload = () => {
|
|
16
|
+
loaded[i] = { src: url, portrait: image.naturalHeight > image.naturalWidth };
|
|
17
|
+
setImages([...loaded]);
|
|
18
|
+
};
|
|
19
|
+
image.src = url;
|
|
20
|
+
return image;
|
|
21
|
+
});
|
|
22
|
+
return () => {
|
|
23
|
+
for (const image of probes)
|
|
24
|
+
image.onload = null;
|
|
25
|
+
for (const url of localUrls)
|
|
26
|
+
URL.revokeObjectURL(url);
|
|
27
|
+
};
|
|
28
|
+
}, [sources]);
|
|
29
|
+
return images.filter((image) => image !== null);
|
|
30
|
+
}
|
|
31
|
+
export function DeliveryRecipientPreview(props) {
|
|
32
|
+
const [phone, setPhone] = useState(() => window.matchMedia("(max-width: 760px)").matches);
|
|
33
|
+
const [page, setPage] = useState(0);
|
|
34
|
+
const [showUnlocked, setShowUnlocked] = useState(false);
|
|
35
|
+
const locked = props.locked && !showUnlocked;
|
|
36
|
+
useEffect(() => { setShowUnlocked(false); }, [props.locked]);
|
|
37
|
+
const covers = usePreviewCovers(props.covers);
|
|
38
|
+
useEffect(() => { setPage(0); }, [phone, props.covers]);
|
|
39
|
+
const groups = [];
|
|
40
|
+
for (let i = 0; i < covers.length; i++) {
|
|
41
|
+
const group = [covers[i]];
|
|
42
|
+
if (!phone && covers[i].portrait && covers[i + 1]?.portrait)
|
|
43
|
+
group.push(covers[++i]);
|
|
44
|
+
groups.push(group);
|
|
45
|
+
}
|
|
46
|
+
const current = Math.min(page, Math.max(0, groups.length - 1));
|
|
47
|
+
const group = locked ? [] : groups[current] ?? [];
|
|
48
|
+
return _jsxs("section", { className: "dl-recipient", "aria-label": "Anteprima destinatario", children: [_jsxs("header", { className: "dl-recipient-tools", children: [_jsx("h3", { children: "Anteprima destinatario" }), _jsxs("div", { className: "dl-preview-devices", role: "group", "aria-label": "Formato anteprima", children: [_jsx("button", { type: "button", "aria-pressed": !phone, onClick: () => setPhone(false), children: "Desktop" }), _jsx("button", { type: "button", "aria-pressed": phone, onClick: () => setPhone(true), children: "Mobile" })] })] }), _jsx("div", { className: "dl-preview-surround", children: _jsx("div", { className: "dl-preview-page" + (phone ? " is-phone" : "") + (group.length ? " with-covers" : ""), children: _jsxs("div", { className: "dl-preview-sheet", children: [_jsx("span", { className: "dl-preview-menu", "aria-hidden": "true", children: "menu" }), _jsxs("div", { className: "dl-preview-info", children: [_jsx("span", { className: "dl-preview-kicker", children: "Consegna file" }), _jsx("strong", { className: "dl-preview-title", children: props.clientName || props.title }), props.clientName && _jsx("span", { className: "dl-preview-work", children: props.title }), locked ? _jsxs("div", { className: "dl-preview-gate", children: [_jsx("span", { children: "Codice di accesso" }), _jsxs("div", { children: [_jsx("span", { className: "dl-preview-code", "aria-hidden": "true", children: "\u2022\u2022\u2022\u2022" }), _jsx("button", { type: "button", className: "dl-preview-button", "aria-label": "Simula lo sblocco nell\u2019anteprima", onClick: () => setShowUnlocked(true), children: "Entra" })] })] }) : _jsxs(_Fragment, { children: [props.message && _jsx("p", { className: "dl-preview-message", children: props.message }), props.notice && _jsx("p", { children: props.notice }), props.fileCount > 0 && _jsxs("div", { className: "dl-preview-download", children: [_jsxs("small", { children: [props.fileCount, " file \u00B7 ZIP"] }), _jsx("span", { className: "dl-preview-button", children: props.downloadLabel })] })] }), props.expiryLabel && _jsx("small", { className: "dl-preview-expiry", children: props.expiryLabel }), !locked && props.finalLabel && _jsx("span", { className: "dl-preview-final", children: props.finalLabel })] }), group.length > 0 && _jsx("div", { className: "dl-preview-stage", children: group.map((cover, i) => _jsx("img", { src: cover.src, alt: "" }, i)) })] }) }) }), props.locked && showUnlocked && _jsx("button", { className: "ak-btn dl-preview-relock", type: "button", onClick: () => setShowUnlocked(false), children: "Rivedi la richiesta del codice" }), !locked && groups.length > 1 && _jsxs("div", { className: "dl-preview-pager", role: "group", "aria-label": "Sequenza delle copertine", children: [_jsx("button", { type: "button", "aria-label": "Vista precedente", onClick: () => setPage((current + groups.length - 1) % groups.length), children: "\u2039" }), _jsxs("span", { "aria-live": "polite", children: [current + 1, " / ", groups.length] }), _jsx("button", { type: "button", "aria-label": "Vista successiva", onClick: () => setPage((current + 1) % groups.length), children: "\u203A" })] })] });
|
|
49
|
+
}
|
|
@@ -65,15 +65,15 @@ export function Overview({ deliveries, expiring, requests, pending, features, bo
|
|
|
65
65
|
const hasBookings = features?.appointments === true;
|
|
66
66
|
// Senza «Visitatori» la riga in cima ha tre riquadri, che devono coprire le dodici colonne.
|
|
67
67
|
const statSpan = hasAnalytics ? 3 : 4;
|
|
68
|
-
return (_jsxs("div", { className: "ov", children: [_jsxs("div", { className: "ov-bar", children: [_jsx("p", { className: "ov-bar-hi", children: "Tutto quello che \u00E8 successo mentre non guardavi." }), _jsx("button", { className: "ak-btn ak-btn-quiet", disabled: storage.busy || analytics.busy, onClick: () => { void storage.load(true); analytics.reload(); }, children: storage.busy || analytics.busy ? "Aggiorno…" : "Aggiorna" })] }), _jsxs("div", { className: "ov-grid", children: [hasAnalytics && (_jsx(Stat, { span: 3, label: "Visitatori", icon: Icon.eye, tone: "blue", hint: RANGE_LABEL[analytics.range], value: totals ? int(totals.visitors.value) : null, quiet: analytics.data && !analytics.data.configured ? "Statistiche non collegate" : undefined, delta: totals?.visitors })), _jsx(Stat, { span: statSpan, label: "Transfer attivi", icon: Icon.delivery, tone: "accent", hint: uploading.length ? `+${uploading.length} in caricamento` : `${downloads} download`, value: deliveries ? String(active.length) : null, onClick: () => go("/deliveries") }), _jsx(Stat, { span: statSpan, label: "Spazio in uso", icon: Icon.archive, tone: "quiet", hint: storage.data ? `${int(storage.data.r2.objects)} foto · ${int(storage.data.b2.files)} file trasferiti` : "Media e transfer", value: storage.data ? size(bytes) : null, quiet: storage.error ?? undefined }), _jsxs("button", { className: "ov-tile ov-cta", "data-span": statSpan, onClick: () => go("/deliveries"), children: [_jsxs("span", { className: "ov-cta-copy", children: [_jsx("strong", { children: "Transfer" }), _jsx("span", { children: "Manda le foto a un cliente" })] }), _jsx("span", { className: "ov-cta-go", "aria-hidden": "true", children: _jsx(Icon.delivery, {}) }), _jsx("span", { className: "ov-cta-bars", "aria-hidden": "true", children: BARS.map((h, i) => _jsx("i", { style: { height: `${h}%` } }, i)) }), expiring > 0 && _jsxs("span", { className: "ov-cta-badge", children: [expiring, " in scadenza"] })] }), !hasAnalytics ? (known && _jsx(LockedCard, { feature: "analytics", go: go })) : (_jsxs("section", { className: "ov-tile ov-chart", "data-span": "8", children: [_jsxs("header", { className: "ov-tile-head", children: [_jsxs("div", { children: [_jsx("h2", { children: "Visite al sito" }), _jsxs("p", { children: ["Pagine viste e sessioni", analytics.data?.providerLabel ? `, da ${analytics.data.providerLabel}` : ""] })] }), _jsx("div", { className: "ov-range", role: "group", "aria-label": "Periodo", children: Object.keys(RANGE_LABEL).map((r) => (_jsx("button", { className: "ov-range-btn" + (analytics.range === r ? " is-on" : ""), onClick: () => analytics.setRange(r), children: RANGE_LABEL[r] }, r))) })] }), !analytics.data ? (_jsx("p", { className: "ak-hint ov-pad", children: "Carico\u2026" })) : !analytics.data.configured ? (_jsx(NotConnected, { providers: analytics.data.providers ?? [] })) : (_jsxs(_Fragment, { children: [analytics.error && _jsx("p", { className: "ak-error ov-pad", children: analytics.error }), _jsxs("div", { className: "ov-chart-figures", children: [_jsx(Figure, { label: "Pagine viste", metric: analytics.data.totals?.pageviews }), _jsx(Figure, { label: "Sessioni", metric: analytics.data.totals?.visits }), _jsx(Figure, { label: "Visitatori", metric: analytics.data.totals?.visitors }), _jsx(Figure, { label: "Tempo medio", metric: averageTime(analytics.data.totals), format: seconds })] }), _jsx(Chart, { points: analytics.data.series ?? [], unit: analytics.data.unit ?? "day" })] }))] })), _jsxs("section", { className: "ov-tile", "data-span": "4", children: [_jsx("header", { className: "ov-tile-head", children: _jsxs("div", { children: [_jsx("h2", { children: "Archivi" }), _jsx("p", { children: "Quanto occupano le due librerie" })] }) }), storage.error ? _jsx("p", { className: "ak-error ov-pad", children: storage.error })
|
|
68
|
+
return (_jsxs("div", { className: "ov", children: [_jsxs("div", { className: "ov-bar", children: [_jsx("p", { className: "ov-bar-hi", children: "Tutto quello che \u00E8 successo mentre non guardavi." }), _jsx("button", { className: "ak-btn ak-btn-quiet", disabled: storage.busy || analytics.busy, onClick: () => { void storage.load(true); analytics.reload(); }, children: storage.busy || analytics.busy ? "Aggiorno…" : "Aggiorna" })] }), _jsxs("div", { className: "ov-grid", children: [hasAnalytics && (_jsx(Stat, { span: 3, label: "Visitatori", icon: Icon.eye, tone: "blue", hint: RANGE_LABEL[analytics.range], value: totals ? int(totals.visitors.value) : null, quiet: analytics.data && !analytics.data.configured ? "Statistiche non collegate" : undefined, delta: totals?.visitors })), _jsx(Stat, { span: statSpan, label: "Transfer attivi", icon: Icon.delivery, tone: "accent", hint: uploading.length ? `+${uploading.length} in caricamento` : `${downloads} ${downloads === 1 ? "richiesta" : "richieste"} di download`, value: deliveries ? String(active.length) : null, onClick: () => go("/deliveries") }), _jsx(Stat, { span: statSpan, label: "Spazio in uso", icon: Icon.archive, tone: "quiet", hint: storage.data ? `${int(storage.data.r2.objects)} foto · ${int(storage.data.b2.files)} file trasferiti` : "Media e transfer", value: storage.data ? size(bytes) : null, quiet: storage.error ?? undefined }), _jsxs("button", { className: "ov-tile ov-cta", "data-span": statSpan, onClick: () => go("/deliveries"), children: [_jsxs("span", { className: "ov-cta-copy", children: [_jsx("strong", { children: "Transfer" }), _jsx("span", { children: "Manda le foto a un cliente" })] }), _jsx("span", { className: "ov-cta-go", "aria-hidden": "true", children: _jsx(Icon.delivery, {}) }), _jsx("span", { className: "ov-cta-bars", "aria-hidden": "true", children: BARS.map((h, i) => _jsx("i", { style: { height: `${h}%` } }, i)) }), expiring > 0 && _jsxs("span", { className: "ov-cta-badge", children: [expiring, " in scadenza"] })] }), !hasAnalytics ? (known && _jsx(LockedCard, { feature: "analytics", go: go })) : (_jsxs("section", { className: "ov-tile ov-chart", "data-span": "8", children: [_jsxs("header", { className: "ov-tile-head", children: [_jsxs("div", { children: [_jsx("h2", { children: "Visite al sito" }), _jsxs("p", { children: ["Pagine viste e sessioni", analytics.data?.providerLabel ? `, da ${analytics.data.providerLabel}` : ""] })] }), _jsx("div", { className: "ov-range", role: "group", "aria-label": "Periodo", children: Object.keys(RANGE_LABEL).map((r) => (_jsx("button", { className: "ov-range-btn" + (analytics.range === r ? " is-on" : ""), onClick: () => analytics.setRange(r), children: RANGE_LABEL[r] }, r))) })] }), !analytics.data ? (_jsx("p", { className: "ak-hint ov-pad", children: "Carico\u2026" })) : !analytics.data.configured ? (_jsx(NotConnected, { providers: analytics.data.providers ?? [] })) : (_jsxs(_Fragment, { children: [analytics.error && _jsx("p", { className: "ak-error ov-pad", children: analytics.error }), _jsxs("div", { className: "ov-chart-figures", children: [_jsx(Figure, { label: "Pagine viste", metric: analytics.data.totals?.pageviews }), _jsx(Figure, { label: "Sessioni", metric: analytics.data.totals?.visits }), _jsx(Figure, { label: "Visitatori", metric: analytics.data.totals?.visitors }), _jsx(Figure, { label: "Tempo medio", metric: averageTime(analytics.data.totals), format: seconds })] }), _jsx(Chart, { points: analytics.data.series ?? [], unit: analytics.data.unit ?? "day" })] }))] })), _jsxs("section", { className: "ov-tile", "data-span": "4", children: [_jsx("header", { className: "ov-tile-head", children: _jsxs("div", { children: [_jsx("h2", { children: "Archivi" }), _jsx("p", { children: "Quanto occupano le due librerie" })] }) }), storage.error ? _jsx("p", { className: "ak-error ov-pad", children: storage.error })
|
|
69
69
|
: !storage.data ? _jsx("p", { className: "ak-hint ov-pad", children: "Conto gli oggetti\u2026" })
|
|
70
70
|
: (_jsxs("div", { className: "ov-store", children: [_jsxs("div", { className: "ov-store-rows", children: [_jsx(StoreRow, { name: "Media del sito", where: "R2", bytes: storage.data.r2.bytes, total: bytes, detail: `${int(storage.data.r2.objects)} file`, onClick: () => go("/media") }), _jsx(StoreRow, { name: "Transfer", where: "Spazio", bytes: storage.data.b2.bytes, total: bytes, detail: `${int(storage.data.b2.packages)} pacchetti · ${int(storage.data.b2.files)} file`, onClick: () => go("/deliveries") }), _jsx(StoreRow, { name: "Cestino", where: "R2", bytes: storage.data.r2.trashBytes, total: bytes, detail: storage.data.r2.trashObjects
|
|
71
71
|
? `${int(storage.data.r2.trashObjects)} file recuperabili — svuotalo per liberare spazio`
|
|
72
72
|
: "vuoto", onClick: () => go("/trash") })] }), _jsxs("dl", { className: "ov-store-notes", children: [storage.data.b2.pendingBytes > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "In cancellazione" }), _jsxs("dd", { children: [size(storage.data.b2.pendingBytes), ", spariscono da soli entro sette giorni"] })] })), storage.data.r2.partial && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Attenzione" }), _jsx("dd", { children: "Il conteggio dei media si \u00E8 fermato ai primi 20.000 oggetti: il totale \u00E8 per difetto." })] }))] })] }))] }), !hasBookings
|
|
73
73
|
? known && _jsx(LockedCard, { feature: "appointments", go: go })
|
|
74
|
-
: _jsx(BookingsCard, { rows: bookings, pending: bookingsPending, error: bookingsError, go: go }), _jsxs("section", { className: "ov-tile", "data-span": "8", children: [_jsxs("header", { className: "ov-tile-head", children: [_jsxs("div", { children: [_jsx("h2", { children: "Ultimi transfer" }), _jsx("p", { children: "
|
|
75
|
-
: recent.length === 0 ? _jsx("p", { className: "ak-hint ov-pad", children: "Nessun transfer
|
|
76
|
-
: (_jsxs("table", { className: "ov-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Transfer" }), _jsx("th", { children: "
|
|
74
|
+
: _jsx(BookingsCard, { rows: bookings, pending: bookingsPending, error: bookingsError, go: go }), _jsxs("section", { className: "ov-tile", "data-span": "8", children: [_jsxs("header", { className: "ov-tile-head", children: [_jsxs("div", { children: [_jsx("h2", { children: "Ultimi transfer" }), _jsx("p", { children: "Richieste di download per transfer" })] }), _jsx("button", { className: "ov-more", onClick: () => go("/deliveries"), children: "Tutti" })] }), !deliveries ? _jsx("p", { className: "ak-hint ov-pad", children: "Carico\u2026" })
|
|
75
|
+
: recent.length === 0 ? _jsx("p", { className: "ak-hint ov-pad", children: "Nessun transfer disponibile." })
|
|
76
|
+
: (_jsxs("table", { className: "ov-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Transfer" }), _jsx("th", { children: "Pubblicato" }), _jsx("th", { children: "Peso" }), _jsx("th", { className: "ov-num", children: "Richieste" }), _jsx("th", {})] }) }), _jsx("tbody", { children: recent.map((d) => (_jsxs("tr", { onClick: () => go(`/deliveries/${d.id}`), children: [_jsxs("td", { children: [_jsx("span", { className: "ov-row-main", children: d.title || "Senza nome" }), _jsx("span", { className: "ov-row-sub", children: d.clientName || "—" })] }), _jsx("td", { className: "ov-when", children: day(d.activatedAt || d.updatedAt) }), _jsx("td", { className: "ov-when", children: size(d.storedBytes) }), _jsx("td", { className: "ov-num" + (d.downloadCount ? "" : " is-zero"), children: d.downloadCount }), _jsx("td", { className: "ov-state", children: _jsx(StatusPill, { delivery: d }) })] }, d.id))) })] }))] }), _jsxs("section", { className: "ov-tile", "data-span": "4", children: [_jsxs("header", { className: "ov-tile-head", children: [_jsxs("div", { children: [_jsx("h2", { children: "Ultima richiesta" }), _jsx("p", { children: pending > 0 ? `${pending} ${pending === 1 ? "non letta" : "non lette"}` : "Dal form del sito" })] }), _jsx("button", { className: "ov-more", onClick: () => go("/requests"), children: "Tutte" })] }), !requests ? _jsx("p", { className: "ak-hint ov-pad", children: "Carico\u2026" })
|
|
77
77
|
: requests.length === 0 ? _jsx("p", { className: "ak-hint ov-pad", children: "Nessuna richiesta, per ora." })
|
|
78
78
|
: _jsx(LastRequest, { row: requests[0], go: go })] }), hasAnalytics && _jsx(Top, { span: 4, title: "Pagine pi\u00F9 viste", note: RANGE_LABEL[analytics.range], rows: analytics.data?.pages ?? [], ready: !!analytics.data?.configured, label: (name) => name === "/" ? "/ (home)" : name }), hasAnalytics && _jsx(Top, { span: 4, title: "Da dove arrivano", note: "Siti che portano al tuo", rows: analytics.data?.referrers ?? [], ready: !!analytics.data?.configured, label: (name) => name.replace(/^https?:\/\//, "") })] })] }));
|
|
79
79
|
}
|
|
@@ -220,7 +220,7 @@ function StatusPill({ delivery }) {
|
|
|
220
220
|
if (expired)
|
|
221
221
|
return _jsx("span", { className: "dl-pill", children: "Scaduto" });
|
|
222
222
|
if (delivery.downloadCount > 0)
|
|
223
|
-
return _jsx("span", { className: "dl-pill is-downloaded", children: "
|
|
223
|
+
return _jsx("span", { className: "dl-pill is-downloaded", children: "Download richiesto" });
|
|
224
224
|
return _jsx("span", { className: "dl-pill is-ready", children: "Attivo" });
|
|
225
225
|
}
|
|
226
226
|
/* ---- Formati ------------------------------------------------------------------------- */
|
|
@@ -11,6 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
11
11
|
* sempre.
|
|
12
12
|
*/
|
|
13
13
|
import { useEffect, useState } from "react";
|
|
14
|
+
import { deliveryProgressPercent } from "../lib/delivery-upload";
|
|
14
15
|
import { cancelUpload, dismissUpload, isBusy, pauseUpload, resumeUpload, retryUpload, useUploads, } from "../lib/upload-queue";
|
|
15
16
|
import { dismissMediaUpload, useMediaUploads, } from "../../form/media/media-upload-queue.js";
|
|
16
17
|
export function UploadDock() {
|
|
@@ -28,7 +29,7 @@ export function UploadDock() {
|
|
|
28
29
|
}, [busy]);
|
|
29
30
|
if (!jobs.length && !mediaJobs.length)
|
|
30
31
|
return null;
|
|
31
|
-
return (_jsxs("aside", { className: "uk" + (open ? "" : " is-closed"), "aria-label": "Caricamenti", children: [_jsxs("button", { className: "uk-head", onClick: () => setOpen((value) => !value), "aria-expanded": open, children: [_jsx("span", { className: "uk-head-text", children: summary(jobs, mediaJobs) }), _jsx("span", { className: "uk-chevron", "aria-hidden": "true", children: open ? "▾" : "▴" })] }), open && (_jsxs("ul", { className: "uk-list", children: [mediaJobs.map((job) => _jsx(MediaJob, { job: job }, job.id)), jobs.map((job) => (_jsxs("li", { className: "uk-job is-" + job.state, children: [_jsxs("div", { className: "uk-job-top", children: [_jsx("strong", { children: job.title }), _jsx("span", { children: line(job) })] }), isBusy(job) && (_jsx("div", { className: "uk-track", children: _jsx("i", { style: { width: `${percent(job)}%` } }) })), job.error && _jsx("p", { className: "uk-error", children: job.error }), _jsxs("div", { className: "uk-job-actions", children: [job.state === "running" && (_jsx("button", { className: "ak-btn", onClick: () => pauseUpload(job.id), children: "Pausa" })), job.state === "paused" && (_jsx("button", { className: "ak-btn", onClick: () => resumeUpload(job.id), children: "Riprendi" })), isBusy(job) && job.state !== "cancelling" && (confirmStop === job.id ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "uk-confirm", children: "I file
|
|
32
|
+
return (_jsxs("aside", { className: "uk" + (open ? "" : " is-closed"), "aria-label": "Caricamenti", children: [_jsxs("button", { className: "uk-head", onClick: () => setOpen((value) => !value), "aria-expanded": open, children: [_jsx("span", { className: "uk-head-text", children: summary(jobs, mediaJobs) }), _jsx("span", { className: "uk-chevron", "aria-hidden": "true", children: open ? "▾" : "▴" })] }), open && (_jsxs("ul", { className: "uk-list", children: [mediaJobs.map((job) => _jsx(MediaJob, { job: job }, job.id)), jobs.map((job) => (_jsxs("li", { className: "uk-job is-" + job.state, children: [_jsxs("div", { className: "uk-job-top", children: [_jsx("strong", { children: job.title }), _jsx("span", { children: line(job) })] }), isBusy(job) && (_jsx("div", { className: "uk-track", children: _jsx("i", { style: { width: `${percent(job)}%` } }) })), job.error && _jsx("p", { className: "uk-error", children: job.error }), _jsxs("div", { className: "uk-job-actions", children: [job.state === "running" && (_jsx("button", { className: "ak-btn", onClick: () => pauseUpload(job.id), children: "Pausa" })), job.state === "paused" && (_jsx("button", { className: "ak-btn", onClick: () => resumeUpload(job.id), children: "Riprendi" })), isBusy(job) && job.state !== "cancelling" && (confirmStop === job.id ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "uk-confirm", children: "I file di questo caricamento verranno rimossi." }), _jsx("button", { className: "ak-btn", onClick: () => setConfirmStop(null), children: "No" }), _jsx("button", { className: "ak-btn dl-danger-btn", onClick: () => { cancelUpload(job.id); setConfirmStop(null); }, children: "Annulla il caricamento" })] })) : (_jsx("button", { className: "ak-btn ak-btn-quiet", onClick: () => setConfirmStop(job.id), children: "Annulla" }))), job.state === "failed" && job.retryable && _jsx("button", { className: "ak-btn", onClick: () => void retryUpload(job.id), children: "Riprova" }), !isBusy(job) && (_jsx("button", { className: "ak-btn ak-btn-quiet", onClick: () => dismissUpload(job.id), children: "Togli dall'elenco" }))] })] }, job.id)))] }))] }));
|
|
32
33
|
}
|
|
33
34
|
function MediaJob({ job }) {
|
|
34
35
|
const conversionPercent = job.total ? (job.conversionDone / job.total) * 100 : 0;
|
|
@@ -79,7 +80,7 @@ function line(job) {
|
|
|
79
80
|
const progress = job.progress;
|
|
80
81
|
if (!progress)
|
|
81
82
|
return "Preparo…";
|
|
82
|
-
const phase = progress.phase === "originals" ? "Carico
|
|
83
|
+
const phase = progress.phase === "originals" ? "Carico gli originali"
|
|
83
84
|
: progress.phase === "derivatives" ? "Preparo le anteprime"
|
|
84
85
|
: "Ultimi controlli";
|
|
85
86
|
return `${phase} · ${progress.doneFiles} di ${progress.totalFiles}`;
|
|
@@ -88,5 +89,5 @@ function percent(job) {
|
|
|
88
89
|
const progress = job.progress;
|
|
89
90
|
if (!progress || !progress.totalFiles)
|
|
90
91
|
return 3;
|
|
91
|
-
return Math.max(3,
|
|
92
|
+
return Math.max(3, deliveryProgressPercent(progress));
|
|
92
93
|
}
|
|
@@ -176,7 +176,7 @@ export function MediaGrid({ lib, notice, onPick, onCancel }) {
|
|
|
176
176
|
(manage ? lib.view(i) : lib.toggle(f.key)); }, children: [_jsx("img", { className: "mg-img", draggable: false, src: f.url, alt: "", loading: "lazy",
|
|
177
177
|
/* Il rapporto è noto prima che l'immagine arrivi (lo dà l'elenco): la cella
|
|
178
178
|
riserva subito l'ingombro giusto e la griglia non salta mentre si carica. */
|
|
179
|
-
style: { aspectRatio: f.w && f.h ? `${f.w} / ${f.h}` : "3 / 2" } }), manage && altStatus && (_jsx("span", { className: `mg-alt-badge is-${altStatus}`, children: altStatus === "missing" ? "ALT da completare" : altStatus === "decorative" ? "Decorativa" : "ALT completo" })), _jsx("button", { className: "mg-check", "aria-label": on ? "Deseleziona" : "Seleziona"
|
|
179
|
+
style: { aspectRatio: f.w && f.h ? `${f.w} / ${f.h}` : "3 / 2" } }), manage && altStatus && (_jsx("span", { className: `mg-alt-badge is-${altStatus}`, children: altStatus === "missing" ? "ALT da completare" : altStatus === "decorative" ? "Decorativa" : "ALT completo" })), _jsx("button", { className: "mg-check", "aria-pressed": on, "aria-label": manage ? (on ? "Deseleziona" : "Seleziona") : `${on ? "Deseleziona" : "Seleziona"} ${f.name}`, disabled: locked, onClick: (e) => { e.stopPropagation(); lib.toggle(f.key); }, children: on ? "✓" : "" })] }), _jsx("figcaption", { className: "mg-cap", title: f.name, children: f.name })] }, f.key));
|
|
180
180
|
}) }), !lib.busy && lib.shown.length === 0 && (_jsx("p", { className: "ak-hint", children: lib.prefix === "" && lib.folders.length
|
|
181
181
|
? "Nessuna foto fuori dalle cartelle. Scegline una qui a fianco."
|
|
182
182
|
: "Nessun file qui." })), lib.mode === "pick" && (_jsxs("footer", { className: "mg-foot", children: [_jsxs("span", { className: "ak-hint", children: [sel.size, " selezionate"] }), _jsx("span", { className: "ak-spacer" }), _jsx("button", { className: "ak-btn ak-btn-quiet", disabled: locked, onClick: () => onCancel?.(), children: "Annulla" }), _jsxs("button", { className: "ak-btn ak-btn-primary", disabled: locked || !sel.size, onClick: () => onPick?.(lib.shown.filter((f) => sel.has(f.key))), children: ["Usa ", sel.size > 0 ? `(${sel.size})` : ""] })] }))] }), _jsx(Lightbox, { lib: lib }), _jsx(UploadDialog, { lib: lib })] }));
|