Skip to content

The OSINT investigator's workbench. One case, one folder, every tool. Local-first: your media and your investigations never leave your machine.

JavaScript

M6: Satellite captures, Proof Composer curves/text, case management, polish (#4)

OsintMeThatcf8831d04df2
diff --git a/docs/SPEC.md b/docs/SPEC.md
index 937cbc7..9bb6b1c 100644
--- a/docs/SPEC.md
+++ b/docs/SPEC.md
@@ -145,12 +145,12 @@ get media in, annotate the match, publish the proof.
| Tab | What it does |
|-----|--------------|
-| **Media Library** | The case's media shelf. Import local files (drag & drop) or download by URL (X, Telegram, TikTok, YouTube, … via yt-dlp) → clean local file + metadata JSON + sha256. Every media becomes a `media` entity. Items can be assigned a **virtual folder** (stored in sidecar) and annotated with **notes**; an info modal surfaces full provenance (source URL, title, uploader, duration) + editable notes + folder; images show a **lightbox** on click. |
+| **Media Library** | The case's media shelf. Import local files (drag & drop) or download by URL (X, Telegram, TikTok, YouTube, … via yt-dlp) → clean local file + metadata JSON + sha256. Every media becomes a `media` entity. A **facet bar** groups the shelf on the fly — auto **type/source facets** (Images, Videos, Collages, Imports, Downloads, Other, derived from `kind` + `source`) alongside the user's **virtual folders**. Items can be assigned a **virtual folder** (stored in sidecar) and annotated with **notes**; an info modal surfaces full provenance (source URL, title, uploader, duration) + editable notes + folder; images show a **lightbox** on click. |
| **Inspect** | A scratch workspace over any photo/video — **nothing enters the case until Save**. **Selection** (video): scrub, step, scan *sharpest* frames, capture into a transient tray; a gear tunes the whole clip (brightness…) for an optional enhanced-video export. **Frame**: per-frame brightness/contrast/saturation/gamma/sharpness/grayscale/invert/rotate + interactive **crop**, live-previewed, with a fold-out **Analyze** (histogram, EXIF, ELA *hint*). **Collage**: drag/scale and **corner-warp** tray frames (thumbnails show each frame's current adjustments) on a canvas into a hand-made panorama; the canvas fill is a color or **transparent** (RGBA PNG export of just the pieces). Auto-stitch = later. **Save**: tick which of {enhanced video, adjusted frames, collage} to file — each re-derived full-res on the backend with provenance back to its source, into an optional folder; the collage shows a live miniature in the picker. Frames captured from a tuned clip inherit its look; collage pieces are **frozen snapshots** taken when added. The whole workspace can be **saved as a reopenable session** (`inspect-session` entity, spec in `inspect/`) — reload it later from the sidebar with every frame/adjustment/collage intact; re-saving a reopened session **overwrites it in place** (even after a rename). Adjust/analysis controls come from self-describing filter/analysis registries. |
-| **Satellite** | Enter/click coordinates: imagery crop centered on the point, crosshair marker, zoom control, **map rotation** (turn the view off-north; capture matches the on-screen heading, bearing recorded in provenance), provenance (provider, zoom, date, bearing, attribution) recorded — feeds the composer directly. XYZ tile-provider abstraction (see note below). Each capture is one `place` entity with an **editable title + notes** via inline modal. |
-| **Proof Composer** | The heart of v1. Compose panels side by side (frames, photos, satellite crops, imported screenshots); draw colored boxes/ellipses/lines/arrows with the mouse — same color = same feature across panels; per-shape and per-panel **comments/captions**; numbered feature legend; layout rows; export `proof.png` + re-editable JSON spec saved in `proofs/`. |
+| **Satellite** | Enter/click coordinates, then **Save place** (a navigable `place` — coordinates only, no image, clickable to fly back) **or Capture** (a sourced imagery crop → `capture` image entity). Capture options: **marker style** (crosshair / Google-Maps pin / none) baked in, crop-size + **capture-frame outline** (previewed on hover, capture-only), **map rotation** (off-north; capture matches the on-screen heading, bearing in provenance). **Move-pin mode** decouples the marker from center — drag it anywhere in frame (e.g. bottom of shot) and the **recorded coordinates follow the pin** for both actions. Captures are images (open to view, not map-navigable); places are the clickable points. The tool's side panel lists both in **collapsible** sections — **Places** (fly the map back) and **Captures** (open the full image) — each with an inline **title + note editor**; the case sidebar's info panel is the same editor for any capture/place/media. Provenance (provider, zoom, date, bearing, marker, center) recorded — feeds the composer. XYZ tile-provider abstraction (see note below). Editable title + notes per capture. |
+| **Proof Composer** | The heart of v1. Compose panels side by side (frames, photos, satellite crops, imported screenshots); draw colored boxes/ellipses/lines/arrows, multi-point **curves** (rounded, click points + double-click to finish) and **text labels** with the mouse — same color = same feature across panels. Every element stays **editable after placing**: boxes/ellipses/text via transformer handles (text corner-drag = font size), lines/arrows/curves via draggable per-vertex handles; selecting an element lets you change its **color and stroke/font size live**. Palette presets **+ custom color picker**. Legend **annotations are written per color** (one note per feature), while a separate **element list** (id + kind) selects/deletes individual shapes. Per-panel captions; numbered feature legend; export `proof.png` + re-editable JSON spec (`notes` per color) saved in `proofs/`. |
| **Post Composer** | Build a GeoConfirmed-style thread from a proof. Tweet 1 = `Place - Plus code`, description, decimal coordinates (6 digits), `@GeoConfirmed` mention, source. Tweet 2 = optional media (Video / Image(s), removable), with media picked from the case library. Add extra context tweets; per-tweet character count; copy-per-tweet or copy-all. **Save drafts** (in `exports/`, reopenable from the sidebar as `post` entities) and **Publish** (copies the thread and opens X compose prefilled). Copy-paste ready — Ozimut never posts on your behalf. |
-| **Case sidebar** | Always visible, three sections. **Case Notes** (`notes.md`). **Saved work** — every artifact, auto-grouped by the tool that produced it (Media Library / Inspect / Satellite / Proof Composer / Post Composer, from `provenance.by`); suggested entities pinned on top to confirm/dismiss; deleting here removes the item **everywhere** (drops its file — danger confirm). **My work** — the analyst's own **nested folders** (`/`-separated, e.g. `Sources/Telegram`), empty until you **drag** items in from Saved work; an item filed here stays in Saved work too (lives in both); deleting here only **unfiles** it (light confirm), and removing a folder cascades its subtree back to Saved work. Styled confirm dialogs, not browser popups. Create/open/promote cases. |
+| **Case sidebar** | Always visible, three sections. **Case Notes** (`notes.md`). **Saved work** — every artifact, auto-grouped by the tool that produced it (Media Library / Inspect / Satellite / Proof Composer / Post Composer, from `provenance.by`); suggested entities pinned on top to confirm/dismiss; deleting here removes the item **everywhere** (drops its file — danger confirm). **My work** — the analyst's own **nested folders** (`/`-separated, e.g. `Sources/Telegram`), empty until you **drag** items in from Saved work; an item filed here stays in Saved work too (lives in both); deleting here only **unfiles** it (light confirm), and removing a folder cascades its subtree back to Saved work. Styled confirm dialogs, not browser popups. Create/open/promote/**rename**/**delete** cases from the switcher — names must be **unique** (case-insensitive, enforced on create/rename/promote); delete wipes the **whole case folder** and everything in it, gated behind typing `DELETE` in uppercase. |
v1 notes:
@@ -172,9 +172,9 @@ v1 notes:
- **Delete/edit sync is two-way**: an artifact and its sidebar entity are one
thing. Deleting a media / satellite capture / proof / post in its tool removes
the matching entity, and deleting the entity in the sidebar removes the
- underlying file(s). One satellite capture ⇄ one `place` entity (tied by file
+ underlying file(s). One satellite capture ⇄ one `capture` entity (tied by file
path): the entity title defaults to the coordinates but is editable, and
- deleting either side removes the other.
+ deleting either side removes the other. A `place` is coordinates only — no file.
- The previous frame-geolocator engine is **not** reused; v1 is a fresh,
minimal implementation. Frame extraction and image adjustments ship in the
**Inspect** tab (above); v1 also lets you bring images (screenshots/exports)
diff --git a/frontend/index.html b/frontend/index.html
index aeaf123..3c6d65d 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ozimut</title>
- <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='14' fill='%230e1420'/%3E%3Cpath d='M16 4 L19 16 L16 28 L13 16 Z' fill='%23e8a33d'/%3E%3Ccircle cx='16' cy='16' r='2.5' fill='%23e6edf3'/%3E%3C/svg%3E" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
</head>
<body>
<div id="app"></div>
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 1fc826c..e802666 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -8,6 +8,7 @@
"name": "ozimut-frontend",
"version": "0.1.0",
"dependencies": {
+ "@fontsource/oxanium": "^5.2.8",
"konva": "^9.3.0",
"leaflet": "^1.9.4",
"leaflet-rotate": "^0.2.8"
@@ -52,6 +53,15 @@
"tslib": "^2.4.0"
}
},
+ "node_modules/@fontsource/oxanium": {
+ "version": "5.2.8",
+ "resolved": "https://registry.npmjs.org/@fontsource/oxanium/-/oxanium-5.2.8.tgz",
+ "integrity": "sha512-69zbaespIFhjwCWgs2axD6wiwUhtEDK/R9512mv5h/U2/iv7zJowneRFt2y1aYet6RDLDWyK23F+ltbOhFIngg==",
+ "license": "OFL-1.1",
+ "funding": {
+ "url": "https://github.com/sponsors/ayuhito"
+ }
+ },
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.13",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
@@ -224,9 +234,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -244,9 +251,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -264,9 +268,6 @@
"ppc64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -284,9 +285,6 @@
"s390x"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -304,9 +302,6 @@
"x64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -324,9 +319,6 @@
"x64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -784,9 +776,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -808,9 +797,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -832,9 +818,6 @@
"x64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -856,9 +839,6 @@
"x64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
diff --git a/frontend/package.json b/frontend/package.json
index 3275262..f073ae2 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -14,6 +14,7 @@
"vite": "^8.1.4"
},
"dependencies": {
+ "@fontsource/oxanium": "^5.2.8",
"konva": "^9.3.0",
"leaflet": "^1.9.4",
"leaflet-rotate": "^0.2.8"
diff --git a/frontend/public/favicon.svg b/frontend/public/favicon.svg
new file mode 100644
index 0000000..1c4423c
--- /dev/null
+++ b/frontend/public/favicon.svg
@@ -0,0 +1,68 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
+ <circle cx="50" cy="50" r="46" fill="none" stroke="#5d6b84" stroke-width="2.4" opacity="0.4"/>
+ <circle cx="50" cy="50" r="30" fill="none" stroke="#5d6b84" stroke-width="1.2" opacity="0.5"/>
+ <line x1="50.00" y1="19.00" x2="50.00" y2="9.00" stroke="#5d6b84" stroke-width="1.6" opacity="0.85"/>
+ <line x1="53.55" y1="16.19" x2="53.97" y2="12.21" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="57.07" y1="16.74" x2="57.90" y2="12.83" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="60.51" y1="17.66" x2="61.74" y2="13.86" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="63.83" y1="18.94" x2="65.46" y2="15.29" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="67.00" y1="20.56" x2="69.00" y2="17.09" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="69.98" y1="22.49" x2="72.34" y2="19.26" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="72.75" y1="24.73" x2="75.43" y2="21.76" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="75.27" y1="27.25" x2="78.24" y2="24.57" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="77.51" y1="30.02" x2="80.74" y2="27.66" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="79.44" y1="33.00" x2="82.91" y2="31.00" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="81.06" y1="36.17" x2="84.71" y2="34.54" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="82.34" y1="39.49" x2="86.14" y2="38.26" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="83.26" y1="42.93" x2="87.17" y2="42.10" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="83.81" y1="46.45" x2="87.79" y2="46.03" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="81.00" y1="50.00" x2="91.00" y2="50.00" stroke="#5d6b84" stroke-width="1.6" opacity="0.85"/>
+ <line x1="83.81" y1="53.55" x2="87.79" y2="53.97" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="83.26" y1="57.07" x2="87.17" y2="57.90" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="82.34" y1="60.51" x2="86.14" y2="61.74" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="81.06" y1="63.83" x2="84.71" y2="65.46" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="79.44" y1="67.00" x2="82.91" y2="69.00" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="77.51" y1="69.98" x2="80.74" y2="72.34" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="75.27" y1="72.75" x2="78.24" y2="75.43" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="72.75" y1="75.27" x2="75.43" y2="78.24" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="69.98" y1="77.51" x2="72.34" y2="80.74" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="67.00" y1="79.44" x2="69.00" y2="82.91" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="63.83" y1="81.06" x2="65.46" y2="84.71" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="60.51" y1="82.34" x2="61.74" y2="86.14" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="57.07" y1="83.26" x2="57.90" y2="87.17" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="53.55" y1="83.81" x2="53.97" y2="87.79" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="50.00" y1="81.00" x2="50.00" y2="91.00" stroke="#5d6b84" stroke-width="1.6" opacity="0.85"/>
+ <line x1="46.45" y1="83.81" x2="46.03" y2="87.79" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="42.93" y1="83.26" x2="42.10" y2="87.17" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="39.49" y1="82.34" x2="38.26" y2="86.14" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="36.17" y1="81.06" x2="34.54" y2="84.71" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="33.00" y1="79.44" x2="31.00" y2="82.91" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="30.02" y1="77.51" x2="27.66" y2="80.74" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="27.25" y1="75.27" x2="24.57" y2="78.24" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="24.73" y1="72.75" x2="21.76" y2="75.43" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="22.49" y1="69.98" x2="19.26" y2="72.34" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="20.56" y1="67.00" x2="17.09" y2="69.00" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="18.94" y1="63.83" x2="15.29" y2="65.46" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="17.66" y1="60.51" x2="13.86" y2="61.74" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="16.74" y1="57.07" x2="12.83" y2="57.90" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="16.19" y1="53.55" x2="12.21" y2="53.97" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="19.00" y1="50.00" x2="9.00" y2="50.00" stroke="#5d6b84" stroke-width="1.6" opacity="0.85"/>
+ <line x1="16.19" y1="46.45" x2="12.21" y2="46.03" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="16.74" y1="42.93" x2="12.83" y2="42.10" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="17.66" y1="39.49" x2="13.86" y2="38.26" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="18.94" y1="36.17" x2="15.29" y2="34.54" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="20.56" y1="33.00" x2="17.09" y2="31.00" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="22.49" y1="30.02" x2="19.26" y2="27.66" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="24.73" y1="27.25" x2="21.76" y2="24.57" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="27.25" y1="24.73" x2="24.57" y2="21.76" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="30.02" y1="22.49" x2="27.66" y2="19.26" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="33.00" y1="20.56" x2="31.00" y2="17.09" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="36.17" y1="18.94" x2="34.54" y2="15.29" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="39.49" y1="17.66" x2="38.26" y2="13.86" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="42.93" y1="16.74" x2="42.10" y2="12.83" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <line x1="46.45" y1="16.19" x2="46.03" y2="12.21" stroke="#5d6b84" stroke-width="1" opacity="0.5"/>
+ <path d="M50 7 L56 44 L84 50 L58 58 L50 84 L42 58 L16 50 L44 44 Z" fill="#e8edf6"/>
+ <path d="M50 7 L56 45 L50 48 L44 45 Z" fill="#e8a33d"/>
+ <circle cx="50" cy="50" r="8" fill="#e8a33d"/>
+ <circle cx="50" cy="50" r="4" fill="#0b0f17"/>
+</svg>
\ No newline at end of file
diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte
index 2ee6c8e..2de5413 100644
--- a/frontend/src/App.svelte
+++ b/frontend/src/App.svelte
@@ -1,6 +1,7 @@
<script>
import { uiState, initSession } from './lib/state.svelte.js';
import Icon from './components/Icon.svelte';
+ import Logo from './components/Logo.svelte';
import CaseSwitcher from './components/CaseSwitcher.svelte';
import CaseSidebar from './components/CaseSidebar.svelte';
import Toasts from './components/Toasts.svelte';
@@ -34,11 +35,7 @@
<div class="shell">
<header class="topbar">
<div class="brand">
- <svg width="22" height="22" viewBox="0 0 32 32" aria-hidden="true">
- <circle cx="16" cy="16" r="14" fill="var(--bg-2)" stroke="var(--border-strong)" />
- <path d="M16 4 L19 16 L16 28 L13 16 Z" fill="var(--accent)" />
- <circle cx="16" cy="16" r="2.5" fill="var(--text-1)" />
- </svg>
+ <Logo size={26} />
<span class="brand-name">Ozimut</span>
</div>
<CaseSwitcher />
@@ -101,13 +98,18 @@
.brand {
display: flex;
align-items: center;
- gap: 9px;
+ gap: 10px;
padding-right: 6px;
}
.brand-name {
- font-weight: 800;
- letter-spacing: 0.02em;
- font-size: var(--fs-lg);
+ font-family: 'Oxanium', var(--font-sans);
+ font-weight: 600;
+ text-transform: uppercase;
+ letter-spacing: 0.22em;
+ /* trailing tracking pushes the word off-center; nudge it back */
+ margin-right: -0.22em;
+ font-size: var(--fs-md);
+ color: var(--text-1);
}
.spacer {
flex: 1;
diff --git a/frontend/src/components/CaseSidebar.svelte b/frontend/src/components/CaseSidebar.svelte
index f69e0b3..bbf1e25 100644
--- a/frontend/src/components/CaseSidebar.svelte
+++ b/frontend/src/components/CaseSidebar.svelte
@@ -13,6 +13,7 @@
email: 'note',
phone: 'hash',
place: 'pin',
+ capture: 'satellite',
event: 'clock',
media: 'image',
proof: 'proof',
@@ -30,7 +31,7 @@
};
// Entity types backed by a file on disk — deleting them everywhere drops the file.
- const FILE_BACKED = new Set(['media', 'place', 'proof', 'post', 'inspect-session']);
+ const FILE_BACKED = new Set(['media', 'capture', 'proof', 'post', 'inspect-session']);
// ── case notes (single notes.md) ─────────────────────────────────────────
let caseNotes = $state('');
@@ -86,6 +87,14 @@
toast(`Dismissed "${entity.label}"`, 'info');
}
+ // clicking a row: notes open the editor, captures open their image, places
+ // navigate the map — everything else opens its tool
+ function onEntityActivate(entity) {
+ if (entity.type === 'note') return openEditNote(entity);
+ if (entity.type === 'capture') return openInfo(entity);
+ openEntity(entity);
+ }
+
function openEntity(entity) {
if (entity.type === 'proof') {
// load the proof spec into the composer, then switch tab
@@ -155,15 +164,15 @@
})).filter((g) => g.items.length > 0);
});
- let groupOpen = $state({}); // group key -> bool (absent = open)
- const isGroupOpen = (k) => groupOpen[k] !== false;
+ let groupOpen = $state({}); // group key -> bool (absent = collapsed)
+ const isGroupOpen = (k) => groupOpen[k] === true;
const toggleGroup = (k) => (groupOpen[k] = !isGroupOpen(k));
// ── My work: the analyst's own nested folder tree ('/'-separated paths) ────
let newFolder = $state(''); // top-level create input
let addingUnder = $state(undefined); // folder path currently gaining a child
let newSubName = $state('');
- let expanded = $state({}); // path -> bool (absent = expanded)
+ let expanded = $state({}); // path -> bool (absent = collapsed)
let dragEntityId = $state(null);
let dragOverFolder = $state(undefined); // folder path being hovered
@@ -207,7 +216,7 @@
return node.entities.length + node.children.reduce((s, c) => s + subtreeCount(c), 0);
}
- const isExpanded = (path) => expanded[path] !== false;
+ const isExpanded = (path) => expanded[path] === true;
function toggle(path) { expanded[path] = !isExpanded(path); }
function focus(node) { node.focus(); }
@@ -348,19 +357,33 @@
};
}
- // ── entity info modal (media details) ─────────────────────────────────────
+ // ── entity info / edit modal ──────────────────────────────────────────────
let infoEntity = $state(null);
- let infoData = $state(null); // resolved media listing item (or null)
+ let infoData = $state(null); // resolved media/satellite listing item (or null)
let infoLoading = $state(false);
+ // editable fields (title + notes), like the dedicated tool's editor
+ let infoTitle = $state('');
+ let infoNotes = $state('');
+ let infoSaving = $state(false);
+ // which types can be edited straight from the sidebar
+ const EDITABLE = new Set(['capture', 'place', 'media']);
async function openInfo(entity) {
infoEntity = entity;
infoData = null;
- if (entity.type === 'media' && entity.attrs?.path) {
+ infoTitle = entity.label ?? '';
+ infoNotes = entity.attrs?.notes ?? '';
+ const endpoint =
+ entity.type === 'media' ? 'media' : entity.type === 'capture' ? 'satellite' : null;
+ if (endpoint && entity.attrs?.path) {
infoLoading = true;
try {
- const list = await api.get(`/api/cases/${caseState.current.id}/media`);
+ const list = await api.get(`/api/cases/${caseState.current.id}/${endpoint}`);
infoData = list.find((m) => m.path === entity.attrs.path) ?? null;
+ if (infoData) {
+ infoTitle = infoData.title ?? entity.label ?? '';
+ infoNotes = infoData.notes ?? infoNotes;
+ }
} catch {
infoData = null;
} finally {
@@ -369,6 +392,44 @@
}
}
+ async function saveInfo() {
+ if (!infoEntity || infoSaving) return;
+ infoSaving = true;
+ const cid = caseState.current.id;
+ try {
+ if (infoEntity.type === 'capture') {
+ // the satellite PATCH keeps the sidecar (title/notes) and the mirrored
+ // entity label in sync — the same path the Satellite tool uses
+ await api.patch(`/api/cases/${cid}/satellite`, {
+ path: infoEntity.attrs.path,
+ title: infoTitle,
+ notes: infoNotes,
+ });
+ } else if (infoEntity.type === 'media') {
+ // the media PATCH writes the sidecar (title/notes) and mirrors the
+ // title onto the entity label, so the Media tab reflects it too
+ await api.patch(`/api/cases/${cid}/media`, {
+ path: infoEntity.attrs.path,
+ title: infoTitle.trim(),
+ notes: infoNotes,
+ });
+ } else {
+ // place (or any bare entity): retitle + note on the entity itself
+ await api.patch(`/api/cases/${cid}/entities/${infoEntity.id}`, {
+ label: infoTitle.trim() || infoEntity.label,
+ attrs: { notes: infoNotes.trim() },
+ });
+ }
+ infoEntity = null;
+ await reloadCase();
+ toast('Saved', 'ok', 1600);
+ } catch (e) {
+ toast(e.message, 'danger');
+ } finally {
+ infoSaving = false;
+ }
+ }
+
function fmtSize(bytes) {
if (bytes == null) return '';
if (bytes >= 1 << 30) return (bytes / (1 << 30)).toFixed(1) + ' GB';
@@ -616,7 +677,7 @@
<!-- one entity row. zone 'saved' → delete everywhere; 'mywork' → unfile only -->
{#snippet entityRow(e, depth, zone)}
- {@const isClickable = e.type === 'note' || !!ENTITY_TOOL[e.type]}
+ {@const isClickable = e.type === 'note' || e.type === 'capture' || !!ENTITY_TOOL[e.type]}
<div
class="entity"
class:clickable={isClickable}
@@ -625,10 +686,10 @@
draggable="true"
ondragstart={(ev) => onDragStart(ev, e)}
ondragend={() => { dragEntityId = null; dragOverFolder = undefined; }}
- onclick={() => (e.type === 'note' ? openEditNote(e) : openEntity(e))}
+ onclick={() => onEntityActivate(e)}
role={isClickable ? 'button' : undefined}
tabindex={isClickable ? 0 : undefined}
- onkeydown={(ev) => ev.key === 'Enter' && (e.type === 'note' ? openEditNote(e) : openEntity(e))}
+ onkeydown={(ev) => ev.key === 'Enter' && onEntityActivate(e)}
>
<Icon name="grip" size={13} />
<Icon name={ENTITY_ICONS[e.type] ?? 'note'} size={14} />
@@ -734,6 +795,20 @@
<!-- svelte-ignore a11y_media_has_caption -->
<video src={`/files/${caseState.current.id}/${infoData.path}`} controls preload="metadata"></video>
</div>
+ {:else if infoEntity.type === 'capture' && infoEntity.attrs?.path}
+ <div class="info-preview">
+ <img src={`/files/${caseState.current.id}/${infoEntity.attrs.path}`} alt={infoEntity.label} />
+ </div>
+ {/if}
+
+ {#if EDITABLE.has(infoEntity.type)}
+ <label class="modal-label" for="info-title">Title</label>
+ <input
+ id="info-title"
+ class="input"
+ bind:value={infoTitle}
+ placeholder={infoEntity.attrs?.coords ?? 'Title'}
+ />
{/if}
<div class="info-rows">
@@ -741,7 +816,7 @@
{#if folderOf(infoEntity)}
<div class="info-row"><span class="info-k">Folder</span><span>{folderOf(infoEntity)}</span></div>
{/if}
- {#if infoData}
+ {#if infoEntity.type === 'media' && infoData}
<div class="info-row"><span class="info-k">Kind</span><span>{infoData.kind}</span></div>
<div class="info-row"><span class="info-k">Size</span><span>{fmtSize(infoData.size)}</span></div>
{#if infoData.added_at}
@@ -770,8 +845,15 @@
</a>
</div>
{/if}
- {#if infoData.notes}
- <div class="info-row"><span class="info-k">Notes</span><span>{infoData.notes}</span></div>
+ {:else if infoEntity.type === 'capture'}
+ {#if infoData?.provider_label}
+ <div class="info-row"><span class="info-k">Provider</span><span>{infoData.provider_label}</span></div>
+ {/if}
+ {#if infoEntity.attrs?.zoom != null}
+ <div class="info-row"><span class="info-k">Zoom</span><span>z{infoEntity.attrs.zoom}</span></div>
+ {/if}
+ {#if infoData?.fetched_at}
+ <div class="info-row"><span class="info-k">Date</span><span class="mono">{infoData.fetched_at.slice(0, 10)}</span></div>
{/if}
{:else if infoEntity.attrs?.content}
<div class="info-note-body">{infoEntity.attrs.content}</div>
@@ -781,9 +863,21 @@
{/if}
</div>
+ {#if EDITABLE.has(infoEntity.type)}
+ <label class="modal-label" for="info-notes" style="margin-top:10px">Notes</label>
+ <textarea
+ id="info-notes"
+ class="textarea"
+ rows="4"
+ bind:value={infoNotes}
+ placeholder="Add observations, links, context…"
+ ></textarea>
+ {/if}
+
+ {@const filePath = infoData?.path ?? (infoEntity.type === 'capture' ? infoEntity.attrs?.path : null)}
<div class="modal-row">
- {#if infoData?.path}
- <a class="btn btn-ghost btn-sm" href={`/files/${caseState.current.id}/${infoData.path}`} target="_blank" rel="noreferrer">
+ {#if filePath}
+ <a class="btn btn-ghost btn-sm" href={`/files/${caseState.current.id}/${filePath}`} target="_blank" rel="noreferrer">
<Icon name="external" size={13} /> Open file
</a>
{/if}
@@ -794,6 +888,11 @@
{/if}
<div style="flex:1"></div>
<button class="btn" onclick={() => (infoEntity = null)}>Close</button>
+ {#if EDITABLE.has(infoEntity.type)}
+ <button class="btn btn-primary" onclick={saveInfo} disabled={infoSaving}>
+ {infoSaving ? 'Saving…' : 'Save'}
+ </button>
+ {/if}
</div>
</Modal>
{/if}
diff --git a/frontend/src/components/CaseSwitcher.svelte b/frontend/src/components/CaseSwitcher.svelte
index 4e2b62f..aff7fbf 100644
--- a/frontend/src/components/CaseSwitcher.svelte
+++ b/frontend/src/components/CaseSwitcher.svelte
@@ -5,16 +5,54 @@
openCase,
createCase,
promoteCase,
+ renameCase,
closeCase,
+ deleteCase,
toast,
} from '../lib/state.svelte.js';
import Icon from './Icon.svelte';
import Modal from './Modal.svelte';
let open = $state(false);
- let modal = $state(null); // 'create' | 'promote' | null
+ let modal = $state(null); // 'create' | 'promote' | 'rename' | null
let nameInput = $state('');
let busy = $state(false);
+ let renameId = $state(null); // id of the case being renamed (modal === 'rename')
+
+ function askRename(c) {
+ open = false;
+ modal = 'rename';
+ renameId = c.id;
+ nameInput = c.name ?? c.id;
+ }
+
+ // Delete flow: the whole case folder is wiped, so we make the user type
+ // DELETE (uppercase) to confirm. `delTarget` holds the case being deleted.
+ let delTarget = $state(null); // { id, name } | null
+ let delConfirm = $state('');
+ let delBusy = $state(false);
+ const delReady = $derived(delConfirm === 'DELETE');
+
+ function askDelete(c) {
+ open = false;
+ delTarget = { id: c.id, name: c.name ?? c.id };
+ delConfirm = '';
+ }
+
+ async function confirmDelete() {
+ if (!delReady || delBusy || !delTarget) return;
+ delBusy = true;
+ try {
+ await deleteCase(delTarget.id);
+ toast(`Case “${delTarget.name}” deleted`, 'ok');
+ delTarget = null;
+ delConfirm = '';
+ } catch (e) {
+ toast(e.message, 'danger');
+ } finally {
+ delBusy = false;
+ }
+ }
async function toggle() {
open = !open;
@@ -27,17 +65,22 @@
}
async function submit() {
- if (!nameInput.trim() || busy) return;
+ const name = nameInput.trim();
+ if (!name || busy || nameTaken) return;
busy = true;
try {
if (modal === 'create') {
- await createCase(nameInput.trim());
- toast(`Case “${nameInput.trim()}” created`, 'ok');
+ await createCase(name);
+ toast(`Case “${name}” created`, 'ok');
} else if (modal === 'promote') {
- await promoteCase(nameInput.trim());
+ await promoteCase(name);
+ } else if (modal === 'rename') {
+ await renameCase(renameId, name);
+ toast(`Renamed to “${name}”`, 'ok');
}
modal = null;
nameInput = '';
+ renameId = null;
} catch (e) {
toast(e.message, 'danger');
} finally {
@@ -47,6 +90,17 @@
const named = $derived(caseState.list.filter((c) => !c.scratch));
const scratches = $derived(caseState.list.filter((c) => c.scratch));
+
+ // Guard against duplicate names (case-insensitive) — the backend enforces
+ // this too, but flag it early so the button disables instead of erroring.
+ const nameTaken = $derived(
+ !!nameInput.trim() &&
+ named.some(
+ (c) =>
+ c.id !== renameId &&
+ c.name.trim().toLowerCase() === nameInput.trim().toLowerCase()
+ )
+ );
</script>
<div class="switcher">
@@ -94,20 +148,33 @@
{#if named.length}
<div class="section">Cases</div>
{#each named as c (c.id)}
- <button class="item" class:active={c.id === caseState.current?.id} onclick={() => pick(c.id)}>
- <Icon name="folder" size={15} />
- <span class="grow">{c.name}</span>
- <span class="meta">{c.entity_count} entities</span>
- </button>
+ <div class="row" class:active={c.id === caseState.current?.id}>
+ <button class="item" onclick={() => pick(c.id)}>
+ <Icon name="folder" size={15} />
+ <span class="grow">{c.name}</span>
+ <span class="meta">{c.entity_count} entities</span>
+ </button>
+ <button class="del rename" title="Rename case" onclick={() => askRename(c)}>
+ <Icon name="edit" size={14} />
+ </button>
+ <button class="del" title="Delete case" onclick={() => askDelete(c)}>
+ <Icon name="trash" size={14} />
+ </button>
+ </div>
{/each}
{/if}
{#if scratches.length}
<div class="section">Scratch sessions</div>
{#each scratches as c (c.id)}
- <button class="item" class:active={c.id === caseState.current?.id} onclick={() => pick(c.id)}>
- <Icon name="clock" size={15} />
- <span class="grow">{c.id}</span>
- </button>
+ <div class="row" class:active={c.id === caseState.current?.id}>
+ <button class="item" onclick={() => pick(c.id)}>
+ <Icon name="clock" size={15} />
+ <span class="grow">{c.id}</span>
+ </button>
+ <button class="del" title="Delete session" onclick={() => askDelete(c)}>
+ <Icon name="trash" size={14} />
+ </button>
+ </div>
{/each}
{/if}
{#if !named.length && !scratches.length}
@@ -119,7 +186,11 @@
{#if modal}
<Modal
- title={modal === 'create' ? 'New case' : 'Keep this session as a case'}
+ title={modal === 'create'
+ ? 'New case'
+ : modal === 'rename'
+ ? 'Rename case'
+ : 'Keep this session as a case'}
onclose={() => (modal = null)}
>
<form
@@ -137,10 +208,58 @@
bind:value={nameInput}
autofocus
/>
+ {#if nameTaken}
+ <p class="err">A case with this name already exists — pick another.</p>
+ {/if}
<div class="actions">
<button type="button" class="btn" onclick={() => (modal = null)}>Cancel</button>
- <button type="submit" class="btn btn-primary" disabled={!nameInput.trim() || busy}>
- {modal === 'create' ? 'Create' : 'Promote'}
+ <button
+ type="submit"
+ class="btn btn-primary"
+ disabled={!nameInput.trim() || busy || nameTaken}
+ >
+ {modal === 'create' ? 'Create' : modal === 'rename' ? 'Rename' : 'Promote'}
+ </button>
+ </div>
+ </form>
+ </Modal>
+{/if}
+
+{#if delTarget}
+ <Modal title="Delete case" onclose={() => (delTarget = null)}>
+ <div class="warn">
+ <span class="warn-badge"><Icon name="trash" size={18} /></span>
+ <div>
+ <p class="warn-title">
+ You will lose everything in “{delTarget.name}”.
+ </p>
+ <p class="warn-body">
+ This permanently deletes the whole case folder and all its contents —
+ media, satellite crops, proofs, exports and notes. This cannot be
+ undone.
+ </p>
+ </div>
+ </div>
+ <form
+ onsubmit={(e) => {
+ e.preventDefault();
+ confirmDelete();
+ }}
+ >
+ <label class="label" for="del-confirm">Type <b>DELETE</b> to confirm</label>
+ <!-- svelte-ignore a11y_autofocus -->
+ <input
+ id="del-confirm"
+ class="input"
+ placeholder="DELETE"
+ bind:value={delConfirm}
+ autocomplete="off"
+ autofocus
+ />
+ <div class="actions">
+ <button type="button" class="btn" onclick={() => (delTarget = null)}>Cancel</button>
+ <button type="submit" class="btn btn-danger" disabled={!delReady || delBusy}>
+ {delBusy ? 'Deleting…' : 'Delete everything'}
</button>
</div>
</form>
@@ -204,6 +323,43 @@
color: var(--text-3);
padding: 10px 10px 4px;
}
+ .row {
+ display: flex;
+ align-items: center;
+ border-radius: var(--r-sm);
+ }
+ .row:hover {
+ background: var(--bg-2);
+ }
+ .row.active {
+ background: var(--accent-soft);
+ }
+ .row.active .item {
+ color: var(--accent);
+ }
+ .row .item {
+ flex: 1;
+ min-width: 0;
+ background: none;
+ }
+ .row .item:hover {
+ background: none;
+ }
+ .del {
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ padding: 8px 10px;
+ color: var(--text-3);
+ opacity: 0;
+ border-radius: var(--r-sm);
+ }
+ .row:hover .del {
+ opacity: 1;
+ }
+ .del:hover {
+ color: var(--danger, #e5484d);
+ }
.item {
display: flex;
align-items: center;
@@ -222,6 +378,42 @@
background: var(--accent-soft);
color: var(--accent);
}
+ .warn {
+ display: flex;
+ gap: 13px;
+ align-items: flex-start;
+ margin-bottom: 16px;
+ }
+ .warn-badge {
+ flex-shrink: 0;
+ width: 38px;
+ height: 38px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 10px;
+ background: color-mix(in srgb, var(--danger, #e5484d) 16%, transparent);
+ color: var(--danger, #e5484d);
+ }
+ .warn-title {
+ font-size: var(--fs-sm);
+ font-weight: 700;
+ color: var(--text-1);
+ margin-bottom: 4px;
+ }
+ .warn-body {
+ font-size: var(--fs-xs);
+ color: var(--text-3);
+ line-height: 1.45;
+ }
+ .btn-danger {
+ background: var(--danger, #e5484d);
+ color: #fff;
+ border-color: transparent;
+ }
+ .btn-danger:hover:not(:disabled) {
+ filter: brightness(1.08);
+ }
.item.new {
color: var(--accent);
font-weight: 600;
@@ -241,6 +433,11 @@
color: var(--text-3);
font-size: var(--fs-sm);
}
+ .err {
+ font-size: var(--fs-xs);
+ color: var(--danger, #e5484d);
+ margin-top: 8px;
+ }
.actions {
display: flex;
justify-content: flex-end;
diff --git a/frontend/src/components/Icon.svelte b/frontend/src/components/Icon.svelte
index 469375b..1fdd5af 100644
--- a/frontend/src/components/Icon.svelte
+++ b/frontend/src/components/Icon.svelte
@@ -49,6 +49,7 @@
square: 'M5 5h14a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z',
circle: 'M12 4a8 8 0 1 1 0 16 8 8 0 0 1 0-16Z',
line: 'M5 19 19 5',
+ curve: 'M4 18c4 0 4-12 8-12s4 12 8 12',
arrow: 'M5 19 19 5m0 0h-8m8 0v8',
text: 'M5 6V4h14v2M12 4v16m-3 0h6',
hand: 'M8 12V6a1.5 1.5 0 0 1 3 0v5m0-6.5a1.5 1.5 0 0 1 3 0V11m0-5a1.5 1.5 0 0 1 3 0v9a6 6 0 0 1-6 6h-1a6 6 0 0 1-5-2.7L3.5 15A1.6 1.6 0 0 1 6 13.2l2 1.8',
diff --git a/frontend/src/components/Logo.svelte b/frontend/src/components/Logo.svelte
new file mode 100644
index 0000000..5b785e8
--- /dev/null
+++ b/frontend/src/components/Logo.svelte
@@ -0,0 +1,76 @@
+<script>
+ export let size = 32;
+ export let variant = 'default'; // 'default' | 'mono' | 'inverted'
+
+ // Instrument bezel: 60 radial ticks, emphasised at the cardinals (N/E/S/W).
+ const R_IN = 34,
+ R_OUT = 38,
+ R_CARD_IN = 31,
+ R_CARD_OUT = 41;
+ const ticks = Array.from({ length: 60 }, (_, i) => {
+ const a = (i / 60) * Math.PI * 2 - Math.PI / 2;
+ const cardinal = i % 15 === 0;
+ const r1 = cardinal ? R_CARD_IN : R_IN;
+ const r2 = cardinal ? R_CARD_OUT : R_OUT;
+ return {
+ x1: 50 + Math.cos(a) * r1,
+ y1: 50 + Math.sin(a) * r1,
+ x2: 50 + Math.cos(a) * r2,
+ y2: 50 + Math.sin(a) * r2,
+ cardinal,
+ };
+ });
+</script>
+
+<svg
+ width={size}
+ height={size}
+ viewBox="0 0 100 100"
+ aria-label="Ozimut logo"
+ class={variant}
+>
+ <!-- Outer ring (world / scope) -->
+ <circle cx="50" cy="50" r="46" fill="none" stroke="currentColor" stroke-width="2.4" opacity="0.4" />
+ <!-- Bezel ring (analysis / investigation) -->
+ <circle cx="50" cy="50" r="30" fill="none" stroke="currentColor" stroke-width="1.2" opacity="0.5" />
+
+ <!-- Graduation ticks -->
+ {#each ticks as t}
+ <line
+ x1={t.x1}
+ y1={t.y1}
+ x2={t.x2}
+ y2={t.y2}
+ stroke="currentColor"
+ stroke-width={t.cardinal ? 1.6 : 1}
+ stroke-linecap="round"
+ opacity={t.cardinal ? 0.85 : 0.5}
+ />
+ {/each}
+
+ <!-- Compass rose (focus / truth) — slender north arm -->
+ <path
+ d="M50 7 L56 44 L84 50 L58 58 L50 84 L42 58 L16 50 L44 44 Z"
+ fill="var(--text-1)"
+ />
+ <!-- North point (accent / azimuth) -->
+ <path d="M50 7 L56 45 L50 48 L44 45 Z" fill="var(--accent)" />
+
+ <!-- Center focus -->
+ <circle cx="50" cy="50" r="8" fill="var(--accent)" />
+ <circle cx="50" cy="50" r="4" fill="var(--bg-0)" />
+</svg>
+
+<style>
+ svg {
+ display: inline-block;
+ color: var(--text-2);
+ }
+ svg.mono {
+ color: currentColor;
+ }
+ svg.inverted {
+ color: #fff;
+ filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.3));
+ }
+</style>
diff --git a/frontend/src/lib/composer.js b/frontend/src/lib/composer.js
index c769051..188b320 100644
--- a/frontend/src/lib/composer.js
+++ b/frontend/src/lib/composer.js
@@ -37,24 +37,46 @@ export function layoutPanels(panels) {
});
}
-/** Distinct colors in order of first use → feature numbering (same color = same feature). */
+/**
+ * Distinct colors in order of first use → feature numbering (same color = same
+ * feature). Text labels are excluded — they annotate, they aren't features.
+ */
export function featureColors(shapes) {
const seen = [];
for (const s of shapes) {
+ if (s.kind === 'text') continue;
if (!seen.includes(s.color)) seen.push(s.color);
}
return seen;
}
-/** Legend lines: one per used color, comments joined. */
-export function legendLines(shapes) {
+/**
+ * Legend lines: one per used color (feature), text taken from the per-color
+ * `notes` map. Annotations are written by color, not per element.
+ */
+export function legendLines(shapes, notes = {}) {
const colors = featureColors(shapes);
- return colors.map((color, i) => {
- const comments = shapes
- .filter((s) => s.color === color && s.comment?.trim())
- .map((s) => s.comment.trim());
- return { color, n: i + 1, text: [...new Set(comments)].join(' · ') };
- });
+ return colors.map((color, i) => ({
+ color,
+ n: i + 1,
+ text: (notes?.[color] ?? '').trim(),
+ }));
+}
+
+/**
+ * Build a per-color notes map from legacy per-shape comments (old specs stored
+ * the legend text on each shape). Used once when opening an old proof.
+ */
+export function notesFromShapes(shapes) {
+ const notes = {};
+ for (const s of shapes) {
+ const c = s.comment?.trim();
+ if (!c) continue;
+ const existing = notes[s.color];
+ if (!existing) notes[s.color] = c;
+ else if (!existing.split(' · ').includes(c)) notes[s.color] = `${existing} · ${c}`;
+ }
+ return notes;
}
/** Unique attribution strings from panel metadata. */
@@ -69,12 +91,12 @@ export function attributionLine(panels) {
}
/** Full document size given panels + shapes (legend grows with features). */
-export function docSize(panels, shapes) {
+export function docSize(panels, shapes, notes = {}) {
const boxes = layoutPanels(panels);
const width = boxes.length
? boxes[boxes.length - 1].x + boxes[boxes.length - 1].w + PAD
: 640;
- const legend = legendLines(shapes).filter((l) => l.text);
+ const legend = legendLines(shapes, notes).filter((l) => l.text);
const height =
PAD + PANEL_H + CAPTION_H + (legend.length ? 10 + legend.length * LEGEND_LINE_H : 0) + FOOTER_H + PAD;
return { width: Math.max(width, 640), height, legend };
@@ -86,6 +108,7 @@ export function toSpec(proof) {
ozimut_proof: 1,
title: proof.title,
coords: proof.coords ?? null,
+ notes: { ...(proof.notes ?? {}) },
panels: proof.panels.map((p) => ({
id: p.id, // kept so shapes stay bound to their panel on reload
src: p.src,
diff --git a/frontend/src/lib/state.svelte.js b/frontend/src/lib/state.svelte.js
index fd25e9b..80b0a34 100644
--- a/frontend/src/lib/state.svelte.js
+++ b/frontend/src/lib/state.svelte.js
@@ -113,6 +113,16 @@ export async function ensureCase() {
return caseState.current;
}
+/**
+ * Rename a case in place (keeps the same id/folder — only the display name
+ * changes). Refreshes the list, and the open case if it is the one renamed.
+ */
+export async function renameCase(id, name) {
+ await api.patch(`/api/cases/${id}`, { name });
+ await refreshCaseList();
+ if (caseState.current?.id === id) await openCase(id);
+}
+
export async function promoteCase(name) {
if (!caseState.current?.scratch) return;
const promoted = await api.post(`/api/cases/${caseState.current.id}/promote`, { name });
@@ -125,3 +135,15 @@ export function closeCase() {
caseState.current = null;
rememberCase(null);
}
+
+/**
+ * Permanently delete a case and everything it contains (the whole folder on
+ * disk — media, satellite, proofs, exports). Irreversible; the caller is
+ * responsible for the "type DELETE" confirmation. If the deleted case is the
+ * one open, we drop back to one-shot mode.
+ */
+export async function deleteCase(id) {
+ await api.del(`/api/cases/${id}`);
+ if (caseState.current?.id === id) closeCase();
+ await refreshCaseList();
+}
diff --git a/frontend/src/main.js b/frontend/src/main.js
index 130d994..1d28068 100644
--- a/frontend/src/main.js
+++ b/frontend/src/main.js
@@ -1,4 +1,7 @@
import { mount } from 'svelte';
+import '@fontsource/oxanium/400.css';
+import '@fontsource/oxanium/600.css';
+import '@fontsource/oxanium/700.css';
import './app.css';
import App from './App.svelte';
diff --git a/frontend/src/tools/MediaLibrary.svelte b/frontend/src/tools/MediaLibrary.svelte
index 65b3c5d..57f285c 100644
--- a/frontend/src/tools/MediaLibrary.svelte
+++ b/frontend/src/tools/MediaLibrary.svelte
@@ -13,20 +13,43 @@
let jobs = $state([]); // active download jobs: {id, url, progress}
let fileInput;
- // --- folder filter ---
+ // --- category facets (auto-derived from kind + source) ---
+ // Overlapping filters (a downloaded video matches both Videos and Downloads);
+ // clicking one narrows the grid to that facet. Order matches the sidebar bar.
+ const CATEGORIES = [
+ { key: 'image', label: 'Images', icon: 'image', match: (i) => i.kind === 'image' },
+ { key: 'video', label: 'Videos', icon: 'video', match: (i) => i.kind === 'video' },
+ { key: 'collage', label: 'Collages', icon: 'layers', match: (i) => i.source?.op === 'collage' },
+ { key: 'upload', label: 'Imports', icon: 'upload', match: (i) => i.source?.type === 'upload' },
+ { key: 'download', label: 'Downloads', icon: 'download', match: (i) => i.source?.type === 'download' },
+ { key: 'other', label: 'Other files', icon: 'file', match: (i) => i.kind !== 'image' && i.kind !== 'video' },
+ ];
+
+ let catFilter = $state(null); // null = All types
+
+ const activeCats = $derived(
+ CATEGORIES.map((c) => ({ ...c, count: items.filter(c.match).length })).filter(
+ (c) => c.count > 0
+ )
+ );
+ const catMatch = $derived(CATEGORIES.find((c) => c.key === catFilter)?.match ?? null);
+
+ // --- folder filter (user-defined folders) ---
let folderFilter = $state(null); // null = All
const folders = $derived(
[...new Set(items.filter((i) => i.folder).map((i) => i.folder))].sort()
);
const filteredItems = $derived(
- folderFilter ? items.filter((i) => i.folder === folderFilter) : items
+ items.filter(
+ (i) => (!catMatch || catMatch(i)) && (!folderFilter || i.folder === folderFilter)
+ )
);
// --- info/edit modal ---
let editItem = $state(null);
let editNotes = $state('');
- let editLabel = $state('');
+ let editTitle = $state('');
let editSaving = $state(false);
// --- lightbox ---
@@ -34,11 +57,12 @@
$effect(() => {
const id = caseState.current?.id;
+ caseState.rev; // also refetch when the case is reloaded elsewhere (e.g. sidebar edit)
if (id !== loadedFor) {
loadedFor = id;
items = [];
- if (id) refresh(id);
}
+ if (id) refresh(id);
});
async function refresh(id = caseState.current?.id) {
@@ -150,7 +174,7 @@
function openInfo(item) {
editItem = item;
editNotes = item.notes ?? '';
- editLabel = item.label ?? '';
+ editTitle = item.title ?? '';
}
async function saveInfo() {
@@ -160,11 +184,13 @@
const updated = await api.patch(`/api/cases/${caseState.current.id}/media`, {
path: editItem.path,
notes: editNotes,
- label: editLabel,
+ title: editTitle,
});
const idx = items.findIndex((i) => i.path === editItem.path);
if (idx !== -1) items[idx] = updated;
editItem = null;
+ // mirror the title/notes onto the case sidebar entity live
+ await reloadCase();
toast('Saved', 'ok', 1600);
} catch (e) {
toast(e.message, 'danger');
@@ -222,27 +248,43 @@
/>
</div>
- <!-- folder filter bar -->
+ <!-- category + folder filter bar -->
{#if items.length > 0}
<div class="folder-bar">
+ <!-- type / source facets -->
<button
class="folder-chip"
- class:active={folderFilter === null}
- onclick={() => (folderFilter = null)}
+ class:active={catFilter === null}
+ onclick={() => (catFilter = null)}
>
<Icon name="media" size={13} /> All
<span class="chip-count">{items.length}</span>
</button>
- {#each folders as f (f)}
+ {#each activeCats as c (c.key)}
<button
class="folder-chip"
- class:active={folderFilter === f}
- onclick={() => (folderFilter = f)}
+ class:active={catFilter === c.key}
+ onclick={() => (catFilter = catFilter === c.key ? null : c.key)}
>
- <Icon name="folder" size={13} />{f}
- <span class="chip-count">{items.filter((i) => i.folder === f).length}</span>
+ <Icon name={c.icon} size={13} />{c.label}
+ <span class="chip-count">{c.count}</span>
</button>
{/each}
+
+ <!-- user-defined folders (independent facet) -->
+ {#if folders.length}
+ <span class="bar-sep"></span>
+ {#each folders as f (f)}
+ <button
+ class="folder-chip"
+ class:active={folderFilter === f}
+ onclick={() => (folderFilter = folderFilter === f ? null : f)}
+ >
+ <Icon name="folder" size={13} />{f}
+ <span class="chip-count">{items.filter((i) => i.folder === f).length}</span>
+ </button>
+ {/each}
+ {/if}
</div>
{/if}
@@ -277,7 +319,8 @@
{:else if filteredItems.length === 0}
<div class="empty" style="height: 100%">
<div class="empty-icon"><Icon name="folder" size={38} /></div>
- <h3>Folder is empty</h3>
+ <h3>Nothing here</h3>
+ <p>No media matches this filter.</p>
</div>
{:else}
<div class="grid">
@@ -310,7 +353,7 @@
{/if}
</div>
<div class="body">
- <span class="name" title={item.filename}>{item.label ?? item.filename}</span>
+ <span class="name" title={item.filename}>{item.title ?? item.filename}</span>
<span class="meta">
{fmtSize(item.size)} ·
<span class="mono" title={item.sha256}>{item.sha256.slice(0, 8)}</span>
@@ -459,12 +502,12 @@
<hr class="divider" />
<!-- editable fields -->
- <label class="field-label" for="edit-label">Label</label>
+ <label class="field-label" for="edit-title">Title</label>
<input
- id="edit-label"
+ id="edit-title"
class="input"
placeholder={editItem.filename}
- bind:value={editLabel}
+ bind:value={editTitle}
/>
<label class="field-label" for="edit-notes" style="margin-top: 12px;">Notes</label>
@@ -564,6 +607,13 @@
color: var(--text-3);
margin-left: 2px;
}
+ .bar-sep {
+ width: 1px;
+ align-self: stretch;
+ margin: 2px 4px;
+ background: var(--border);
+ flex-shrink: 0;
+ }
.job {
display: flex;
diff --git a/frontend/src/tools/PostComposer.svelte b/frontend/src/tools/PostComposer.svelte
index f6d878b..1cb17db 100644
--- a/frontend/src/tools/PostComposer.svelte
+++ b/frontend/src/tools/PostComposer.svelte
@@ -15,6 +15,7 @@
let mention = $state('@GeoConfirmed');
let source = $state('');
let proofPng = $state(null);
+ let proofVer = $state(0); // cache-buster: bumped whenever proofPng is (re)assigned
let tweet1 = $state('');
let tweet1Edited = $state(false);
@@ -36,6 +37,10 @@
let pickerOpen = $state(false);
let mediaLibrary = $state([]);
+ // Proof picker modal
+ let proofPickerOpen = $state(false);
+ let proofLibrary = $state([]);
+
// Ingest a proof handed over by the Proof Composer
$effect(() => {
const p = uiState.postProof;
@@ -43,7 +48,7 @@
uiState.postProof = null;
description = p.title === 'Untitled proof' ? '' : (p.title ?? '');
source = p.sources?.[0] ?? '';
- proofPng = p.png ?? null;
+ setProof(p.png ?? null);
tweet1Edited = false;
if (p.coords) {
coordsText = `${p.coords.lat.toFixed(6)}, ${p.coords.lon.toFixed(6)}`;
@@ -201,12 +206,50 @@
mediaPath = null;
}
+ // ---- proof picker -------------------------------------------------------
+
+ /** Assign the attached proof and bump the cache-buster so the preview always
+ * reflects the current file — proofs default to the same slug/filename, so
+ * the URL alone can be identical across different proofs. */
+ function setProof(png) {
+ proofPng = png;
+ proofVer = png ? Date.now() : 0;
+ }
+
+ async function openProofPicker() {
+ if (!caseState.current) {
+ toast('Open a case to pick a proof', 'warn');
+ return;
+ }
+ try {
+ proofLibrary = await api.get(`/api/cases/${caseState.current.id}/proofs`);
+ proofPickerOpen = true;
+ } catch (e) {
+ toast(e.message, 'danger');
+ }
+ }
+
+ function pickProof(item) {
+ setProof(item.png);
+ if (!description.trim() && item.title && item.title !== 'Untitled proof') {
+ description = item.title;
+ regenerate();
+ }
+ proofPickerOpen = false;
+ }
+
+ function clearProof() {
+ setProof(null);
+ }
+
const mediaHref = $derived(
mediaPath && caseState.current ? `/files/${caseState.current.id}/${mediaPath}` : null
);
const proofHref = $derived(
- proofPng && caseState.current ? `/files/${caseState.current.id}/${proofPng}` : null
+ proofPng && caseState.current
+ ? `/files/${caseState.current.id}/${proofPng}${proofVer ? `?v=${proofVer}` : ''}`
+ : null
);
// ---- one-click image copy / media download ------------------------------
@@ -311,7 +354,7 @@
place = s.place ?? '';
mention = s.mention ?? '@GeoConfirmed';
source = s.source ?? '';
- proofPng = s.proofPng ?? null;
+ setProof(s.proofPng ?? null);
mediaEnabled = s.mediaEnabled ?? true;
mediaType = s.mediaType ?? 'none';
mediaText = s.mediaText ?? '';
@@ -443,17 +486,31 @@
/>
</div>
- {#if proofPng && caseState.current}
+ {#if caseState.current}
<div class="field">
<div class="proof-head">
<span class="label" style="margin:0">Attached proof</span>
- <button class="btn btn-ghost btn-sm" onclick={() => copyImage(proofHref)} title="Copy the image — paste it into X">
- <Icon name="copy" size={13} /> Copy image
- </button>
+ {#if proofPng}
+ <button class="btn btn-ghost btn-sm" onclick={() => copyImage(proofHref)} title="Copy the image — paste it into X">
+ <Icon name="copy" size={13} /> Copy image
+ </button>
+ <button class="btn btn-ghost btn-sm" onclick={openProofPicker} title="Attach a different proof">
+ <Icon name="proof" size={13} /> Change
+ </button>
+ <button class="btn btn-ghost btn-sm danger-hover" onclick={clearProof} title="Detach proof">
+ <Icon name="x" size={13} />
+ </button>
+ {/if}
</div>
- <a href={proofHref} target="_blank" rel="noreferrer">
- <img class="proof-preview card" src={proofHref} alt="proof" />
- </a>
+ {#if proofPng}
+ <a href={proofHref} target="_blank" rel="noreferrer">
+ <img class="proof-preview card" src={proofHref} alt="proof" />
+ </a>
+ {:else}
+ <button class="btn btn-ghost btn-sm proof-attach" onclick={openProofPicker}>
+ <Icon name="proof" size={14} /> Attach a proof
+ </button>
+ {/if}
</div>
{/if}
</div>
@@ -624,6 +681,29 @@
</Modal>
{/if}
+{#if proofPickerOpen}
+ <Modal title="Attach a proof" width="640px" onclose={() => (proofPickerOpen = false)}>
+ {#if proofLibrary.length === 0}
+ <p class="picker-empty">No proofs in this case yet — build one in the Proof tab.</p>
+ {:else}
+ <div class="picker-grid">
+ {#each proofLibrary as item (item.name)}
+ <button class="picker-item" onclick={() => pickProof(item)} title={item.title} disabled={!item.png}>
+ <div class="picker-thumb">
+ {#if item.png}
+ <img src={`/files/${caseState.current.id}/${item.png}`} alt={item.title} />
+ {:else}
+ <Icon name="proof" size={24} />
+ {/if}
+ </div>
+ <span class="picker-name">{item.title || item.name}</span>
+ </button>
+ {/each}
+ </div>
+ {/if}
+ </Modal>
+{/if}
+
<style>
.layout {
display: grid;
@@ -679,6 +759,10 @@
gap: 10px;
margin-bottom: 6px;
}
+ .proof-attach {
+ align-self: flex-start;
+ border: 1px dashed var(--border);
+ }
/* Thread / tweet blocks */
.tweet-block {
diff --git a/frontend/src/tools/ProofComposer.svelte b/frontend/src/tools/ProofComposer.svelte
index 8262a8b..45b6035 100644
--- a/frontend/src/tools/ProofComposer.svelte
+++ b/frontend/src/tools/ProofComposer.svelte
@@ -9,6 +9,7 @@
ANNO_COLORS, PAD, CAPTION_H, LEGEND_LINE_H, FOOTER_H,
BG, TEXT_MAIN, TEXT_DIM, TEXT_FAINT,
layoutPanels, attributionLine, docSize, toSpec, newId, loadImage,
+ featureColors, notesFromShapes,
} from '../lib/composer.js';
const DRAW_TOOLS = [
@@ -17,10 +18,14 @@
{ id: 'ellipse', icon: 'circle', label: 'Ellipse' },
{ id: 'arrow', icon: 'arrow', label: 'Arrow' },
{ id: 'line', icon: 'line', label: 'Line' },
+ { id: 'curve', icon: 'curve', label: 'Curve (click points, double-click to finish)' },
+ { id: 'text', icon: 'text', label: 'Text' },
];
// ---- document state -------------------------------------------------------
- const proof = $state({ title: 'Untitled proof', panels: [], shapes: [], coords: null });
+ // `notes` holds the legend text per color (annotations are written by color,
+ // not per element); `shapes` are the drawn geometry bound to a panel.
+ const proof = $state({ title: 'Untitled proof', panels: [], shapes: [], notes: {}, coords: null });
let savedName = $state(null);
let dirty = $state(false);
let tool = $state('select');
@@ -35,8 +40,9 @@
// ---- konva ------------------------------------------------------------------
let containerEl;
- let stage, docLayer, uiLayer, transformer;
+ let stage, docLayer, uiLayer, transformer, endHandles;
let drawing = null; // {panel, node, start, box, kind}
+ let pathDraft = null; // {panel, box, node, points:[]} — multi-click curve in progress
onMount(() => {
stage = new Konva.Stage({ container: containerEl, width: 100, height: 100 });
@@ -55,6 +61,8 @@
ignoreStroke: true,
});
uiLayer.add(transformer);
+ endHandles = new Konva.Group();
+ uiLayer.add(endHandles);
const resize = new ResizeObserver(() => {
stage.width(containerEl.clientWidth);
@@ -67,6 +75,7 @@
stage.on('pointerdown', onPointerDown);
stage.on('pointermove', onPointerMove);
stage.on('pointerup', onPointerUp);
+ stage.on('dblclick dbltap', () => { if (pathDraft) finishPath(true); });
return () => {
resize.disconnect();
@@ -101,11 +110,17 @@
}
});
+ // leaving the curve tool abandons an unfinished draft
+ $effect(() => {
+ if (tool !== 'curve' && pathDraft) finishPath(false);
+ });
+
// rebuild canvas whenever the document changes
$effect(() => {
JSON.stringify([
proof.panels.map((p) => [p.src, p.caption]),
proof.shapes,
+ proof.notes,
selectedId,
]);
if (stage) rebuild();
@@ -115,6 +130,7 @@
proof.title = 'Untitled proof';
proof.panels = [];
proof.shapes = [];
+ proof.notes = {};
proof.coords = null;
savedName = null;
selectedId = null;
@@ -230,7 +246,7 @@
function fit() {
if (!stage || !containerEl || !containerEl.clientWidth) return;
- const { width, height } = docSize(proof.panels, proof.shapes);
+ const { width, height } = docSize(proof.panels, proof.shapes, proof.notes);
const k = Math.min(
(containerEl.clientWidth - 24) / width,
(containerEl.clientHeight - 24) / height,
@@ -289,6 +305,36 @@
const panel = proof.panels[hit.index];
const group = docLayer.findOne(`#pg-${panel.id}`);
if (!group) return;
+ // text is placed with a single click (no drag) then edited in the side list
+ if (tool === 'text') {
+ const s = {
+ id: newId('s'), panel: panel.id, kind: 'text', color,
+ x: hit.nx, y: hit.ny, text: 'Text', fontSize: 28,
+ };
+ proof.shapes.push(s);
+ selectedId = s.id;
+ tool = 'select';
+ dirty = true;
+ return;
+ }
+ // curve: each click drops a vertex; double-click / Enter finishes
+ if (tool === 'curve') {
+ if (pathDraft && pathDraft.panel.id !== panel.id) return;
+ if (!pathDraft) {
+ const node = new Konva.Line({
+ points: [hit.nx, hit.ny], tension: 0.5, stroke: color,
+ strokeWidth: strokeW / hit.box.scale, lineCap: 'round', lineJoin: 'round',
+ listening: false,
+ });
+ group.add(node);
+ pathDraft = { panel, box: hit.box, node, points: [hit.nx, hit.ny] };
+ } else {
+ pathDraft.points.push(hit.nx, hit.ny);
+ pathDraft.node.points([...pathDraft.points]);
+ docLayer.batchDraw();
+ }
+ return;
+ }
const sw = strokeW / hit.box.scale;
const common = { stroke: color, strokeWidth: sw, listening: false };
let node;
@@ -310,6 +356,15 @@
}
function onPointerMove() {
+ if (pathDraft) {
+ const box = pathDraft.box;
+ const doc = docPoint();
+ const nx = Math.min(Math.max((doc.x - box.x) / box.scale, 0), pathDraft.panel.natural[0]);
+ const ny = Math.min(Math.max((doc.y - box.y) / box.scale, 0), pathDraft.panel.natural[1]);
+ pathDraft.node.points([...pathDraft.points, nx, ny]);
+ docLayer.batchDraw();
+ return;
+ }
if (!drawing) return;
const box = drawing.box;
const doc = docPoint();
@@ -358,7 +413,7 @@
if (shape) {
const s = {
id: newId('s'), panel: panel.id, color,
- strokeWidth: strokeW, comment: '', ...shape,
+ strokeWidth: strokeW, ...shape,
};
proof.shapes.push(s);
selectedId = s.id;
@@ -366,11 +421,35 @@
}
}
+ function finishPath(commit) {
+ if (!pathDraft) return;
+ const { node, points, panel } = pathDraft;
+ pathDraft = null;
+ node.destroy();
+ // the double-click that finishes drops a duplicate last vertex — trim it
+ const n = points.length;
+ if (n >= 4 && Math.hypot(points[n - 2] - points[n - 4], points[n - 1] - points[n - 3]) < 3) {
+ points.length = n - 2;
+ }
+ if (commit && points.length >= 4) {
+ const s = {
+ id: newId('s'), panel: panel.id, kind: 'curve', color,
+ strokeWidth: strokeW, points, tension: 0.5,
+ };
+ proof.shapes.push(s);
+ selectedId = s.id;
+ tool = 'select';
+ dirty = true;
+ } else {
+ proof.shapes = [...proof.shapes]; // force rebuild to drop the preview
+ }
+ }
+
// ---- rebuild canvas from state ------------------------------------------------------
function rebuild() {
docLayer.destroyChildren();
- const { width, height, legend } = docSize(proof.panels, proof.shapes);
+ const { width, height, legend } = docSize(proof.panels, proof.shapes, proof.notes);
const boxes = layoutPanels(proof.panels);
docLayer.add(
@@ -435,19 +514,95 @@
// selection
const selectedNode = selectedId ? docLayer.findOne(`#${selectedId}`) : null;
transformer.nodes(selectedNode ? [selectedNode] : []);
+ const cls = selectedNode?.className;
+ transformer.rotateEnabled(cls === 'Text' || cls === 'Rect' || cls === 'Ellipse');
transformer.enabledAnchors(
- selectedNode && (selectedNode.className === 'Rect' || selectedNode.className === 'Ellipse')
+ cls === 'Rect' || cls === 'Ellipse'
? ['top-left', 'top-right', 'bottom-left', 'bottom-right', 'middle-left', 'middle-right', 'top-center', 'bottom-center']
- : []
+ : cls === 'Text'
+ ? ['top-left', 'top-right', 'bottom-left', 'bottom-right']
+ : []
);
+ drawEndHandles(boxes);
docLayer.batchDraw();
uiLayer.batchDraw();
}
+ // Draggable per-vertex handles for the selected line / arrow / curve, so any
+ // point can be re-placed after drawing (rects/ellipses/text use the transformer).
+ const POINT_KINDS = new Set(['line', 'arrow', 'curve']);
+ function drawEndHandles(boxes) {
+ endHandles.destroyChildren();
+ const s = selectedShape;
+ if (tool !== 'select' || !s || !POINT_KINDS.has(s.kind)) return;
+ const idx = proof.panels.findIndex((p) => p.id === s.panel);
+ if (idx < 0) return;
+ const box = boxes[idx];
+ const panel = proof.panels[idx];
+ const node = docLayer.findOne(`#${s.id}`);
+ const r = 7 / stage.scaleX();
+ for (let vi = 0; vi < s.points.length; vi += 2) {
+ const handle = new Konva.Circle({
+ x: box.x + s.points[vi] * box.scale,
+ y: box.y + s.points[vi + 1] * box.scale,
+ radius: r, fill: '#161e2e', stroke: '#e8a33d', strokeWidth: 2 / stage.scaleX(),
+ draggable: true, name: 'endh',
+ });
+ const apply = (commit) => {
+ const nx = Math.min(Math.max((handle.x() - box.x) / box.scale, 0), panel.natural[0]);
+ const ny = Math.min(Math.max((handle.y() - box.y) / box.scale, 0), panel.natural[1]);
+ handle.position({ x: box.x + nx * box.scale, y: box.y + ny * box.scale });
+ if (commit) {
+ s.points[vi] = nx;
+ s.points[vi + 1] = ny;
+ s.points = [...s.points];
+ dirty = true;
+ } else if (node) {
+ const pts = [...s.points];
+ pts[vi] = nx;
+ pts[vi + 1] = ny;
+ node.points(pts);
+ docLayer.batchDraw();
+ }
+ };
+ handle.on('dragmove', () => apply(false));
+ handle.on('dragend', () => apply(true));
+ endHandles.add(handle);
+ }
+ }
+
function makeShapeNode(s, panelScale) {
+ if (s.kind === 'text') {
+ const node = new Konva.Text({
+ id: s.id, x: s.x, y: s.y, text: s.text || ' ',
+ fontSize: s.fontSize ?? 28, fontFamily: 'system-ui, sans-serif',
+ fontStyle: 'bold', fill: s.color, rotation: s.rotation ?? 0, draggable: true,
+ });
+ node.on('pointerdown', (e) => {
+ if (tool === 'select') {
+ e.cancelBubble = true;
+ selectedId = s.id;
+ }
+ });
+ node.on('dragend', () => {
+ s.x = node.x();
+ s.y = node.y();
+ dirty = true;
+ });
+ node.on('transformend', () => {
+ // corner drag scales the font, the top handle rotates; fold both back in
+ s.fontSize = Math.max(6, Math.round((s.fontSize ?? 28) * node.scaleX()));
+ s.rotation = node.rotation();
+ s.x = node.x();
+ s.y = node.y();
+ node.scale({ x: 1, y: 1 });
+ dirty = true;
+ });
+ return node;
+ }
const sw = (s.strokeWidth ?? 4) / panelScale;
const common = {
- id: s.id, stroke: s.color, strokeWidth: sw,
+ id: s.id, stroke: s.color, strokeWidth: sw, rotation: s.rotation ?? 0,
draggable: true, hitStrokeWidth: Math.max(sw * 3, 14 / panelScale),
};
let node;
@@ -455,6 +610,11 @@
node = new Konva.Rect({ x: s.x, y: s.y, width: s.w, height: s.h, cornerRadius: 2, ...common });
} else if (s.kind === 'ellipse') {
node = new Konva.Ellipse({ x: s.x, y: s.y, radiusX: s.w / 2, radiusY: s.h / 2, ...common });
+ } else if (s.kind === 'curve') {
+ node = new Konva.Line({
+ points: s.points, tension: s.tension ?? 0.5,
+ lineCap: 'round', lineJoin: 'round', ...common,
+ });
} else {
node = new Konva.Arrow({
points: s.points,
@@ -475,8 +635,9 @@
s.x = node.x();
s.y = node.y();
} else {
+ // arrow / line / curve: fold the drag offset back into every vertex
const dx = node.x(), dy = node.y();
- s.points = [s.points[0] + dx, s.points[1] + dy, s.points[2] + dx, s.points[3] + dy];
+ s.points = s.points.map((v, i) => (i % 2 === 0 ? v + dx : v + dy));
node.position({ x: 0, y: 0 });
}
dirty = true;
@@ -491,6 +652,7 @@
s.w = Math.abs(node.radiusX() * 2 * node.scaleX());
s.h = Math.abs(node.radiusY() * 2 * node.scaleY());
}
+ s.rotation = node.rotation();
node.scale({ x: 1, y: 1 });
dirty = true;
});
@@ -500,19 +662,56 @@
// ---- shape ops from the side panel -----------------------------------------------------
function deleteShape(id) {
+ const gone = proof.shapes.find((s) => s.id === id);
proof.shapes = proof.shapes.filter((s) => s.id !== id);
+ // drop the legend note if this was the last element of its color
+ if (gone && !proof.shapes.some((s) => s.color === gone.color)) {
+ delete proof.notes[gone.color];
+ }
if (selectedId === id) selectedId = null;
dirty = true;
}
- function setShapeColor(s, c) {
- s.color = c;
- dirty = true;
+ const KIND_ICON = { rect: 'square', ellipse: 'circle', arrow: 'arrow', line: 'line', curve: 'curve', text: 'text' };
+ const KIND_LABEL = { rect: 'Box', ellipse: 'Ellipse', arrow: 'Arrow', line: 'Line', curve: 'Curve', text: 'Text' };
+
+ // Color / stroke controls act on the selected shape when there is one
+ // (live edit), otherwise they set the defaults for the next drawn shape.
+ function setColor(c) {
+ if (selectedShape) {
+ const oldColor = selectedShape.color;
+ selectedShape.color = c;
+ // carry the legend note over if this color is otherwise unused
+ if (proof.notes[oldColor] && !proof.notes[c] &&
+ !proof.shapes.some((s) => s !== selectedShape && s.color === oldColor)) {
+ proof.notes[c] = proof.notes[oldColor];
+ delete proof.notes[oldColor];
+ }
+ dirty = true;
+ } else {
+ color = c;
+ }
+ }
+
+ function setStroke(w) {
+ if (selectedShape?.kind === 'text') {
+ selectedShape.fontSize = w;
+ dirty = true;
+ } else if (selectedShape) {
+ selectedShape.strokeWidth = w;
+ dirty = true;
+ } else {
+ strokeW = w;
+ }
}
function onKeydown(e) {
if (uiState.tool !== 'proof') return;
if (['INPUT', 'TEXTAREA', 'SELECT'].includes(e.target.tagName)) return;
+ if (pathDraft && (e.key === 'Enter' || e.key === 'Escape')) {
+ finishPath(e.key === 'Enter');
+ return;
+ }
if ((e.key === 'Delete' || e.key === 'Backspace') && selectedId) {
deleteShape(selectedId);
} else if (e.key === 'Escape') {
@@ -523,13 +722,15 @@
else if (e.key === 'e') tool = 'ellipse';
else if (e.key === 'a') tool = 'arrow';
else if (e.key === 'l') tool = 'line';
+ else if (e.key === 'c') tool = 'curve';
+ else if (e.key === 't') tool = 'text';
else if (e.key === 'f') fit();
}
// ---- persistence -------------------------------------------------------------------------
function exportPng() {
- const { width, height } = docSize(proof.panels, proof.shapes);
+ const { width, height } = docSize(proof.panels, proof.shapes, proof.notes);
const prevScale = stage.scale();
const prevPos = stage.position();
const prevSize = { w: stage.width(), h: stage.height() };
@@ -600,6 +801,8 @@
}
const validPanels = new Set(proof.panels.map((p) => p.id));
proof.shapes = (spec.shapes ?? []).filter((s) => validPanels.has(s.panel));
+ // legend text lives in `notes` (per color); migrate old per-shape comments
+ proof.notes = spec.notes ?? notesFromShapes(proof.shapes);
savedName = entry.name;
openList = null;
dirty = false;
@@ -607,6 +810,8 @@
}
const selectedShape = $derived(proof.shapes.find((s) => s.id === selectedId));
+ const activeColor = $derived(selectedShape?.color ?? color);
+ const featureList = $derived(featureColors(proof.shapes));
</script>
<svelte:window onkeydown={onKeydown} />
@@ -622,7 +827,7 @@
{/if}
<button class="btn" onclick={openPicker}><Icon name="plus" size={15} /> Add panel</button>
<button class="btn btn-primary" onclick={() => save()} disabled={!proof.panels.length || saving}>
- <Icon name="check" size={15} /> {saving ? 'Saving…' : 'Save + export'}
+ <Icon name="check" size={15} /> {saving ? 'Saving…' : 'Save'}
</button>
<button class="btn" onclick={() => save({ andPost: true })} disabled={!proof.panels.length || saving}>
<Icon name="post" size={15} /> To Post
@@ -646,19 +851,39 @@
{#each ANNO_COLORS as c (c)}
<button
class="color-btn"
- class:active={(selectedShape?.color ?? color) === c}
+ class:active={activeColor === c}
style:background={c}
title="Same color = same feature"
- onclick={() => (selectedShape ? setShapeColor(selectedShape, c) : (color = c))}
+ onclick={() => setColor(c)}
aria-label={`color ${c}`}
></button>
{/each}
+ <label
+ class="color-btn color-pick"
+ class:active={!ANNO_COLORS.includes(activeColor)}
+ style:background={activeColor}
+ title="Custom color"
+ >
+ <Icon name="plus" size={12} />
+ <input
+ type="color"
+ value={activeColor}
+ oninput={(e) => setColor(e.target.value)}
+ aria-label="custom color"
+ />
+ </label>
<div class="tb-sep"></div>
<input
class="stroke-slider"
- type="range" min="2" max="10" step="1"
- bind:value={strokeW}
- title="Stroke width"
+ type="range"
+ min={selectedShape?.kind === 'text' ? 8 : 1}
+ max={selectedShape?.kind === 'text' ? 120 : 24}
+ step="1"
+ value={selectedShape?.kind === 'text'
+ ? (selectedShape.fontSize ?? 28)
+ : (selectedShape?.strokeWidth ?? strokeW)}
+ oninput={(e) => setStroke(+e.target.value)}
+ title={selectedShape?.kind === 'text' ? 'Font size' : selectedShape ? 'Stroke width (selected)' : 'Stroke width'}
/>
<div class="tb-sep"></div>
<button class="tb-btn" title="Fit view (f)" onclick={fit}><Icon name="eye" size={18} /></button>
@@ -705,13 +930,35 @@
</div>
{/each}
+ <!-- Annotations: one legend note per color (feature), not per element -->
<div class="side-title" style="margin-top: 14px">
- Annotations <span class="count">{proof.shapes.length}</span>
+ Annotations <span class="count">{featureList.length}</span>
</div>
- {#if !proof.shapes.length}
- <div class="none">Draw on the panels with the box, ellipse, arrow or line tools.</div>
+ {#if !featureList.length}
+ <div class="none">Draw on the panels with the box, ellipse, arrow or line tools. Same color = same feature.</div>
{/if}
- {#each proof.shapes as s (s.id)}
+ {#each featureList as c, i (c)}
+ <div class="anno-row" class:active={activeColor === c}>
+ <button
+ class="chip-num"
+ style:background={c}
+ title="Select this color"
+ onclick={() => setColor(c)}
+ >{i + 1}</button>
+ <input
+ class="input comment-input"
+ placeholder={`Feature ${i + 1} — legend text…`}
+ bind:value={proof.notes[c]}
+ onchange={() => (dirty = true)}
+ />
+ </div>
+ {/each}
+
+ <!-- Elements: every drawn shape, for quick select / delete -->
+ <div class="side-title" style="margin-top: 14px">
+ Elements <span class="count">{proof.shapes.length}</span>
+ </div>
+ {#each proof.shapes as s, i (s.id)}
<div
class="shape-row"
class:selected={selectedId === s.id}
@@ -721,16 +968,20 @@
onkeydown={(e) => e.key === 'Enter' && (selectedId = s.id)}
>
<span class="chip" style:background={s.color}></span>
- <Icon name={s.kind === 'rect' ? 'square' : s.kind === 'ellipse' ? 'circle' : s.kind} size={13} />
- <input
- class="input comment-input"
- placeholder="Feature comment (legend)…"
- bind:value={s.comment}
- onchange={() => (dirty = true)}
- onclick={(e) => e.stopPropagation()}
- />
+ <Icon name={KIND_ICON[s.kind]} size={13} />
+ {#if s.kind === 'text'}
+ <input
+ class="input comment-input"
+ placeholder="Text…"
+ bind:value={s.text}
+ onchange={() => (dirty = true)}
+ onclick={(e) => e.stopPropagation()}
+ />
+ {:else}
+ <span class="el-label">{KIND_LABEL[s.kind]} <span class="el-id">#{i + 1}</span></span>
+ {/if}
<button class="btn btn-ghost btn-sm" title="Delete" onclick={(e) => { e.stopPropagation(); deleteShape(s.id); }}>
- <Icon name="x" size={13} />
+ <Icon name="trash" size={13} />
</button>
</div>
{/each}
@@ -841,6 +1092,21 @@
border-color: var(--text-1);
box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 3.5px var(--text-3);
}
+ .color-pick {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: #0b0f17;
+ cursor: pointer;
+ position: relative;
+ overflow: hidden;
+ }
+ .color-pick input {
+ position: absolute;
+ inset: 0;
+ opacity: 0;
+ cursor: pointer;
+ }
.stroke-slider {
width: 80px;
transform: rotate(-90deg);
@@ -908,6 +1174,41 @@
color: var(--text-3);
padding: 2px 2px 8px;
}
+ .anno-row {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 3px 4px;
+ border-radius: var(--r-sm);
+ margin-bottom: 4px;
+ border: 1px solid transparent;
+ }
+ .anno-row.active { border-color: var(--accent); background: var(--accent-soft); }
+ .chip-num {
+ width: 20px;
+ height: 20px;
+ border-radius: 50%;
+ flex-shrink: 0;
+ font-size: 11px;
+ font-weight: 700;
+ color: #0b0f17;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border: 2px solid transparent;
+ cursor: pointer;
+ }
+ .chip-num:hover { border-color: var(--text-1); }
+ .el-label {
+ flex: 1;
+ font-size: var(--fs-xs);
+ color: var(--text-2);
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ .el-id { color: var(--text-3); }
.shape-row {
display: flex;
align-items: center;
diff --git a/frontend/src/tools/Satellite.svelte b/frontend/src/tools/Satellite.svelte
index 3ea13a3..c462e63 100644
--- a/frontend/src/tools/Satellite.svelte
+++ b/frontend/src/tools/Satellite.svelte
@@ -15,9 +15,13 @@
let coordsText = $state('');
let center = $state({ lat: 48.8584, lon: 2.2945, zoom: 16 });
let size = $state('1000x700');
- let crosshair = $state(true);
+ let markerStyle = $state('crosshair'); // 'crosshair' | 'pin' | 'none'
+ let moveMode = $state(false); // pin decoupled from center, draggable
+ let marker = null; // Leaflet marker instance while in move mode
+ let markerLatLng = $state(null); // {lat, lon} of the moved pin
let bearing = $state(0);
let capturing = $state(false);
+ let captureHover = $state(false); // previewing the crop frame (capture group hover)
let captures = $state([]);
let capturesFor = $state(null);
let capturesCollapsed = $state(false);
@@ -77,6 +81,14 @@
api.get(`/api/cases/${id}/satellite`).then((r) => (captures = r));
});
+ // the case sidebar mounts/unmounts outside this component — when it does,
+ // the map container resizes, so redraw tiles for the newly exposed area
+ $effect(() => {
+ uiState.sidebarOpen; // track the global sidebar toggle
+ if (!mapReady) return;
+ tick().then(() => map?.invalidateSize());
+ });
+
// fly to coordinates handed off from the sidebar (place entity click) —
// match the capture's own zoom/bearing, like clicking its card
$effect(() => {
@@ -113,10 +125,101 @@
setBearing(0);
}
+ // --- marker (crosshair / pin), optionally decoupled from center ---
+
+ // the coordinates shown & recorded: the moved pin, else the crop center
+ const displayCoords = $derived(
+ moveMode && markerLatLng ? markerLatLng : { lat: center.lat, lon: center.lon }
+ );
+
+ // crop dimensions in px — drawn as the capture-frame outline
+ const frameSize = $derived(size.split('x').map(Number));
+
+ function markerIcon(style) {
+ if (style === 'pin') {
+ return L.divIcon({
+ className: 'sat-marker',
+ iconSize: [30, 42],
+ iconAnchor: [15, 42], // tip points at the location
+ html: `<svg width="30" height="42" viewBox="0 0 30 42">
+ <path d="M15 41 C15 41 27 24 27 14 A12 12 0 1 0 3 14 C3 24 15 41 15 41 Z"
+ fill="#e5484d" stroke="#3c0c0e" stroke-width="1.5"/>
+ <circle cx="15" cy="14" r="4.5" fill="#fff" stroke="#3c0c0e" stroke-width="1"/>
+ </svg>`,
+ });
+ }
+ return L.divIcon({
+ className: 'sat-marker',
+ iconSize: [46, 46],
+ iconAnchor: [23, 23],
+ html: `<svg width="46" height="46" viewBox="0 0 46 46">
+ <g stroke="#000" stroke-width="4" opacity="0.55">
+ <line x1="1" y1="23" x2="16" y2="23"/><line x1="30" y1="23" x2="45" y2="23"/>
+ <line x1="23" y1="1" x2="23" y2="16"/><line x1="23" y1="30" x2="23" y2="45"/>
+ </g>
+ <g stroke="#fff" stroke-width="2">
+ <line x1="1" y1="23" x2="16" y2="23"/><line x1="30" y1="23" x2="45" y2="23"/>
+ <line x1="23" y1="1" x2="23" y2="16"/><line x1="23" y1="30" x2="23" y2="45"/>
+ <circle cx="23" cy="23" r="2.5" fill="none"/>
+ </g>
+ </svg>`,
+ });
+ }
+
+ function removeMarker() {
+ if (marker) marker.remove();
+ marker = null;
+ markerLatLng = null;
+ }
+
+ function toggleMoveMode() {
+ if (markerStyle === 'none') return;
+ moveMode = !moveMode;
+ if (!moveMode) {
+ removeMarker();
+ return;
+ }
+ const c = map.getCenter();
+ marker = L.marker(c, {
+ draggable: true,
+ icon: markerIcon(markerStyle),
+ zIndexOffset: 1000,
+ }).addTo(map);
+ markerLatLng = { lat: c.lat, lon: c.lng };
+ marker.on('drag move', () => {
+ const p = marker.getLatLng();
+ markerLatLng = { lat: p.lat, lon: p.lng };
+ });
+ }
+
+ // keep the live marker's look in sync with the chosen style; leaving move
+ // mode (or picking "none") drops the marker
+ $effect(() => {
+ if (markerStyle === 'none' && moveMode) {
+ moveMode = false;
+ removeMarker();
+ } else if (marker) {
+ marker.setIcon(markerIcon(markerStyle));
+ }
+ });
+
async function captureCrop() {
if (capturing) return;
capturing = true;
const [width, height] = size.split('x').map(Number);
+ // marker offset (px from crop center) + its coordinates; when the pin has
+ // been moved, its container offset already accounts for map rotation
+ let marker_x = 0, marker_y = 0;
+ let marker_lat = center.lat, marker_lon = center.lon;
+ if (moveMode && marker) {
+ const ll = marker.getLatLng();
+ marker_lat = ll.lat;
+ marker_lon = ll.lng;
+ const mapSize = map.getSize();
+ const p = map.latLngToContainerPoint(ll);
+ marker_x = Math.round(p.x - mapSize.x / 2);
+ marker_y = Math.round(p.y - mapSize.y / 2);
+ }
try {
const c = await ensureCase();
const result = await api.post(`/api/cases/${c.id}/satellite/capture`, {
@@ -126,8 +229,12 @@
width,
height,
provider: providerId,
- crosshair,
bearing,
+ marker_style: markerStyle,
+ marker_x,
+ marker_y,
+ marker_lat,
+ marker_lon,
});
captures = [result, ...captures];
await reloadCase();
@@ -144,6 +251,28 @@
}
}
+ // save just the point (pin if moved, else center) as a navigable place — no image
+ let savingPlace = $state(false);
+ async function savePlace() {
+ if (savingPlace) return;
+ savingPlace = true;
+ try {
+ const c = await ensureCase();
+ await api.post(`/api/cases/${c.id}/satellite/place`, {
+ lat: displayCoords.lat,
+ lon: displayCoords.lon,
+ zoom: center.zoom,
+ bearing,
+ });
+ await reloadCase();
+ toast('Place saved — find it in the case sidebar', 'ok');
+ } catch (e) {
+ toast(`Could not save place: ${e.message}`, 'danger', 6000);
+ } finally {
+ savingPlace = false;
+ }
+ }
+
async function removeCapture(item) {
await api.del(
`/api/cases/${caseState.current.id}/satellite?path=${encodeURIComponent(item.path)}`
@@ -200,7 +329,7 @@
}
async function copyCoords() {
- await navigator.clipboard.writeText(`${fmt(center.lat)}, ${fmt(center.lon)}`);
+ await navigator.clipboard.writeText(`${fmt(displayCoords.lat)}, ${fmt(displayCoords.lon)}`);
toast('Coordinates copied', 'ok', 1600);
}
@@ -211,10 +340,92 @@
map?.invalidateSize();
}
- function flyToCapture(item) {
- if (!map || !Number.isFinite(item.lat) || !Number.isFinite(item.lon)) return;
- map.setView([item.lat, item.lon], item.zoom);
- setBearing(item.bearing ?? 0);
+ // saved places (navigable points) live on the case as `place` entities
+ const places = $derived(
+ (caseState.current?.entities ?? []).filter((e) => e.type === 'place')
+ );
+
+ function flyToPlace(p) {
+ const lat = Number(p.attrs?.lat);
+ const lon = Number(p.attrs?.lon);
+ if (!map || !Number.isFinite(lat) || !Number.isFinite(lon)) return;
+ map.setView([lat, lon], Number(p.attrs?.zoom) || map.getZoom());
+ setBearing(Number(p.attrs?.bearing) || 0);
+ }
+
+ async function removePlace(p) {
+ await api.del(`/api/cases/${caseState.current.id}/entities/${p.id}`);
+ await reloadCase();
+ }
+
+ // collapse state for the two saved-work sections
+ let placesCollapsed = $state(false);
+ let capturesSubCollapsed = $state(false);
+
+ // --- place edit modal (title + notes), used for both save & later edits ---
+ // { id: string|null, title, notes, lat, lon, zoom, bearing }; id null = new
+ let placeModal = $state(null);
+ let placeSaving = $state(false);
+
+ function openNewPlace() {
+ placeModal = {
+ id: null,
+ title: '',
+ notes: '',
+ lat: displayCoords.lat,
+ lon: displayCoords.lon,
+ zoom: center.zoom,
+ bearing,
+ };
+ }
+
+ function openEditPlace(p) {
+ placeModal = {
+ id: p.id,
+ title: p.label ?? '',
+ notes: p.attrs?.notes ?? '',
+ lat: Number(p.attrs?.lat),
+ lon: Number(p.attrs?.lon),
+ zoom: p.attrs?.zoom,
+ bearing: p.attrs?.bearing,
+ };
+ }
+
+ function placeCoordsLabel(m) {
+ return `${m.lat.toFixed(6)}, ${m.lon.toFixed(6)}`;
+ }
+
+ async function savePlaceModal() {
+ if (!placeModal || placeSaving) return;
+ placeSaving = true;
+ try {
+ const m = placeModal;
+ if (m.id) {
+ // edit existing place: retitle + set/clear the note
+ const title = m.title.trim() || placeCoordsLabel(m);
+ await api.patch(`/api/cases/${caseState.current.id}/entities/${m.id}`, {
+ label: title,
+ attrs: { notes: m.notes.trim() },
+ });
+ } else {
+ const c = await ensureCase();
+ await api.post(`/api/cases/${c.id}/satellite/place`, {
+ lat: m.lat,
+ lon: m.lon,
+ zoom: m.zoom,
+ bearing: m.bearing,
+ title: m.title,
+ notes: m.notes,
+ });
+ }
+ placeModal = null;
+ await reloadCase();
+ toast('Place saved', 'ok', 1600);
+ } catch (e) {
+ toast(`Could not save place: ${e.message}`, 'danger', 6000);
+ } finally {
+ placeSaving = false;
+ }
}
</script>
@@ -244,25 +455,50 @@
<div class="body">
<div class="map-wrap">
<div class="map" bind:this={mapEl}></div>
- <div class="crosshair-overlay" class:hidden={!crosshair} aria-hidden="true">
- <svg width="46" height="46" viewBox="0 0 46 46">
- <g stroke="#000" stroke-width="4" opacity="0.55">
- <line x1="1" y1="23" x2="16" y2="23" /><line x1="30" y1="23" x2="45" y2="23" />
- <line x1="23" y1="1" x2="23" y2="16" /><line x1="23" y1="30" x2="23" y2="45" />
- </g>
- <g stroke="#fff" stroke-width="2">
- <line x1="1" y1="23" x2="16" y2="23" /><line x1="30" y1="23" x2="45" y2="23" />
- <line x1="23" y1="1" x2="23" y2="16" /><line x1="23" y1="30" x2="23" y2="45" />
- <circle cx="23" cy="23" r="2.5" fill="none" />
- </g>
- </svg>
- </div>
+
+ <!-- capture-frame outline: what the crop will cover — only while a capture
+ is the intent (hovering the capture group, or mid-capture) -->
+ {#if captureHover || capturing}
+ <div
+ class="frame-overlay"
+ style="width:{frameSize[0]}px;height:{frameSize[1]}px"
+ aria-hidden="true"
+ ></div>
+ {/if}
+
+ <!-- fixed center marker; a draggable Leaflet marker takes over in move mode -->
+ {#if markerStyle !== 'none' && !moveMode}
+ <div class="marker-overlay marker-{markerStyle}" aria-hidden="true">
+ {#if markerStyle === 'pin'}
+ <svg width="30" height="42" viewBox="0 0 30 42">
+ <path
+ d="M15 41 C15 41 27 24 27 14 A12 12 0 1 0 3 14 C3 24 15 41 15 41 Z"
+ fill="#e5484d" stroke="#3c0c0e" stroke-width="1.5"
+ />
+ <circle cx="15" cy="14" r="4.5" fill="#fff" stroke="#3c0c0e" stroke-width="1" />
+ </svg>
+ {:else}
+ <svg width="46" height="46" viewBox="0 0 46 46">
+ <g stroke="#000" stroke-width="4" opacity="0.55">
+ <line x1="1" y1="23" x2="16" y2="23" /><line x1="30" y1="23" x2="45" y2="23" />
+ <line x1="23" y1="1" x2="23" y2="16" /><line x1="23" y1="30" x2="23" y2="45" />
+ </g>
+ <g stroke="#fff" stroke-width="2">
+ <line x1="1" y1="23" x2="16" y2="23" /><line x1="30" y1="23" x2="45" y2="23" />
+ <line x1="23" y1="1" x2="23" y2="16" /><line x1="23" y1="30" x2="23" y2="45" />
+ <circle cx="23" cy="23" r="2.5" fill="none" />
+ </g>
+ </svg>
+ {/if}
+ </div>
+ {/if}
<div class="hud card">
<button class="hud-coords mono" onclick={copyCoords} title="Copy coordinates">
<Icon name="crosshair" size={13} />
- {fmt(center.lat)}, {fmt(center.lon)}
+ {fmt(displayCoords.lat)}, {fmt(displayCoords.lon)}
<span class="z">z{center.zoom}</span>
+ {#if moveMode && markerLatLng}<span class="pin-tag">pin</span>{/if}
<Icon name="copy" size={12} />
</button>
</div>
@@ -310,22 +546,63 @@
</option>
{/each}
</select>
- <select class="select" bind:value={size} title="Crop size">
- <option value="800x600">800 × 600</option>
- <option value="1000x700">1000 × 700</option>
- <option value="1280x800">1280 × 800</option>
- <option value="1000x1000">1000 × 1000</option>
+ <select class="select" bind:value={markerStyle} title="Marker style">
+ <option value="crosshair">✛ crosshair</option>
+ <option value="pin">📍 pin</option>
+ <option value="none">no marker</option>
</select>
- <label class="check">
- <input type="checkbox" bind:checked={crosshair} /> crosshair
- </label>
- <button class="btn btn-primary" onclick={captureCrop} disabled={capturing}>
- {#if capturing}
- <span class="spinner"></span> Capturing…
- {:else}
- <Icon name="satellite" size={15} /> Capture
- {/if}
+ <button
+ class="btn btn-toggle"
+ class:on={moveMode}
+ onclick={toggleMoveMode}
+ disabled={markerStyle === 'none'}
+ title="Move the marker off-center — recorded coordinates follow the pin"
+ >
+ <Icon name="crosshair" size={14} /> {moveMode ? 'Moving' : 'Move pin'}
</button>
+ <span class="bar-sep" aria-hidden="true"></span>
+ <div class="place-save">
+ <button
+ class="btn place-save-main"
+ onclick={savePlace}
+ disabled={savingPlace}
+ title="Save just this point (the pin, or the crop center) as a navigable place — no image"
+ >
+ <Icon name="pin" size={15} /> {savingPlace ? 'Saving…' : 'Save place'}
+ </button>
+ <button
+ class="btn place-save-edit"
+ onclick={openNewPlace}
+ title="Save place with a title and note…"
+ aria-label="Save place with a title and note"
+ >
+ <Icon name="note" size={14} />
+ </button>
+ </div>
+ <!-- crop size only concerns a capture, so it lives with the Capture button;
+ hovering this group previews the crop frame on the map -->
+ <div
+ class="capture-group"
+ onmouseenter={() => (captureHover = true)}
+ onmouseleave={() => (captureHover = false)}
+ onfocusin={() => (captureHover = true)}
+ onfocusout={() => (captureHover = false)}
+ role="group"
+ >
+ <select class="select" bind:value={size} title="Crop size">
+ <option value="800x600">800 × 600</option>
+ <option value="1000x700">1000 × 700</option>
+ <option value="1280x800">1280 × 800</option>
+ <option value="1000x1000">1000 × 1000</option>
+ </select>
+ <button class="btn btn-primary" onclick={captureCrop} disabled={capturing}>
+ {#if capturing}
+ <span class="spinner"></span> Capturing…
+ {:else}
+ <Icon name="satellite" size={15} /> Capture
+ {/if}
+ </button>
+ </div>
</div>
</div>
@@ -337,74 +614,149 @@
title={capturesCollapsed ? 'Show captures' : 'Hide captures'}
>
<Icon name={capturesCollapsed ? 'chevronLeft' : 'chevronRight'} size={15} />
- <span class="label" style="margin:0">Captures</span>
- <span class="count">{captures.length}</span>
+ <span class="label" style="margin:0">Saved</span>
+ <span class="count">{places.length + captures.length}</span>
</button>
{#if capturesCollapsed}
<!-- collapsed: header acts as the toggle back to the list -->
- {:else if !captures.length}
- <div class="none">
- Captured crops land in the case with full provenance: provider, zoom, date,
- attribution.
- </div>
{:else}
- <div class="cap-list">
- {#each captures as item (item.path)}
- <div class="cap card fade-up">
- <button
- type="button"
- class="cap-goto"
- title="Show on map (same zoom)"
- onclick={() => flyToCapture(item)}
- >
- <img
- src={`/files/${caseState.current.id}/${item.path}`}
- alt={item.filename}
- loading="lazy"
- />
- <div class="cap-meta">
- <span class="title">{item.title ?? coordsLabel(item)}</span>
- <span class="mono coords">{coordsLabel(item)}</span>
- <span class="prov">z{item.zoom}{item.bearing ? ` · ${Math.round(item.bearing)}°` : ''} · {item.provider_label} · {item.fetched_at?.slice(0, 10)}</span>
+ <div class="panel-scroll">
+ <!-- Places: navigable points (no image) -->
+ <button
+ type="button"
+ class="sub-head"
+ onclick={() => (placesCollapsed = !placesCollapsed)}
+ >
+ <Icon name={placesCollapsed ? 'chevronRight' : 'chevronDown'} size={12} />
+ <Icon name="pin" size={13} />
+ <span>Places</span>
+ <span class="count">{places.length}</span>
+ </button>
+ {#if !placesCollapsed}
+ {#if !places.length}
+ <div class="none">Use “Save place” to drop a point you can fly back to.</div>
+ {:else}
+ <div class="place-list">
+ {#each places as p (p.id)}
+ <div class="place-row card fade-up">
+ <div class="place-main">
+ <button
+ type="button"
+ class="place-goto"
+ title="Fly the map to this point"
+ onclick={() => flyToPlace(p)}
+ >
+ <Icon name="pin" size={15} />
+ <div class="place-meta">
+ <span class="title">{p.label}</span>
+ <span class="prov">
+ z{p.attrs?.zoom}{p.attrs?.bearing ? ` · ${Math.round(p.attrs.bearing)}°` : ''}
+ </span>
+ </div>
+ </button>
+ <button
+ class="btn btn-ghost btn-sm"
+ title="Edit title & note"
+ onclick={() => openEditPlace(p)}
+ >
+ <Icon name="note" size={14} />
+ </button>
+ <button
+ class="btn btn-ghost btn-sm"
+ title="Delete place"
+ onclick={() => removePlace(p)}
+ >
+ <Icon name="trash" size={14} />
+ </button>
+ </div>
+ {#if p.attrs?.notes}
+ <div class="place-notes">{p.attrs.notes}</div>
+ {/if}
+ </div>
+ {/each}
+ </div>
+ {/if}
+ {/if}
+
+ <!-- Captures: sourced imagery crops (images) -->
+ <button
+ type="button"
+ class="sub-head"
+ onclick={() => (capturesSubCollapsed = !capturesSubCollapsed)}
+ >
+ <Icon name={capturesSubCollapsed ? 'chevronRight' : 'chevronDown'} size={12} />
+ <Icon name="satellite" size={13} />
+ <span>Captures</span>
+ <span class="count">{captures.length}</span>
+ </button>
+ {#if !capturesSubCollapsed}
+ {#if !captures.length}
+ <div class="none">
+ Captured crops land in the case with full provenance: provider, zoom, date,
+ attribution.
+ </div>
+ {:else}
+ <div class="cap-list">
+ {#each captures as item (item.path)}
+ <div class="cap card fade-up">
+ <a
+ class="cap-goto"
+ href={`/files/${caseState.current.id}/${item.path}`}
+ target="_blank"
+ rel="noreferrer"
+ title="Open the full image"
+ >
+ <img
+ src={`/files/${caseState.current.id}/${item.path}`}
+ alt={item.filename}
+ loading="lazy"
+ />
+ <div class="cap-meta">
+ <span class="title">{item.title ?? coordsLabel(item)}</span>
+ <span class="mono coords">{coordsLabel(item)}</span>
+ <span class="prov">z{item.zoom}{item.bearing ? ` · ${Math.round(item.bearing)}°` : ''} · {item.provider_label} · {item.fetched_at?.slice(0, 10)}</span>
+ </div>
+ </a>
+ <div class="cap-actions">
+ <button
+ class="btn btn-ghost btn-sm"
+ title="Edit title & note"
+ onclick={() => openNotes(item)}
+ >
+ <Icon name="note" size={14} />
+ </button>
+ <button
+ class="btn btn-ghost btn-sm"
+ title="Send to Proof Composer"
+ onclick={() => sendToComposer(item)}
+ >
+ <Icon name="proof" size={14} />
+ </button>
+ <a
+ class="btn btn-ghost btn-sm"
+ href={`/files/${caseState.current.id}/${item.path}`}
+ target="_blank"
+ rel="noreferrer"
+ title="Open"
+ >
+ <Icon name="external" size={14} />
+ </a>
+ <button
+ class="btn btn-ghost btn-sm"
+ title="Delete"
+ onclick={() => removeCapture(item)}
+ >
+ <Icon name="trash" size={14} />
+ </button>
+ </div>
+ {#if item.notes}
+ <div class="cap-notes">{item.notes}</div>
+ {/if}
</div>
- </button>
- <div class="cap-actions">
- <button
- class="btn btn-ghost btn-sm"
- title="Notes"
- onclick={() => openNotes(item)}
- >
- <Icon name="note" size={14} />
- </button>
- <button
- class="btn btn-ghost btn-sm"
- title="Send to Proof Composer"
- onclick={() => sendToComposer(item)}
- >
- <Icon name="proof" size={14} />
- </button>
- <a
- class="btn btn-ghost btn-sm"
- href={`/files/${caseState.current.id}/${item.path}`}
- target="_blank"
- rel="noreferrer"
- title="Open"
- >
- <Icon name="external" size={14} />
- </a>
- <button
- class="btn btn-ghost btn-sm"
- title="Delete"
- onclick={() => removeCapture(item)}
- >
- <Icon name="trash" size={14} />
- </button>
+ {/each}
</div>
- {#if item.notes}
- <div class="cap-notes">{item.notes}</div>
- {/if}
- </div>
- {/each}
+ {/if}
+ {/if}
</div>
{/if}
</aside>
@@ -456,6 +808,47 @@
</Modal>
{/if}
+<!-- place edit / save-with-details modal -->
+{#if placeModal}
+ <Modal
+ title={placeModal.id ? 'Edit place' : 'Save place'}
+ onclose={() => (placeModal = null)}
+ width="420px"
+ >
+ <label style="display:block;font-size:var(--fs-xs);color:var(--text-3);margin-bottom:5px">Title</label>
+ <input
+ class="input"
+ placeholder={placeCoordsLabel(placeModal)}
+ bind:value={placeModal.title}
+ />
+ <hr style="border:none;border-top:1px solid var(--border);margin:12px 0" />
+ <div class="sat-info-rows">
+ <div class="sat-info-row">
+ <span class="sat-info-label">Coordinates</span>
+ <span class="mono">{placeCoordsLabel(placeModal)}</span>
+ </div>
+ <div class="sat-info-row">
+ <span class="sat-info-label">Zoom</span>
+ <span>z{placeModal.zoom}{placeModal.bearing ? ` · ${Math.round(placeModal.bearing)}°` : ''}</span>
+ </div>
+ </div>
+ <hr style="border:none;border-top:1px solid var(--border);margin:12px 0" />
+ <label style="display:block;font-size:var(--fs-xs);color:var(--text-3);margin-bottom:5px">Notes</label>
+ <textarea
+ class="textarea"
+ rows="5"
+ placeholder="Add observations, links, context…"
+ bind:value={placeModal.notes}
+ ></textarea>
+ <div style="display:flex;gap:8px;justify-content:flex-end;margin-top:12px">
+ <button class="btn" onclick={() => (placeModal = null)}>Cancel</button>
+ <button class="btn btn-primary" onclick={savePlaceModal} disabled={placeSaving}>
+ {placeSaving ? 'Saving…' : 'Save'}
+ </button>
+ </div>
+ </Modal>
+{/if}
+
<style>
.spacer {
flex: 1;
@@ -474,23 +867,50 @@
position: relative;
flex: 1;
min-width: 0;
+ overflow: hidden;
}
.map {
position: absolute;
inset: 0;
background: var(--bg-2);
}
- .crosshair-overlay {
+ .frame-overlay {
position: absolute;
- inset: 0;
- display: flex;
- align-items: center;
- justify-content: center;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ border: 1px dashed rgba(255, 255, 255, 0.55);
+ box-shadow: 0 0 0 100vmax rgba(8, 11, 18, 0.28);
+ pointer-events: none;
+ z-index: 450;
+ }
+ .marker-overlay {
+ position: absolute;
+ top: 50%;
+ left: 50%;
pointer-events: none;
z-index: 500;
}
- .crosshair-overlay.hidden {
- display: none;
+ .marker-crosshair {
+ transform: translate(-50%, -50%);
+ }
+ .marker-pin {
+ /* tip of the pin sits on the point */
+ transform: translate(-50%, -100%);
+ filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
+ }
+ :global(.sat-marker) {
+ filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
+ }
+ .pin-tag {
+ font-size: 9px;
+ font-weight: 700;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ color: var(--accent-text, #fff);
+ background: var(--accent);
+ border-radius: 3px;
+ padding: 1px 4px;
}
.hud {
position: absolute;
@@ -603,17 +1023,39 @@
.capture-bar .select {
width: auto;
}
- .check {
+ .bar-sep {
+ width: 1px;
+ align-self: stretch;
+ background: var(--border);
+ margin: 0 2px;
+ }
+ .capture-group {
display: flex;
align-items: center;
- gap: 6px;
- font-size: var(--fs-sm);
- color: var(--text-2);
- user-select: none;
+ gap: 10px;
+ }
+ .place-save {
+ display: flex;
+ align-items: stretch;
+ }
+ .place-save-main {
+ border-top-right-radius: 0;
+ border-bottom-right-radius: 0;
+ }
+ .place-save-edit {
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+ border-left: none;
+ padding-left: 8px;
+ padding-right: 8px;
+ }
+ .btn-toggle {
white-space: nowrap;
}
- .check input {
- accent-color: var(--accent);
+ .btn-toggle.on {
+ background: var(--accent);
+ color: var(--accent-text);
+ border-color: var(--accent);
}
.spinner {
width: 13px;
@@ -677,10 +1119,85 @@
font-size: var(--fs-xs);
color: var(--text-3);
}
- .cap-list {
+ .panel-scroll {
flex: 1;
overflow-y: auto;
- padding: 6px 12px 12px;
+ padding: 4px 12px 12px;
+ display: flex;
+ flex-direction: column;
+ }
+ .sub-head {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ width: 100%;
+ padding: 12px 2px 6px;
+ background: none;
+ border: none;
+ font: inherit;
+ font-size: var(--fs-xs);
+ font-weight: 600;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ color: var(--text-2);
+ text-align: left;
+ cursor: pointer;
+ }
+ .sub-head:hover {
+ color: var(--accent);
+ }
+ .sub-head .count {
+ margin-left: auto;
+ text-transform: none;
+ }
+ .place-notes {
+ padding: 0 10px 8px 30px;
+ font-size: var(--fs-xs);
+ color: var(--text-2);
+ font-style: italic;
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+ word-break: break-word;
+ }
+ .place-list {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ }
+ .place-row {
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+ }
+ .place-main {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ padding: 4px 6px 4px 4px;
+ }
+ .place-goto {
+ display: flex;
+ align-items: center;
+ gap: 9px;
+ flex: 1;
+ min-width: 0;
+ padding: 5px 6px;
+ background: none;
+ border: none;
+ color: var(--text-2);
+ text-align: left;
+ cursor: pointer;
+ }
+ .place-goto:hover,
+ .place-goto:hover .title {
+ color: var(--accent);
+ }
+ .place-meta {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ }
+ .cap-list {
display: flex;
flex-direction: column;
gap: 10px;
diff --git a/frontend/src/tools/inspect/CollageCanvas.svelte b/frontend/src/tools/inspect/CollageCanvas.svelte
index f6ff651..3f92545 100644
--- a/frontend/src/tools/inspect/CollageCanvas.svelte
+++ b/frontend/src/tools/inspect/CollageCanvas.svelte
@@ -146,6 +146,10 @@
position: absolute;
top: 0;
left: 0;
+ /* size is driven by explicit width/height + matrix3d warp; the global
+ `img { max-width: 100% }` would shrink oversized frames below their
+ box and push the warp handles outside the image. */
+ max-width: none;
transform-origin: 0 0;
cursor: move;
user-select: none;
diff --git a/src/ozimut/api/cases.py b/src/ozimut/api/cases.py
index 25f36e2..4fae95d 100644
--- a/src/ozimut/api/cases.py
+++ b/src/ozimut/api/cases.py
@@ -21,6 +21,18 @@ def get_case(case_id: str) -> Case:
raise HTTPException(status_code=404, detail=str(exc)) from exc
+def _ensure_name_free(name: str, *, exclude_id: str | None = None) -> None:
+ """Reject a case name already taken by another (non-scratch) case, matched
+ case-insensitively on the trimmed name. ``exclude_id`` lets a rename keep
+ its own name."""
+ wanted = name.strip().casefold()
+ for c in Case.list_all():
+ if c.get("scratch") or c["id"] == exclude_id:
+ continue
+ if str(c.get("name", "")).strip().casefold() == wanted:
+ raise HTTPException(status_code=409, detail=f"a case named '{name}' already exists")
+
+
def _unlink_inside(case: Case, rel_path: str) -> None:
try:
case.resolve_inside(rel_path).unlink(missing_ok=True)
@@ -72,6 +84,7 @@ def list_cases() -> list[dict[str, Any]]:
@router.post("")
def create_case(body: CreateCase) -> dict[str, Any]:
+ _ensure_name_free(body.name)
try:
case = Case.create(body.name)
except CaseError as exc:
@@ -94,6 +107,7 @@ def read_case(case_id: str) -> dict[str, Any]:
@router.post("/{case_id}/promote")
def promote_case(case_id: str, body: PromoteCase) -> dict[str, Any]:
case = get_case(case_id)
+ _ensure_name_free(body.name)
try:
promoted = case.promote(body.name)
except CaseError as exc:
@@ -104,6 +118,7 @@ def promote_case(case_id: str, body: PromoteCase) -> dict[str, Any]:
@router.patch("/{case_id}")
def rename_case(case_id: str, body: CreateCase) -> dict[str, Any]:
case = get_case(case_id)
+ _ensure_name_free(body.name, exclude_id=case.id)
case.rename(body.name)
return {"id": case.id, **case.read()}
@@ -163,8 +178,9 @@ def remove_entity(case_id: str, entity_id: str) -> dict[str, str]:
raise HTTPException(status_code=400, detail=str(exc)) from exc
return {"status": "deleted"}
- # other artifact-backed types: drop the file(s) before removing the row
- if etype == "place" and attrs.get("path"):
+ # other artifact-backed types: drop the file(s) before removing the row.
+ # captures carry the image; a bare place (no path) has nothing on disk.
+ if etype in ("capture", "place") and attrs.get("path"):
satellite_engine.unlink_capture(case, attrs["path"])
elif etype == "proof" and attrs.get("spec"):
_unlink_inside(case, attrs["spec"])
diff --git a/src/ozimut/api/media.py b/src/ozimut/api/media.py
index 85aee3e..c733d4e 100644
--- a/src/ozimut/api/media.py
+++ b/src/ozimut/api/media.py
@@ -27,7 +27,7 @@ class UpdateIn(BaseModel):
path: str
notes: str | None = None
folder: str | None = None
- label: str | None = None
+ title: str | None = None
@router.get("/cases/{case_id}/media")
@@ -93,8 +93,8 @@ def update_media_item(case_id: str, body: UpdateIn) -> dict[str, Any]:
patch["notes"] = body.notes
if body.folder is not None:
patch["folder"] = body.folder
- if body.label is not None:
- patch["label"] = body.label
+ if body.title is not None:
+ patch["title"] = body.title
try:
return media_engine.update_media(case, body.path, patch)
except (ValueError, CaseError) as exc:
diff --git a/src/ozimut/api/satellite.py b/src/ozimut/api/satellite.py
index cac8e96..72d7629 100644
--- a/src/ozimut/api/satellite.py
+++ b/src/ozimut/api/satellite.py
@@ -16,14 +16,28 @@ router = APIRouter(prefix="/api", tags=["satellite"])
class CaptureIn(BaseModel):
- lat: float = Field(ge=-90, le=90)
+ lat: float = Field(ge=-90, le=90) # crop frame center
lon: float = Field(ge=-180, le=180)
zoom: int = Field(ge=1, le=22)
width: int = Field(default=1000, ge=256, le=2048)
height: int = Field(default=700, ge=256, le=2048)
provider: str = "esri-world-imagery"
- crosshair: bool = True
bearing: float = Field(default=0.0, ge=0, le=360)
+ # marker (recorded point of interest): style + optional offset from center
+ marker_style: str = Field(default="crosshair", pattern="^(crosshair|pin|none)$")
+ marker_x: int = Field(default=0, ge=-2048, le=2048)
+ marker_y: int = Field(default=0, ge=-2048, le=2048)
+ marker_lat: float | None = Field(default=None, ge=-90, le=90)
+ marker_lon: float | None = Field(default=None, ge=-180, le=180)
+
+
+class PlaceIn(BaseModel):
+ lat: float = Field(ge=-90, le=90)
+ lon: float = Field(ge=-180, le=180)
+ zoom: int = Field(default=16, ge=1, le=22)
+ bearing: float = Field(default=0.0, ge=0, le=360)
+ title: str | None = None
+ notes: str | None = None
class ParseIn(BaseModel):
@@ -85,7 +99,9 @@ def capture(case_id: str, body: CaptureIn) -> dict[str, Any]:
try:
image, provenance = tiles.fetch_crop(
body.lat, body.lon, body.zoom, body.width, body.height,
- provider, crosshair=body.crosshair, bearing=body.bearing,
+ provider, bearing=body.bearing, marker_style=body.marker_style,
+ marker_x=body.marker_x, marker_y=body.marker_y,
+ marker_lat=body.marker_lat, marker_lon=body.marker_lon,
)
except tiles.TileFetchError as exc:
raise HTTPException(status_code=422, detail=str(exc)) from exc
@@ -97,21 +113,24 @@ def capture(case_id: str, body: CaptureIn) -> dict[str, Any]:
rel_path = f"satellite/{name}"
sat_dir = case.subdir("satellite")
image.save(sat_dir / name, "PNG")
- label = satellite_engine.coords_label(body.lat, body.lon)
+ # the recorded point is the marker (== center unless it was moved off-center)
+ marker_lat, marker_lon = provenance["lat"], provenance["lon"]
+ label = satellite_engine.coords_label(marker_lat, marker_lon)
provenance["filename"] = name
provenance["title"] = label
- provenance["plus_code"] = geo.plus_code(body.lat, body.lon)
- provenance["dms"] = geo.to_dms(body.lat, body.lon)
+ provenance["plus_code"] = geo.plus_code(marker_lat, marker_lon)
+ provenance["dms"] = geo.to_dms(marker_lat, marker_lon)
(sat_dir / f"{name}.json").write_text(
json.dumps(provenance, indent=2, ensure_ascii=False) + "\n", encoding="utf-8"
)
- # one capture == one place entity, tied by its path (spec §3.5); capturing is
- # a deliberate act, so it's filed straight away — retitle/refile/delete later
+ # a capture is an image artifact, mirrored by one ``capture`` entity tied by
+ # its path (spec §3.5) — it carries the marker's coordinates as info but is
+ # not a navigable point; saving a ``place`` (below) is the separate act for that
case.add_entity(
- "place",
+ "capture",
label,
- attrs={"coords": label, "lat": body.lat, "lon": body.lon,
+ attrs={"coords": label, "lat": marker_lat, "lon": marker_lon,
"plus_code": provenance["plus_code"], "path": rel_path,
"zoom": provenance["zoom"], "bearing": body.bearing},
by="satellite",
@@ -121,6 +140,21 @@ def capture(case_id: str, body: CaptureIn) -> dict[str, Any]:
return {"path": rel_path, **provenance}
[email protected]("/cases/{case_id}/satellite/place")
+def save_place(case_id: str, body: PlaceIn) -> dict[str, Any]:
+ """Save just a point (the pin, or the crop center) as a navigable ``place`` —
+ no image. Clicking it in the sidebar flies the map back to it."""
+ case = get_case(case_id)
+ coords = satellite_engine.coords_label(body.lat, body.lon)
+ label = (body.title or "").strip() or coords
+ attrs = {"coords": coords, "lat": body.lat, "lon": body.lon,
+ "plus_code": geo.plus_code(body.lat, body.lon),
+ "zoom": body.zoom, "bearing": body.bearing}
+ if body.notes and body.notes.strip():
+ attrs["notes"] = body.notes.strip()
+ return case.add_entity("place", label, attrs=attrs, by="satellite", status="confirmed")
+
+
@router.get("/cases/{case_id}/satellite")
def list_captures(case_id: str) -> list[dict[str, Any]]:
return satellite_engine.list_captures(get_case(case_id))
diff --git a/src/ozimut/engine/media.py b/src/ozimut/engine/media.py
index b8ccbe1..7165cb7 100644
--- a/src/ozimut/engine/media.py
+++ b/src/ozimut/engine/media.py
@@ -272,7 +272,7 @@ def update_media(case: Case, rel_path: str, patch: dict[str, Any]) -> dict[str,
raise ValueError(f"no sidecar found for {rel_path!r}")
data = json.loads(sidecar.read_text(encoding="utf-8"))
- for key in ("notes", "folder", "label"):
+ for key in ("notes", "folder", "title"):
if key in patch:
val = patch[key]
if val is None or val == "":
@@ -282,12 +282,12 @@ def update_media(case: Case, rel_path: str, patch: dict[str, Any]) -> dict[str,
_write_sidecar(media_path, data)
- # mirror onto the media entity (label + folder/notes attrs)
+ # mirror onto the media entity (label mirrors the title; folder/notes attrs)
entity = case.find_entity(attr="path", value=rel_path)
if entity:
entity_patch: dict[str, Any] = {}
- if patch.get("label"):
- entity_patch["label"] = patch["label"]
+ if patch.get("title"):
+ entity_patch["label"] = patch["title"]
attrs: dict[str, Any] = {}
if "folder" in patch:
attrs["folder"] = patch["folder"] or ""
diff --git a/src/ozimut/engine/satellite.py b/src/ozimut/engine/satellite.py
index 7c63d45..ed988cb 100644
--- a/src/ozimut/engine/satellite.py
+++ b/src/ozimut/engine/satellite.py
@@ -5,17 +5,19 @@ A capture is an image plus a JSON sidecar under ``<case>/satellite/``:
satellite/sat_<stamp>_z<zoom>_<provider>.png
satellite/sat_<stamp>_z<zoom>_<provider>.png.json # provenance (lat/lon/…)
-Every capture is mirrored by exactly one ``place`` entity in ``case.json``
+Every capture is mirrored by exactly one ``capture`` entity in ``case.json``
(spec §3.5): one capture == one entity on the right. They are tied by the
capture's relative ``path``, stored on the entity as ``attrs.path`` — not by
coordinates, so two captures of the same point stay two independent entities.
The entity ``label`` is the capture title (coordinates by default, editable).
+A capture is an *image* (its marker coordinates are recorded as info); saving a
+bare ``place`` — a navigable point with no image — is a separate act.
Deleting in one place must delete in the other, so all delete paths funnel here:
-* delete a capture → drop the one ``place`` entity that points at it;
-* delete a ``place`` → drop the one capture file it points at (handled by the
- entities API via :func:`unlink_capture`).
+* delete a capture → drop the one ``capture`` entity that points at it;
+* delete a ``capture`` row → drop the one capture file it points at (handled by
+ the entities API via :func:`unlink_capture`).
"""
from __future__ import annotations
diff --git a/src/ozimut/engine/tiles.py b/src/ozimut/engine/tiles.py
index dc8424f..8754f5d 100644
--- a/src/ozimut/engine/tiles.py
+++ b/src/ozimut/engine/tiles.py
@@ -139,11 +139,22 @@ def fetch_crop(
height: int,
provider: Provider,
*,
- crosshair: bool = True,
+ marker_style: str = "crosshair",
+ marker_x: int = 0,
+ marker_y: int = 0,
+ marker_lat: float | None = None,
+ marker_lon: float | None = None,
bearing: float = 0.0,
fetch_tile: Callable[[httpx.Client, str], Image.Image | None] | None = None,
) -> tuple[Image.Image, dict[str, Any]]:
- """Stitch a width×height crop centered on (lat, lon). Returns (image, provenance).
+ """Stitch a width×height crop framed on (lat, lon). Returns (image, provenance).
+
+ ``lat``/``lon`` frame the crop (its center). The marker — the recorded point
+ of interest — defaults to that same center, but can be offset: ``marker_x``/
+ ``marker_y`` place it that many pixels from the crop center (WYSIWYG offset
+ computed on the client, already accounting for rotation), and ``marker_lat``/
+ ``marker_lon`` are its geographic coordinates, recorded as the capture's
+ ``lat``/``lon``. ``marker_style`` is ``"crosshair"``, ``"pin"`` or ``"none"``.
Missing tiles become labeled gray placeholders instead of failing the crop.
``bearing`` (degrees clockwise from north) rotates the crop: a larger
@@ -216,15 +227,25 @@ def fetch_crop(
off_x, off_y = (fetch_w - width) // 2, (fetch_h - height) // 2
canvas = canvas.crop((off_x, off_y, off_x + width, off_y + height))
- if crosshair:
- _draw_crosshair(canvas)
+ marker_lat = lat if marker_lat is None else marker_lat
+ marker_lon = lon if marker_lon is None else marker_lon
+ mx = width // 2 + int(marker_x)
+ my = height // 2 + int(marker_y)
+ if marker_style == "pin":
+ _draw_pin(canvas, mx, my)
+ elif marker_style != "none":
+ marker_style = "crosshair"
+ _draw_crosshair(canvas, mx, my)
provenance = {
"provider": provider.id,
"provider_label": provider.label,
"attribution": provider.attribution,
- "lat": lat,
- "lon": lon,
+ # lat/lon are the marker (point of interest); center frames the crop
+ "lat": marker_lat,
+ "lon": marker_lon,
+ "center_lat": lat,
+ "center_lon": lon,
"zoom": zoom,
"width": width,
"height": height,
@@ -233,15 +254,18 @@ def fetch_crop(
"tiles": n_tiles,
"tiles_missing": missing,
"fetched_at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
- "crosshair": crosshair,
+ "marker_style": marker_style,
+ "marker_x": int(marker_x),
+ "marker_y": int(marker_y),
+ # kept for backward-compatible readers of older captures
+ "crosshair": marker_style != "none",
}
return canvas, provenance
-def _draw_crosshair(img: Image.Image) -> None:
- """Center marker: thin cross with an open middle, white with dark outline."""
+def _draw_crosshair(img: Image.Image, cx: int, cy: int) -> None:
+ """Marker at (cx, cy): thin cross with an open middle, white with dark outline."""
draw = ImageDraw.Draw(img)
- cx, cy = img.width // 2, img.height // 2
arm, gap = 22, 7
for dx, dy, colour in ((1, 1, (0, 0, 0)), (0, 0, (255, 255, 255))):
for (x0, y0, x1, y1) in (
@@ -252,3 +276,45 @@ def _draw_crosshair(img: Image.Image) -> None:
):
draw.line((x0 + dx, y0 + dy, x1 + dx, y1 + dy), fill=colour, width=2)
draw.ellipse((cx - 2 + dx, cy - 2 + dy, cx + 2 + dx, cy + 2 + dy), outline=colour, width=1)
+
+
+def _draw_pin(img: Image.Image, x: int, y: int) -> None:
+ """Google-Maps-style teardrop pin whose tip points at (x, y).
+
+ Rendered on a transparent layer at 4× and downsampled, so the curved body
+ and its outline come out smooth instead of jagged (PIL has no anti-aliasing).
+ """
+ head_r, tip_len, stroke, pad = 12, 28, 1.6, 3
+ red, dark, white = (229, 72, 77, 255), (58, 12, 14, 255), (255, 255, 255, 255)
+
+ s = 4 # supersample factor
+ w = (head_r + pad) * 2
+ h = head_r + tip_len + pad * 2
+ layer = Image.new("RGBA", (w * s, h * s), (0, 0, 0, 0))
+ draw = ImageDraw.Draw(layer)
+
+ cx = (head_r + pad) * s # head center within the (supersampled) layer
+ cy = (head_r + pad) * s
+ tip_y = cy + tip_len * s
+
+ def body(radius: float, tip_offset: float, fill: tuple[int, int, int, int]) -> None:
+ # circle head at (cx, cy) unioned with a triangle down to the tip; the
+ # triangle sides are tangent to the circle, so the join is seamless
+ ty = tip_y - tip_offset
+ theta = math.asin(min(1.0, radius / (ty - cy)))
+ lx = cx - radius * math.cos(theta)
+ rx = cx + radius * math.cos(theta)
+ ly = cy + radius * math.sin(theta)
+ draw.ellipse((cx - radius, cy - radius, cx + radius, cy + radius), fill=fill)
+ draw.polygon([(lx, ly), (cx, ty), (rx, ly)], fill=fill)
+
+ sw = stroke * s
+ body(head_r * s, 0, dark) # dark silhouette = the outline
+ body(head_r * s - sw, sw * 1.7, red) # red body inset by the stroke width
+ hole = 4.4 * s # inner white dot with a thin dark ring
+ draw.ellipse((cx - hole - sw * 0.6, cy - hole - sw * 0.6,
+ cx + hole + sw * 0.6, cy + hole + sw * 0.6), fill=dark)
+ draw.ellipse((cx - hole, cy - hole, cx + hole, cy + hole), fill=white)
+
+ layer = layer.resize((w, h), Image.Resampling.LANCZOS)
+ img.paste(layer, (round(x - (head_r + pad)), round(y - (head_r + pad + tip_len))), layer)
diff --git a/src/ozimut/workspace.py b/src/ozimut/workspace.py
index b7d0f1a..4735878 100644
--- a/src/ozimut/workspace.py
+++ b/src/ozimut/workspace.py
@@ -34,7 +34,7 @@ EntityStatus = Literal["confirmed", "suggested"]
# well-known ones the UI knows how to render.
ENTITY_TYPES = (
"person", "organization", "alias", "account", "email", "phone", "domain",
- "ip", "vehicle", "place", "event", "media", "proof", "note",
+ "ip", "vehicle", "place", "capture", "event", "media", "proof", "note",
)
diff --git a/tests/test_cases_api.py b/tests/test_cases_api.py
index a6743c2..6faa08d 100644
--- a/tests/test_cases_api.py
+++ b/tests/test_cases_api.py
@@ -23,6 +23,46 @@ def test_case_lifecycle(client):
assert client.get("/api/cases/kharkiv-strike").status_code == 404
+def test_duplicate_name_rejected_case_insensitively(client):
+ client.post("/api/cases", json={"name": "Alpha Site"})
+
+ # a differently-cased name maps to the same case → 409
+ assert client.post("/api/cases", json={"name": "alpha site"}).status_code == 409
+ # a genuinely new name is fine
+ assert client.post("/api/cases", json={"name": "Beta Site"}).status_code == 200
+
+
+def test_rename_rejects_existing_name_but_allows_self(client):
+ a = client.post("/api/cases", json={"name": "One"}).json()
+ client.post("/api/cases", json={"name": "Two"})
+
+ # renaming onto another case's name (any casing) → 409
+ assert client.patch(f"/api/cases/{a['id']}", json={"name": "two"}).status_code == 409
+ # renaming to its own current name is allowed (no false positive)
+ assert client.patch(f"/api/cases/{a['id']}", json={"name": "One"}).status_code == 200
+
+
+def test_promote_rejects_existing_name(client):
+ client.post("/api/cases", json={"name": "Taken"})
+ scratch = client.post("/api/cases/scratch").json()
+ res = client.post(f"/api/cases/{scratch['id']}/promote", json={"name": "Taken"})
+ assert res.status_code == 409
+
+
+def test_delete_wipes_whole_case_folder(client):
+ import ozimut.config as cfg
+
+ cid = client.post("/api/cases", json={"name": "Doomed"}).json()["id"]
+ # plant content across subdirs so we can prove the whole tree is gone
+ _plant_capture(client, cid)
+ case_dir = cfg.cases_dir() / cid
+ assert case_dir.exists()
+
+ assert client.delete(f"/api/cases/{cid}").json()["status"] == "deleted"
+ assert not case_dir.exists()
+ assert client.get(f"/api/cases/{cid}").status_code == 404
+
+
def test_scratch_promote(client):
scratch = client.post("/api/cases/scratch").json()
assert scratch["id"].startswith("scratch_")
diff --git a/tests/test_media_api.py b/tests/test_media_api.py
index 27ce978..39d623b 100644
--- a/tests/test_media_api.py
+++ b/tests/test_media_api.py
@@ -41,6 +41,17 @@ def test_upload_and_list(client):
assert client.get(f"/files/{cid}/{item['thumbnail']}").status_code == 200
+def test_listing_carries_category_fields(client):
+ """The Media Library groups items into facets (Images/Videos/Imports/…) purely
+ from ``kind`` and ``source`` — guard that both survive upload + listing."""
+ cid = client.post("/api/cases", json={"name": "Facets"}).json()["id"]
+ _upload(client, cid, "shot.png", _png_bytes())
+
+ item = client.get(f"/api/cases/{cid}/media").json()[0]
+ assert item["kind"] == "image" # drives the Images facet
+ assert item["source"]["type"] == "upload" # drives the Imports facet
+
+
def test_duplicate_detection(client):
cid = client.post("/api/cases", json={"name": "Dup"}).json()["id"]
data = _png_bytes(color=(1, 2, 3))
@@ -96,25 +107,26 @@ def test_update_media_notes_and_folder(client):
assert entity["attrs"]["folder"] == ""
-def test_update_media_label(client):
- cid = client.post("/api/cases", json={"name": "Label"}).json()["id"]
+def test_update_media_title(client):
+ cid = client.post("/api/cases", json={"name": "Title"}).json()["id"]
item = _upload(client, cid, "img.png", _png_bytes()).json()["item"]
updated = client.patch(
f"/api/cases/{cid}/media",
- json={"path": item["path"], "label": "Strike video — Kharkiv"},
+ json={"path": item["path"], "title": "Strike video — Kharkiv"},
).json()
- assert updated["label"] == "Strike video — Kharkiv"
+ # the media's own title lives on the sidecar (shown in the Media tab)
+ assert updated["title"] == "Strike video — Kharkiv"
- # entity label updated too
+ # the entity label mirrors the title so the case sidebar stays in sync
entities = client.get(f"/api/cases/{cid}").json()["entities"]
assert entities[0]["label"] == "Strike video — Kharkiv"
- # clear label reverts to no custom label
+ # clearing the title reverts to no custom title
cleared = client.patch(
- f"/api/cases/{cid}/media", json={"path": item["path"], "label": ""}
+ f"/api/cases/{cid}/media", json={"path": item["path"], "title": ""}
).json()
- assert "label" not in cleared
+ assert "title" not in cleared
def test_update_media_clear_notes(client):
diff --git a/tests/test_proofs_api.py b/tests/test_proofs_api.py
index 93bd519..3bf08df 100644
--- a/tests/test_proofs_api.py
+++ b/tests/test_proofs_api.py
@@ -23,6 +23,7 @@ SPEC = {
"color": "#ff5252", "strokeWidth": 4, "comment": "blue roof"},
],
"coords": {"lat": 1.0, "lon": 2.0},
+ "notes": {"#ff5252": "blue roof matches"},
}
@@ -43,6 +44,7 @@ def test_save_load_roundtrip(client):
spec = client.get(f"/api/cases/{cid}/proofs/kharkiv-strike-proof").json()
assert spec["title"] == "Kharkiv strike proof"
assert spec["shapes"][0]["comment"] == "blue roof"
+ assert spec["notes"] == {"#ff5252": "blue roof matches"} # legend text is per color
assert spec["panels"][0]["id"] == "p1" # panel ids survive → shapes stay bound
# PNG served
diff --git a/tests/test_satellite_api.py b/tests/test_satellite_api.py
index 76426b2..9e67c4a 100644
--- a/tests/test_satellite_api.py
+++ b/tests/test_satellite_api.py
@@ -43,26 +43,89 @@ def _capture(client, cid, lat, lon, zoom=16):
).json()
-def _places(client, cid):
+def _of_type(client, cid, etype):
return [e for e in client.get(f"/api/cases/{cid}").json()["entities"]
- if e["type"] == "place"]
+ if e["type"] == etype]
+
+
+def _captures(client, cid):
+ return _of_type(client, cid, "capture")
+
+
+def _places(client, cid):
+ return _of_type(client, cid, "place")
-def test_capture_creates_place_entity(client, monkeypatch):
+def test_capture_creates_capture_entity_not_place(client, monkeypatch):
monkeypatch.setattr(tiles, "_default_fetch", _fake_tile)
cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
cap = _capture(client, cid, 48.8584, 2.2945)
- places = _places(client, cid)
- assert len(places) == 1
+ # a capture is an image entity, not a navigable place
+ assert _places(client, cid) == []
+ caps = _captures(client, cid)
+ assert len(caps) == 1
# the entity is tied to this exact capture by path, titled with its coords
- assert places[0]["attrs"]["coords"] == "48.858400, 2.294500"
- assert places[0]["attrs"]["path"] == cap["path"]
- assert places[0]["label"] == "48.858400, 2.294500"
- # zoom/bearing travel with the place so the sidebar can restore the view
- assert places[0]["attrs"]["zoom"] == 16
- assert places[0]["attrs"]["bearing"] == 0.0
- # capturing files the place straight away — no confirm step
- assert places[0]["provenance"]["status"] == "confirmed"
+ assert caps[0]["attrs"]["coords"] == "48.858400, 2.294500"
+ assert caps[0]["attrs"]["path"] == cap["path"]
+ assert caps[0]["label"] == "48.858400, 2.294500"
+ assert caps[0]["attrs"]["zoom"] == 16
+ assert caps[0]["attrs"]["bearing"] == 0.0
+ # capturing files it straight away — no confirm step
+ assert caps[0]["provenance"]["status"] == "confirmed"
+
+
+def test_save_place_creates_place_without_image(client):
+ cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
+ place = client.post(
+ f"/api/cases/{cid}/satellite/place",
+ json={"lat": 48.8584, "lon": 2.2945, "zoom": 18, "bearing": 30},
+ ).json()
+ assert place["type"] == "place"
+ assert place["label"] == "48.858400, 2.294500"
+ # a bare place carries coordinates but no image path — nothing on disk
+ assert "path" not in place["attrs"]
+ assert place["attrs"]["zoom"] == 18 and place["attrs"]["bearing"] == 30
+ assert len(_places(client, cid)) == 1
+ assert _captures(client, cid) == []
+ # no satellite image file was written
+ assert client.get(f"/api/cases/{cid}/satellite").json() == []
+
+
+def test_save_place_with_note(client):
+ cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
+ place = client.post(
+ f"/api/cases/{cid}/satellite/place",
+ json={"lat": 48.8584, "lon": 2.2945, "title": "HQ", "notes": " seen on video "},
+ ).json()
+ assert place["label"] == "HQ"
+ assert place["attrs"]["notes"] == "seen on video"
+
+
+def test_edit_place_title_and_note_via_entity_patch(client):
+ cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
+ place = client.post(
+ f"/api/cases/{cid}/satellite/place",
+ json={"lat": 48.8584, "lon": 2.2945},
+ ).json()
+ # the generic entity PATCH retitles and sets the note (used by the editor)
+ updated = client.patch(
+ f"/api/cases/{cid}/entities/{place['id']}",
+ json={"label": "Command post", "attrs": {"notes": "north wall"}},
+ ).json()
+ assert updated["label"] == "Command post"
+ assert updated["attrs"]["notes"] == "north wall"
+ # coordinates are untouched by the merge
+ assert updated["attrs"]["lat"] == 48.8584 and updated["attrs"]["lon"] == 2.2945
+
+
+def test_save_place_honors_custom_title(client):
+ cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
+ place = client.post(
+ f"/api/cases/{cid}/satellite/place",
+ json={"lat": 48.8584, "lon": 2.2945, "title": " Eiffel Tower "},
+ ).json()
+ assert place["label"] == "Eiffel Tower"
+ assert place["attrs"]["coords"] == "48.858400, 2.294500"
def test_each_capture_is_its_own_entity(client, monkeypatch):
@@ -71,39 +134,110 @@ def test_each_capture_is_its_own_entity(client, monkeypatch):
# two captures at the same coordinates are two independent entities (1:1)
_capture(client, cid, 48.8584, 2.2945, zoom=16)
_capture(client, cid, 48.8584, 2.2945, zoom=17)
- assert len(_places(client, cid)) == 2
+ assert len(_captures(client, cid)) == 2
-def test_delete_capture_removes_only_its_place(client, monkeypatch):
+def test_delete_capture_removes_only_its_entity(client, monkeypatch):
monkeypatch.setattr(tiles, "_default_fetch", _fake_tile)
cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
first = _capture(client, cid, 48.8584, 2.2945, zoom=16)
second = _capture(client, cid, 48.8584, 2.2945, zoom=17)
client.delete(f"/api/cases/{cid}/satellite", params={"path": first["path"]})
- # only the deleted capture's place is gone; the sibling stays intact
- places = _places(client, cid)
- assert len(places) == 1
- assert places[0]["attrs"]["path"] == second["path"]
+ # only the deleted capture's entity is gone; the sibling stays intact
+ caps = _captures(client, cid)
+ assert len(caps) == 1
+ assert caps[0]["attrs"]["path"] == second["path"]
remaining = client.get(f"/api/cases/{cid}/satellite").json()
assert [c["path"] for c in remaining] == [second["path"]]
-def test_delete_place_entity_removes_only_its_capture(client, monkeypatch):
+def test_delete_capture_entity_removes_only_its_image(client, monkeypatch):
monkeypatch.setattr(tiles, "_default_fetch", _fake_tile)
cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
first = _capture(client, cid, 48.8584, 2.2945, zoom=16)
second = _capture(client, cid, 48.8584, 2.2945, zoom=17)
- place = next(p for p in _places(client, cid) if p["attrs"]["path"] == first["path"])
+ cap = next(c for c in _captures(client, cid) if c["attrs"]["path"] == first["path"])
- # deleting the place from the sidebar wipes just its one capture
- client.delete(f"/api/cases/{cid}/entities/{place['id']}")
- assert len(_places(client, cid)) == 1
+ # deleting the capture row from the sidebar wipes just its one image
+ client.delete(f"/api/cases/{cid}/entities/{cap['id']}")
+ assert len(_captures(client, cid)) == 1
remaining = client.get(f"/api/cases/{cid}/satellite").json()
assert [c["path"] for c in remaining] == [second["path"]]
-def test_edit_title_renames_place_entity(client, monkeypatch):
+def test_delete_place_entity_leaves_captures_alone(client, monkeypatch):
+ monkeypatch.setattr(tiles, "_default_fetch", _fake_tile)
+ cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
+ cap = _capture(client, cid, 48.8584, 2.2945, zoom=16)
+ client.post(
+ f"/api/cases/{cid}/satellite/place",
+ json={"lat": 48.8600, "lon": 2.3000},
+ )
+ place = _places(client, cid)[0]
+
+ # a bare place has no image; deleting it must not touch capture files
+ client.delete(f"/api/cases/{cid}/entities/{place['id']}")
+ assert _places(client, cid) == []
+ assert [c["path"] for c in client.get(f"/api/cases/{cid}/satellite").json()] == [cap["path"]]
+
+
+def test_default_marker_is_centered_crosshair(client, monkeypatch):
+ monkeypatch.setattr(tiles, "_default_fetch", _fake_tile)
+ cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
+ result = _capture(client, cid, 48.8584, 2.2945)
+ # marker defaults to the crop center; recorded coords == center
+ assert result["marker_style"] == "crosshair"
+ assert result["marker_x"] == 0 and result["marker_y"] == 0
+ assert result["lat"] == 48.8584 and result["lon"] == 2.2945
+ assert result["center_lat"] == 48.8584 and result["center_lon"] == 2.2945
+
+
+def test_pin_style_persists(client, monkeypatch):
+ monkeypatch.setattr(tiles, "_default_fetch", _fake_tile)
+ cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
+ result = client.post(
+ f"/api/cases/{cid}/satellite/capture",
+ json={"lat": 48.8584, "lon": 2.2945, "zoom": 16,
+ "width": 512, "height": 512, "marker_style": "pin"},
+ ).json()
+ assert result["marker_style"] == "pin"
+ assert client.get(f"/api/cases/{cid}/satellite").json()[0]["marker_style"] == "pin"
+
+
+def test_moved_marker_records_pin_coords_not_center(client, monkeypatch):
+ monkeypatch.setattr(tiles, "_default_fetch", _fake_tile)
+ cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
+ # crop framed on center, but the pin was dragged to a different point
+ result = client.post(
+ f"/api/cases/{cid}/satellite/capture",
+ json={"lat": 48.8584, "lon": 2.2945, "zoom": 16, "width": 512, "height": 512,
+ "marker_style": "pin", "marker_x": 0, "marker_y": 200,
+ "marker_lat": 48.8600, "marker_lon": 2.3000},
+ ).json()
+ # recorded coordinates & offset follow the pin, center stays the frame
+ assert (result["lat"], result["lon"]) == (48.86, 2.3)
+ assert (result["center_lat"], result["center_lon"]) == (48.8584, 2.2945)
+ assert result["marker_y"] == 200
+ # the mirrored capture entity is titled/located at the pin, not the center
+ cap = _captures(client, cid)[0]
+ assert cap["attrs"]["lat"] == 48.86 and cap["attrs"]["lon"] == 2.3
+ assert cap["label"] == "48.860000, 2.300000"
+
+
+def test_no_marker_leaves_image_unmarked(client, monkeypatch):
+ monkeypatch.setattr(tiles, "_default_fetch", _fake_tile)
+ cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
+ result = client.post(
+ f"/api/cases/{cid}/satellite/capture",
+ json={"lat": 48.8584, "lon": 2.2945, "zoom": 16,
+ "width": 256, "height": 256, "marker_style": "none"},
+ ).json()
+ assert result["marker_style"] == "none"
+ assert result["crosshair"] is False
+
+
+def test_edit_title_renames_capture_entity(client, monkeypatch):
monkeypatch.setattr(tiles, "_default_fetch", _fake_tile)
cid = client.post("/api/cases", json={"name": "Sat"}).json()["id"]
cap = _capture(client, cid, 48.8584, 2.2945)
@@ -113,7 +247,7 @@ def test_edit_title_renames_place_entity(client, monkeypatch):
json={"path": cap["path"], "title": "Eiffel Tower"},
).json()
assert updated["title"] == "Eiffel Tower"
- assert _places(client, cid)[0]["label"] == "Eiffel Tower"
+ assert _captures(client, cid)[0]["label"] == "Eiffel Tower"
# listing reflects the stored title
listed = client.get(f"/api/cases/{cid}/satellite").json()
@@ -121,4 +255,4 @@ def test_edit_title_renames_place_entity(client, monkeypatch):
# clearing the title falls back to the coordinates on both sides
client.patch(f"/api/cases/{cid}/satellite", json={"path": cap["path"], "title": " "})
- assert _places(client, cid)[0]["label"] == "48.858400, 2.294500"
+ assert _captures(client, cid)[0]["label"] == "48.858400, 2.294500"
diff --git a/tests/test_tiles.py b/tests/test_tiles.py
index 1d49e17..892e15e 100644
--- a/tests/test_tiles.py
+++ b/tests/test_tiles.py
@@ -31,7 +31,7 @@ def test_fetch_crop_stitches_and_records_provenance():
return Image.new("RGB", (256, 256), (10, 120, 10))
img, prov = tiles.fetch_crop(
- 48.8584, 2.2945, 17, 640, 480, provider, crosshair=True, fetch_tile=fake_fetch
+ 48.8584, 2.2945, 17, 640, 480, provider, fetch_tile=fake_fetch
)
assert img.size == (640, 480)
assert prov["provider"] == "esri-world-imagery"
@@ -43,11 +43,42 @@ def test_fetch_crop_stitches_and_records_provenance():
assert img.getpixel((320 - 10, 240)) == (255, 255, 255)
+def test_fetch_crop_marker_offset_moves_crosshair_and_records_pin():
+ provider = tiles.BUILTIN_PROVIDERS[0]
+
+ def fake(client, url):
+ return Image.new("RGB", (256, 256), (10, 120, 10))
+
+ img, prov = tiles.fetch_crop(
+ 48.8584, 2.2945, 17, 640, 480, provider,
+ marker_x=120, marker_y=-60, marker_lat=48.86, marker_lon=2.30,
+ fetch_tile=fake,
+ )
+ # crosshair arm sits at the offset point, not the center
+ assert img.getpixel((320 + 120 - 10, 240 - 60)) == (255, 255, 255)
+ assert img.getpixel((320 - 10, 240)) == (10, 120, 10) # center untouched
+ # recorded coords are the pin; center is remembered separately
+ assert (prov["lat"], prov["lon"]) == (48.86, 2.30)
+ assert (prov["center_lat"], prov["center_lon"]) == (48.8584, 2.2945)
+ assert prov["marker_style"] == "crosshair"
+
+
+def test_fetch_crop_none_marker_leaves_center_clean():
+ provider = tiles.BUILTIN_PROVIDERS[0]
+ img, prov = tiles.fetch_crop(
+ 48.8584, 2.2945, 17, 256, 256, provider, marker_style="none",
+ fetch_tile=lambda c, u: Image.new("RGB", (256, 256), (10, 120, 10)),
+ )
+ assert img.getpixel((128, 128)) == (10, 120, 10)
+ assert prov["marker_style"] == "none"
+ assert prov["crosshair"] is False
+
+
def test_fetch_crop_missing_tiles_dont_fail():
provider = tiles.BUILTIN_PROVIDERS[0]
img, prov = tiles.fetch_crop(
- 10.0, 10.0, 15, 512, 512, provider, crosshair=False,
+ 10.0, 10.0, 15, 512, 512, provider, marker_style="none",
fetch_tile=lambda client, url: None,
)
assert prov["tiles_missing"] == prov["tiles"] > 0
@@ -68,11 +99,11 @@ def test_fetch_crop_bearing_rotates_and_fills_corners():
return fetch
north, _ = tiles.fetch_crop(
- 48.8584, 2.2945, 17, 640, 480, provider, crosshair=False,
+ 48.8584, 2.2945, 17, 640, 480, provider, marker_style="none",
fetch_tile=count("north"),
)
img, prov = tiles.fetch_crop(
- 48.8584, 2.2945, 17, 640, 480, provider, crosshair=False, bearing=45,
+ 48.8584, 2.2945, 17, 640, 480, provider, marker_style="none", bearing=45,
fetch_tile=count("rotated"),
)
@@ -94,7 +125,7 @@ def test_fetch_crop_bearing_zero_matches_unrotated():
return Image.new("RGB", (256, 256), (10, 120, 10))
img, prov = tiles.fetch_crop(
- 48.8584, 2.2945, 17, 640, 480, provider, crosshair=False, bearing=0,
+ 48.8584, 2.2945, 17, 640, 480, provider, marker_style="none", bearing=0,
fetch_tile=fetch,
)
assert img.size == (640, 480)