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

Put Figure in the row the capture menu opens on (#109)

OsintMeThat1550db5d4bf7
diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md
index acc8c59..89df3fb 100644
--- a/docs/RELEASE_NOTES.md
+++ b/docs/RELEASE_NOTES.md
@@ -61,6 +61,13 @@ clearly what went wrong.
## Maps
+- A Copernicus layer no longer has to be made in the Copernicus dashboard. The
+ date chip writes one here — three bands on red, green and blue, a normalised
+ difference on a ramp, or the evalscript itself — previews it on the chosen
+ date, and once saved it joins the picker in Satellite, Compare and Detect.
+- **Figure** lays one pass out through several layers, each panel captioned and
+ filed as its own capture, opened as a Geo Proof with its credit line written.
+ It sits beside Capture and Select area in the capture menu.
- FIRMS fires are drawn as marks that keep their size through a zoom.
- Town and village names sit over the imagery in Satellite, Detect and the point
dialog, on by default beside Borders.
@@ -77,6 +84,12 @@ clearly what went wrong.
- The analyzer builder works on the map: one satellite, one or two dates,
checks made with pins, and **Test** says what the rules find before you save.
+- An analyzer of your own downloads as a file, its checks included or left
+ behind, carrying nothing of this machine: a rule set travels without the
+ settings backup and its API keys. Areas and area groups go the same way, names,
+ colours and folder kept. An import never writes over what is already here.
+- A layer written for the map becomes a rule with its arithmetic, and a rule
+ draws back as a layer. Moving a rule's line repaints its ground as you drag it.
- Areas sit in ordered groups, and the dock can be resized.
- **What** starts with nothing picked and lists the analyzers by what they look
for.
diff --git a/docs/UI.md b/docs/UI.md
index d83db4c..5cc3a47 100644
--- a/docs/UI.md
+++ b/docs/UI.md
@@ -2032,12 +2032,17 @@ screenshot gets neither, since its coordinates describe the map view at filing
time rather than the picture itself. What was drawn is written into the
capture's provenance.
-**Build a figure** sits in the same menu while Sentinel-2 is on: the same ground
-on the day already chosen, through the layers you pick, each panel captioned and
-filed as its own capture. It opens in Geo Proof with its credit line written —
-the day, the point and Copernicus Sentinel-2 L2A — ready to annotate. Up to
-eight panels, one to four per row, each layer once, at the capture size the menu
-is set to. Every panel is the same acquisition by design: panels of different
+**Figure** sits in the same menu while Sentinel-2 is on, in its first row beside
+Capture and Select area, since it is a third thing to take off this map rather
+than a setting for the other two: the same ground on the day already chosen,
+through the layers you pick, each panel captioned and filed as its own capture.
+It opens in Geo Proof with its credit line written — the day, the point and
+Copernicus Sentinel-2 L2A — ready to annotate. Up to eight panels, one to four
+per row, each layer once, at the capture size the menu is set to. The chip is
+never greyed: what a figure still needs is said in the dialog, where it can be
+read and acted on — an undated map has nothing to build from and says so instead
+of the panels, and a configuration with fewer than two layers says where another
+one comes from. Every panel is the same acquisition by design: panels of different
dates compare two things at once, which is what Compare is for, so an undated
map says to pick a date first.
diff --git a/frontend/src/tools/Satellite.svelte b/frontend/src/tools/Satellite.svelte
index 474c969..21a5bc1 100644
--- a/frontend/src/tools/Satellite.svelte
+++ b/frontend/src/tools/Satellite.svelte
@@ -424,14 +424,20 @@
api,
});
const isSentinel = $derived(currentProvider?.id === SENTINEL_ID);
- /** Why a figure cannot be built from what is on screen, or '' when it can. */
- const figureProblem = $derived(
- !s2.day
- ? 'A figure needs a dated pass: every panel is the same acquisition.'
- : s2.layers.length < 2
- ? 'A figure needs more than one layer. Check your Copernicus layers, or write one.'
- : ''
- );
+
+ /**
+ * Open the figure with the layers it is made of.
+ *
+ * The list is read when the date chip is first opened, and a figure can be
+ * the first thing asked of a session: without this it opens offering nothing
+ * and says the configuration is empty, which is a lie about the instance.
+ * Asked the way the chip asks it, so whichever comes first pays for it and
+ * the other finds it read (`state/sentinel.svelte.js`).
+ */
+ async function openFigure() {
+ if (!s2.layers.length) await s2.loadLayers(true, true);
+ figureOpen = true;
+ }
// --- Esri Wayback: which release of World Imagery ---
// The release rides on the provider id like a Sentinel-2 window, and both
@@ -2525,8 +2531,7 @@
bind:scaleNorth={capture.scaleNorth}
openScreenshot={() => (capture.shotOpen = true)}
openExtensionGate={() => (capture.extGate = true)}
- openFigure={isSentinel ? () => (figureOpen = true) : null}
- figureBlocked={figureProblem}
+ openFigure={isSentinel ? openFigure : null}
/>
</MapStatusBar>
{#if figureOpen && caseState.current}
diff --git a/frontend/src/tools/Satellite.test.js b/frontend/src/tools/Satellite.test.js
index 8fcce42..b7ca7f7 100644
--- a/frontend/src/tools/Satellite.test.js
+++ b/frontend/src/tools/Satellite.test.js
@@ -330,6 +330,14 @@ describe('the capture button', () => {
expect(source).toContain('if (measure.setMode(mode)) capture.disarm()');
});
+ it('offers a figure on Sentinel-2 only, with the layers it is made of read first', () => {
+ // The layer list is read when the date chip is first opened. A figure can be
+ // the first thing asked of a session, and one opened before that list came
+ // would say the configuration is empty.
+ expect(source).toContain('openFigure={isSentinel ? openFigure : null}');
+ expect(source).toContain('if (!s2.layers.length) await s2.loadLayers(true, true);');
+ });
+
it('gives the store the map element rather than reaching for one itself', () => {
expect(source).toContain('element: () => mapEl');
expect(source).toContain('function onSelectDrag(e)');
diff --git a/frontend/src/tools/satellite/CaptureOptions.render.test.js b/frontend/src/tools/satellite/CaptureOptions.render.test.js
new file mode 100644
index 0000000..8ace6c8
--- /dev/null
+++ b/frontend/src/tools/satellite/CaptureOptions.render.test.js
@@ -0,0 +1,102 @@
+// @vitest-environment happy-dom
+/**
+ * The capture menu, actually mounted.
+ *
+ * A figure is the one thing in here that is not a size or a ratio, and it was
+ * buried under them: a row of its own at the bottom of the menu, below the
+ * custom size inputs, which nobody scrolls to. It now sits where the menu is
+ * read, beside Capture and Select area. So what is asserted is that it is
+ * there, that it is pressable whatever the map is set to, since what a figure
+ * still needs is the dialog's to say, and that pressing it opens that dialog
+ * without arming a capture mode.
+ */
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { flushSync, mount, unmount } from 'svelte';
+import CaptureOptions from './CaptureOptions.svelte';
+
+const RATIOS = [{ id: 'free', label: 'Free' }, { id: '16:9', label: '16:9' }];
+const PRESETS = [{ id: 'md', label: '1200' }, { id: 'custom', label: 'Custom' }];
+
+let held = null;
+
+function show(props = {}) {
+ held = mount(CaptureOptions, {
+ target: document.body,
+ props: {
+ menuOpen: true,
+ mode: 'center',
+ hover: false,
+ selectArmed: false,
+ capturing: false,
+ blocked: false,
+ widgetBase: false,
+ runCapture: vi.fn(),
+ ratios: RATIOS,
+ ratio: 'free',
+ presets: PRESETS,
+ preset: 'md',
+ customWidth: 1200,
+ customHeight: 1200,
+ resolution: 1,
+ scaleNorth: false,
+ openScreenshot: vi.fn(),
+ openExtensionGate: vi.fn(),
+ ...props,
+ },
+ });
+ flushSync();
+ return document.body;
+}
+
+afterEach(() => {
+ if (held) unmount(held);
+ held = null;
+ document.body.innerHTML = '';
+});
+
+/** The chips of the first row, which is the one the menu opens on. */
+const modeChips = () =>
+ [...document.body.querySelectorAll('.menu-row')][0].querySelectorAll('.chip');
+const labels = () => [...modeChips()].map((node) => node.textContent.trim());
+const chip = (label) => [...modeChips()].find((node) => node.textContent.trim() === label);
+const hints = () =>
+ [...document.body.querySelectorAll('.menu-hint')].map((node) => node.textContent.trim());
+
+function press(node) {
+ node.click();
+ flushSync();
+}
+
+describe('on Sentinel-2', () => {
+ it('is a chip beside the two capture modes, pressable', () => {
+ show({ openFigure: vi.fn() });
+
+ expect(labels()).toEqual(['Capture', 'Select area', 'Figure…']);
+ expect(chip('Figure…').disabled).toBe(false);
+ });
+
+ it('opens the dialog and closes the menu, leaving the mode alone', () => {
+ const openFigure = vi.fn();
+ show({ openFigure, mode: 'center' });
+
+ press(chip('Figure…'));
+
+ expect(openFigure).toHaveBeenCalledOnce();
+ expect(document.body.querySelector('.size-menu')).toBeNull();
+ // The big button still does what it did: a figure is an act, not a mode.
+ expect(document.body.querySelector('.capture-main').textContent.trim()).toBe('Capture');
+ });
+});
+
+describe('on a basemap with no figure to build', () => {
+ it('leaves the row at the two capture modes, and the menu unchanged', () => {
+ show({ openFigure: null });
+
+ expect(labels()).toEqual(['Capture', 'Select area']);
+ expect(hints()).toEqual([
+ 'Captures the centred size below.',
+ 'Captures a deeper zoom for a sharper file.',
+ 'Drawn into the capture, in your units.',
+ ]);
+ });
+});
diff --git a/frontend/src/tools/satellite/CaptureOptions.svelte b/frontend/src/tools/satellite/CaptureOptions.svelte
index 7abf0bf..438a4eb 100644
--- a/frontend/src/tools/satellite/CaptureOptions.svelte
+++ b/frontend/src/tools/satellite/CaptureOptions.svelte
@@ -24,10 +24,9 @@
openScreenshot,
openExtensionGate,
/** Build a figure instead of one picture. Absent where there is none to
- * build: a figure is several renderings of one Copernicus acquisition. */
+ * build: a figure is several renderings of one Copernicus acquisition.
+ * What is missing for this one is the dialog's to say, not the menu's. */
openFigure = null,
- /** Why a figure cannot be built here, for the row that says so. */
- figureBlocked = '',
} = $props();
</script>
@@ -73,6 +72,15 @@
<div class="chips">
<button class="chip" class:on={mode === 'center'} onclick={() => (mode = 'center')}>Capture</button>
<button class="chip" class:on={mode === 'select'} onclick={() => (mode = 'select')}>Select area</button>
+ {#if openFigure}
+ <button
+ class="chip"
+ onclick={() => { menuOpen = false; openFigure(); }}
+ title="Several renderings of this acquisition, laid out and captioned"
+ >
+ Figure…
+ </button>
+ {/if}
</div>
</div>
<div class="menu-hint">
@@ -127,26 +135,6 @@
{/if}
{/if}
- {#if openFigure}
- <div class="menu-row">
- <span class="menu-label">Figure</span>
- <div class="chips">
- <button
- class="chip"
- disabled={!!figureBlocked}
- onclick={() => { menuOpen = false; openFigure(); }}
- title={figureBlocked || 'Several renderings of this acquisition, laid out and captioned'}
- >
- Build a figure…
- </button>
- </div>
- </div>
- <div class="menu-hint">
- {figureBlocked ||
- 'The same ground through the layers you pick, filed as a Geo Proof ready to annotate.'}
- </div>
- {/if}
-
{#if widgetBase}
<div class="menu-row">
<span class="menu-label">Source</span>
@@ -260,8 +248,6 @@
}
.chip:hover { border-color: var(--border-strong); color: var(--text-1); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
- .chip:disabled { opacity: 0.45; cursor: default; }
- .chip:disabled:hover { border-color: var(--border); color: var(--text-2); }
.menu-hint { font-size: 10px; color: var(--text-3); margin: -1px 0 5px; }
.menu-hint.last { margin-bottom: 0; }
/* The one setting here that outlives the session, so it reads as a switch
diff --git a/frontend/src/tools/satellite/FigureDialog.svelte b/frontend/src/tools/satellite/FigureDialog.svelte
index 7790c56..8f21afd 100644
--- a/frontend/src/tools/satellite/FigureDialog.svelte
+++ b/frontend/src/tools/satellite/FigureDialog.svelte
@@ -160,7 +160,13 @@
<p class="help">
<Icon name="info" size={12} />
<span>
- Panels are numbered down the list, so a caption can be referred to as panel 2.
+ {#if layers.length < 2}
+ A figure reads one acquisition several ways, and there {layers.length ? 'is one layer' : 'is none'}
+ here. Write another from the date chip, or add it to your Copernicus configuration from
+ Settings → Imagery.
+ {:else}
+ Panels are numbered down the list, so a caption can be referred to as panel 2.
+ {/if}
</span>
</p>
</div>
diff --git a/frontend/src/tools/satellite/FigureDialog.test.js b/frontend/src/tools/satellite/FigureDialog.test.js
index 1f68139..e5a66e2 100644
--- a/frontend/src/tools/satellite/FigureDialog.test.js
+++ b/frontend/src/tools/satellite/FigureDialog.test.js
@@ -101,6 +101,20 @@ it('will not build an undated figure, and says why', () => {
expect(button('Build the figure')).toBeUndefined();
});
+it('opens on a thin configuration and says where another layer comes from', () => {
+ // The menu offers the figure whatever the map is set to, so this is where an
+ // analyst with one layer learns what a figure wants and how to get there.
+ const said = () => document.body.textContent.replace(/\s+/g, ' ');
+ open({ layers: [LAYERS[0]] });
+ expect(said()).toContain('there is one layer here');
+ expect(said()).toContain('Settings → Imagery');
+ expect(said()).not.toContain('numbered down the list');
+
+ unmount(live);
+ open({ layers: [] });
+ expect(said()).toContain('there is none here');
+});
+
it('builds nothing until a layer is picked and the figure is named', () => {
open();
expect(button('Build the figure').disabled).toBe(true);