feat(admin): Reorganize dialog in the Library and after the archive templates change
Owner review 2, R7 asks to rename and move sequences after import, on the web panel too. The Library's mass bar gets Reorganize… for the selection (every sequence after Select all without a filter, else at most a thousand ids), and saving a changed folder or file template on the Archive page offers it for all sequences in the save toast. The dialog (reorganize.js) has a switch and a field for the folder, file and title templates, prefilled from the archive settings; each change asks POST /archive/reorganize for a dry run, one request at a time, and the table shows every step before and after (title, folder, renamed files with samples, photos that keep their names and why). Apply confirms with the counts of sequences, folders and photos, sends the shown plan's fingerprint back, and the toast links to the queued job; a plan_changed refusal plans again. Server refusals land on the field they name. Toasts can carry an action; the audit entry archive_reorganized reads as a sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 13939dff9a1e8a23ce7802ac38f2ded7fdbc2a74)
This commit is contained in:
1 parent
eb2395d9b0
commit
17efb50e11
11 files changed
+802
-17
No files matched your search
@@ -1,12 +1,14 @@
|
||||
// Library (owner review 2, R6; BRIEF §14.8): the panel browses, views and deletes sequences and photos and runs mass
|
||||
// operations on them, but never edits a video (no settings, no render). #/library lists the sequences with filters in the
|
||||
// address, #/library?id=<sequence> opens one (library/sequence.js), #/library?view=trash the archive's trash (library/trash.js).
|
||||
// Reorganize (R7) applies new folder, file and title templates to the selection (reorganize.js).
|
||||
import { t, plural, applyStrings } from "../i18n.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, toast, errorText, confirmDialog, formDialog, markInvalid, emptyState, routeParams, redraw } from "../ui.js";
|
||||
import { icons } from "../icons.js";
|
||||
import { BULK_LIMIT, factsLine, captureText, cameraLabel, statusChips, lazyImage, watchImages, Selection, selectableGrid, chunks, saveFile, sequencesCsv, today, tagList, coverUrl, listed, JOB_ENDED } from "./library/shared.js";
|
||||
import { renderSequence } from "./library/sequence.js";
|
||||
import { renderTrash } from "./library/trash.js";
|
||||
import { openReorganize } from "../reorganize.js";
|
||||
|
||||
const VIEW_KEY = "chronos.admin.library.view";
|
||||
const PAGE = 100;
|
||||
@@ -256,8 +258,7 @@ async function renderList(root, { api, setMeta, actions, onEvent }, params) {
|
||||
if (rows.length === 0) {
|
||||
itemsHost.removeAttribute("role");
|
||||
itemsHost.removeAttribute("aria-multiselectable");
|
||||
const filtered = FILTERS.some((f) => f !== "sort" && filters[f]);
|
||||
itemsHost.innerHTML = filtered
|
||||
itemsHost.innerHTML = isFiltered()
|
||||
? emptyState("Admin.Library.NoMatch", `<button class="btn small" id="clear" data-i18n="Admin.Library.ClearFilters" data-i18n-title="Admin.Library.ClearFilters.Tip"></button>`)
|
||||
: emptyState("Admin.Library.Empty", `<button class="btn small" id="scan" data-i18n="Admin.Archive.Scan" data-i18n-title="Admin.Archive.Scan.Tip"></button>`);
|
||||
applyStrings(itemsHost);
|
||||
@@ -343,6 +344,7 @@ async function renderList(root, { api, setMeta, actions, onEvent }, params) {
|
||||
<strong class="nowrap" role="status">${escapeHtml(plural("Admin.Library.Selected", selection.size))}</strong>${selectAll}
|
||||
<span class="spacer"></span>
|
||||
${JOBS.map(job).join("")}
|
||||
<button class="btn small" id="mass-reorganize" data-mass="reorganize" data-i18n="Admin.Reorganize.Action" data-i18n-title="Admin.Reorganize.Action.Tip"></button>
|
||||
<button class="btn small" id="mass-retag" data-mass="retag" data-i18n="Admin.Library.Retag" data-i18n-title="Admin.Library.Retag.Tip"></button>
|
||||
<button class="btn small" id="mass-csv" data-mass="csv" data-i18n="Admin.Library.ExportCsv" data-i18n-title="Admin.Library.ExportCsv.Tip"></button>
|
||||
<button class="btn small destructive" id="mass-delete" data-mass="delete" data-i18n="Admin.Library.Delete" data-i18n-title="Admin.Library.Delete.Tip"></button>
|
||||
@@ -362,6 +364,8 @@ async function renderList(root, { api, setMeta, actions, onEvent }, params) {
|
||||
}
|
||||
if (action === "all") return selectAll();
|
||||
if (action === "csv") return exportCsv();
|
||||
// A modal dialog: the button stays enabled, so the focus comes back to it when the dialog closes.
|
||||
if (action === "reorganize") return reorganize();
|
||||
button.disabled = true;
|
||||
try {
|
||||
if (action === "job") await queueJobs(button.dataset.kind);
|
||||
@@ -415,6 +419,25 @@ async function renderList(root, { api, setMeta, actions, onEvent }, params) {
|
||||
toast([done, skipped > 0 ? plural("Admin.Library.Skipped", skipped) : "", failure ?? ""].filter(Boolean).join(" · "), failure !== null);
|
||||
}
|
||||
|
||||
/** Whether a filter narrows the list (the sort order does not). */
|
||||
function isFiltered() {
|
||||
return FILTERS.some((f) => f !== "sort" && filters[f]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorganize (owner review 2, R7) of the selected sequences: every sequence of the archive after Select all without a
|
||||
* filter, else their ids, at most a bulk request's thousand (one plan, one job).
|
||||
*/
|
||||
async function reorganize() {
|
||||
const everything = matching !== null && !isFiltered() && selection.size === matching.length;
|
||||
if (!everything && selection.size > BULK_LIMIT) {
|
||||
toast(t("Admin.Reorganize.TooMany", formatNumber(BULK_LIMIT)), true);
|
||||
return;
|
||||
}
|
||||
const names = new Map(selectedRows().map((s) => [s.id, s.displayTitle]));
|
||||
await openReorganize({ api, target: everything ? { all: true } : { sequenceIds: [...selection.ids] }, names });
|
||||
}
|
||||
|
||||
async function retag() {
|
||||
const datalist = facets.tags.map((f) => `<option value="${attr(f.value)}"></option>`).join("");
|
||||
const data = await formDialog({
|
||||
|
||||
Reference in new issue
Block a user