D1, prima parte: Dashboard al posto di Attività e «Cosa scaricare prima» generale
Richiesta di Alberto (#59): decidere cosa scaricare prima, una Dashboard compatta come pagina iniziale da guardare mentre il motore lavora, e le miniature di ciò che è arrivato. - Dashboard (§7.9, §10.2): /dashboard è la pagina iniziale e la prima voce della barra; /, /attivita, «Ho finito» del browser, il riquadro di stato e il ritorno dopo l'accesso portano lì. In alto l'anteprima del browser sempre visibile, chiesta ogni secondo mentre il motore lavora (LiveBrowserPreview cattura al più un fotogramma al secondo), accanto cosa sta facendo e i quattro tetti; poi la striscia più bassa, la cronologia con le miniature e la coda ridotta alle prime righe con «Mostra tutta». Sotto i 1000 px una colonna sola. - Miniature della cronologia: /api/activity/arrived dà gli elementi che una ricetta ha salvato (account, inizio e fine della ricetta), chiesti solo quando la riga entra in vista, al più otto con «+N». Un clic apre un'anteprima leggera con foto o video senza audio, frecce fra i file della riga, Esc, «Apri nella Libreria» e «Apri l'account». - «Cosa scaricare prima» (§7.2, §6.5): ordine generale dei tipi in Impostazioni → Limiti e comportamento (trascinare, «Su» e «Giù», nota sulle storie che scadono), predefinito storie, evidenza, post, reel, taggati. Dopo il giro, il lavoro dovuto si estrae con il peso dell'account per il peso del tipo (16, 8, 4, 2, 1): pesa, non rende fisso. La coda dei file segue lo stesso ordine. - Prove: DownloadOrderTests (ordine, pesi, coda, motore con seme fisso: il primo tipo viene più spesso ma non sempre, il giro resta primo, un tipo senza lavoro non si visita), DashboardApiTests, una prova dell'interfaccia per / e /attivita. Non ancora fatto: ordine per account e segno del reel (serve una migrazione da concordare con E1), «Raggruppa i post» / «Tutte le foto», confronto con i mockup, revisione del resto della guida che nomina ancora Attività. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2068dd28f3
commit
d6c0ef851d
38 files changed
+1468
-479
No files matched your search
@@ -12,11 +12,13 @@ import { checkbox, confirmDialog, label, showError, toast, toggle } from '../cor
|
||||
import { guardChanges, heading } from './settings.js';
|
||||
|
||||
const PACES = ['slow', 'natural', 'brisk'];
|
||||
// «Cosa scaricare prima» (spec §7.2): the default order of the kinds, the one the server also uses.
|
||||
const DEFAULT_ORDER = ['storie', 'evidenza', 'post', 'reel', 'taggati'];
|
||||
const DAY_ORDER = [1, 2, 3, 4, 5, 6, 0]; // Monday first; the API counts from Sunday = 0
|
||||
|
||||
export default async function limits(page, box) {
|
||||
let data = await api('/api/settings/limits', { signal: page.signal });
|
||||
const snapshot = () => JSON.stringify({ profile: form.profile, values: form.values, pace: form.pace, gradualStart: form.gradualStart, activeDays: [...form.activeDays].sort() });
|
||||
const snapshot = () => JSON.stringify({ profile: form.profile, values: form.values, pace: form.pace, gradualStart: form.gradualStart, activeDays: [...form.activeDays].sort(), order: form.order });
|
||||
let form = fromData(data);
|
||||
let original = snapshot();
|
||||
const dirty = () => snapshot() !== original;
|
||||
@@ -32,9 +34,83 @@ export default async function limits(page, box) {
|
||||
gradualStart: d.gradualStart,
|
||||
activeDays: new Set(d.activeDays),
|
||||
jitterOn: d.current.jitterMinutes > 0,
|
||||
order: Array.isArray(d.downloadOrder) && d.downloadOrder.length ? [...d.downloadOrder] : [...DEFAULT_ORDER],
|
||||
};
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- download order
|
||||
// The rows move by dragging (mouse) or with «Su» and «Giù» (keyboard); the order is saved with the save bar.
|
||||
const orderList = h('ol.ordine-tipi', { 'aria-label': t('impostazioni.limiti.ordine') });
|
||||
const orderStatus = h('span.vh', { 'aria-live': 'polite' });
|
||||
let dragged = null;
|
||||
|
||||
function move(from, to, focus) {
|
||||
if (to < 0 || to >= form.order.length || from === to) return;
|
||||
const [kind] = form.order.splice(from, 1);
|
||||
form.order.splice(to, 0, kind);
|
||||
drawOrder();
|
||||
drawSaveBar();
|
||||
orderStatus.textContent = t('impostazioni.limiti.ordineSpostato', { tipo: t(`impostazioni.limiti.tipi.${kind}`), n: to + 1 });
|
||||
if (focus) {
|
||||
const again = orderList.querySelector(`[data-tipo="${kind}"] [data-verso="${focus}"]`);
|
||||
if (again && !again.disabled) again.focus();
|
||||
else orderList.querySelector(`[data-tipo="${kind}"] button:not([disabled])`)?.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function drawOrder() {
|
||||
fill(orderList, form.order.map((kind, i) => {
|
||||
const name = t(`impostazioni.limiti.tipi.${kind}`);
|
||||
const row = h('li.riga-ordine', { draggable: 'true', dataset: { tipo: kind } },
|
||||
h('span.maniglia', { title: t('impostazioni.limiti.ordineManiglia'), 'aria-hidden': 'true' }, icon('grip-vertical', 's')),
|
||||
h('span.posizione.dati', String(i + 1)),
|
||||
h('b', name),
|
||||
kind === 'storie' && i > 0 ? h('span.muto.piccolo', icon('clock', 'xs'), ' ', t('impostazioni.limiti.ordineStorie')) : null,
|
||||
h('div.destra',
|
||||
h('button.btn.piccolo.nudo', {
|
||||
type: 'button', disabled: i === 0, dataset: { verso: 'su' }, 'aria-label': t('impostazioni.limiti.ordineSuDi', { tipo: name }), onclick: () => move(i, i - 1, 'su'),
|
||||
}, icon('chevron-up', 's'), h('span.testo-btn', t('impostazioni.limiti.ordineSu'))),
|
||||
h('button.btn.piccolo.nudo', {
|
||||
type: 'button', disabled: i === form.order.length - 1, dataset: { verso: 'giu' }, 'aria-label': t('impostazioni.limiti.ordineGiuDi', { tipo: name }), onclick: () => move(i, i + 1, 'giu'),
|
||||
}, icon('chevron-down', 's'), h('span.testo-btn', t('impostazioni.limiti.ordineGiu')))));
|
||||
row.addEventListener('dragstart', (event) => {
|
||||
dragged = i;
|
||||
row.classList.add('trascinata');
|
||||
try {
|
||||
event.dataTransfer.effectAllowed = 'move';
|
||||
event.dataTransfer.setData('text/plain', kind);
|
||||
} catch {
|
||||
// Some browsers refuse data on a drag: the index above is enough.
|
||||
}
|
||||
});
|
||||
row.addEventListener('dragend', () => {
|
||||
dragged = null;
|
||||
row.classList.remove('trascinata');
|
||||
});
|
||||
row.addEventListener('dragover', (event) => {
|
||||
if (dragged === null) return;
|
||||
event.preventDefault();
|
||||
});
|
||||
row.addEventListener('drop', (event) => {
|
||||
if (dragged === null) return;
|
||||
event.preventDefault();
|
||||
const from = dragged;
|
||||
dragged = null;
|
||||
move(from, i, null);
|
||||
});
|
||||
return row;
|
||||
}));
|
||||
}
|
||||
|
||||
const orderReset = h('button.btn.collegamento', {
|
||||
type: 'button',
|
||||
onclick: () => {
|
||||
form.order = [...DEFAULT_ORDER];
|
||||
drawOrder();
|
||||
drawSaveBar();
|
||||
},
|
||||
}, t('impostazioni.limiti.ordineMetti'));
|
||||
|
||||
/** Any edit turns the profile into «Su misura» (spec §7.5). */
|
||||
function edited() {
|
||||
form.profile = 'custom';
|
||||
@@ -363,7 +439,7 @@ export default async function limits(page, box) {
|
||||
try {
|
||||
data = await api('/api/settings/limits', {
|
||||
method: 'PUT',
|
||||
body: { profile: form.profile, values: form.values, pace: form.pace, gradualStart: form.gradualStart, activeDays: [...form.activeDays] },
|
||||
body: { profile: form.profile, values: form.values, pace: form.pace, gradualStart: form.gradualStart, activeDays: [...form.activeDays], downloadOrder: form.order },
|
||||
});
|
||||
form = fromData(data);
|
||||
original = snapshot();
|
||||
@@ -381,6 +457,7 @@ export default async function limits(page, box) {
|
||||
drawWindow();
|
||||
drawPace();
|
||||
drawTable();
|
||||
drawOrder();
|
||||
drawSaveBar();
|
||||
}
|
||||
|
||||
@@ -411,7 +488,11 @@ export default async function limits(page, box) {
|
||||
heading(t('impostazioni.limiti.tetti'), t('impostazioni.limiti.tettiAiuto')),
|
||||
h('div.pannello.tabella-tetti', h('table.tab',
|
||||
h('thead', h('tr', h('th', t('impostazioni.limiti.colonne.attivita')), h('th', t('impostazioni.limiti.colonne.ora')), h('th', t('impostazioni.limiti.colonne.giorno')))),
|
||||
table))));
|
||||
table))),
|
||||
h('div.sezione',
|
||||
heading(t('impostazioni.limiti.ordine'), t('impostazioni.limiti.ordineAiuto')),
|
||||
h('div.pannello', orderList),
|
||||
h('div.riga-sotto', orderReset, orderStatus)));
|
||||
}
|
||||
|
||||
function toInt(text) {
|
||||
|
||||
Reference in new issue
Block a user