feat(admin): Convert dialog in the Library for JPEG, TIFF-16 or linear DNG

Owner review 2, R7 asks for mass conversion after import on the web panel too, with what
happens to the originals chosen at every run. The Library's mass bar gets Convert… for the
selection (every sequence after Select all without a filter, else at most a thousand ids,
the same rule as Reorganize, now one helper).

The dialog (convert.js) offers the format (linear DNG, the archival choice, first), the JPEG
quality (shown for JPEG only, 1-100, checked on the field) and the mode, Replace or New
sequence, never preselected, each tooltip saying what happens to the originals. Every change
asks POST /archive/convert for a dry run, one request at a time and debounced while typing;
the table shows per sequence the photos converted, the photos left as they are with why
(what blocks the whole sequence first), and the size before and after, then the totals and
the server's space line. While no mode is chosen the table is planned as New sequence (what
converts does not depend on the mode) and Apply waits; choosing Replace plans again, since the
fingerprint names the mode. Apply confirms Replace by typing the localised word, New sequence
with a plain confirmation, sends the shown plan's fingerprint back and links the queued job;
plan_changed, not_enough_space and nothing_to_convert plan again. Server refusals land on the
field they name.

The trash says what Restore does to a replaced entry (the originals swap back while their
conversions are unchanged) and toasts it; the audit entry archive_converted reads as a sentence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2a09572e3e67ef95a931333c35cd3bb1e818db71)
(cherry picked from commit 1d71a18fa112a7cb39e3e7ced7d7234230eb4453)
This commit is contained in:
Alby96 committed 2026-10-27 22:02:04 +01:00
1 parent 0e52929274
commit 2143a093a2
11 files changed
+863 -27

No files matched your search

+29 -9
View File
@@ -1,7 +1,8 @@
// 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).
// Reorganize (R7) applies new folder, file and title templates to the selection (reorganize.js), Convert (R7) converts its
// photos to JPEG, TIFF-16 or linear DNG (convert.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";
@@ -9,6 +10,7 @@ import { BULK_LIMIT, factsLine, captureText, cameraLabel, statusChips, lazyImage
import { renderSequence } from "./library/sequence.js";
import { renderTrash } from "./library/trash.js";
import { openReorganize } from "../reorganize.js";
import { openConvert } from "../convert.js";
const VIEW_KEY = "chronos.admin.library.view";
const PAGE = 100;
@@ -345,6 +347,7 @@ async function renderList(root, { api, setMeta, actions, onEvent }, params) {
<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-convert" data-mass="convert" data-i18n="Admin.Convert.Action" data-i18n-title="Admin.Convert.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>
@@ -364,8 +367,9 @@ 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.
// Modal dialogs: the button stays enabled, so the focus comes back to it when the dialog closes.
if (action === "reorganize") return reorganize();
if (action === "convert") return convert();
button.disabled = true;
try {
if (action === "job") await queueJobs(button.dataset.kind);
@@ -425,20 +429,36 @@ async function renderList(root, { api, setMeta, actions, onEvent }, params) {
}
/**
* Reorganize (owner review 2, R7) of the selected sequences: their ids, at most a bulk request's thousand (one plan,
* one job). Beyond that, every sequence of the archive, but only while the selection is exactly what Select all
* fetched without a filter and the archive has not grown since: a sequence unticked or added later is never included.
* What a plan-first mass operation (owner review 2, R7: Reorganize, Convert) works on: the selected sequences' ids, at
* most a bulk request's thousand (one plan, one job). Beyond that, every sequence of the archive, but only while the
* selection is exactly what Select all fetched without a filter and the archive has not grown since: a sequence unticked
* or added later is never included. Null, with tooMany's toast, otherwise.
*/
async function reorganize() {
function planTarget(tooMany) {
const ids = [...selection.ids];
const everything = ids.length > BULK_LIMIT && matching !== null && !isFiltered() && total === matching.length &&
ids.length === matching.length && matching.every((s) => selection.has(s.id));
if (!everything && ids.length > BULK_LIMIT) {
toast(t("Admin.Reorganize.TooMany", formatNumber(BULK_LIMIT)), true);
return;
toast(t(tooMany, formatNumber(BULK_LIMIT)), true);
return null;
}
return everything ? { all: true } : { sequenceIds: ids };
}
/** Reorganize of the selected sequences: new folder, file and title templates, with a dry run. */
async function reorganize() {
const target = planTarget("Admin.Reorganize.TooMany");
if (!target) return;
const names = new Map(selectedRows().map((s) => [s.id, s.displayTitle]));
await openReorganize({ api, target: everything ? { all: true } : { sequenceIds: ids }, names });
await openReorganize({ api, target, names });
}
/** Convert of the selected sequences' photos: the format and, at every run, Replace or New sequence, with a dry run. */
async function convert() {
const target = planTarget("Admin.Convert.TooMany");
if (!target) return;
const names = new Map(selectedRows().map((s) => [s.id, s.displayTitle]));
await openConvert({ api, target, names });
}
async function retag() {