Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d039f90de8 | ||
|
|
efc3aafd8a |
No files matched your search
@@ -591,8 +591,8 @@ export class DeliveryService {
|
||||
}
|
||||
const client = this.client(item.target);
|
||||
await client.ensureFolder(folder);
|
||||
// The author as the service shows it: the photographer's name from the IPTC creator ("Peter Spark / PhotoReport.pt").
|
||||
const creator = typeof iptc?.values.creator === "string" ? iptc.values.creator.split(" / ")[0]!.trim() : "";
|
||||
// ZeroZero's Autor / Fotógrafo is this whole line ("Peter Spark / Kapta+"), not only the name before the slash.
|
||||
const creator = typeof iptc?.values.creator === "string" ? iptc.values.creator.trim() : "";
|
||||
const remote = await client.upload(folder + fileName, data, { author: creator || item.photo.uploader?.name || undefined });
|
||||
const remotePath = typeof remote === "string" ? remote : folder + fileName;
|
||||
// "synced-…" means the desk already had this file, so this attempt did not put a new image up.
|
||||
|
||||
@@ -585,7 +585,7 @@ describe("delivery", () => {
|
||||
method: "POST",
|
||||
url: `/v1/orgs/${orgId}/delivery-targets`,
|
||||
headers: bearer(token),
|
||||
payload: { name: "ZeroZero", kind: "ZEROZERO", baseUrl: "https://fotos.zerozero.pt", username: "kapta", password: "zz-pass", folderTemplate: "zerozero", fileNameTemplate: "PS_{home} x {away}_{n}.jpg", longEdge: 3000, jpegQuality: 92 },
|
||||
payload: { name: "ZeroZero", kind: "ZEROZERO", baseUrl: "https://fotos.zerozero.pt", username: "kapta", password: "zz-pass", folderTemplate: "zerozero", fileNameTemplate: "PS_{home} x {away}_{n}.jpg", longEdge: 3000, jpegQuality: 92, iptcOverrides: { creator: "Peter Spark / Kapta+", credit: "Peter Spark / Kapta+", copyright: "Peter Spark / Kapta+", source: "Peter Spark / Kapta+" } },
|
||||
});
|
||||
expect(created.statusCode).toBe(201);
|
||||
const targetId = (created.json() as { id: string }).id;
|
||||
@@ -619,7 +619,7 @@ describe("delivery", () => {
|
||||
expect(items.map((i) => i.remotePath).sort()).toEqual(["12627747/img-1", "12627747/img-2"]);
|
||||
expect((await ctx.db.event.findUniqueOrThrow({ where: { id: event.id } })).zerozeroGameId).toBe("12627747");
|
||||
const first = [...zz.uploads.values()].find((u) => u.meta.filename?.endsWith("_1.jpg"))!;
|
||||
expect(first.meta).toMatchObject({ match_id: "12627747", artist: "Peter Spark", filename: "PS_SC Torreense x Sunderland_1.jpg", filetype: "image/jpeg" });
|
||||
expect(first.meta).toMatchObject({ match_id: "12627747", artist: "Peter Spark / Kapta+", filename: "PS_SC Torreense x Sunderland_1.jpg", filetype: "image/jpeg" });
|
||||
expect(first.data.length).toBe(first.length);
|
||||
expect((await sharp(first.data).metadata()).width).toBe(3000);
|
||||
// Signed in once for the whole batch.
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import type { PhotoSummary } from "@photoreport/contracts";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { Grid } from "./Grid.js";
|
||||
|
||||
function photo(id: string): PhotoSummary {
|
||||
return {
|
||||
id,
|
||||
eventId: "e1",
|
||||
originalName: `${id}.jpg`,
|
||||
name: `${id}.jpg`,
|
||||
sha256: `sha-${id}`,
|
||||
originalStored: true,
|
||||
status: "READY",
|
||||
width: 600,
|
||||
height: 400,
|
||||
capturedAt: "2026-09-23T20:00:00Z",
|
||||
cameraModel: null,
|
||||
lens: null,
|
||||
focalLength: null,
|
||||
aperture: null,
|
||||
exposureTime: null,
|
||||
iso: null,
|
||||
rating: 0,
|
||||
flag: "NONE",
|
||||
colorLabel: "NONE",
|
||||
players: [],
|
||||
uploader: null,
|
||||
developSeq: 0,
|
||||
urls: { thumb: "", preview: "", source: "" },
|
||||
};
|
||||
}
|
||||
|
||||
describe("grid", () => {
|
||||
it("opens the photo on a double-click", () => {
|
||||
const onOpen = vi.fn();
|
||||
render(
|
||||
<Grid
|
||||
photos={[photo("a")]}
|
||||
selected={new Set()}
|
||||
focus={null}
|
||||
srcFor={() => ""}
|
||||
onPick={() => {}}
|
||||
onSelectMany={() => {}}
|
||||
onOpen={onOpen}
|
||||
/>,
|
||||
);
|
||||
fireEvent.doubleClick(screen.getByRole("button", { name: /a\.jpg/ }));
|
||||
expect(onOpen).toHaveBeenCalledWith("a");
|
||||
});
|
||||
});
|
||||
@@ -171,6 +171,8 @@ export function Grid(props: {
|
||||
const dy = e.clientY - current.y;
|
||||
if (!current.moved && Math.hypot(dx, dy) < DRAG_PX) return;
|
||||
current.moved = true;
|
||||
// Capture only once the drag is real. Capturing on the first press steals the second click, so a double-click never opens the photo.
|
||||
if (!section.hasPointerCapture(e.pointerId)) section.setPointerCapture(e.pointerId);
|
||||
const left = Math.min(current.x, e.clientX);
|
||||
const top = Math.min(current.y, e.clientY);
|
||||
const width = Math.abs(e.clientX - current.x);
|
||||
@@ -197,7 +199,6 @@ export function Grid(props: {
|
||||
base: [...props.selected],
|
||||
moved: false,
|
||||
};
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
}}
|
||||
onPointerMove={moveBand}
|
||||
onPointerUp={(e) => {
|
||||
@@ -256,6 +257,7 @@ export function Loupe({
|
||||
total,
|
||||
faces = [],
|
||||
onMenu,
|
||||
onClose,
|
||||
}: {
|
||||
photo: PhotoSummary;
|
||||
src: string;
|
||||
@@ -264,6 +266,8 @@ export function Loupe({
|
||||
total: number;
|
||||
faces?: LoupeFace[];
|
||||
onMenu?: (id: string, e: React.MouseEvent) => void;
|
||||
/** Double-click returns to the grid. */
|
||||
onClose?: () => void;
|
||||
}) {
|
||||
// Desktop app: previews seen once show again without a network; never seen, the thumbnail stands in.
|
||||
const preview = useCachedImage(src, isDesktop());
|
||||
@@ -288,7 +292,8 @@ export function Loupe({
|
||||
return (
|
||||
<section
|
||||
aria-label="Lupa"
|
||||
className="relative flex h-full min-h-[420px] items-center justify-center bg-[#121213] p-6"
|
||||
className="relative flex h-full min-h-0 flex-1 items-center justify-center bg-[#121213]"
|
||||
onDoubleClick={() => onClose?.()}
|
||||
onContextMenu={(e) => {
|
||||
if (!onMenu) {
|
||||
e.preventDefault();
|
||||
@@ -298,13 +303,13 @@ export function Loupe({
|
||||
onMenu(photo.id, e);
|
||||
}}
|
||||
>
|
||||
<span className="relative inline-block max-h-full max-w-full">
|
||||
<span className="relative flex h-full max-h-full w-full items-center justify-center">
|
||||
<img
|
||||
src={shown}
|
||||
onError={() => setFailed(true)}
|
||||
alt={photo.name}
|
||||
draggable={false}
|
||||
className="pointer-events-none block max-h-[calc(100vh-14rem)] max-w-full object-contain shadow-[0_2px_12px_rgba(0,0,0,0.7)]"
|
||||
className="pointer-events-none block max-h-full max-w-full object-contain"
|
||||
/>
|
||||
{softCrop && <SoftCropGuide crop={softCrop} />}
|
||||
{faces.map((f) => (
|
||||
|
||||
@@ -777,7 +777,7 @@ export function LibraryPage() {
|
||||
)}
|
||||
|
||||
<div
|
||||
className={`min-h-0 flex-1 ${sheet ? "flex flex-col overflow-hidden" : "overflow-y-auto"} ${dragging ? "outline outline-2 -outline-offset-4 outline-accent" : ""}`}
|
||||
className={`min-h-0 flex-1 ${sheet || loupe ? "flex flex-col overflow-hidden" : "overflow-y-auto"} ${dragging ? "outline outline-2 -outline-offset-4 outline-accent" : ""}`}
|
||||
onDragOver={(e) => {
|
||||
if (!e.dataTransfer.types.includes("Files")) return;
|
||||
e.preventDefault();
|
||||
@@ -884,6 +884,7 @@ export function LibraryPage() {
|
||||
index={visibleIds.indexOf(focus.id)}
|
||||
total={visibleIds.length}
|
||||
faces={loupeFaces}
|
||||
onClose={() => setLoupe(false)}
|
||||
{...(canCull ? { onMenu: onPhotoMenu } : {})}
|
||||
/>
|
||||
) : visible.length || suggested.length ? (
|
||||
|
||||
Reference in new issue
Block a user