Merge branch 'main' into denis/gev-cockpit-entry

This commit is contained in:
Sameh Khamis authored and GitHub committed 2026-11-05 14:01:31 -08:00
commit e3f668831c
90 files changed
+4333 -460

No files matched your search

+2
View File
@@ -1,6 +1,7 @@
/** Contact readouts and nearby-signal presentation for the Cockpit controller. */
import * as Cesium from 'cesium';
import { formatNumber, t, tn } from '../i18n/index.js';
import { sourceStatusLabel } from './layerNames.js';
import { unitLabel } from './unitLabels.js';
import {
bearingBetweenCoordinates,
@@ -143,6 +144,7 @@ export function updateContext(info, heading) {
if (shown) {
shown.count = cohort.count === null ? '?' : String(cohort.count);
shown.unknown = cohort.relationship === 'UNKNOWN';
shown.source = sourceStatusLabel(cohort.source, cohort.sourceStatus);
}
if (cohort.count === null) unknownCount += 1;
for (const item of cohort.nearest) nearest.push({ ...item, cohort });
+44
View File
@@ -103,6 +103,13 @@ test('before the controller presents, the card shows the state it starts in', (t
),
['—', '—', '—', '—'],
);
// No provider is named before a snapshot reports one.
assert.deepEqual(
[...document.querySelectorAll('[data-context-cohort] small')].map(
(source) => source.textContent,
),
['—', '—', '—', '—'],
);
assert.equal(text('#cockpit-context-nearest-label'), 'NO AVAILABLE EXAMPLE');
assert.equal(
$('#cockpit-context-nearest-label').hasAttribute('aria-label'),
@@ -166,6 +173,43 @@ test('a snapshot fills the card and keeps classes other code sets', async (t) =>
assert.equal(layouts.length, 1);
});
test('each count names the provider its snapshot reports, with its feed state', async (t) => {
const reported = snapshot();
reported.cohorts[0].source = 'adsb.lol';
reported.cohorts[0].sourceStatus = 'fallback';
reported.cohorts[1].source = 'Plane Finder';
reported.cohorts.push(
{
id: 'ais-live-vessels',
label: 'AIS vessels',
source: 'Datalastic',
sourceStatus: 'stale',
count: 3,
relationship: 'OBSERVED',
nearest: [],
},
{
id: 'military-installations',
label: 'Mapped installations',
source: 'OpenStreetMap',
sourceStatus: null,
count: 0,
relationship: 'MAPPED',
nearest: [],
},
);
const { $, owner } = fixture(t, reported);
updateContext.call(owner, INFO, 0);
await nextTick();
const source = (id) => $(`[data-context-cohort="${id}"] small`);
assert.equal(source('flights').textContent, 'adsb.lol · FALLBACK');
assert.equal(source('military').textContent, 'Plane Finder');
assert.equal(source('ais-live-vessels').textContent, 'Datalastic · STALE');
assert.equal(source('military-installations').textContent, 'OpenStreetMap');
// The tile ellipsizes; the full name stays readable on hover.
assert.equal(source('flights').title, 'adsb.lol · FALLBACK');
});
test('a lost contact holds its readout behind the CONTACT LOST cue', async (t) => {
const { $, text, owner, layouts } = fixture(t, snapshot());
updateContext.call(owner, INFO, 0);
+4 -1
View File
@@ -25,7 +25,10 @@ export function createContextState() {
canPrevious: true,
canNext: true,
cohorts: Object.fromEntries(
COCKPIT_CONTEXT_COHORTS.map((id) => [id, { count: '—', unknown: false }]),
COCKPIT_CONTEXT_COHORTS.map((id) => [
id,
{ count: '—', unknown: false, source: '—' },
]),
),
nearest: { label: t('NO AVAILABLE EXAMPLE'), ariaLabel: null },
distance: { text: '—', ariaLabel: null },
+15
View File
@@ -117,3 +117,18 @@ test('a radio group moves from the focused option, an arrows group from the sele
assert.deepEqual(arrows.emitted('update:modelValue'), [['a']]);
arrows.unmount();
});
test("an option's own tip wins; an icon option without one is titled by its label", () => {
const wrapper = mountGroup({
options: [
{ value: 'a', label: 'Alpha', attrs: { title: 'Alpha tip' } },
{ value: 'b', label: 'Beta', icon: 'star' },
{ value: 'c', label: 'Gamma' },
],
});
const titles = wrapper
.findAll('button')
.map((b) => b.attributes('title') ?? null);
assert.deepEqual(titles, ['Alpha tip', 'Beta', null]);
wrapper.unmount();
});
+3 -2
View File
@@ -8,7 +8,8 @@ import { computed } from 'vue';
// End). Each option may carry `attrs` (an id, data attributes, a tip), and
// Core's classes sit beside the kit's: `gev-segmented`, `gev-segment` and the
// selected option's `activeClass`. An option with an `icon` shows the glyph,
// and its label becomes the button's accessible name and tooltip.
// and its label becomes the button's accessible name and tooltip, unless its
// `attrs` carry a tip of their own.
const props = defineProps({
modelValue: { type: String, default: undefined },
/** `{value, label, icon?, disabled?, attrs?}`, labels already translated. */
@@ -119,7 +120,7 @@ function onKey(event) {
]"
:aria-checked="String(option.value === props.modelValue)"
:aria-label="option.icon ? option.label : undefined"
:title="option.icon ? option.label : undefined"
:title="option.attrs?.title ?? (option.icon ? option.label : undefined)"
:disabled="optionOff(option)"
:tabindex="tabindex(index)"
@click="choose(index)"
+6
View File
@@ -141,6 +141,12 @@ export class LayerBindings {
});
this._weatherShellModules.push(layer);
}
// Active Fires drapes its far-zoom heatmap on the same imagery host.
const fires = this._dataManager?.layers?.get('local-firms')?.module;
if (typeof fires?.attachShellServices === 'function') {
fires.attachShellServices({ imageryHost: this.services.imageryHost });
this._weatherShellModules.push(fires);
}
}
_persistAwarenessSelection(event, cleared = false) {
+14
View File
@@ -141,3 +141,17 @@ export function sourceLabel(source) {
? source.split(' · ').map(translateKnown).join(' · ')
: translateKnown(source);
}
/**
* A provider name with the feed state it answered in, so a fallback or stale
* snapshot does not read as the live primary feed.
* @param {string} source English source name.
* @param {'fallback'|'stale'|null} status Feed state from `layerFeedState`.
* @returns {string}
*/
export function sourceStatusLabel(source, status) {
const name = sourceLabel(source);
if (status === 'fallback') return `${name} · ${t('FALLBACK')}`;
if (status === 'stale') return `${name} · ${t('STALE')}`;
return name;
}
+17
View File
@@ -7,6 +7,7 @@ import {
LAYER_NAME_KEYS,
PANEL_LABEL_KEYS,
sourceLabel,
sourceStatusLabel,
} from './layerNames.js';
// Layers whose module name is a proper name and stays as it is in every
@@ -51,3 +52,19 @@ for (const locale of ['es', 'ru']) {
}
});
}
test('a provider name carries the fallback or stale state it answered in', () => {
assert.equal(sourceStatusLabel('Plane Finder', null), 'Plane Finder');
assert.equal(sourceStatusLabel('adsb.lol', 'fallback'), 'adsb.lol · FALLBACK');
assert.equal(sourceStatusLabel('OpenSky Network', 'stale'), 'OpenSky Network · STALE');
setLocale('ru');
try {
assert.equal(
sourceStatusLabel('adsb.lol', 'fallback'),
`adsb.lol · ${t('FALLBACK')}`,
);
assert.notEqual(t('FALLBACK'), 'FALLBACK');
} finally {
setLocale('en');
}
});
+35 -5
View File
@@ -442,6 +442,8 @@ export class LayerPanel {
this._selectChip(layerId, chipId, generation),
onListItem: (layerId, itemId) =>
this._selectListItem(layerId, itemId, generation),
onSlider: (layerId, sliderId, value) =>
this._moveSlider(layerId, sliderId, value, generation),
}),
id === null ? this._toggleContainer : this._groupContainers.get(id),
);
@@ -471,7 +473,8 @@ export class LayerPanel {
}
/**
* A layer's row chips, color legend, info line and ordered list. The block
* A layer's row chips, one-of-many switch, slider, color legend, info line
* and ordered list. The block
* is hidden while the layer is off (or while a dependency owner has
* surrendered it), so a quiet row stays quiet. Chips and list items are
* keyed, so the refresh a chip's own click triggers keeps keyboard focus.
@@ -495,11 +498,20 @@ export class LayerPanel {
: `${item.label} ${formatCount(item.count)}`,
}));
const infoText = controls?.info ? String(controls.info) : '';
const segmented = controls?.segmented || null;
const slider = controls?.slider || null;
// The info line, once shown, stays in place and hides when empty.
if (infoText) row.info = true;
return {
hidden: chips.length === 0 && legend.length === 0 && !infoText,
hidden:
chips.length === 0 &&
legend.length === 0 &&
!infoText &&
!segmented &&
!slider,
chips,
segmented,
slider,
legend,
info: row.info
? { text: infoText, title: controls?.infoTitle || '' }
@@ -537,15 +549,33 @@ export class LayerPanel {
// listeners, so a click from a released generation is dropped.
_selectChip(id, chipId, generation = this._generation) {
if (this._destroyed || this._generation !== generation) return;
const chip = this._rowControlsFor(id)?.chips?.find(
(entry) => entry.id === chipId,
);
// A switch option carries the same fields as a chip.
const live = this._rowControlsFor(id);
const chip = [
...(live?.chips || []),
...(live?.segmented?.options || []),
].find((entry) => entry.id === chipId);
if (!chip || chip.disabled || !this.isEnabled(id)) return;
if (typeof chip.onClick === 'function') chip.onClick();
else if (chip.params)
this.setLayerParams(id, chip.params, { origin: 'user' });
}
// A row slider (e.g. the Active Fires minimum-FRP filter) maps its position
// to params through the live descriptor on every tick.
_moveSlider(id, sliderId, value, generation = this._generation) {
if (this._destroyed || this._generation !== generation) return;
const slider = this._rowControlsFor(id)?.slider;
if (
!slider ||
slider.id !== sliderId ||
typeof slider.params !== 'function' ||
!this.isEnabled(id)
)
return;
this.setLayerParams(id, slider.params(value), { origin: 'user' });
}
_selectListItem(id, itemId, generation = this._generation) {
if (this._destroyed || this._generation !== generation) return;
const item = this._rowControlsFor(id)?.list?.items?.find(
+13
View File
@@ -1,6 +1,8 @@
<script setup>
import RailChips from '../rail/RailChips.vue';
import RailRowList from '../rail/RailRowList.vue';
import RowSlider from './RowSlider.vue';
import RowSwitch from './RowSwitch.vue';
import RowText from './RowText.vue';
import { vClassToggle } from '../rail/classToggle.js';
@@ -12,6 +14,7 @@ defineProps({
onToggle: { type: Function, default: () => {} },
onChip: { type: Function, default: () => {} },
onListItem: { type: Function, default: () => {} },
onSlider: { type: Function, default: () => {} },
});
</script>
@@ -55,6 +58,16 @@ defineProps({
><RailChips
:chips="item.controls.chips"
:on-select="(chip) => onChip(item.id, chip.id)"
/><RowSwitch
v-if="item.controls.segmented"
:segmented="item.controls.segmented"
:on-select="(optionId) => onChip(item.id, optionId)"
/><RowSlider
v-if="item.controls.slider"
:slider="item.controls.slider"
:on-input="
(value) => onSlider(item.id, item.controls.slider.id, value)
"
/><span
v-for="(entry, index) in item.controls.legend"
:key="index"
+44
View File
@@ -0,0 +1,44 @@
<script setup>
import UiSlider from '../kit/UiSlider.js';
// A row's quantitative slider (e.g. the Active Fires minimum-FRP filter).
// `track` is a CSS background painting the runnable track, so a color ramp
// doubles as the legend; each tick sits at `at` (0..1) along it. The input
// holds its position while focused, so a refresh from its own tick never
// moves the thumb under the pointer.
defineProps({
slider: { type: Object, required: true },
onInput: { type: Function, default: () => {} },
});
</script>
<template>
<div class="data-toggle-slider" :data-slider-id="slider.id"
><div class="data-toggle-slider-head"
><span class="data-toggle-slider-label">{{ slider.label }}</span
><span class="data-toggle-slider-value gev-slider-value">{{
slider.valueText
}}</span></div
><UiSlider
class="data-toggle-slider-input"
:data-slider-id="slider.id"
:min="slider.min"
:max="slider.max"
:step="slider.step ?? 1"
:model-value="slider.value"
hold
:aria-label="slider.ariaLabel || undefined"
:aria-valuetext="slider.valueText || undefined"
:style="slider.track ? { '--slider-track': slider.track } : undefined"
@update:model-value="onInput"
/><div class="data-toggle-slider-ticks"
><span
v-for="tick in slider.ticks || []"
:key="tick.at"
class="data-toggle-slider-tick"
:style="{ '--at': `${(tick.at * 100).toFixed(2)}%` }"
>{{ tick.label }}</span
></div
></div
>
</template>
+38
View File
@@ -0,0 +1,38 @@
<script setup>
import UiSegmented from '../kit/UiSegmented.vue';
// A row's one-of-many switch (e.g. Active Fires confidence). Options carry
// the same fields as chips, so the owner resolves a choice the way it
// resolves a chip; `label` is an optional caption beside the group.
defineProps({
segmented: { type: Object, required: true },
onSelect: { type: Function, default: () => {} },
});
const options = (segmented) =>
(segmented.options || []).map((option) => ({
value: option.id,
label: option.label,
disabled: Boolean(option.disabled),
attrs: { 'data-chip-id': option.id, title: option.title || undefined },
}));
const activeId = (segmented) =>
(segmented.options || []).find((option) => option.active)?.id;
</script>
<template>
<span
v-if="segmented.label"
class="data-toggle-segmented-label"
:data-segmented-caption-for="segmented.id"
>{{ segmented.label }}</span
><UiSegmented
class="data-toggle-segmented"
:data-segmented-id="segmented.id"
:model-value="activeId(segmented)"
:options="options(segmented)"
:label="segmented.ariaLabel || segmented.label || ''"
item-class="data-toggle-segment"
@update:model-value="onSelect"
/>
</template>
+116 -1
View File
@@ -39,8 +39,123 @@ test('the count-line class toggles without dropping the voice highlight', () =>
assert.equal(element.classList.contains('gev-voice-focus'), true);
render(h(LayerRows, { items: [row(false)] }), container);
assert.equal(element.classList.contains('data-toggle-row--count-line'), false);
assert.equal(
element.classList.contains('data-toggle-row--count-line'),
false,
);
assert.equal(element.classList.contains('gev-voice-focus'), true);
assert.equal(element.classList.contains('data-toggle-row'), true);
render(null, container);
});
const fireRow = (value, active = 'all') => ({
...row(false),
key: 'fires',
id: 'fires',
controls: {
hidden: false,
chips: [],
segmented: {
id: 'confidence',
label: 'Confidence',
ariaLabel: 'Detection confidence',
options: ['all', 'high'].map((mode) => ({
id: `confidence-${mode}`,
label: mode.toUpperCase(),
title: `${mode} title`,
active: mode === active,
})),
},
slider: {
id: 'min-frp',
label: 'Fire intensity (FRP)',
ariaLabel: 'Minimum fire radiative power, megawatts',
valueText: value ? `≥ ${value} MW` : 'All',
min: 0,
max: 1000,
step: 1,
value,
track: 'linear-gradient(90deg, #9e2a1b, #fff3b0)',
ticks: [
{ at: 0, label: '0' },
{ at: 0.5, label: '30' },
],
},
legend: [],
info: null,
list: null,
},
});
test('a row switch and slider render their markup and report choices', () => {
document.body.replaceChildren();
const container = document.body.appendChild(document.createElement('div'));
const chips = [];
const moves = [];
const props = {
onChip: (id, chipId) => chips.push([id, chipId]),
onSlider: (id, sliderId, value) => moves.push([id, sliderId, value]),
};
render(h(LayerRows, { items: [fireRow(0)], ...props }), container);
const caption = container.querySelector('.data-toggle-segmented-label');
assert.equal(caption.textContent, 'Confidence');
const group = container.querySelector('.gev-segmented.data-toggle-segmented');
assert.equal(group.getAttribute('role'), 'radiogroup');
assert.equal(group.getAttribute('aria-label'), 'Detection confidence');
const segments = [
...group.querySelectorAll('.gev-segment.data-toggle-segment'),
];
assert.deepEqual(
segments.map((button) => button.dataset.chipId),
['confidence-all', 'confidence-high'],
);
assert.equal(segments[0].classList.contains('active'), true);
assert.equal(segments[1].title, 'high title');
segments[1].click();
assert.deepEqual(chips, [['fires', 'confidence-high']]);
const block = container.querySelector('.data-toggle-slider');
assert.equal(block.dataset.sliderId, 'min-frp');
assert.equal(
block.querySelector('.data-toggle-slider-label').textContent,
'Fire intensity (FRP)',
);
assert.equal(
block.querySelector('.data-toggle-slider-value').textContent,
'All',
);
const input = block.querySelector('input.data-toggle-slider-input');
assert.equal(input.classList.contains('gev-quantitative-slider'), true);
assert.equal(input.type, 'range');
assert.equal(input.max, '1000');
assert.equal(
input.getAttribute('aria-label'),
'Minimum fire radiative power, megawatts',
);
assert.equal(input.getAttribute('aria-valuetext'), 'All');
assert.match(
input.style.getPropertyValue('--slider-track'),
/^linear-gradient/,
);
const ticks = [...block.querySelectorAll('.data-toggle-slider-tick')];
assert.deepEqual(
ticks.map((tick) => tick.textContent),
['0', '30'],
);
assert.equal(ticks[1].style.getPropertyValue('--at'), '50.00%');
input.value = '120';
input.dispatchEvent(new Event('input', { bubbles: true }));
assert.deepEqual(moves, [['fires', 'min-frp', 120]]);
// The refresh that tick triggers keeps the same nodes and updates the text.
render(h(LayerRows, { items: [fireRow(120, 'high')], ...props }), container);
assert.equal(
container.querySelector('input.data-toggle-slider-input'),
input,
);
assert.equal(input.getAttribute('aria-valuetext'), '≥ 120 MW');
assert.equal(segments[1].classList.contains('active'), true);
render(null, container);
});
+112
View File
@@ -1042,6 +1042,118 @@ html:not([lang='en']) .data-row-list-text {
padding-top: 3px;
overflow-wrap: anywhere;
}
/* Optional per-layer one-of-many switch (Active Fires confidence). The shared
.gev-segmented surface, sized to the chip row. */
.data-toggle-controls .data-toggle-segmented {
flex-basis: 100%;
max-width: 220px;
}
.data-toggle-segmented-label {
flex-basis: 100%;
padding-top: 2px;
font-family: var(--font-mono);
font-size: 8px;
letter-spacing: 1.2px;
color: var(--text-dim);
text-transform: uppercase;
}
.data-toggle-controls .data-toggle-segment {
min-height: 20px;
padding: 3px 6px;
font-size: 8px;
letter-spacing: 0.8px;
}
/* Optional per-layer quantitative slider (Active Fires minimum FRP). The
track is painted by the layer (`--slider-track`, a stepped color ramp), so
the slider doubles as the marker legend; ticks sit under their thresholds. */
.data-toggle-slider {
flex-basis: 100%;
display: grid;
gap: 2px;
padding-top: 2px;
}
.data-toggle-slider-head {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 8px;
font-family: var(--font-mono);
font-size: 8px;
letter-spacing: 1.2px;
color: var(--text-dim);
text-transform: uppercase;
}
.data-toggle-slider-value {
min-width: 0;
font-size: 9px;
letter-spacing: 0.5px;
text-transform: none;
}
.data-toggle-slider-input {
height: 14px;
}
.data-toggle-slider-input::-webkit-slider-runnable-track {
height: 5px;
border-radius: 3px;
background: var(--slider-track, rgba(255, 255, 255, 0.08));
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.data-toggle-slider-input::-moz-range-track,
.data-toggle-slider-input::-moz-range-progress {
height: 5px;
border-radius: 3px;
background: var(--slider-track, rgba(255, 255, 255, 0.08));
}
.data-toggle-slider-input::-webkit-slider-thumb {
width: 11px;
height: 11px;
margin-top: -3px;
background: var(--text-primary);
box-shadow:
0 0 0 1px rgba(0, 0, 0, 0.6),
0 0 6px rgba(255, 255, 255, 0.35);
}
.data-toggle-slider-input::-moz-range-thumb {
width: 11px;
height: 11px;
background: var(--text-primary);
box-shadow:
0 0 0 1px rgba(0, 0, 0, 0.6),
0 0 6px rgba(255, 255, 255, 0.35);
}
.data-toggle-slider-ticks {
position: relative;
height: 10px;
margin: 0 5px;
font-family: var(--font-mono);
font-size: 7px;
letter-spacing: 0.4px;
color: var(--text-dim);
}
.data-toggle-slider-tick {
position: absolute;
top: 0;
left: var(--at);
transform: translateX(-50%);
white-space: nowrap;
}
.data-toggle-slider-tick:first-child {
transform: none;
}
/* ── Local RTL-SDR card (FM + Local ADS-B receiver) ── */
.sdr-radio-card {
display: grid;
+4 -4
View File
@@ -49,10 +49,10 @@ const weatherLabel = computed(() =>
<span class="cockpit-context-qualifier">{{ t('CONTEXT ONLY') }}</span>
</header>
<div class="cockpit-context-cohorts" role="list" :aria-label="t('Nearby cohort counts')">
<div v-class-toggle="{ unknown: c.cohorts.flights.unknown }" role="listitem" data-context-cohort="flights"><span>{{ t('FLT') }}</span><strong>{{ c.cohorts.flights.count }}</strong><small translate="no">OpenSky</small></div>
<div v-class-toggle="{ unknown: c.cohorts.military.unknown }" role="listitem" data-context-cohort="military"><span>{{ t('MIL') }}</span><strong>{{ c.cohorts.military.count }}</strong><small translate="no">adsb.lol</small></div>
<div v-class-toggle="{ unknown: c.cohorts['ais-live-vessels'].unknown }" role="listitem" data-context-cohort="ais-live-vessels"><span translate="no">AIS</span><strong>{{ c.cohorts['ais-live-vessels'].count }}</strong><small translate="no">AISStream</small></div>
<div v-class-toggle="{ unknown: c.cohorts['military-installations'].unknown }" role="listitem" data-context-cohort="military-installations"><span>{{ t('SITE') }}</span><strong>{{ c.cohorts['military-installations'].count }}</strong><small translate="no">OpenStreetMap</small></div>
<div v-class-toggle="{ unknown: c.cohorts.flights.unknown }" role="listitem" data-context-cohort="flights"><span>{{ t('FLT') }}</span><strong>{{ c.cohorts.flights.count }}</strong><small translate="no" :title="c.cohorts.flights.source">{{ c.cohorts.flights.source }}</small></div>
<div v-class-toggle="{ unknown: c.cohorts.military.unknown }" role="listitem" data-context-cohort="military"><span>{{ t('MIL') }}</span><strong>{{ c.cohorts.military.count }}</strong><small translate="no" :title="c.cohorts.military.source">{{ c.cohorts.military.source }}</small></div>
<div v-class-toggle="{ unknown: c.cohorts['ais-live-vessels'].unknown }" role="listitem" data-context-cohort="ais-live-vessels"><span translate="no">AIS</span><strong>{{ c.cohorts['ais-live-vessels'].count }}</strong><small translate="no" :title="c.cohorts['ais-live-vessels'].source">{{ c.cohorts['ais-live-vessels'].source }}</small></div>
<div v-class-toggle="{ unknown: c.cohorts['military-installations'].unknown }" role="listitem" data-context-cohort="military-installations"><span>{{ t('SITE') }}</span><strong>{{ c.cohorts['military-installations'].count }}</strong><small translate="no" :title="c.cohorts['military-installations'].source">{{ c.cohorts['military-installations'].source }}</small></div>
</div>
<div class="cockpit-context-nearest">
<span id="cockpit-context-direction" v-class-toggle="{ unknown: c.direction.unknown }" class="material-symbols-outlined" :style="directionStyle" aria-hidden="true">navigation</span>