mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Merge branch 'main' into sv-locale
Translate the 148 strings main added since (mostly the News layer) and prune the 5 it no longer uses; keep both Hebrew and Swedish in the language lists.
This commit is contained in:
commit
45d9ff1d86
395 files changed
+45142
-1917
No files matched your search
@@ -472,7 +472,12 @@ export class StyleManager extends ShellFacade {
|
||||
initialShareCode,
|
||||
});
|
||||
this.shareLinkManager.setFollowSubjectProvider(({ nowMs }) =>
|
||||
readShareFollowSubject({ viewer: this.viewer, nowMs }),
|
||||
readShareFollowSubject({
|
||||
viewer: this.viewer,
|
||||
nowMs,
|
||||
readSelectedVessel: () =>
|
||||
this.services.aisLiveVesselsLayer?.getSelectedFix?.() ?? null,
|
||||
}),
|
||||
);
|
||||
this.shareLinkManager.setPanelStateProvider(() =>
|
||||
this._buildSharePanelState(),
|
||||
|
||||
@@ -245,3 +245,73 @@ test('a repaint that leaves focus outside the panel does not pull it back', asyn
|
||||
'an empty cohort renders no list',
|
||||
);
|
||||
});
|
||||
|
||||
const photo = (extra = {}) => ({
|
||||
src: 'https://t.plnspttrs.net/1/abc123_280.jpg',
|
||||
width: 280,
|
||||
height: 186,
|
||||
link: 'https://www.planespotters.net/photo/1/n123ab',
|
||||
credit: 'Photo © Jane Doe',
|
||||
...extra,
|
||||
});
|
||||
|
||||
test('a tracked flight’s photo shows under its name, credited and linked to its page', async (t) => {
|
||||
const { panel, publish } = fixture(t);
|
||||
await publish({ ...results(), photo: photo() });
|
||||
const root = panel();
|
||||
const link = root.querySelector('a.military-awareness-photo');
|
||||
assert.ok(link, 'the photo renders');
|
||||
assert.equal(
|
||||
root.querySelector('.military-awareness-subject').nextElementSibling,
|
||||
link,
|
||||
'directly under the subject line',
|
||||
);
|
||||
assert.equal(link.getAttribute('href'), photo().link);
|
||||
assert.equal(link.getAttribute('target'), '_blank');
|
||||
assert.equal(link.getAttribute('rel'), 'noopener');
|
||||
const img = link.querySelector('img');
|
||||
assert.equal(img.getAttribute('src'), photo().src);
|
||||
assert.equal(img.getAttribute('alt'), '');
|
||||
assert.equal(img.getAttribute('width'), '280');
|
||||
assert.equal(img.getAttribute('height'), '186');
|
||||
assert.equal(link.querySelector('small').textContent, 'Photo © Jane Doe');
|
||||
});
|
||||
|
||||
test('no photo renders without one', async (t) => {
|
||||
const { panel, publish } = fixture(t);
|
||||
await publish({ ...results(), photo: null });
|
||||
assert.equal(panel().querySelector('.military-awareness-photo'), null);
|
||||
});
|
||||
|
||||
test('a photo whose image fails to load is hidden until another arrives', async (t) => {
|
||||
const { panel, publish } = fixture(t);
|
||||
await publish({ ...results(), photo: photo() });
|
||||
panel()
|
||||
.querySelector('.military-awareness-photo img')
|
||||
.dispatchEvent(new Event('error'));
|
||||
await nextTick();
|
||||
assert.equal(panel().querySelector('.military-awareness-photo'), null);
|
||||
// A repaint with the same photo keeps it hidden.
|
||||
await publish({ ...results({ previousDisabled: false }), photo: photo() });
|
||||
assert.equal(panel().querySelector('.military-awareness-photo'), null);
|
||||
// Another plane's photo shows.
|
||||
const next = photo({ src: 'https://t.plnspttrs.net/2/def456_280.jpg' });
|
||||
await publish({ ...results(), photo: next });
|
||||
assert.equal(
|
||||
panel().querySelector('.military-awareness-photo img').getAttribute('src'),
|
||||
next.src,
|
||||
);
|
||||
});
|
||||
|
||||
test('a late error from a previous photo’s image does not hide the current one', async (t) => {
|
||||
const { panel, publish } = fixture(t);
|
||||
const previous = photo();
|
||||
const current = photo({ src: 'https://t.plnspttrs.net/2/def456_280.jpg' });
|
||||
await publish({ ...results(), photo: current });
|
||||
// The error belongs to the image that failed: here, one still on the old src.
|
||||
const img = panel().querySelector('.military-awareness-photo img');
|
||||
img.setAttribute('src', previous.src);
|
||||
img.dispatchEvent(new Event('error'));
|
||||
await nextTick();
|
||||
assert.ok(panel().querySelector('.military-awareness-photo'));
|
||||
});
|
||||
@@ -15,6 +15,7 @@ import { vesselCockpitInfo } from '../layers/vessels/cockpitSubject.js';
|
||||
import { VesselRecords } from '../layers/vessels/records.js';
|
||||
|
||||
const RECORD = Object.freeze({
|
||||
id: '211000000',
|
||||
mmsi: '211000000',
|
||||
name: 'NORDIC STAR',
|
||||
type: '70',
|
||||
@@ -65,9 +66,9 @@ function vesselLayer(record) {
|
||||
enabled && selected
|
||||
? { ...vesselCockpitInfo(selected), seaSurfaceHeightM: 0 }
|
||||
: null,
|
||||
setCockpitSubject(mmsi) {
|
||||
calls.push(['subject', mmsi]);
|
||||
subject = mmsi;
|
||||
setCockpitSubject(id) {
|
||||
calls.push(['subject', id]);
|
||||
subject = id;
|
||||
return true;
|
||||
},
|
||||
// Like the layer, leaves out the ship whose bridge the Cockpit rides.
|
||||
@@ -75,7 +76,7 @@ function vesselLayer(record) {
|
||||
radarQueries.push({ lat, lon, rangeM, maxCount });
|
||||
const own = {
|
||||
...NEIGHBOUR,
|
||||
id: record.mmsi,
|
||||
id: record.id,
|
||||
latitude: record.lat,
|
||||
longitude: record.lon,
|
||||
};
|
||||
@@ -257,7 +258,7 @@ test('entering the bridge hides the vessel and shows bridge readouts', async (t)
|
||||
await settle();
|
||||
assert.equal(cockpit.active, true);
|
||||
assert.equal(cockpit.subjectKind, 'vessel');
|
||||
assert.deepEqual(vessels.calls, [['subject', RECORD.mmsi]]);
|
||||
assert.deepEqual(vessels.calls, [['subject', RECORD.id]]);
|
||||
assert.equal(document.body.classList.contains('cockpit-mode'), true);
|
||||
|
||||
assert.equal(
|
||||
@@ -303,7 +304,7 @@ test('exiting the bridge releases the vessel and returns to its map view', async
|
||||
assert.equal(cockpit.active, false);
|
||||
assert.equal(cockpit.subjectKind, null);
|
||||
assert.deepEqual(vessels.calls, [
|
||||
['subject', RECORD.mmsi],
|
||||
['subject', RECORD.id],
|
||||
['subject', null],
|
||||
['focus'],
|
||||
]);
|
||||
@@ -374,7 +375,7 @@ test('tracking an aircraft from the bridge ends it without refocusing the vessel
|
||||
assert.equal(viewer.trackedEntity, aircraft, 'the aircraft keeps tracking');
|
||||
assert.equal(aircraft.show, true, 'the aircraft was never adopted');
|
||||
assert.deepEqual(vessels.calls, [
|
||||
['subject', RECORD.mmsi],
|
||||
['subject', RECORD.id],
|
||||
['subject', null],
|
||||
]);
|
||||
});
|
||||
@@ -1474,7 +1475,7 @@ test('a fix the feed keeps re-serving goes on ageing into a stale feed', async (
|
||||
effects,
|
||||
);
|
||||
poll();
|
||||
const record = records.byMmsi.get(RECORD.mmsi);
|
||||
const record = records.byId.get(RECORD.id);
|
||||
const { $, cockpit, shots } = fixture(t, { record });
|
||||
cockpit.enter();
|
||||
await settle();
|
||||
@@ -1540,7 +1541,12 @@ test("a ship's double-click memory does not carry over to another ship", async (
|
||||
heightSensitiveProjection(viewer);
|
||||
cockpit.onScenePointerDown(1000);
|
||||
// Within the memory another ship is selected, drawn elsewhere.
|
||||
vessels.select({ ...RECORD, mmsi: '211000009', name: 'OTHER' });
|
||||
vessels.select({
|
||||
...RECORD,
|
||||
id: '211000009',
|
||||
mmsi: '211000009',
|
||||
name: 'OTHER',
|
||||
});
|
||||
heightSensitiveProjection(viewer, { x: 900 });
|
||||
assert.equal(cockpit.onSceneDoubleClick({ x: 400, y: 300 }, 1250), false);
|
||||
assert.equal(cockpit.active, false);
|
||||
|
||||
@@ -1,9 +1,29 @@
|
||||
/**
|
||||
* The Cockpit briefing's pages and the state it starts in. It needs only the
|
||||
* i18n module, so the controller and the view can both read it.
|
||||
* i18n module and the regional-news window, so the controller and the view
|
||||
* can both read it.
|
||||
*/
|
||||
import { REGIONAL_NEWS_WINDOW_HOURS } from '../data/regionalNewsWindow.js';
|
||||
import { msg, t } from '../i18n/index.js';
|
||||
|
||||
// i18n-ignore: provider name
|
||||
/** The news feed named before any briefing has answered. */
|
||||
export const DEFAULT_NEWS_SOURCE = 'GOOGLE NEWS RSS';
|
||||
|
||||
/**
|
||||
* The Regional News footer for a fresh, empty or unavailable list: the feed
|
||||
* and the window its articles are held to.
|
||||
* @param {string} [source]
|
||||
* @param {number} [hours]
|
||||
* @returns {string}
|
||||
*/
|
||||
export function newsWindowFooter(
|
||||
source = DEFAULT_NEWS_SOURCE,
|
||||
hours = REGIONAL_NEWS_WINDOW_HOURS,
|
||||
) {
|
||||
return t('{source} · LAST {hours} H', { source, hours });
|
||||
}
|
||||
|
||||
export const COCKPIT_BRIEF_PAGES = [
|
||||
{
|
||||
id: 'signals',
|
||||
@@ -15,8 +35,7 @@ export const COCKPIT_BRIEF_PAGES = [
|
||||
id: 'news',
|
||||
kickerKey: msg('REGIONAL NEWS'),
|
||||
subtitleKey: msg('LATEST LOCATION-MATCHED REPORTING'),
|
||||
sourceKey: msg('{source} · LOCATION QUERY · RECENT'),
|
||||
sourceName: 'GOOGLE NEWS RSS', // i18n-ignore: provider name
|
||||
// The news footer comes from the news state (`news.footer`), not here.
|
||||
},
|
||||
{
|
||||
id: 'local',
|
||||
@@ -60,6 +79,7 @@ export function createBriefState() {
|
||||
statusHidden: false,
|
||||
state: null,
|
||||
status: t('ACQUIRING REGIONAL NEWS'),
|
||||
footer: newsWindowFooter(),
|
||||
articles: [],
|
||||
},
|
||||
local: {
|
||||
|
||||
+113
-21
@@ -12,7 +12,14 @@ import {
|
||||
COCKPIT_BRIEF_PAGES,
|
||||
CYCLE_HELP_KEYS,
|
||||
createBriefState,
|
||||
newsWindowFooter,
|
||||
} from './cockpitBriefPages.js';
|
||||
import {
|
||||
recentRegionalArticles,
|
||||
regionalNewsWindowHours,
|
||||
} from '../data/regionalNewsWindow.js';
|
||||
|
||||
const NEWS_ROWS = 4;
|
||||
|
||||
// regionalModel.weatherCodeLabel is shared with node code and returns
|
||||
// English; translate it here.
|
||||
@@ -52,9 +59,13 @@ export function showBriefPage(index, { manual = false } = {}) {
|
||||
kicker: t(page.kickerKey),
|
||||
subtitle: t(page.subtitleKey),
|
||||
position: `${this.briefPageIndex + 1} / ${count}`,
|
||||
source: page.sourceKey
|
||||
? t(page.sourceKey, { source: page.sourceName })
|
||||
: page.source,
|
||||
// The news footer follows the news state, so it survives page changes.
|
||||
source:
|
||||
page.id === 'news'
|
||||
? this.brief.news.footer
|
||||
: page.sourceKey
|
||||
? t(page.sourceKey)
|
||||
: page.source,
|
||||
});
|
||||
this.publishBriefView();
|
||||
if (manual && this.briefAutoRotateEnabled)
|
||||
@@ -153,7 +164,7 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
!Number.isFinite(info.longitude)
|
||||
)
|
||||
return;
|
||||
const subjectId = `${info.layerId || 'aircraft'}:${info.icao24 || info.mmsi || info.noradId || info.registration || info.callsign || 'unknown'}`;
|
||||
const subjectId = `${info.layerId || 'aircraft'}:${info.icao24 || (info.kind === 'vessel' ? info.id : '') || info.noradId || info.registration || info.callsign || 'unknown'}`;
|
||||
if (subjectId !== this.regionalBriefSubjectId) {
|
||||
this.regionalBriefAbort?.abort();
|
||||
this.regionalBriefAbort = null;
|
||||
@@ -176,6 +187,13 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
)
|
||||
return;
|
||||
|
||||
// The brief held stands in after a failed refresh only near where its news
|
||||
// was read; past the refresh distance it is another place's.
|
||||
const previous =
|
||||
this.services.regionalDistanceM(this.regionalBriefPoint, point) <
|
||||
COCKPIT_REGIONAL_REFRESH_DISTANCE_M
|
||||
? this.regionalBrief
|
||||
: null;
|
||||
this.regionalBriefAnchor = point;
|
||||
this.regionalBriefFetchedAt = Date.now();
|
||||
const controller = new AbortController();
|
||||
@@ -193,8 +211,9 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
subjectId !== this.regionalBriefSubjectId
|
||||
)
|
||||
return;
|
||||
this.regionalBrief = payload;
|
||||
this.renderRegionalBrief(payload, info);
|
||||
this.regionalBrief = withCachedNews(payload, previous);
|
||||
if (this.regionalBrief === payload) this.regionalBriefPoint = point;
|
||||
this.renderRegionalBrief(this.regionalBrief, info);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (
|
||||
@@ -203,7 +222,14 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
requestToken === this.regionalBriefRequestToken &&
|
||||
subjectId === this.regionalBriefSubjectId
|
||||
) {
|
||||
this.renderRegionalBriefStatus('unavailable', info);
|
||||
if (previous) {
|
||||
this.regionalBrief = cachedNews(previous, previous);
|
||||
this.renderRegionalBrief(this.regionalBrief, info);
|
||||
} else {
|
||||
// Another place's brief: not to come back with a language change.
|
||||
this.regionalBrief = null;
|
||||
this.renderRegionalBriefStatus('unavailable', info);
|
||||
}
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -212,6 +238,75 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A brief whose news comes from `previous` after a refresh that brought none:
|
||||
* the earlier articles stay, marked `cached` so they are labelled as such.
|
||||
* @param {object} payload The brief to keep everything else from.
|
||||
* @param {object} previous The last brief rendered for this subject.
|
||||
*/
|
||||
function cachedNews(payload, previous) {
|
||||
return {
|
||||
...payload,
|
||||
newsStatus: 'cached',
|
||||
newsSource: previous.newsSource,
|
||||
newsWindowHours: previous.newsWindowHours,
|
||||
newsFetchedAt: previous.newsFetchedAt ?? previous.retrievedAt ?? null,
|
||||
articles: previous.articles,
|
||||
};
|
||||
}
|
||||
|
||||
// A refresh whose news read failed keeps the articles from before it.
|
||||
function withCachedNews(payload, previous) {
|
||||
return previous && payload?.newsStatus === 'unavailable'
|
||||
? cachedNews(payload, previous)
|
||||
: payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Regional News state a brief presents. `ready` and `cached` have rows
|
||||
* inside the window; `cached` is a refresh that failed (a client-side failure,
|
||||
* or the local proxy's `stale` answer). `empty` is a source that answered with
|
||||
* nothing in the window; anything else is `unavailable`.
|
||||
* @returns {{state: string, status: string, footer: string, articles: object[]}}
|
||||
*/
|
||||
function regionalNewsView(payload) {
|
||||
const hours = regionalNewsWindowHours(payload?.newsWindowHours);
|
||||
// Old caches and the local path are held to the window here too.
|
||||
const articles = recentRegionalArticles(payload?.articles, {
|
||||
windowHours: hours,
|
||||
limit: NEWS_ROWS,
|
||||
});
|
||||
const source = String(
|
||||
payload?.newsSource || t('REGIONAL NEWS'),
|
||||
).toUpperCase();
|
||||
const refreshFailed =
|
||||
payload?.newsStatus === 'cached' || payload?.status === 'stale';
|
||||
if (articles.length && refreshFailed)
|
||||
return {
|
||||
state: 'cached',
|
||||
status: t('CACHED · REFRESH FAILED'),
|
||||
footer: t('{source} · CACHED {age}', {
|
||||
source,
|
||||
age: formatCockpitBriefAge(
|
||||
payload?.newsFetchedAt ?? payload?.retrievedAt,
|
||||
),
|
||||
}),
|
||||
articles,
|
||||
};
|
||||
const answered =
|
||||
!refreshFailed && ['ready', 'empty'].includes(payload?.newsStatus);
|
||||
return {
|
||||
state: articles.length ? 'ready' : answered ? 'empty' : 'unavailable',
|
||||
status: articles.length
|
||||
? ''
|
||||
: answered
|
||||
? t('NO NEWS IN THE LAST {hours} H', { hours })
|
||||
: t('REGIONAL NEWS UNAVAILABLE'),
|
||||
footer: newsWindowFooter(source, hours),
|
||||
articles,
|
||||
};
|
||||
}
|
||||
|
||||
export function renderRegionalBriefStatus(status, info) {
|
||||
const { news, local } = this.brief;
|
||||
news.statusHidden = false;
|
||||
@@ -220,7 +315,10 @@ export function renderRegionalBriefStatus(status, info) {
|
||||
status === 'loading'
|
||||
? t('ACQUIRING REGIONAL NEWS')
|
||||
: t('REGIONAL NEWS UNAVAILABLE');
|
||||
if (status === 'unavailable') news.articles = [];
|
||||
news.footer = newsWindowFooter();
|
||||
// Only called with no brief for this subject: any rows are another's.
|
||||
news.articles = [];
|
||||
if (this.briefPageIndex === 1) this.brief.source = news.footer;
|
||||
if (status === 'loading') local.place = t('RESOLVING REGION');
|
||||
if (status === 'unavailable') local.place = t('REGION UNAVAILABLE');
|
||||
local.coordinates = localCoordinates(info);
|
||||
@@ -228,7 +326,7 @@ export function renderRegionalBriefStatus(status, info) {
|
||||
}
|
||||
|
||||
export function renderRegionalBrief(payload, info) {
|
||||
const articles = Array.isArray(payload?.articles) ? payload.articles : [];
|
||||
const { state, status, footer, articles } = regionalNewsView(payload);
|
||||
const seen = new Map();
|
||||
const storyKey = (url) => {
|
||||
const count = seen.get(url) ?? 0;
|
||||
@@ -241,13 +339,11 @@ export function renderRegionalBrief(payload, info) {
|
||||
const placeLabel =
|
||||
payload?.place?.label || payload?.place?.country || t('REGION UNAVAILABLE');
|
||||
this.brief.news = {
|
||||
statusHidden: articles.length > 0,
|
||||
state: payload?.newsStatus || 'unavailable',
|
||||
status:
|
||||
payload?.newsStatus === 'empty'
|
||||
? t('NO RECENT LOCATION MATCHES')
|
||||
: t('REGIONAL NEWS UNAVAILABLE'),
|
||||
articles: articles.slice(0, 4).map((article) => ({
|
||||
statusHidden: state === 'ready',
|
||||
state,
|
||||
status,
|
||||
footer,
|
||||
articles: articles.map((article) => ({
|
||||
// A row keeps its node, and so its focus, only for the same story.
|
||||
key: storyKey(article.url),
|
||||
url: article.url,
|
||||
@@ -281,11 +377,7 @@ export function renderRegionalBrief(payload, info) {
|
||||
: '—',
|
||||
};
|
||||
this.brief.regionalStatus = payload?.status || 'partial';
|
||||
if (this.briefPageIndex === 1) {
|
||||
this.brief.source = t('{source} · LOCATION QUERY', {
|
||||
source: String(payload?.newsSource || t('REGIONAL NEWS')).toUpperCase(),
|
||||
});
|
||||
}
|
||||
if (this.briefPageIndex === 1) this.brief.source = footer;
|
||||
this.publishBriefView();
|
||||
this.scheduleContextLayout();
|
||||
}
|
||||
+365
-18
@@ -3,11 +3,14 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import { createBriefState } from './cockpitBriefPages.js';
|
||||
import {
|
||||
maybeRefreshRegionalBrief,
|
||||
publishBriefView,
|
||||
renderRegionalBrief,
|
||||
renderRegionalBriefStatus,
|
||||
@@ -88,10 +91,7 @@ test('pages, the cycle toggle and the source follow the controller', async (t) =
|
||||
await nextTick();
|
||||
assert.equal(text('#cockpit-brief-kicker'), 'REGIONAL NEWS');
|
||||
assert.equal(text('#cockpit-brief-position'), '2 / 3');
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'GOOGLE NEWS RSS · LOCATION QUERY · RECENT',
|
||||
);
|
||||
assert.equal(text('#cockpit-brief-source'), 'GOOGLE NEWS RSS · LAST 24 H');
|
||||
assert.deepEqual(visiblePages(), ['news']);
|
||||
assert.deepEqual(current(), ['false', 'true', 'false']);
|
||||
assert.equal($('#cockpit-signal-stream').dataset.briefPage, 'news');
|
||||
@@ -129,7 +129,8 @@ test('regional news and local conditions render what the region returned', async
|
||||
url: `https://example.com/${index}`,
|
||||
title: `Story ${index}`,
|
||||
domain: 'example.com',
|
||||
publishedAt: new Date().toISOString(),
|
||||
// Newest first is the shown order, so Story 0 is the newest.
|
||||
publishedAt: new Date(Date.now() - index * 60_000).toISOString(),
|
||||
})),
|
||||
weather: {
|
||||
temperatureC: 21.6,
|
||||
@@ -159,7 +160,7 @@ test('regional news and local conditions render what the region returned', async
|
||||
assert.equal(text('#cockpit-local-condition'), 'RAIN');
|
||||
assert.equal(text('#cockpit-local-cloud'), 'CLOUD 40%');
|
||||
assert.equal(text('#cockpit-local-precipitation'), '1.3');
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LOCATION QUERY');
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LAST 24 H');
|
||||
assert.equal($('#cockpit-signal-stream').dataset.regionalStatus, 'ok');
|
||||
renderRegionalBriefStatus.call(owner, 'unavailable', {});
|
||||
await nextTick();
|
||||
@@ -170,11 +171,15 @@ test('regional news and local conditions render what the region returned', async
|
||||
assert.equal(text('#cockpit-local-coordinates'), 'POSITION UNAVAILABLE');
|
||||
});
|
||||
|
||||
// One time for every story: newest-first order then keeps the order a test
|
||||
// lists them in. A clock read per story could tick between two of them and
|
||||
// swap them.
|
||||
const STORY_PUBLISHED_AT = new Date().toISOString();
|
||||
const story = (id, url = `https://example.com/${id}`) => ({
|
||||
url,
|
||||
title: `Story ${id}`,
|
||||
domain: 'example.com',
|
||||
publishedAt: new Date().toISOString(),
|
||||
publishedAt: STORY_PUBLISHED_AT,
|
||||
});
|
||||
|
||||
test('a refreshed news list keeps a focused story on its own link', async (t) => {
|
||||
@@ -210,26 +215,293 @@ test('a refreshed news list keeps a focused story on its own link', async (t) =>
|
||||
assert.equal($('#cockpit-news-list').textContent.includes('Story y'), true);
|
||||
});
|
||||
|
||||
test('the news source names the feed only while it is current on page 2', async (t) => {
|
||||
// This contract changed on purpose: the footer used to fall back to a
|
||||
// static "· RECENT" on every page change, which promised nothing. It now
|
||||
// follows the news state and names the window it holds articles to.
|
||||
test('the news footer follows the news state across page changes, not a static RECENT', async (t) => {
|
||||
const { text, owner } = fixture(t);
|
||||
showBriefPage.call(owner, 1);
|
||||
renderRegionalBrief.call(owner, { newsSource: 'wire', articles: [] }, INFO);
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'wire',
|
||||
newsWindowHours: 24,
|
||||
articles: [story('a')],
|
||||
},
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LOCATION QUERY');
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LAST 24 H');
|
||||
showBriefPage.call(owner, 2);
|
||||
showBriefPage.call(owner, 1);
|
||||
await nextTick();
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LAST 24 H');
|
||||
showBriefPage.call(owner, 0);
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'wire',
|
||||
newsWindowHours: 12,
|
||||
articles: [story('a')],
|
||||
},
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
// Off page 2 the footer is the current page's.
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'SOURCE-BACKED EVENTS · NO SYNTHETIC NEWS',
|
||||
);
|
||||
showBriefPage.call(owner, 1);
|
||||
await nextTick();
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LAST 12 H');
|
||||
});
|
||||
|
||||
test('the news banner is hidden by the stylesheet, not only by the attribute', async (t) => {
|
||||
// happy-dom applies no author CSS by itself, so `hidden` alone proves
|
||||
// nothing: `.cockpit-brief-status { display: grid }` used to beat it.
|
||||
const css = readFileSync(
|
||||
fileURLToPath(new URL('./styles/cockpit.css', import.meta.url)),
|
||||
'utf8',
|
||||
);
|
||||
assert.match(
|
||||
css,
|
||||
/\.cockpit-brief-status\[hidden\]\s*\{\s*display:\s*none;?\s*\}/,
|
||||
);
|
||||
const { $, owner } = fixture(t);
|
||||
const style = document.head.appendChild(document.createElement('style'));
|
||||
t.after(() => style.remove());
|
||||
style.textContent = css;
|
||||
showBriefPage.call(owner, 1);
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{ newsStatus: 'ready', articles: [story('a')] },
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
const banner = $('#cockpit-news-status');
|
||||
assert.equal(banner.hidden, true);
|
||||
assert.equal(getComputedStyle(banner).display, 'none');
|
||||
renderRegionalBrief.call(owner, { newsStatus: 'empty', articles: [] }, INFO);
|
||||
await nextTick();
|
||||
assert.equal(getComputedStyle(banner).display, 'grid');
|
||||
});
|
||||
|
||||
const hoursAgo = (hours) =>
|
||||
new Date(Date.now() - hours * 3_600_000).toISOString();
|
||||
|
||||
test('ready, cached, empty and unavailable each label the news differently', async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
showBriefPage.call(owner, 1);
|
||||
const rows = () =>
|
||||
[...document.querySelectorAll('#cockpit-news-list strong')].map(
|
||||
(row) => row.textContent,
|
||||
);
|
||||
const banner = () => ({
|
||||
hidden: $('#cockpit-news-status').hidden,
|
||||
state: $('#cockpit-news-status').dataset.state,
|
||||
text: text('#cockpit-news-status'),
|
||||
});
|
||||
const ready = {
|
||||
status: 'ready',
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'Google News RSS',
|
||||
newsWindowHours: 24,
|
||||
newsFetchedAt: hoursAgo(0.5),
|
||||
articles: [story('a'), story('b')],
|
||||
};
|
||||
renderRegionalBrief.call(owner, ready, INFO);
|
||||
await nextTick();
|
||||
assert.equal(banner().hidden, true);
|
||||
assert.equal(banner().state, 'ready');
|
||||
assert.deepEqual(rows(), ['Story a', 'Story b']);
|
||||
assert.equal(text('#cockpit-brief-source'), 'GOOGLE NEWS RSS · LAST 24 H');
|
||||
|
||||
// The local proxy's stale answer is a refresh that failed.
|
||||
renderRegionalBrief.call(owner, { ...ready, status: 'stale' }, INFO);
|
||||
await nextTick();
|
||||
assert.deepEqual(banner(), {
|
||||
hidden: false,
|
||||
state: 'cached',
|
||||
text: 'CACHED · REFRESH FAILED',
|
||||
});
|
||||
assert.deepEqual(rows(), ['Story a', 'Story b']);
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'GOOGLE NEWS RSS · CACHED 30M AGO',
|
||||
);
|
||||
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{
|
||||
...ready,
|
||||
newsStatus: 'empty',
|
||||
newsSource: 'Google News RSS',
|
||||
articles: [],
|
||||
},
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.deepEqual(banner(), {
|
||||
hidden: false,
|
||||
state: 'empty',
|
||||
text: 'NO NEWS IN THE LAST 24 H',
|
||||
});
|
||||
assert.deepEqual(rows(), []);
|
||||
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{ ...ready, newsStatus: 'unavailable', newsSource: null, articles: [] },
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.deepEqual(banner(), {
|
||||
hidden: false,
|
||||
state: 'unavailable',
|
||||
text: 'REGIONAL NEWS UNAVAILABLE',
|
||||
});
|
||||
assert.deepEqual(rows(), []);
|
||||
});
|
||||
|
||||
test('articles outside the window are dropped even when a server sends them', async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
showBriefPage.call(owner, 1);
|
||||
const dated = (id, publishedAt) => ({ ...story(id), publishedAt });
|
||||
// The reported case: 4, 104, 215 and 165 days old under "RECENT".
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{
|
||||
newsStatus: 'ready',
|
||||
articles: [
|
||||
dated('old', hoursAgo(4 * 24)),
|
||||
dated('older', hoursAgo(104 * 24)),
|
||||
dated('undated', null),
|
||||
dated('one', hoursAgo(20)),
|
||||
dated('two', hoursAgo(2)),
|
||||
],
|
||||
},
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.deepEqual(
|
||||
[...document.querySelectorAll('#cockpit-news-list strong')].map(
|
||||
(row) => row.textContent,
|
||||
),
|
||||
['Story two', 'Story one'],
|
||||
);
|
||||
assert.equal($('#cockpit-news-status').hidden, true);
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{ newsStatus: 'ready', articles: [dated('old', hoursAgo(25))] },
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.equal(document.querySelectorAll('#cockpit-news-list li').length, 0);
|
||||
assert.equal(text('#cockpit-news-status'), 'NO NEWS IN THE LAST 24 H');
|
||||
});
|
||||
|
||||
test('a failed refresh keeps the earlier articles as cached, and clears only when there are none', async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
const answers = [];
|
||||
Object.assign(owner, {
|
||||
active: true,
|
||||
regionalBriefSubjectId: null,
|
||||
regionalBriefAbort: null,
|
||||
regionalBriefRequestToken: 0,
|
||||
regionalBriefFetchedAt: 0,
|
||||
regionalBrief: null,
|
||||
renderRegionalBrief,
|
||||
renderRegionalBriefStatus,
|
||||
});
|
||||
owner.services = {
|
||||
...owner.services,
|
||||
regionalDistanceM: () => 0,
|
||||
fetchRegionalBrief: () => answers.shift()(),
|
||||
};
|
||||
const refresh = async (answer, info = { ...INFO, icao24: 'abc123' }) => {
|
||||
answers.push(answer);
|
||||
owner.regionalBriefFetchedAt = 0;
|
||||
maybeRefreshRegionalBrief.call(owner, info);
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
};
|
||||
const rows = () => document.querySelectorAll('#cockpit-news-list li').length;
|
||||
showBriefPage.call(owner, 1);
|
||||
|
||||
// No earlier brief: an error clears and says unavailable.
|
||||
await refresh(() => Promise.reject(new Error('503')));
|
||||
assert.equal($('#cockpit-news-status').dataset.state, 'unavailable');
|
||||
assert.equal(text('#cockpit-news-status'), 'REGIONAL NEWS UNAVAILABLE');
|
||||
assert.equal(rows(), 0);
|
||||
|
||||
const fetchedAt = hoursAgo(1);
|
||||
await refresh(() =>
|
||||
Promise.resolve({
|
||||
status: 'ready',
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'Google News RSS',
|
||||
newsWindowHours: 24,
|
||||
newsFetchedAt: fetchedAt,
|
||||
articles: [story('a'), story('b')],
|
||||
}),
|
||||
);
|
||||
assert.equal($('#cockpit-news-status').hidden, true);
|
||||
assert.equal(rows(), 2);
|
||||
|
||||
// A network failure keeps the rows and says so, with their age.
|
||||
await refresh(() => Promise.reject(new TypeError('Failed to fetch')));
|
||||
assert.equal($('#cockpit-news-status').hidden, false);
|
||||
assert.equal(text('#cockpit-news-status'), 'CACHED · REFRESH FAILED');
|
||||
assert.equal(rows(), 2);
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'GOOGLE NEWS RSS · CACHED 1H AGO',
|
||||
);
|
||||
showBriefPage.call(owner, 2);
|
||||
showBriefPage.call(owner, 1);
|
||||
await nextTick();
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'GOOGLE NEWS RSS · LOCATION QUERY · RECENT',
|
||||
'GOOGLE NEWS RSS · CACHED 1H AGO',
|
||||
);
|
||||
showBriefPage.call(owner, 0);
|
||||
renderRegionalBrief.call(owner, { newsSource: 'wire', articles: [] }, INFO);
|
||||
await nextTick();
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'SOURCE-BACKED EVENTS · NO SYNTHETIC NEWS',
|
||||
|
||||
// So does a brief whose news read failed while weather answered.
|
||||
await refresh(() =>
|
||||
Promise.resolve({
|
||||
status: 'partial',
|
||||
newsStatus: 'unavailable',
|
||||
articles: [],
|
||||
}),
|
||||
);
|
||||
assert.equal(text('#cockpit-news-status'), 'CACHED · REFRESH FAILED');
|
||||
assert.equal(rows(), 2);
|
||||
|
||||
// A successful refresh clears the cached label; a true empty clears rows.
|
||||
await refresh(() =>
|
||||
Promise.resolve({
|
||||
status: 'ready',
|
||||
newsStatus: 'empty',
|
||||
newsSource: 'Google News RSS',
|
||||
articles: [],
|
||||
}),
|
||||
);
|
||||
assert.equal(text('#cockpit-news-status'), 'NO NEWS IN THE LAST 24 H');
|
||||
assert.equal(rows(), 0);
|
||||
assert.equal(text('#cockpit-brief-source'), 'GOOGLE NEWS RSS · LAST 24 H');
|
||||
|
||||
// Another aircraft never inherits the last one's rows.
|
||||
await refresh(() =>
|
||||
Promise.resolve({ newsStatus: 'ready', articles: [story('c')] }),
|
||||
);
|
||||
assert.equal(rows(), 1);
|
||||
await refresh(() => Promise.reject(new Error('503')), {
|
||||
...INFO,
|
||||
icao24: 'def456',
|
||||
});
|
||||
assert.equal(text('#cockpit-news-status'), 'REGIONAL NEWS UNAVAILABLE');
|
||||
assert.equal(rows(), 0);
|
||||
});
|
||||
|
||||
test('an unchanged position publishes nothing new', (t) => {
|
||||
@@ -278,7 +550,10 @@ test('the card and its toggle render the collapse the controller presents', asyn
|
||||
await nextTick();
|
||||
assert.equal(card.dataset.collapsed, 'true');
|
||||
assert.equal(toggle.getAttribute('aria-expanded'), 'false');
|
||||
assert.equal(toggle.getAttribute('aria-label'), 'Expand cockpit briefing panel');
|
||||
assert.equal(
|
||||
toggle.getAttribute('aria-label'),
|
||||
'Expand cockpit briefing panel',
|
||||
);
|
||||
assert.equal(toggle.title, 'Expand briefing panel');
|
||||
assert.equal(toggle.textContent.trim(), 'right_panel_open');
|
||||
assert.equal(owner.signalUserCollapsed, true);
|
||||
@@ -287,3 +562,75 @@ test('the card and its toggle render the collapse the controller presents', asyn
|
||||
assert.equal(card.dataset.collapsed, 'false');
|
||||
assert.equal(toggle.textContent.trim(), 'right_panel_close');
|
||||
});
|
||||
|
||||
test("a refresh that fails after a move never shows the last location's brief as current", async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
const answers = [];
|
||||
Object.assign(owner, {
|
||||
active: true,
|
||||
regionalBriefSubjectId: null,
|
||||
regionalBriefAbort: null,
|
||||
regionalBriefRequestToken: 0,
|
||||
regionalBriefFetchedAt: 0,
|
||||
regionalBrief: null,
|
||||
renderRegionalBrief,
|
||||
renderRegionalBriefStatus,
|
||||
});
|
||||
owner.services = {
|
||||
...owner.services,
|
||||
// One degree of latitude stands for a move past the refresh distance.
|
||||
regionalDistanceM: (from, to) =>
|
||||
from ? Math.abs(from.latitude - to.latitude) * 111_000 : Infinity,
|
||||
fetchRegionalBrief: () => answers.shift()(),
|
||||
};
|
||||
const refresh = async (answer, latitude) => {
|
||||
answers.push(answer);
|
||||
owner.regionalBriefFetchedAt = 0;
|
||||
maybeRefreshRegionalBrief.call(owner, {
|
||||
...INFO,
|
||||
icao24: 'abc123',
|
||||
latitude,
|
||||
});
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
};
|
||||
const rows = () => document.querySelectorAll('#cockpit-news-list li').length;
|
||||
const here = () =>
|
||||
Promise.resolve({
|
||||
status: 'ready',
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'Google News RSS',
|
||||
newsWindowHours: 24,
|
||||
newsFetchedAt: hoursAgo(1),
|
||||
articles: [story('a'), story('b')],
|
||||
});
|
||||
showBriefPage.call(owner, 1);
|
||||
|
||||
await refresh(here, 40);
|
||||
assert.equal(rows(), 2);
|
||||
// The same place: a failed refresh keeps the rows as cached.
|
||||
await refresh(() => Promise.reject(new TypeError('Failed to fetch')), 40);
|
||||
assert.equal(text('#cockpit-news-status'), 'CACHED · REFRESH FAILED');
|
||||
assert.equal(rows(), 2);
|
||||
// Elsewhere: the brief is unavailable, as it was before there was a cache.
|
||||
await refresh(() => Promise.reject(new TypeError('Failed to fetch')), 45);
|
||||
assert.equal($('#cockpit-news-status').dataset.state, 'unavailable');
|
||||
assert.equal(rows(), 0);
|
||||
// Nor is it held, for a language change to show again.
|
||||
assert.equal(owner.regionalBrief, null);
|
||||
|
||||
// Nor does a brief there whose news read failed borrow the last place's rows.
|
||||
await refresh(here, 40);
|
||||
assert.equal(rows(), 2);
|
||||
await refresh(
|
||||
() =>
|
||||
Promise.resolve({
|
||||
status: 'partial',
|
||||
newsStatus: 'unavailable',
|
||||
articles: [],
|
||||
}),
|
||||
45,
|
||||
);
|
||||
assert.equal($('#cockpit-news-status').dataset.state, 'unavailable');
|
||||
assert.equal(rows(), 0);
|
||||
});
|
||||
@@ -128,7 +128,7 @@ function vesselSurfaceM(info, nowMs, at = info) {
|
||||
: 0;
|
||||
const scene = this.viewer.scene;
|
||||
let read =
|
||||
this.vesselWaterline?.mmsi === info.mmsi ? this.vesselWaterline : null;
|
||||
this.vesselWaterline?.vesselId === info.id ? this.vesselWaterline : null;
|
||||
if (
|
||||
typeof scene?.sampleHeightMostDetailed === 'function' &&
|
||||
(!read || nowMs - read.sampledMs >= VESSEL_WATERLINE_REFRESH_MS)
|
||||
@@ -138,7 +138,7 @@ function vesselSurfaceM(info, nowMs, at = info) {
|
||||
);
|
||||
if (!read) {
|
||||
read = {
|
||||
mmsi: info.mmsi,
|
||||
vesselId: info.id,
|
||||
heightM: loadedWaterlineM(scene, probes, seaM),
|
||||
sampledMs: nowMs,
|
||||
// Whether a full-detail read has answered for this ship.
|
||||
@@ -219,7 +219,7 @@ function updateVessel(nowMs) {
|
||||
return;
|
||||
}
|
||||
const info = this.readVesselInfo();
|
||||
if (!info || info.mmsi !== this.subjectId) {
|
||||
if (!info || info.id !== this.subjectId) {
|
||||
this.exit({ restoreTracking: false });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ export class CockpitViewController {
|
||||
*/
|
||||
this.subjectKind = null;
|
||||
/**
|
||||
* The vessel subject's MMSI or the satellite's NORAD id; aircraft are
|
||||
* The vessel subject's id or the satellite's NORAD id; aircraft are
|
||||
* identified by trackedEntity.
|
||||
*/
|
||||
this.subjectId = null;
|
||||
|
||||
@@ -255,7 +255,7 @@ export class CockpitCoordinator {
|
||||
: vessel
|
||||
? {
|
||||
kind: 'vessel',
|
||||
id: vessel.mmsi,
|
||||
id: vessel.id,
|
||||
layerId: vessel.layerId,
|
||||
callsign: null,
|
||||
name: vessel.name,
|
||||
|
||||
@@ -83,8 +83,10 @@ export function onScenePointerDown(nowMs = performance.now()) {
|
||||
return;
|
||||
}
|
||||
const at = subjectCanvasPosition.call(this);
|
||||
const mmsi = this.readVesselInfo()?.mmsi ?? null;
|
||||
this.doubleClickStart = at ? { x: at.x, y: at.y, atMs: nowMs, mmsi } : null;
|
||||
const vesselId = this.readVesselInfo()?.id ?? null;
|
||||
this.doubleClickStart = at
|
||||
? { x: at.x, y: at.y, atMs: nowMs, vesselId }
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +113,7 @@ export function onSceneDoubleClick(position, nowMs = performance.now()) {
|
||||
// The memory is the ship's it was taken for: one followed since (an
|
||||
// aircraft, another ship) is hit only where it is drawn.
|
||||
this.resolveEntryKind() === 'vessel' &&
|
||||
start.mmsi === (this.readVesselInfo()?.mmsi ?? null) &&
|
||||
start.vesselId === (this.readVesselInfo()?.id ?? null) &&
|
||||
doubleClickHitsSubject(position, start));
|
||||
if (!hit) return false;
|
||||
this.enter();
|
||||
|
||||
@@ -65,7 +65,12 @@ export function resolveEntryKind() {
|
||||
|
||||
export function dispatchCockpitModeChanged(active, info = null) {
|
||||
const subjectId = active
|
||||
? String(info?.icao24 || info?.mmsi || info?.noradId || '')
|
||||
? String(
|
||||
info?.icao24 ||
|
||||
(info?.kind === 'vessel' ? info.id : '') ||
|
||||
info?.noradId ||
|
||||
'',
|
||||
)
|
||||
.trim()
|
||||
.toLowerCase() || null
|
||||
: null;
|
||||
@@ -245,7 +250,7 @@ export function enter({ kind = null } = {}) {
|
||||
// Each session reads its own water: never a height left from the last.
|
||||
this.vesselWaterline = null;
|
||||
this.vesselFix = null;
|
||||
this.subjectId = vessel ? info.mmsi : satellite ? info.noradId : null;
|
||||
this.subjectId = vessel ? info.id : satellite ? info.noradId : null;
|
||||
this.trackedEntity = entity;
|
||||
if (entity) {
|
||||
this.trackedEntityWasShown = entity.show;
|
||||
@@ -255,7 +260,7 @@ export function enter({ kind = null } = {}) {
|
||||
this.services.satellitesLayer?.setCockpitSubject?.(info.noradId);
|
||||
this.beginOrbital();
|
||||
} else {
|
||||
this.services.aisLiveVesselsLayer?.setCockpitSubject?.(info.mmsi);
|
||||
this.services.aisLiveVesselsLayer?.setCockpitSubject?.(info.id);
|
||||
}
|
||||
// A ship reporting neither heading nor course keeps the camera's own
|
||||
// heading: no direction is made up for it.
|
||||
|
||||
@@ -147,6 +147,15 @@ export class LayerBindings {
|
||||
fires.attachShellServices({ imageryHost: this.services.imageryHost });
|
||||
this._weatherShellModules.push(fires);
|
||||
}
|
||||
// News flies to a chosen report or hotspot through the same release.
|
||||
const news = this._dataManager?.layers?.get('news')?.module;
|
||||
if (typeof news?.attachShellServices === 'function') {
|
||||
news.attachShellServices({
|
||||
runNavigation: (navigate) =>
|
||||
this.runImmediateNavigation('news', navigate),
|
||||
});
|
||||
this._weatherShellModules.push(news);
|
||||
}
|
||||
}
|
||||
|
||||
_persistAwarenessSelection(event, cleared = false) {
|
||||
|
||||
@@ -38,6 +38,8 @@ export const LAYER_NAME_KEYS = Object.freeze({
|
||||
'drone-airspace': msg('Prohibited & Restricted Airspace'),
|
||||
'wildlife-sightings': msg('Wildlife Sightings'),
|
||||
's2-ghostmaps': msg('S2 GhostMaps'),
|
||||
news: msg('News'),
|
||||
shipwrecks: msg('Shipwrecks'),
|
||||
wind: msg('Wind'),
|
||||
'weather-radar': msg('Rain radar'),
|
||||
'weather-satellite': msg('Satellite clouds'),
|
||||
|
||||
+57
-9
@@ -11,14 +11,18 @@ import {
|
||||
} from './layerNames.js';
|
||||
export { localizeLayerName } from './layerNames.js';
|
||||
import { createWeatherPanel } from './weatherPanel.js';
|
||||
import { translateFeedError, translateStatusLine } from './statusText.js';
|
||||
import { createNewsPanel } from './newsPanel.js';
|
||||
import {
|
||||
translateFeedError,
|
||||
translateStatusLine,
|
||||
translateStatusMessage,
|
||||
} from './statusText.js';
|
||||
import {
|
||||
formatNumber,
|
||||
getLocale,
|
||||
msg,
|
||||
onLocaleChange,
|
||||
t,
|
||||
translateKnown,
|
||||
} from '../i18n/index.js';
|
||||
|
||||
// Feed-state values are machine ids (QA hooks, CSS feed-* classes); only the
|
||||
@@ -78,6 +82,8 @@ const PANEL_GROUPS = [
|
||||
'fire-perimeters',
|
||||
'gnss-integrity',
|
||||
's2-ghostmaps',
|
||||
'shipwrecks',
|
||||
'news',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -314,6 +320,11 @@ export class LayerPanel {
|
||||
container?.ownerDocument?.getElementById?.('weather-panel-body'),
|
||||
setLayerParams: this.setLayerParams,
|
||||
});
|
||||
this._newsPanel?.destroy();
|
||||
this._newsPanel = createNewsPanel({
|
||||
container: container?.ownerDocument?.getElementById?.('news-panel-body'),
|
||||
setLayerParams: this.setLayerParams,
|
||||
});
|
||||
this._mountRecentImagery();
|
||||
this._renderToggles();
|
||||
}
|
||||
@@ -349,6 +360,8 @@ export class LayerPanel {
|
||||
this._releaseBindings();
|
||||
this._weatherPanel?.destroy();
|
||||
this._weatherPanel = null;
|
||||
this._newsPanel?.destroy();
|
||||
this._newsPanel = null;
|
||||
this._recentImageryPanel?.destroy();
|
||||
this._recentImageryPanel = null;
|
||||
this._recentImageryFactory = null;
|
||||
@@ -413,10 +426,12 @@ export class LayerPanel {
|
||||
onLocaleChange(() => {
|
||||
this._paint();
|
||||
this._refreshWeatherPanel();
|
||||
this._refreshNewsPanel();
|
||||
}),
|
||||
);
|
||||
this._paint();
|
||||
this._refreshWeatherPanel();
|
||||
this._refreshNewsPanel();
|
||||
}
|
||||
|
||||
/** Present every row from the layers' current state and render them. */
|
||||
@@ -448,6 +463,8 @@ export class LayerPanel {
|
||||
this._selectListItem(layerId, itemId, generation),
|
||||
onSlider: (layerId, sliderId, value) =>
|
||||
this._moveSlider(layerId, sliderId, value, generation),
|
||||
onRange: (layerId, rangeId, end, value) =>
|
||||
this._pickRangeEnd(layerId, rangeId, end, value, generation),
|
||||
}),
|
||||
id === null ? this._toggleContainer : this._groupContainers.get(id),
|
||||
);
|
||||
@@ -477,7 +494,7 @@ export class LayerPanel {
|
||||
}
|
||||
|
||||
/**
|
||||
* A layer's row chips, one-of-many switch, slider, color legend, info line
|
||||
* A layer's row chips, one-of-many switch, slider, start/end pickers, 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
|
||||
@@ -504,6 +521,7 @@ export class LayerPanel {
|
||||
const infoText = controls?.info ? String(controls.info) : '';
|
||||
const segmented = controls?.segmented || null;
|
||||
const slider = controls?.slider || null;
|
||||
const range = controls?.range || null;
|
||||
// The info line, once shown, stays in place and hides when empty.
|
||||
if (infoText) row.info = true;
|
||||
return {
|
||||
@@ -512,10 +530,12 @@ export class LayerPanel {
|
||||
legend.length === 0 &&
|
||||
!infoText &&
|
||||
!segmented &&
|
||||
!slider,
|
||||
!slider &&
|
||||
!range,
|
||||
chips,
|
||||
segmented,
|
||||
slider,
|
||||
range,
|
||||
legend,
|
||||
info: row.info
|
||||
? { text: infoText, title: controls?.infoTitle || '' }
|
||||
@@ -580,6 +600,20 @@ export class LayerPanel {
|
||||
this.setLayerParams(id, slider.params(value), { origin: 'user' });
|
||||
}
|
||||
|
||||
_pickRangeEnd(id, rangeId, end, value, generation = this._generation) {
|
||||
if (this._destroyed || this._generation !== generation) return;
|
||||
const range = this._rowControlsFor(id)?.range;
|
||||
if (
|
||||
!range ||
|
||||
range.id !== rangeId ||
|
||||
(end !== 'from' && end !== 'to') ||
|
||||
typeof range.params !== 'function' ||
|
||||
!this.isEnabled(id)
|
||||
)
|
||||
return;
|
||||
this.setLayerParams(id, range.params(end, value), { origin: 'user' });
|
||||
}
|
||||
|
||||
_selectListItem(id, itemId, generation = this._generation) {
|
||||
if (this._destroyed || this._generation !== generation) return;
|
||||
const item = this._rowControlsFor(id)?.list?.items?.find(
|
||||
@@ -645,6 +679,15 @@ export class LayerPanel {
|
||||
}
|
||||
this._paint();
|
||||
this._refreshWeatherPanel();
|
||||
this._refreshNewsPanel();
|
||||
}
|
||||
|
||||
/** Feed the News rail panel the view the news layer publishes while on. */
|
||||
_refreshNewsPanel() {
|
||||
const layer = this.getAll().find(({ id }) => id === 'news');
|
||||
this._newsPanel?.update(
|
||||
layer?.enabled ? this._rowControlsFor(layer.id)?.feed || null : null,
|
||||
);
|
||||
}
|
||||
|
||||
_buildMetaText(layer) {
|
||||
@@ -695,9 +738,11 @@ export class LayerPanel {
|
||||
typeof stats.statusMessage === 'string' &&
|
||||
stats.statusMessage.trim()
|
||||
) {
|
||||
return `${source} · ${translateKnown(stats.statusMessage.trim())}`;
|
||||
return `${source} · ${translateStatusMessage(stats.statusMessage.trim())}`;
|
||||
}
|
||||
const ago = stats.lastUpdate ? this._timeAgo(stats.lastUpdate) : t('never');
|
||||
const ago = stats.lastUpdate
|
||||
? this._timeAgo(stats.lastUpdate, stats.atMs)
|
||||
: t('never');
|
||||
if (stats.loading) {
|
||||
const loadingLabel =
|
||||
typeof stats.loadingLabel === 'string' && stats.loadingLabel.trim()
|
||||
@@ -740,7 +785,7 @@ export class LayerPanel {
|
||||
// row by the oldest of it, not by the load that re-served it.
|
||||
const dataAgo =
|
||||
Number(stats.oldestTileAt) > 0
|
||||
? this._timeAgo(stats.oldestTileAt)
|
||||
? this._timeAgo(stats.oldestTileAt, stats.atMs)
|
||||
: ago;
|
||||
if (typeof stats.retryInSec === 'number' && stats.retryInSec > 0) {
|
||||
return t('{state} · {source} · {ago} · retrying in {seconds}s', {
|
||||
@@ -765,8 +810,11 @@ export class LayerPanel {
|
||||
return t('{source} · {ago}', { source, ago });
|
||||
}
|
||||
|
||||
_timeAgo(timestamp) {
|
||||
const diff = Math.floor((Date.now() - timestamp) / 1000);
|
||||
/** How long before `nowMs` (the layer's world time, else the wall clock). */
|
||||
_timeAgo(timestamp, nowMs) {
|
||||
const diff = Math.floor(
|
||||
((Number.isFinite(nowMs) ? nowMs : Date.now()) - timestamp) / 1000,
|
||||
);
|
||||
if (diff < 5) return t('just now');
|
||||
if (diff < 60) return t('{count}s ago', { count: diff });
|
||||
if (diff < 3600) return t('{count}m ago', { count: Math.floor(diff / 60) });
|
||||
|
||||
@@ -50,7 +50,8 @@ test('Wildlife follows Events and precedes Weather', () => {
|
||||
);
|
||||
const wildlife = order.findIndex(({ id }) => id === 'wildlife-sightings');
|
||||
assert.equal(order[wildlife].label, 'Wildlife');
|
||||
assert.equal(order[wildlife - 1].id, 's2-ghostmaps');
|
||||
// News is the last of Events.
|
||||
assert.equal(order[wildlife - 1].id, 'news');
|
||||
assert.equal(order[wildlife + 1].id, 'air-quality');
|
||||
assert.equal(order.filter(({ id }) => id === 'wildlife-sightings').length, 1);
|
||||
});
|
||||
@@ -452,3 +453,57 @@ test('without the Utilities list, Directions stays in Data Layers under Utilitie
|
||||
restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('a layer with no feed in view says why instead of "never"', async () => {
|
||||
const { LayerPanel, presentLayerCount, presentLayerToggle } =
|
||||
await import('./layerPanel.js');
|
||||
const { setLocale } = await import('../i18n/index.js');
|
||||
const panel = LayerPanel.prototype;
|
||||
const rows = [
|
||||
{
|
||||
id: 'transit',
|
||||
name: 'Transit',
|
||||
source: 'GTFS-RT',
|
||||
enabled: true,
|
||||
stats: {
|
||||
count: 0,
|
||||
lastUpdate: null,
|
||||
source: 'GTFS-RT',
|
||||
status: 'zoom-in',
|
||||
statusMessage: 'No feed here yet · 16 regions available',
|
||||
},
|
||||
meta: 'GTFS-RT · No feed here yet · 16 regions available',
|
||||
},
|
||||
{
|
||||
id: 'bikeshare',
|
||||
name: 'Bikeshare',
|
||||
source: 'GBFS',
|
||||
enabled: true,
|
||||
stats: {
|
||||
count: 0,
|
||||
lastUpdate: null,
|
||||
loading: false,
|
||||
status: 'zoom-in',
|
||||
statusMessage: 'Fly below 48 km to a covered city',
|
||||
},
|
||||
meta: 'GBFS · Fly below 48 km to a covered city',
|
||||
},
|
||||
];
|
||||
for (const layer of rows) {
|
||||
// Guidance is normal operation: the layer is on and nothing has failed.
|
||||
assert.equal(presentLayerToggle(layer).text, 'ON');
|
||||
assert.equal(presentLayerCount(layer.stats).empty, true);
|
||||
assert.equal(panel._buildMetaText(layer), layer.meta);
|
||||
}
|
||||
|
||||
setLocale('ru');
|
||||
try {
|
||||
for (const layer of rows) {
|
||||
const meta = panel._buildMetaText(layer);
|
||||
assert.doesNotMatch(meta, /never|Fly below|No feed|covered/, meta);
|
||||
assert.match(meta, /^(GTFS-RT|GBFS) · /, meta);
|
||||
}
|
||||
} finally {
|
||||
setLocale('en');
|
||||
}
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
import RailChips from '../rail/RailChips.vue';
|
||||
import RailRowList from '../rail/RailRowList.vue';
|
||||
import RowRange from './RowRange.vue';
|
||||
import RowSlider from './RowSlider.vue';
|
||||
import RowSwitch from './RowSwitch.vue';
|
||||
import RowText from './RowText.vue';
|
||||
@@ -15,6 +16,7 @@ defineProps({
|
||||
onChip: { type: Function, default: () => {} },
|
||||
onListItem: { type: Function, default: () => {} },
|
||||
onSlider: { type: Function, default: () => {} },
|
||||
onRange: { type: Function, default: () => {} },
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -68,6 +70,13 @@ defineProps({
|
||||
:on-input="
|
||||
(value) => onSlider(item.id, item.controls.slider.id, value)
|
||||
"
|
||||
/><RowRange
|
||||
v-if="item.controls.range"
|
||||
:range="item.controls.range"
|
||||
:on-select="
|
||||
(end, value) =>
|
||||
onRange(item.id, item.controls.range.id, end, value)
|
||||
"
|
||||
/><span
|
||||
v-for="(entry, index) in item.controls.legend"
|
||||
:key="index"
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup>
|
||||
// A row's start and end pickers on one line (e.g. the Shipwrecks period).
|
||||
// Both ends share one option list; `onSelect` reports which end moved
|
||||
// ('from' or 'to') and the chosen option value.
|
||||
defineProps({
|
||||
range: { type: Object, required: true },
|
||||
onSelect: { type: Function, default: () => {} },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="data-toggle-range" :data-range-id="range.id"
|
||||
><div class="data-toggle-slider-head"
|
||||
><span class="data-toggle-slider-label">{{ range.label }}</span
|
||||
><span class="data-toggle-slider-value gev-slider-value">{{
|
||||
range.valueText
|
||||
}}</span></div
|
||||
><div class="data-toggle-range-ends"
|
||||
><label
|
||||
v-for="end in ['from', 'to']"
|
||||
:key="end"
|
||||
class="data-toggle-range-end"
|
||||
><span class="data-toggle-range-caption">{{ range[end].label }}</span
|
||||
><select
|
||||
class="data-toggle-range-select"
|
||||
:data-range-end="end"
|
||||
:aria-label="range[end].ariaLabel || undefined"
|
||||
:value="String(range[end].value)"
|
||||
@change="onSelect(end, $event.target.value)"
|
||||
><option
|
||||
v-for="option in range.options"
|
||||
:key="option.value"
|
||||
:value="String(option.value)"
|
||||
>{{ option.label }}</option
|
||||
></select
|
||||
></label
|
||||
></div
|
||||
></div
|
||||
>
|
||||
</template>
|
||||
@@ -159,3 +159,62 @@ test('a row switch and slider render their markup and report choices', () => {
|
||||
assert.equal(segments[1].classList.contains('active'), true);
|
||||
render(null, container);
|
||||
});
|
||||
|
||||
test('a row range renders start and end pickers and reports which end moved', () => {
|
||||
document.body.replaceChildren();
|
||||
const container = document.body.appendChild(document.createElement('div'));
|
||||
const picks = [];
|
||||
const item = {
|
||||
...row(false),
|
||||
key: 'shipwrecks',
|
||||
id: 'shipwrecks',
|
||||
controls: {
|
||||
hidden: false,
|
||||
chips: [],
|
||||
segmented: null,
|
||||
slider: null,
|
||||
range: {
|
||||
id: 'period',
|
||||
label: 'Period',
|
||||
valueText: '2010–2024',
|
||||
from: { label: 'From', ariaLabel: 'First year', value: 2010 },
|
||||
to: { label: 'To', ariaLabel: 'Last year', value: 2024 },
|
||||
options: [2024, 2010, 2007].map((year) => ({
|
||||
value: year,
|
||||
label: String(year),
|
||||
})),
|
||||
},
|
||||
legend: [],
|
||||
info: null,
|
||||
list: null,
|
||||
},
|
||||
};
|
||||
render(
|
||||
h(LayerRows, {
|
||||
items: [item],
|
||||
onRange: (id, rangeId, end, value) =>
|
||||
picks.push([id, rangeId, end, value]),
|
||||
}),
|
||||
container,
|
||||
);
|
||||
const block = container.querySelector('.data-toggle-range');
|
||||
assert.equal(block.dataset.rangeId, 'period');
|
||||
assert.equal(
|
||||
block.querySelector('.data-toggle-slider-value').textContent,
|
||||
'2010–2024',
|
||||
);
|
||||
const [from, to] = block.querySelectorAll('select.data-toggle-range-select');
|
||||
assert.equal(from.getAttribute('aria-label'), 'First year');
|
||||
assert.equal(from.value, '2010');
|
||||
assert.equal(to.value, '2024');
|
||||
assert.deepEqual(
|
||||
[...block.querySelectorAll('.data-toggle-range-caption')].map(
|
||||
(caption) => caption.textContent,
|
||||
),
|
||||
['From', 'To'],
|
||||
);
|
||||
to.value = '2007';
|
||||
to.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
assert.deepEqual(picks, [['shipwrecks', 'period', 'to', '2007']]);
|
||||
render(null, container);
|
||||
});
|
||||
@@ -53,6 +53,7 @@ test('the current language comes first, the rest by their own names', () => {
|
||||
'it',
|
||||
'pt',
|
||||
'sv',
|
||||
'he',
|
||||
'ar',
|
||||
'zh-CN',
|
||||
'zh-Hant',
|
||||
@@ -77,6 +78,7 @@ test('the current language comes first, the rest by their own names', () => {
|
||||
'sv',
|
||||
'ru',
|
||||
'uk',
|
||||
'he',
|
||||
'ar',
|
||||
'zh-CN',
|
||||
'zh-Hant',
|
||||
@@ -101,6 +103,7 @@ test('the current language comes first, the rest by their own names', () => {
|
||||
'sv',
|
||||
'ru',
|
||||
'uk',
|
||||
'he',
|
||||
'ar',
|
||||
'zh-CN',
|
||||
'zh-Hant',
|
||||
@@ -126,6 +129,7 @@ test('the current language comes first, the rest by their own names', () => {
|
||||
'sv',
|
||||
'ru',
|
||||
'uk',
|
||||
'he',
|
||||
'zh-CN',
|
||||
'zh-Hant',
|
||||
'ja',
|
||||
|
||||
@@ -977,3 +977,20 @@ test('a slow downward pull is claimed before Android native scroll takes ownersh
|
||||
assert.equal(shell.getSheet(), null);
|
||||
shell.destroy();
|
||||
});
|
||||
|
||||
test('on phones the News panel shows in the Context sheet only, like Weather', () => {
|
||||
const css = readFileSync(
|
||||
new URL('./styles/mobile-shell.css', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
// Hidden by id: the rail's own `#news-panel:not(.collapsed)` rule outranks
|
||||
// the generic `#right-context-rail > *` hiding rule.
|
||||
assert.match(
|
||||
css,
|
||||
/body\.mobile-shell #right-context-rail > #news-panel,\n[^{}]*\{\s*display: none;/,
|
||||
);
|
||||
assert.match(
|
||||
css,
|
||||
/body\.mobile-shell\[data-mobile-sheet='context'\]\s+#right-context-rail\s+> #news-panel:not\(\[hidden\]\),/,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,159 @@
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
|
||||
// One event in the News panel: the publisher's
|
||||
// picture when the event has one, the headline, a mono meta line (severity
|
||||
// marker, category, place, sources, age), who reported it, its attestation
|
||||
// and media chips, and the service it came through ("via …"), which some ask
|
||||
// to be credited wherever their reports show. A click chooses it (the layer
|
||||
// flies there and opens its card on the globe); open, it plays the post's
|
||||
// clip when it has one (on request, with sound and controls), and shows the
|
||||
// summary, the other sides' reports and the link to the original article.
|
||||
// The layer computes every value shown (feedCardView in
|
||||
// src/layers/news/model.js).
|
||||
const props = defineProps({
|
||||
item: { type: Object, required: true },
|
||||
open: { type: Boolean, default: false },
|
||||
onChoose: { type: Function, default: () => {} },
|
||||
onClear: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
// A picture the publisher no longer serves leaves the card without one.
|
||||
const pictureFailed = ref(false);
|
||||
const dropPicture = () => {
|
||||
pictureFailed.value = true;
|
||||
};
|
||||
// So does a clip whose signed link has expired.
|
||||
const clipFailed = ref(false);
|
||||
const dropClip = () => {
|
||||
clipFailed.value = true;
|
||||
};
|
||||
watch(
|
||||
() => props.item.picture?.url,
|
||||
() => {
|
||||
pictureFailed.value = false;
|
||||
clipFailed.value = false;
|
||||
},
|
||||
);
|
||||
const meta = () =>
|
||||
[
|
||||
props.item.category,
|
||||
props.item.place &&
|
||||
(props.item.placedByModel
|
||||
? t('{place} (placed by model)', { place: props.item.place })
|
||||
: props.item.place),
|
||||
props.item.sources,
|
||||
props.item.age,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article
|
||||
class="news-card"
|
||||
:class="{ 'is-open': open, 'is-unmapped': !item.mappable }"
|
||||
:data-report-id="item.id"
|
||||
:style="{ '--news-color': item.color }"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="news-card__main ui-focus"
|
||||
:aria-expanded="open ? 'true' : 'false'"
|
||||
@click="onChoose(item)"
|
||||
>
|
||||
<span v-if="item.picture && !pictureFailed" class="news-card__thumb"
|
||||
><img
|
||||
:src="item.picture.url"
|
||||
alt=""
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
referrerpolicy="no-referrer"
|
||||
v-on="{ error: dropPicture }"
|
||||
/><span
|
||||
v-if="item.picture.video && !clipFailed"
|
||||
class="news-card__play"
|
||||
role="img"
|
||||
:aria-label="t('Video')"
|
||||
>▶</span
|
||||
><span v-if="item.picture.credit" class="news-card__credit">{{
|
||||
item.picture.credit
|
||||
}}</span></span
|
||||
>
|
||||
<span class="news-card__title">{{ item.title }}</span>
|
||||
<span v-if="item.original" class="news-card__note">{{
|
||||
t('English headline by the model')
|
||||
}}</span>
|
||||
<span class="news-card__meta ui-mono"
|
||||
><span
|
||||
class="news-card__marker"
|
||||
:class="{ solid: item.solid }"
|
||||
role="img"
|
||||
:aria-label="item.severityLabel"
|
||||
:title="item.severityLabel"
|
||||
><svg viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path :d="item.icon" /></svg></span
|
||||
><span v-if="item.severity >= 2" class="news-card__severity">{{
|
||||
item.severityLabel
|
||||
}}</span
|
||||
>{{ item.severity >= 2 ? ` · ${meta()}` : meta() }}</span
|
||||
>
|
||||
<span v-if="item.sides" class="news-card__sides">{{ item.sides }}</span>
|
||||
<span v-if="item.chips.length" class="news-card__chips"
|
||||
><span
|
||||
v-for="chip in item.chips"
|
||||
:key="`${chip.kind}:${chip.label}`"
|
||||
class="news-chip"
|
||||
:class="`news-chip--${chip.kind}`"
|
||||
>{{ chip.label }}</span
|
||||
></span
|
||||
>
|
||||
<span v-if="item.via" class="news-card__via ui-mono">{{ item.via }}</span>
|
||||
</button>
|
||||
<div v-if="open" class="news-card__open">
|
||||
<video
|
||||
v-if="item.picture?.video && !clipFailed"
|
||||
class="news-card__clip"
|
||||
:src="item.picture.video"
|
||||
:poster="pictureFailed ? undefined : item.picture.url"
|
||||
controls
|
||||
playsinline
|
||||
preload="none"
|
||||
referrerpolicy="no-referrer"
|
||||
v-on="{ error: dropClip }"
|
||||
></video>
|
||||
<p v-if="item.original" class="news-card__original">{{
|
||||
item.original
|
||||
}}</p>
|
||||
<p v-if="item.snippet" class="news-card__snippet">{{ item.snippet }}</p>
|
||||
<p v-if="!item.mappable" class="news-card__note">
|
||||
{{ t('Not placed on the map') }}
|
||||
</p>
|
||||
<ul v-if="item.others.length" class="news-card__others">
|
||||
<li v-for="other in item.others" :key="other.url">
|
||||
<span class="news-card__side ui-mono">{{ other.side }}</span
|
||||
><a :href="other.url" target="_blank" rel="noopener noreferrer"
|
||||
>{{ other.publisher }}: {{ other.title }}</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="news-card__actions">
|
||||
<a
|
||||
class="news-card__link"
|
||||
:href="item.url"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>{{ item.sourceLink }}</a
|
||||
>
|
||||
<UiButton
|
||||
class="data-toggle-chip news-card__clear"
|
||||
type="button"
|
||||
@click="onClear()"
|
||||
>{{ t('Close') }}</UiButton
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
@@ -0,0 +1,294 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiEmpty from '../kit/UiEmpty.vue';
|
||||
import UiSelect from '../kit/UiSelect.js';
|
||||
import RailChips from '../rail/RailChips.vue';
|
||||
import NewsCard from './NewsCard.vue';
|
||||
|
||||
// The News panel: the window the server serves only (the last 24 hours, or
|
||||
// fewer where the host serves less), or a shorter one chosen at the
|
||||
// top (24/12/6/3/1 h), and two sections. Conflicts: hotspot chips, the
|
||||
// severity floor, the chosen event and a continuous feed, newest first.
|
||||
// Local: every report in the area at the view centre (its country, a large
|
||||
// country's state; within a radius at sea) while the camera is low, named at
|
||||
// the top, which the map then shows, outlined, instead of the hotspots' news.
|
||||
// A section read from a key the server lacks (or whose allowance for the day
|
||||
// is spent) says which key instead. It
|
||||
// renders the `feed` view the news layer publishes and acts only through
|
||||
// `onParams`.
|
||||
const props = defineProps({
|
||||
view: { type: Object, default: null },
|
||||
onParams: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
const filters = computed(() => props.view?.filters ?? {});
|
||||
const local = computed(() => filters.value.section === 'local');
|
||||
const sections = computed(() =>
|
||||
[
|
||||
{ id: 'conflicts', label: t('Conflicts') },
|
||||
{ id: 'local', label: t('Local') },
|
||||
].map((chip) => ({
|
||||
...chip,
|
||||
active: (filters.value.section ?? 'conflicts') === chip.id,
|
||||
})),
|
||||
);
|
||||
const chips = computed(() =>
|
||||
(props.view?.hotspots ?? []).map((chip) => ({
|
||||
id: chip.id,
|
||||
label: `${chip.label} ${chip.count}`,
|
||||
active: chip.active,
|
||||
title: chip.label,
|
||||
})),
|
||||
);
|
||||
const severityOptions = computed(() => {
|
||||
const levels = props.view?.severities ?? [];
|
||||
return [
|
||||
{ value: '0', label: t('Any severity') },
|
||||
...levels.slice(1, 3).map((level) => ({
|
||||
value: String(level.value),
|
||||
label: t('{severity} and above', { severity: level.label }),
|
||||
})),
|
||||
...levels.slice(3).map((level) => ({
|
||||
value: String(level.value),
|
||||
label: t('{severity} only', { severity: level.label }),
|
||||
})),
|
||||
];
|
||||
});
|
||||
const categoryOptions = computed(() => [
|
||||
{ value: 'all', label: t('All categories') },
|
||||
...(props.view?.categories ?? []),
|
||||
]);
|
||||
const windowOptions = computed(() =>
|
||||
(props.view?.windowChoices ?? []).map((hours) => ({
|
||||
value: String(hours),
|
||||
label: t('Last {hours} h', { hours }),
|
||||
})),
|
||||
);
|
||||
// The longest choice is the server's whole window, kept as no choice.
|
||||
const chooseWindow = (hours) =>
|
||||
setFilter('hours', hours === props.view?.windowChoices?.[0] ? null : hours);
|
||||
const selectedId = computed(() => props.view?.selected?.id ?? null);
|
||||
// The chosen event leads the panel unless the feed already shows it open.
|
||||
const selectedApart = computed(() => {
|
||||
const chosen = props.view?.selected;
|
||||
if (!chosen) return null;
|
||||
const listed = local.value
|
||||
? props.view.inView.items.some((item) => item.id === chosen.id)
|
||||
: props.view.items.some((item) => item.id === chosen.id);
|
||||
return listed ? null : chosen;
|
||||
});
|
||||
// What Local reads: the area named, else the radius; neither while the
|
||||
// first area is being named, so the radius does not flash before it.
|
||||
const areaHead = computed(() => {
|
||||
const inView = props.view?.inView;
|
||||
if (!inView?.active) return '';
|
||||
if (inView.area) return t('News from {area}', { area: inView.area });
|
||||
if (inView.areaLoading) return '';
|
||||
return t('Within {km} km of the view centre', { km: inView.radiusKm });
|
||||
});
|
||||
const status = computed(() => {
|
||||
const view = props.view;
|
||||
if (!view) return '';
|
||||
if (view.error) return view.error;
|
||||
if (view.loading && !view.items.length) return t('Reading the news…');
|
||||
return '';
|
||||
});
|
||||
|
||||
const setFilter = (name, value) =>
|
||||
props.onParams({ filters: { [name]: value } });
|
||||
function choose(item) {
|
||||
if (item.id === selectedId.value) props.onParams({ clear: true });
|
||||
else props.onParams({ reportId: item.id, focus: true });
|
||||
}
|
||||
const clear = () => props.onParams({ clear: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
v-if="view"
|
||||
class="news-readout"
|
||||
:aria-label="t('News, last {hours} hours', { hours: view.windowHours })"
|
||||
>
|
||||
<UiSelect
|
||||
v-if="windowOptions.length > 1"
|
||||
class="gev-field news-filter news-readout__window-choice"
|
||||
:aria-label="t('Time window')"
|
||||
:model-value="String(view.windowHours)"
|
||||
:options="windowOptions"
|
||||
@update:model-value="chooseWindow(Number($event))"
|
||||
/>
|
||||
<p v-else class="news-readout__window ui-mono">{{
|
||||
t('Last {hours} h', { hours: view.windowHours })
|
||||
}}</p>
|
||||
<div
|
||||
class="news-readout__sections"
|
||||
role="group"
|
||||
:aria-label="t('News sections')"
|
||||
>
|
||||
<RailChips
|
||||
:chips="sections"
|
||||
:on-select="(chip) => setFilter('section', chip.id)"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-if="!local"
|
||||
class="news-readout__chips"
|
||||
role="group"
|
||||
:aria-label="t('Hotspots')"
|
||||
>
|
||||
<RailChips
|
||||
:chips="chips"
|
||||
:on-select="(chip) => setFilter('hotspot', chip.id)"
|
||||
/>
|
||||
</div>
|
||||
<div class="news-readout__filters">
|
||||
<UiSelect
|
||||
v-if="!local"
|
||||
class="gev-field news-filter"
|
||||
:aria-label="t('Severity')"
|
||||
:model-value="String(filters.minSeverity ?? 2)"
|
||||
:options="severityOptions"
|
||||
@update:model-value="setFilter('minSeverity', Number($event))"
|
||||
/>
|
||||
<UiSelect
|
||||
class="gev-field news-filter"
|
||||
:aria-label="t('Category')"
|
||||
:model-value="filters.category ?? 'all'"
|
||||
:options="categoryOptions"
|
||||
@update:model-value="setFilter('category', $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<NewsCard
|
||||
v-if="selectedApart"
|
||||
class="news-readout__selected"
|
||||
:item="selectedApart"
|
||||
open
|
||||
:on-choose="choose"
|
||||
:on-clear="clear"
|
||||
/>
|
||||
|
||||
<section
|
||||
v-if="local"
|
||||
class="news-readout__section"
|
||||
:aria-label="t('Local')"
|
||||
>
|
||||
<p v-if="areaHead" class="news-readout__head news-readout__area ui-mono">
|
||||
{{ areaHead }}
|
||||
</p>
|
||||
<UiEmpty
|
||||
v-if="!view.inView.active"
|
||||
class="news-readout__empty"
|
||||
:title="t('Zoom in to see local news')"
|
||||
/>
|
||||
<UiEmpty
|
||||
v-else-if="view.inView.key"
|
||||
class="news-readout__empty"
|
||||
:title="view.inView.key.title"
|
||||
:hint="view.inView.key.hint"
|
||||
/>
|
||||
<p v-else-if="view.inView.error" class="news-readout__status">
|
||||
{{ view.inView.error }}
|
||||
</p>
|
||||
<UiEmpty
|
||||
v-else-if="!view.inView.items.length && !view.inView.loading"
|
||||
class="news-readout__empty"
|
||||
:title="
|
||||
t('Nothing reported near here in the last {hours} h', {
|
||||
hours: view.windowHours,
|
||||
})
|
||||
"
|
||||
/>
|
||||
<ol
|
||||
v-else
|
||||
class="news-readout__list"
|
||||
:class="{ 'is-stale': view.inView.loading }"
|
||||
:aria-busy="view.inView.loading ? 'true' : 'false'"
|
||||
>
|
||||
<li v-for="item in view.inView.items" :key="item.id">
|
||||
<NewsCard
|
||||
:item="item"
|
||||
:open="item.id === selectedId"
|
||||
:on-choose="choose"
|
||||
:on-clear="clear"
|
||||
/>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-else
|
||||
class="news-readout__section"
|
||||
:aria-label="t('Latest news')"
|
||||
>
|
||||
<h3 class="news-readout__head ui-mono">{{ t('Latest') }}</h3>
|
||||
<UiEmpty
|
||||
v-if="view.key"
|
||||
class="news-readout__empty"
|
||||
:title="view.key.title"
|
||||
:hint="view.key.hint"
|
||||
/>
|
||||
<ol
|
||||
v-else-if="view.items.length"
|
||||
class="news-readout__list news-readout__feed"
|
||||
>
|
||||
<li v-for="item in view.items" :key="item.id">
|
||||
<NewsCard
|
||||
:item="item"
|
||||
:open="item.id === selectedId"
|
||||
:on-choose="choose"
|
||||
:on-clear="clear"
|
||||
/>
|
||||
</li>
|
||||
</ol>
|
||||
<UiEmpty
|
||||
v-else-if="!view.loading && !view.error"
|
||||
class="news-readout__empty"
|
||||
:title="
|
||||
t('No news matches these filters in the last {hours} h', {
|
||||
hours: view.windowHours,
|
||||
})
|
||||
"
|
||||
/>
|
||||
<div class="news-readout__footer">
|
||||
<span class="news-readout__status" role="status">{{ status }}</span>
|
||||
<UiButton
|
||||
v-if="view.hasMore && !view.loading"
|
||||
class="data-toggle-chip"
|
||||
type="button"
|
||||
@click="onParams({ loadMore: true })"
|
||||
>{{ t('Load older news') }}</UiButton
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<details class="news-legend">
|
||||
<summary>{{ t('How to read the map') }}</summary>
|
||||
<p>{{ t('Colour: severity · icon: type of event') }}</p>
|
||||
<ul class="news-legend__severity">
|
||||
<li
|
||||
v-for="level in view.severities"
|
||||
:key="level.value"
|
||||
:style="{ '--news-color': level.color }"
|
||||
>
|
||||
{{ level.label }}
|
||||
</li>
|
||||
</ul>
|
||||
<p>{{
|
||||
t(
|
||||
'Solid rim: reported by both sides or independently. Dashed rim: a claim. Thin rim: one source, or one side’s own press.',
|
||||
)
|
||||
}}</p>
|
||||
<p>{{
|
||||
t(
|
||||
'Larger: more sources · fainter: older. Picture card: a major or fast-growing event with two or more sources.',
|
||||
)
|
||||
}}</p>
|
||||
<p>{{
|
||||
t('Side labels describe the source, not whether a report is true.')
|
||||
}}</p>
|
||||
</details>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,89 @@
|
||||
import { h, render as renderVue } from 'vue';
|
||||
import NewsFeed from './news/NewsFeed.vue';
|
||||
|
||||
const LAYER_ID = 'news';
|
||||
const LOAD_MORE_MARGIN_PX = 160;
|
||||
// Remounting must not reopen a panel the reader already collapsed.
|
||||
const appearedPanels = new WeakSet();
|
||||
const set = (node, key, value) => {
|
||||
if (node[key] !== value) node[key] = value;
|
||||
};
|
||||
|
||||
/**
|
||||
* The News rail panel (`#news-panel`): it renders the `feed` view the news
|
||||
* layer publishes through its row controls, shows itself only while the
|
||||
* layer is on, and acts only through setLayerParams. Near the bottom of its
|
||||
* scroller it asks for the next older page, once per page; other filters or a
|
||||
* failed read let it ask again.
|
||||
*/
|
||||
export function createNewsPanel({ container, setLayerParams = () => {} } = {}) {
|
||||
const document = container?.ownerDocument;
|
||||
if (!document?.createElement) return null;
|
||||
const panel = container.closest?.('#news-panel');
|
||||
const count = panel?.querySelector('#news-panel-count');
|
||||
const onParams = (params) =>
|
||||
setLayerParams(LAYER_ID, params, { origin: 'user' });
|
||||
let view = null;
|
||||
let destroyed = false;
|
||||
let requestedAt = -1;
|
||||
let shownFilters = '';
|
||||
|
||||
function render() {
|
||||
if (destroyed) return;
|
||||
renderVue(h(NewsFeed, { view, onParams }), container);
|
||||
const hidden = !view;
|
||||
if (panel) set(panel, 'hidden', hidden);
|
||||
// The count is the shown section's: Local's list, else the feed.
|
||||
const shown =
|
||||
view?.filters?.section === 'local' ? view.inView?.items : view?.items;
|
||||
if (count) set(count, 'textContent', String(shown?.length ?? 0));
|
||||
if (!hidden && panel && !appearedPanels.has(panel)) {
|
||||
appearedPanels.add(panel);
|
||||
// First appearance opens the panel unless a stored or shared collapse
|
||||
// choice exists (marked by the panel chrome when it restored the state).
|
||||
const preference = panel.dataset?.collapsedPreference;
|
||||
if (
|
||||
panel.classList?.contains('collapsed') &&
|
||||
(preference === undefined || preference === 'default')
|
||||
)
|
||||
panel.querySelector('[data-collapse-target="news-panel"]')?.click();
|
||||
}
|
||||
}
|
||||
|
||||
const onScroll = () => {
|
||||
if (!view?.hasMore || view.loading) return;
|
||||
const remaining =
|
||||
container.scrollHeight - container.scrollTop - container.clientHeight;
|
||||
if (remaining > LOAD_MORE_MARGIN_PX) return;
|
||||
if (requestedAt === view.items.length) return;
|
||||
requestedAt = view.items.length;
|
||||
onParams({ loadMore: true });
|
||||
};
|
||||
container.addEventListener?.('scroll', onScroll, { passive: true });
|
||||
|
||||
return {
|
||||
/** Show the layer's feed view, or hide the panel with null. */
|
||||
update(next) {
|
||||
const filters = JSON.stringify(next?.filters ?? null);
|
||||
// A new list (other filters or hotspot), or a read that failed, may stop
|
||||
// at the same length as the last request: let the next scroll ask.
|
||||
// A list started over is shorter than the one the last request saw.
|
||||
if (
|
||||
filters !== shownFilters ||
|
||||
(next?.error && !view?.error) ||
|
||||
(next?.items?.length ?? 0) < requestedAt
|
||||
)
|
||||
requestedAt = -1;
|
||||
shownFilters = filters;
|
||||
view = next || null;
|
||||
render();
|
||||
},
|
||||
destroy() {
|
||||
destroyed = true;
|
||||
container.removeEventListener?.('scroll', onScroll);
|
||||
renderVue(null, container);
|
||||
if (panel) set(panel, 'hidden', true);
|
||||
if (count) set(count, 'textContent', '0');
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createNewsPanel } from './newsPanel.js';
|
||||
import {
|
||||
NEWS_CATEGORIES,
|
||||
NEWS_SEVERITY,
|
||||
categoryLabel,
|
||||
feedCardView,
|
||||
normalizeFilters,
|
||||
} from '../layers/news/model.js';
|
||||
|
||||
const NOW = Date.parse('2026-10-28T10:00:00Z');
|
||||
const report = (id, extra = {}) => ({
|
||||
id,
|
||||
title: `Report ${id}`,
|
||||
url: `https://www.example.com/${id}`,
|
||||
publishedAt: '2026-10-28T09:00:00.000Z',
|
||||
publisher: 'Example',
|
||||
side: 'UA',
|
||||
category: 'strike',
|
||||
severity: 2,
|
||||
geo: { lat: 50, lon: 36, place: 'Kharkiv', mappable: true },
|
||||
pins: [{ lat: 50, lon: 36, place: 'Kharkiv', mappable: true }],
|
||||
event: null,
|
||||
media: [],
|
||||
...extra,
|
||||
});
|
||||
const big = report('big', {
|
||||
severity: 3,
|
||||
titleEn: 'Strike on Kharkiv',
|
||||
title: 'Удар по Харкову',
|
||||
media: ['video'],
|
||||
event: {
|
||||
size: 4,
|
||||
severity: 3,
|
||||
status: 'both-sides',
|
||||
lastAt: '2026-10-28T09:50:00.000Z',
|
||||
sides: [
|
||||
{
|
||||
side: 'UA',
|
||||
title: 'a',
|
||||
url: 'https://a.test/',
|
||||
publisher: 'A',
|
||||
publishedAt: '2026-10-28T09:00:00.000Z',
|
||||
},
|
||||
{
|
||||
side: 'RU',
|
||||
title: 'b',
|
||||
url: 'https://b.test/',
|
||||
publisher: 'B',
|
||||
publishedAt: '2026-10-28T09:40:00.000Z',
|
||||
},
|
||||
],
|
||||
image: { url: 'https://a.test/p.jpg', publisher: 'A' },
|
||||
},
|
||||
});
|
||||
|
||||
function view(extra = {}) {
|
||||
return {
|
||||
filters: normalizeFilters(),
|
||||
hotspots: [
|
||||
{ id: 'all', label: 'All', count: 7, active: true },
|
||||
{ id: 'ua-ru-war', label: 'Ukraine–Russia', count: 7, active: false },
|
||||
],
|
||||
categories: Object.keys(NEWS_CATEGORIES).map((id) => ({
|
||||
value: id,
|
||||
label: categoryLabel(id),
|
||||
})),
|
||||
severities: NEWS_SEVERITY.map((level, index) => ({
|
||||
value: index,
|
||||
label: level.label,
|
||||
color: level.color,
|
||||
})),
|
||||
items: [feedCardView(big, NOW), feedCardView(report('lone'), NOW)],
|
||||
inView: { active: false, loading: false, error: null, items: [] },
|
||||
selected: null,
|
||||
hasMore: true,
|
||||
windowHours: 24,
|
||||
loading: false,
|
||||
error: null,
|
||||
...extra,
|
||||
};
|
||||
}
|
||||
|
||||
function fixture() {
|
||||
document.body.innerHTML = `
|
||||
<div id="news-panel" class="collapsed" hidden>
|
||||
<span id="news-panel-count">0</span>
|
||||
<button data-collapse-target="news-panel"></button>
|
||||
<div id="news-panel-body"></div>
|
||||
</div>`;
|
||||
const panel = document.getElementById('news-panel');
|
||||
let opened = 0;
|
||||
panel
|
||||
.querySelector('[data-collapse-target]')
|
||||
.addEventListener('click', () => {
|
||||
opened++;
|
||||
panel.classList.remove('collapsed');
|
||||
});
|
||||
const calls = [];
|
||||
const news = createNewsPanel({
|
||||
container: document.getElementById('news-panel-body'),
|
||||
setLayerParams: (id, params, options) => calls.push([id, params, options]),
|
||||
});
|
||||
return { news, panel, calls, opened: () => opened };
|
||||
}
|
||||
|
||||
test('the panel shows the last 24 h as event cards and opens once', () => {
|
||||
const { news, panel, opened } = fixture();
|
||||
news.update(null);
|
||||
assert.equal(panel.hidden, true);
|
||||
news.update(view());
|
||||
assert.equal(panel.hidden, false);
|
||||
assert.equal(opened(), 1);
|
||||
assert.equal(document.getElementById('news-panel-count').textContent, '2');
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout__window').textContent,
|
||||
'Last 24 h',
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...panel.querySelectorAll('.news-readout__chips [data-chip-id]')].map(
|
||||
(chip) => chip.textContent,
|
||||
),
|
||||
['All 7', 'Ukraine–Russia 7'],
|
||||
);
|
||||
const [first, second] = panel.querySelectorAll(
|
||||
'.news-readout__feed .news-card',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__title').textContent,
|
||||
'Strike on Kharkiv',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__note').textContent,
|
||||
'English headline by the model',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__meta').textContent,
|
||||
'Major · Strike · Kharkiv · 4 sources · 10 min',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__marker').getAttribute('aria-label'),
|
||||
'Major',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__sides').textContent,
|
||||
'Reported by UA sources · RU sources',
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...first.querySelectorAll('.news-chip')].map((c) => c.textContent),
|
||||
['Reported by both sides', 'Video'],
|
||||
);
|
||||
const img = first.querySelector('.news-card__thumb img');
|
||||
assert.equal(img.getAttribute('src'), 'https://a.test/p.jpg');
|
||||
assert.equal(img.getAttribute('referrerpolicy'), 'no-referrer');
|
||||
assert.equal(first.querySelector('.news-card__credit').textContent, 'A');
|
||||
// A lone report has no picture.
|
||||
assert.equal(second.querySelector('.news-card__thumb'), null);
|
||||
// A later update does not reopen a panel the reader collapsed.
|
||||
panel.classList.add('collapsed');
|
||||
news.update(view());
|
||||
assert.equal(opened(), 1);
|
||||
news.destroy();
|
||||
assert.equal(panel.hidden, true);
|
||||
});
|
||||
|
||||
test('a card click flies there; open, it links the source and closes', () => {
|
||||
const { news, panel, calls } = fixture();
|
||||
news.update(view());
|
||||
panel.querySelector('.news-card__main').click();
|
||||
assert.deepEqual(calls.at(-1), [
|
||||
'news',
|
||||
{ reportId: 'big', focus: true },
|
||||
{ origin: 'user' },
|
||||
]);
|
||||
news.update(view({ selected: feedCardView(big, NOW) }));
|
||||
const open = panel.querySelector('.news-card.is-open');
|
||||
const link = open.querySelector('.news-card__link');
|
||||
assert.equal(link.textContent, 'Source: example.com ↗');
|
||||
assert.equal(link.getAttribute('href'), 'https://www.example.com/big');
|
||||
assert.equal(link.getAttribute('rel'), 'noopener noreferrer');
|
||||
assert.equal(
|
||||
open.querySelector('.news-card__original').textContent,
|
||||
'Удар по Харкову',
|
||||
);
|
||||
open.querySelector('.news-card__main').click();
|
||||
assert.deepEqual(calls.at(-1)[1], { clear: true });
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('filters, the Local section and empty or failed reads', () => {
|
||||
const { news, panel, calls } = fixture();
|
||||
news.update(view());
|
||||
assert.equal(panel.querySelector('[aria-label="Local"]'), null);
|
||||
assert.equal(panel.querySelector('.news-toggle'), null);
|
||||
const severity = panel.querySelector('select[aria-label="Severity"]');
|
||||
assert.equal(severity.value, '2');
|
||||
severity.value = '3';
|
||||
severity.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { minSeverity: 3 } });
|
||||
panel.querySelector('[data-chip-id="ua-ru-war"]').click();
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { hotspot: 'ua-ru-war' } });
|
||||
panel.querySelector('[data-chip-id="local"]').click();
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { section: 'local' } });
|
||||
|
||||
news.update(
|
||||
view({
|
||||
items: [],
|
||||
hasMore: false,
|
||||
}),
|
||||
);
|
||||
assert.match(
|
||||
panel.textContent,
|
||||
/No news matches these filters in the last 24 h/,
|
||||
);
|
||||
assert.equal(panel.querySelector('.news-readout__footer button'), null);
|
||||
|
||||
// Local: no hotspot chips or severity floor, and its own empty states.
|
||||
const localView = (inView) =>
|
||||
view({
|
||||
filters: normalizeFilters({ section: 'local' }),
|
||||
inView: { loading: false, error: null, items: [], ...inView },
|
||||
});
|
||||
news.update(localView({ active: false }));
|
||||
const section = panel.querySelector('[aria-label="Local"]');
|
||||
assert.match(section.textContent, /Zoom in to see local news/);
|
||||
assert.equal(panel.querySelector('[data-chip-id="ua-ru-war"]'), null);
|
||||
assert.equal(panel.querySelector('select[aria-label="Severity"]'), null);
|
||||
assert.equal(panel.querySelector('[aria-label="Latest news"]'), null);
|
||||
assert.equal(document.getElementById('news-panel-count').textContent, '0');
|
||||
news.update(
|
||||
localView({ active: true, items: [feedCardView(report('near'), NOW)] }),
|
||||
);
|
||||
assert.equal(document.getElementById('news-panel-count').textContent, '1');
|
||||
news.update(localView({ active: true }));
|
||||
assert.match(
|
||||
panel.querySelector('[aria-label="Local"]').textContent,
|
||||
/Nothing reported near here in the last 24 h/,
|
||||
);
|
||||
news.update(view());
|
||||
|
||||
news.update(
|
||||
view({ items: [], error: 'News feed unavailable', hasMore: false }),
|
||||
);
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout__status').textContent,
|
||||
'News feed unavailable',
|
||||
);
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('each section says which key it lacks; Local names the area it reads', () => {
|
||||
const { news, panel } = fixture();
|
||||
const key = {
|
||||
title: 'Liveuamap key required',
|
||||
hint: 'Needs LIVEUAMAP_API_KEY — add it in Provider Settings',
|
||||
};
|
||||
news.update(view({ key, items: [], hasMore: false }));
|
||||
const latest = panel.querySelector('[aria-label="Latest news"]');
|
||||
assert.match(latest.textContent, /Liveuamap key required/);
|
||||
assert.match(latest.textContent, /Needs LIVEUAMAP_API_KEY/);
|
||||
assert.doesNotMatch(latest.textContent, /No news matches/);
|
||||
|
||||
const localView = (inView) =>
|
||||
view({
|
||||
filters: normalizeFilters({ section: 'local' }),
|
||||
inView: {
|
||||
active: true,
|
||||
loading: false,
|
||||
error: null,
|
||||
items: [],
|
||||
radiusKm: 500,
|
||||
...inView,
|
||||
},
|
||||
});
|
||||
const section = () => panel.querySelector('[aria-label="Local"]');
|
||||
const heading = () => section().querySelector('.news-readout__area');
|
||||
news.update(
|
||||
localView({
|
||||
key: {
|
||||
title: 'World News API limit reached for today',
|
||||
hint: 'News resumes tomorrow, or with a paid plan',
|
||||
},
|
||||
}),
|
||||
);
|
||||
assert.match(section().textContent, /World News API limit reached for today/);
|
||||
assert.match(section().textContent, /News resumes tomorrow/);
|
||||
assert.doesNotMatch(section().textContent, /Nothing reported near here/);
|
||||
|
||||
// The area named, else the radius at sea.
|
||||
news.update(localView({ area: 'Ukraine' }));
|
||||
assert.equal(heading().textContent.trim(), 'News from Ukraine');
|
||||
news.update(localView({ area: null }));
|
||||
assert.equal(
|
||||
heading().textContent.trim(),
|
||||
'Within 500 km of the view centre',
|
||||
);
|
||||
// While the first area is named, neither: the radius does not flash.
|
||||
news.update(localView({ area: null, areaLoading: true, loading: true }));
|
||||
assert.equal(heading(), null);
|
||||
// A new area on the way keeps the one shown.
|
||||
news.update(localView({ area: 'Ukraine', areaLoading: true, loading: true }));
|
||||
assert.equal(heading().textContent.trim(), 'News from Ukraine');
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('a card credits the service its report came through', () => {
|
||||
const { news, panel } = fixture();
|
||||
news.update(
|
||||
view({
|
||||
items: [
|
||||
feedCardView(report('gdelt', { attribution: 'GDELT Project' }), NOW),
|
||||
feedCardView(report('own'), NOW),
|
||||
],
|
||||
}),
|
||||
);
|
||||
const [credited, own] = panel.querySelectorAll('.news-card');
|
||||
assert.equal(
|
||||
credited.querySelector('.news-card__via').textContent,
|
||||
'via GDELT Project',
|
||||
);
|
||||
assert.equal(own.querySelector('.news-card__via'), null);
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('scrolling to the end asks once per page, again after a filter change or a failed read', () => {
|
||||
const { news, calls } = fixture();
|
||||
const body = document.getElementById('news-panel-body');
|
||||
// A scroller at its bottom.
|
||||
Object.defineProperty(body, 'scrollHeight', {
|
||||
value: 1000,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(body, 'clientHeight', {
|
||||
value: 400,
|
||||
configurable: true,
|
||||
});
|
||||
body.scrollTop = 600;
|
||||
const loadMores = () => calls.filter(([, p]) => p.loadMore === true).length;
|
||||
const scroll = () => body.dispatchEvent(new Event('scroll'));
|
||||
news.update(view());
|
||||
scroll();
|
||||
scroll();
|
||||
assert.equal(loadMores(), 1);
|
||||
// The page came back with nothing new (as many items): no second request.
|
||||
news.update(view());
|
||||
scroll();
|
||||
assert.equal(loadMores(), 1);
|
||||
// Another hotspot, the same number of rows: the new list can be read on.
|
||||
const hotspot = normalizeFilters({ hotspot: 'ua-ru-war' }, [
|
||||
{ id: 'ua-ru-war' },
|
||||
]);
|
||||
news.update(view({ filters: hotspot }));
|
||||
scroll();
|
||||
assert.equal(loadMores(), 2);
|
||||
// The read fails: the next scroll tries again.
|
||||
news.update(view({ filters: hotspot, error: 'News feed unavailable' }));
|
||||
scroll();
|
||||
assert.equal(loadMores(), 3);
|
||||
// While loading, or with no older page, nothing is asked.
|
||||
news.update(view({ filters: hotspot, loading: true }));
|
||||
scroll();
|
||||
news.update(view({ filters: hotspot, hasMore: false }));
|
||||
scroll();
|
||||
assert.equal(loadMores(), 3);
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('the window choice offers shorter windows; the longest is the server window', () => {
|
||||
const { news, panel, calls } = fixture();
|
||||
news.update(view({ windowHours: 12, windowChoices: [12, 6, 3, 1] }));
|
||||
assert.equal(panel.querySelector('.news-readout__window'), null);
|
||||
const choice = panel.querySelector('select[aria-label="Time window"]');
|
||||
assert.deepEqual(
|
||||
[...choice.options].map((option) => option.textContent),
|
||||
['Last 12 h', 'Last 6 h', 'Last 3 h', 'Last 1 h'],
|
||||
);
|
||||
assert.equal(choice.value, '12');
|
||||
choice.value = '3';
|
||||
choice.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { hours: 3 } });
|
||||
choice.value = '12';
|
||||
choice.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { hours: null } });
|
||||
});
|
||||
|
||||
test('the panel names the window the server serves', () => {
|
||||
const { news, panel } = fixture();
|
||||
news.update(view({ windowHours: 12 }));
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout__window').textContent,
|
||||
'Last 12 h',
|
||||
);
|
||||
});
|
||||
|
||||
test('a clip waits behind its picture and plays, on request, in the open card', () => {
|
||||
const { news, panel } = fixture();
|
||||
const clipped = report('clip', {
|
||||
event: {
|
||||
size: 1,
|
||||
sides: [],
|
||||
image: {
|
||||
url: 'https://cdn4.telesco.pe/file/v.jpg',
|
||||
publisher: 'Channel',
|
||||
video: 'https://cdn4.telesco.pe/file/v.mp4?token=x',
|
||||
},
|
||||
},
|
||||
});
|
||||
news.update(view({ items: [feedCardView(clipped, NOW)] }));
|
||||
const card = panel.querySelector('.news-card');
|
||||
assert.equal(card.querySelector('.news-card__play').textContent, '▶');
|
||||
assert.equal(card.querySelector('video'), null);
|
||||
news.update(
|
||||
view({
|
||||
items: [feedCardView(clipped, NOW)],
|
||||
selected: feedCardView(clipped, NOW),
|
||||
}),
|
||||
);
|
||||
const video = panel.querySelector('.news-card.is-open video');
|
||||
assert.equal(
|
||||
video.getAttribute('src'),
|
||||
'https://cdn4.telesco.pe/file/v.mp4?token=x',
|
||||
);
|
||||
assert.equal(
|
||||
video.getAttribute('poster'),
|
||||
'https://cdn4.telesco.pe/file/v.jpg',
|
||||
);
|
||||
assert.equal(video.getAttribute('preload'), 'none');
|
||||
assert.ok(video.hasAttribute('controls'));
|
||||
// An expired link leaves the card without the clip.
|
||||
video.dispatchEvent(new Event('error'));
|
||||
news.update(
|
||||
view({
|
||||
items: [feedCardView(clipped, NOW)],
|
||||
selected: feedCardView(clipped, NOW),
|
||||
}),
|
||||
);
|
||||
assert.equal(panel.querySelector('.news-card.is-open video'), null);
|
||||
news.destroy();
|
||||
});
|
||||
@@ -17,6 +17,7 @@ const SHARE_PANEL_STATE_SPECS = Object.freeze([
|
||||
{ id: 'data-panel' },
|
||||
{ id: 'cctv-panel' },
|
||||
{ id: 'weather-panel' },
|
||||
{ id: 'news-panel' },
|
||||
{ id: 'recent-imagery-panel' },
|
||||
{ id: 'street-level-panel' },
|
||||
{ id: 'radio-panel' },
|
||||
@@ -41,6 +42,7 @@ const COCKPIT_ENTRY_COLLAPSE_PANEL_IDS = Object.freeze([
|
||||
'data-panel',
|
||||
'cctv-panel',
|
||||
'weather-panel',
|
||||
'news-panel',
|
||||
'recent-imagery-panel',
|
||||
'street-level-panel',
|
||||
'scene-panel',
|
||||
|
||||
@@ -97,6 +97,7 @@ export class PanelLayoutController {
|
||||
this._ppToggles = document.getElementById('pp-toggles');
|
||||
this._cctvPanel = document.getElementById('cctv-panel');
|
||||
this._weatherPanel = document.getElementById('weather-panel');
|
||||
this._newsPanel = document.getElementById('news-panel');
|
||||
this._recentImageryPanel = document.getElementById('recent-imagery-panel');
|
||||
this._streetLevelPanel = document.getElementById('street-level-panel');
|
||||
}
|
||||
@@ -193,6 +194,7 @@ export class PanelLayoutController {
|
||||
for (const panel of [
|
||||
this._cctvPanel,
|
||||
this._weatherPanel,
|
||||
this._newsPanel,
|
||||
this._recentImageryPanel,
|
||||
this._streetLevelPanel,
|
||||
]) {
|
||||
@@ -208,6 +210,7 @@ export class PanelLayoutController {
|
||||
this._ppToggles,
|
||||
this._cctvPanel,
|
||||
this._weatherPanel,
|
||||
this._newsPanel,
|
||||
this._recentImageryPanel,
|
||||
this._streetLevelPanel,
|
||||
globalContextPanel,
|
||||
|
||||
@@ -22,6 +22,7 @@ export const PANEL_RAIL_ITEMS = Object.freeze({
|
||||
'pp-toggles': { icon: 'tune', label: msg('DISPLAY') },
|
||||
'cctv-panel': { icon: 'videocam', label: msg('CCTV') },
|
||||
'weather-panel': { icon: 'partly_cloudy_day', label: msg('WEATHER') },
|
||||
'news-panel': { icon: 'public', label: msg('NEWS') },
|
||||
'recent-imagery-panel': {
|
||||
icon: 'satellite_alt',
|
||||
label: msg('RECENT IMAGERY'),
|
||||
|
||||
+59
-6
@@ -2,6 +2,8 @@ import * as Cesium from 'cesium';
|
||||
import { trackedDisplayPositionForCamera } from '../data/trackedCamera.js';
|
||||
import {
|
||||
SHARE_VIEW_ENTITY_KINDS,
|
||||
SHARE_VIEW_FOLLOW_RANGE_MAX_M,
|
||||
followOffsetFor,
|
||||
followOffsetFromEnu,
|
||||
followOffsetToEnu,
|
||||
} from '../share/follow.js';
|
||||
@@ -28,17 +30,68 @@ function enuOffset(origin, position) {
|
||||
return { east: local.x, north: local.y, up: local.z };
|
||||
}
|
||||
|
||||
/** Degrees to the share format's 10⁻⁴-degree coordinate precision. */
|
||||
const toCoordinate = (radians) =>
|
||||
Math.round(Cesium.Math.toDegrees(radians) * 1e4) / 1e4;
|
||||
|
||||
/**
|
||||
* The entity the camera follows as `{ kind, id, offset, lastKnown }`, with
|
||||
* the camera's offset from it and its displayed position as of `nowMs`; null
|
||||
* when the camera follows nothing a share link can name. A selected vessel is
|
||||
* not followed (the camera stays where the user puts it), so a link made then
|
||||
* keeps its own camera.
|
||||
* The selected vessel as a thing view's subject: its drawn position as the
|
||||
* last-known fix, and the follow offset that puts the derived camera
|
||||
* (followCameraFor) where the camera is now. The offset is computed from the
|
||||
* fix at the format's precision, so the opened link's camera matches this
|
||||
* one to within the offset's whole metres and degrees. Null when the offset
|
||||
* cannot carry the camera (it is not above the vessel's horizon, or its range
|
||||
* is outside 1 m to SHARE_VIEW_FOLLOW_RANGE_MAX_M): the link is then a place
|
||||
* view.
|
||||
*/
|
||||
export function readShareFollowSubject({ viewer, nowMs = Date.now() }) {
|
||||
function selectedVesselSubject(cameraPosition, vessel, nowMs) {
|
||||
const id = String(vessel?.id || '');
|
||||
if (!id || !vessel.position) return null;
|
||||
const fixAt = Cesium.Cartographic.fromCartesian(vessel.position);
|
||||
const cameraAt = Cesium.Cartographic.fromCartesian(cameraPosition);
|
||||
if (!fixAt || !cameraAt) return null;
|
||||
const lastKnown = {
|
||||
lat: toCoordinate(fixAt.latitude),
|
||||
lon: toCoordinate(fixAt.longitude),
|
||||
alt: Math.round(fixAt.height),
|
||||
observedAtMs: Number.isFinite(vessel.observedAtMs)
|
||||
? vessel.observedAtMs
|
||||
: nowMs,
|
||||
};
|
||||
const offset = followOffsetFor(lastKnown, {
|
||||
lat: Cesium.Math.toDegrees(cameraAt.latitude),
|
||||
lon: Cesium.Math.toDegrees(cameraAt.longitude),
|
||||
alt: cameraAt.height,
|
||||
});
|
||||
if (
|
||||
!offset ||
|
||||
!(offset.range >= 1 && offset.range <= SHARE_VIEW_FOLLOW_RANGE_MAX_M)
|
||||
)
|
||||
return null;
|
||||
return { kind: 'vessel', id, offset, lastKnown };
|
||||
}
|
||||
|
||||
/**
|
||||
* The entity a share link made now names, as `{ kind, id, offset, lastKnown }`:
|
||||
* the entity the camera follows, with the camera's offset from it and its
|
||||
* displayed position as of `nowMs`; else, while the camera follows nothing,
|
||||
* the selected vessel (`readSelectedVessel()`, the vessel layer's
|
||||
* `getSelectedFix()`). A selected vessel is not followed (the camera stays
|
||||
* where the user puts it), so its offset is the one that derives the camera
|
||||
* where it is now. Null when there is nothing a share link can name.
|
||||
*/
|
||||
export function readShareFollowSubject({
|
||||
viewer,
|
||||
nowMs = Date.now(),
|
||||
readSelectedVessel = null,
|
||||
}) {
|
||||
const cameraPosition = viewer?.camera?.positionWC;
|
||||
if (!cameraPosition) return null;
|
||||
const tracked = viewer.trackedEntity;
|
||||
if (!tracked) {
|
||||
const vessel = readSelectedVessel?.() ?? null;
|
||||
return vessel ? selectedVesselSubject(cameraPosition, vessel, nowMs) : null;
|
||||
}
|
||||
const trackedId = String(tracked?.gevTrackedId || '');
|
||||
const separator = trackedId.indexOf(':');
|
||||
if (separator <= 0) return null;
|
||||
|
||||
+218
-10
@@ -12,6 +12,7 @@ import {
|
||||
} from './shareFollow.js';
|
||||
import { createDefaultLayerState } from '../data/layerState.js';
|
||||
import { parseSharePath, shareLinkUrl } from '../share/shareLinkPath.js';
|
||||
import { worldClock } from '../time/worldClock.js';
|
||||
import {
|
||||
decodeShareView,
|
||||
encodeShareView,
|
||||
@@ -234,7 +235,9 @@ test('a code that fails its check restores nothing and says so', async (t) => {
|
||||
(await page.owner.initialRestorePromise).status,
|
||||
'not-requested',
|
||||
);
|
||||
assert.deepEqual(page.notices, ["This share link can't be opened"]);
|
||||
assert.deepEqual(page.notices, [
|
||||
{ message: "This share link can't be opened" },
|
||||
]);
|
||||
// The default start's first address write leaves the bad link behind.
|
||||
page.manager._updateHash();
|
||||
assert.equal(page.location.pathname, '/');
|
||||
@@ -334,9 +337,10 @@ test('a thing that is not reporting leaves the view at its last-known fix, with
|
||||
await flush();
|
||||
assert.equal(page.notices.length, 1);
|
||||
assert.match(
|
||||
page.notices[0],
|
||||
/^A1B2C3 isn't reporting now — showing where it was at .+/,
|
||||
page.notices[0].message,
|
||||
/^The shared flight isn't reporting now — showing where it was at .+/,
|
||||
);
|
||||
assert.equal(page.notices[0].detail, 'ICAO: A1B2C3');
|
||||
// A long link names no fix and keeps the existing notice.
|
||||
page.owner._initialShareState = { shareView: null };
|
||||
page.owner._handleShareTrackingRestoreStatus({
|
||||
@@ -345,19 +349,48 @@ test('a thing that is not reporting leaves the view at its last-known fix, with
|
||||
label: 'flight',
|
||||
classification: 'expired',
|
||||
});
|
||||
assert.equal(page.notices[1], 'Shared flight follow expired');
|
||||
assert.deepEqual(page.notices[1], {
|
||||
message: 'Shared flight follow expired',
|
||||
});
|
||||
});
|
||||
|
||||
test('the not-reporting notice names the id and the time of the fix', () => {
|
||||
test('the not-reporting notice is a sentence per kind with the id on a second line', () => {
|
||||
const at = new Date(2026, 9, 26, 14, 5).getTime();
|
||||
const flight = sharedFixNotice(
|
||||
{ kind: 'aircraft', id: 'a1b2c3' },
|
||||
at,
|
||||
at + 60_000,
|
||||
);
|
||||
assert.match(
|
||||
sharedFixNotice({ kind: 'aircraft', id: 'a1b2c3' }, at, at + 60_000),
|
||||
/^A1B2C3 isn't reporting now — showing where it was at .*05/,
|
||||
flight.message,
|
||||
/^The shared flight isn't reporting now — showing where it was at .*05/,
|
||||
);
|
||||
assert.equal(flight.detail, 'ICAO: A1B2C3');
|
||||
assert.deepEqual(
|
||||
sharedFixNotice({ kind: 'military_aircraft', id: 'ae01ce' }, null),
|
||||
{
|
||||
message:
|
||||
"The shared military flight isn't reporting now — showing where it was last seen",
|
||||
detail: 'ICAO: AE01CE',
|
||||
},
|
||||
);
|
||||
assert.deepEqual(sharedFixNotice({ kind: 'vessel', id: '366999712' }, null), {
|
||||
message:
|
||||
"The shared vessel isn't reporting now — showing where it was last seen",
|
||||
detail: 'MMSI: 366999712',
|
||||
});
|
||||
assert.equal(
|
||||
sharedFixNotice({ kind: 'vessel', id: '366999712' }, null),
|
||||
"366999712 isn't reporting now — showing where it was last seen",
|
||||
sharedFixNotice(
|
||||
{ kind: 'vessel', id: '3F2504E0-4F89-11D3-9A0C-0305E82C3301' },
|
||||
null,
|
||||
).detail,
|
||||
'Vessel UUID: 3f2504e0-4f89-11d3-9a0c-0305e82c3301',
|
||||
);
|
||||
assert.deepEqual(sharedFixNotice({ kind: 'satellite', id: '25544' }, null), {
|
||||
message:
|
||||
"The shared satellite isn't reporting now — showing where it was last seen",
|
||||
detail: 'NORAD: 25544',
|
||||
});
|
||||
});
|
||||
|
||||
test('a shared vessel is selected once the vessel feed has it', async (t) => {
|
||||
@@ -398,7 +431,11 @@ test('a shared vessel is selected once the vessel feed has it', async (t) => {
|
||||
page.runAll();
|
||||
}
|
||||
assert.equal(await missing, false);
|
||||
assert.match(page.notices.at(-1), /^366999712 isn't reporting now/);
|
||||
assert.match(
|
||||
page.notices.at(-1).message,
|
||||
/^The shared vessel isn't reporting now/,
|
||||
);
|
||||
assert.equal(page.notices.at(-1).detail, 'MMSI: 366999712');
|
||||
});
|
||||
|
||||
test('the share button links to /share/<code>, following the followed entity', (t) => {
|
||||
@@ -552,3 +589,174 @@ test('long links and hash navigation are unaffected by a share code start', asyn
|
||||
assert.equal(page.restores.length, 2);
|
||||
assert.equal(page.restores[1].style, 'normal');
|
||||
});
|
||||
|
||||
const VESSEL_UUID = '0770e3ca-b896-c307-f499-4f9df2b8f86b';
|
||||
const VESSEL_AT = { lat: 51.93012, lon: 4.05118, alt: 46.6 };
|
||||
|
||||
/** A camera `offset` from the vessel, as Cesium places it (WGS84). */
|
||||
function cameraAround(offset) {
|
||||
const vessel = Cesium.Cartesian3.fromDegrees(
|
||||
VESSEL_AT.lon,
|
||||
VESSEL_AT.lat,
|
||||
VESSEL_AT.alt,
|
||||
);
|
||||
const local = followOffsetToEnu(offset);
|
||||
return {
|
||||
vessel,
|
||||
camera: Cesium.Matrix4.multiplyByPoint(
|
||||
Cesium.Transforms.eastNorthUpToFixedFrame(vessel),
|
||||
new Cesium.Cartesian3(local.east, local.north, local.up),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
test('a selected vessel is the subject when the camera follows nothing', (t) => {
|
||||
installPage(t, 'https://gev.example/');
|
||||
const offset = { range: 6400, heading: 250, pitch: -28 };
|
||||
const { vessel, camera } = cameraAround(offset);
|
||||
const viewer = fakeViewer();
|
||||
viewer.camera.positionWC = camera;
|
||||
const fixAtMs = Math.floor(NOW_MS / 1000) * 1000 - 90_000;
|
||||
let selected = { id: VESSEL_UUID, position: vessel, observedAtMs: fixAtMs };
|
||||
const readSelectedVessel = () => selected;
|
||||
const subject = readShareFollowSubject({
|
||||
viewer,
|
||||
nowMs: NOW_MS,
|
||||
readSelectedVessel,
|
||||
});
|
||||
assert.equal(subject.kind, 'vessel');
|
||||
assert.equal(subject.id, VESSEL_UUID);
|
||||
// The fix is the vessel's drawn position at the format's precision.
|
||||
assert.deepEqual(subject.lastKnown, {
|
||||
lat: 51.9301,
|
||||
lon: 4.0512,
|
||||
alt: 47,
|
||||
observedAtMs: fixAtMs,
|
||||
});
|
||||
// The inverse of the derived camera, from the user's camera: within the
|
||||
// offset's whole degrees of the camera that placed it.
|
||||
// (The fix is rounded to 10⁻⁴°, about 11 m, before the offset is taken.)
|
||||
assert.ok(Math.abs(subject.offset.range - offset.range) <= 20);
|
||||
assert.ok(Math.abs(subject.offset.heading - offset.heading) <= 1);
|
||||
assert.ok(Math.abs(subject.offset.pitch - offset.pitch) <= 1);
|
||||
|
||||
// The share button's link opens with its camera where this one is.
|
||||
const manager = new ShareLinkManager(viewer);
|
||||
manager.setFollowSubjectProvider(({ nowMs }) =>
|
||||
readShareFollowSubject({ viewer, nowMs, readSelectedVessel }),
|
||||
);
|
||||
const href = manager.buildLink({ nowMs: NOW_MS });
|
||||
const code = parseSharePath(new URL(href).pathname).code;
|
||||
const { state } = decodeShareView(code, { nowMs: NOW_MS });
|
||||
assert.deepEqual(state.view.entity, { kind: 'vessel', id: VESSEL_UUID });
|
||||
assert.equal(state.view.lastKnown.observedAtMs, fixAtMs);
|
||||
const opened = Cesium.Cartesian3.fromDegrees(state.lon, state.lat, state.alt);
|
||||
const missM = Cesium.Cartesian3.distance(opened, camera);
|
||||
// Whole degrees at 6.4 km are at most about 80 m; 10⁻⁴° is about 11 m.
|
||||
assert.ok(missM < 100, `${missM.toFixed(1)} m from the camera`);
|
||||
// The UUID costs 13 bytes more than an ICAO address: 16 against 3.
|
||||
manager.setFollowSubjectProvider(() => ({
|
||||
...subject,
|
||||
kind: 'aircraft',
|
||||
id: 'a1b2c3',
|
||||
}));
|
||||
const aircraft = parseSharePath(
|
||||
new URL(manager.buildLink({ nowMs: NOW_MS })).pathname,
|
||||
).code;
|
||||
assert.ok(
|
||||
code.length - aircraft.length <= 18,
|
||||
`${code.length} against ${aircraft.length} characters`,
|
||||
);
|
||||
manager.destroy();
|
||||
|
||||
// A camera below the vessel's horizon cannot be carried: a place view.
|
||||
viewer.camera.positionWC = Cesium.Cartesian3.fromDegrees(4.0512, 54, 900);
|
||||
assert.equal(
|
||||
readShareFollowSubject({ viewer, nowMs: NOW_MS, readSelectedVessel }),
|
||||
null,
|
||||
);
|
||||
// Nor can one at the vessel.
|
||||
viewer.camera.positionWC = vessel;
|
||||
assert.equal(
|
||||
readShareFollowSubject({ viewer, nowMs: NOW_MS, readSelectedVessel }),
|
||||
null,
|
||||
);
|
||||
// With nothing selected there is no subject.
|
||||
viewer.camera.positionWC = camera;
|
||||
selected = null;
|
||||
assert.equal(
|
||||
readShareFollowSubject({ viewer, nowMs: NOW_MS, readSelectedVessel }),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test('a followed aircraft or satellite keeps priority over a selected vessel', () => {
|
||||
const { vessel, camera } = cameraAround({
|
||||
range: 2400,
|
||||
heading: 30,
|
||||
pitch: -20,
|
||||
});
|
||||
const readSelectedVessel = () => ({
|
||||
id: VESSEL_UUID,
|
||||
position: vessel,
|
||||
observedAtMs: NOW_MS,
|
||||
});
|
||||
const viewer = {
|
||||
camera: { positionWC: camera },
|
||||
clock: { currentTime: Cesium.JulianDate.now() },
|
||||
trackedEntity: {
|
||||
gevTrackedId: 'satellites:25544',
|
||||
gevDisplayPosition: () => vessel,
|
||||
},
|
||||
};
|
||||
const subject = readShareFollowSubject({ viewer, readSelectedVessel });
|
||||
assert.equal(subject.kind, 'satellite');
|
||||
// A followed entity the share format cannot name is still followed: the
|
||||
// link is a place view, not the selected vessel.
|
||||
viewer.trackedEntity.gevTrackedId = 'local-adsb:abc';
|
||||
assert.equal(readShareFollowSubject({ viewer, readSelectedVessel }), null);
|
||||
});
|
||||
|
||||
test('a link to a UUID vessel at a world time selects it once its snapshot has it', async (t) => {
|
||||
t.after(() => worldClock.goLive());
|
||||
const worldTime = Math.floor((NOW_MS - 3_600_000) / 1000) * 1000;
|
||||
const code = encodeShareView({
|
||||
view: {
|
||||
kind: 'thing',
|
||||
entity: { kind: 'vessel', id: VESSEL_UUID },
|
||||
offset: { range: 3200, heading: 20, pitch: -30 },
|
||||
lastKnown: { ...VESSEL_AT, alt: 47, observedAtMs: worldTime },
|
||||
},
|
||||
sharedAtMs: Math.floor(NOW_MS / 1000) * 1000,
|
||||
worldTime,
|
||||
});
|
||||
const page = openPage(t, `http://localhost/share/${code}`);
|
||||
// The link opens paused at its world time.
|
||||
assert.equal(worldClock.isLive(), false);
|
||||
assert.equal(worldClock.now(), worldTime);
|
||||
// The vessel layer: its records are the snapshot at the clock's time, which
|
||||
// arrives a moment after the layer turns on.
|
||||
const records = new Set();
|
||||
const selected = [];
|
||||
page.owner._dataManager = {
|
||||
layers: new Map([
|
||||
[
|
||||
'ais-live-vessels',
|
||||
{
|
||||
module: {
|
||||
hasContact: (id) => (records.size ? records.has(id) : null),
|
||||
selectById: (id) => records.has(id) && selected.push(id) > 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
]),
|
||||
};
|
||||
await restore(page);
|
||||
assert.deepEqual(selected, []);
|
||||
if (worldClock.now() === worldTime) records.add(VESSEL_UUID);
|
||||
page.runAll();
|
||||
await flush();
|
||||
assert.deepEqual(selected, [VESSEL_UUID]);
|
||||
assert.deepEqual(page.notices, []);
|
||||
});
|
||||
+88
-24
@@ -70,34 +70,88 @@ export function shareTrackingRestoreNotice(result) {
|
||||
: t('Shared {subject} is unavailable', { subject });
|
||||
}
|
||||
|
||||
// The not-reporting notice, one ready-made sentence per shared entity kind
|
||||
// (SHARE_VIEW_ENTITY_KINDS) for the same reason as SHARE_RESTORE_NOTICES.
|
||||
const SHARED_FIX_NOTICES = Object.freeze({
|
||||
aircraft: Object.freeze({
|
||||
lastSeen: msg(
|
||||
"The shared flight isn't reporting now — showing where it was last seen",
|
||||
),
|
||||
at: msg(
|
||||
"The shared flight isn't reporting now — showing where it was at {time}",
|
||||
),
|
||||
}),
|
||||
military_aircraft: Object.freeze({
|
||||
lastSeen: msg(
|
||||
"The shared military flight isn't reporting now — showing where it was last seen",
|
||||
),
|
||||
at: msg(
|
||||
"The shared military flight isn't reporting now — showing where it was at {time}",
|
||||
),
|
||||
}),
|
||||
vessel: Object.freeze({
|
||||
lastSeen: msg(
|
||||
"The shared vessel isn't reporting now — showing where it was last seen",
|
||||
),
|
||||
at: msg(
|
||||
"The shared vessel isn't reporting now — showing where it was at {time}",
|
||||
),
|
||||
}),
|
||||
satellite: Object.freeze({
|
||||
lastSeen: msg(
|
||||
"The shared satellite isn't reporting now — showing where it was last seen",
|
||||
),
|
||||
at: msg(
|
||||
"The shared satellite isn't reporting now — showing where it was at {time}",
|
||||
),
|
||||
}),
|
||||
});
|
||||
|
||||
// The second line names the entity by the id the link carries.
|
||||
function sharedFixDetail(entity) {
|
||||
const id = String(entity.id);
|
||||
switch (entity.kind) {
|
||||
case 'aircraft':
|
||||
case 'military_aircraft':
|
||||
// ICAO addresses read as they are written on the aircraft: upper case.
|
||||
return t('ICAO: {id}', { id: id.toUpperCase() });
|
||||
case 'satellite':
|
||||
return t('NORAD: {id}', { id });
|
||||
case 'vessel':
|
||||
return /^\d+$/.test(id)
|
||||
? t('MMSI: {id}', { id })
|
||||
: t('Vessel UUID: {id}', { id: id.toLowerCase() });
|
||||
default:
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The notice for a shared entity that is not reporting: the view shows where
|
||||
* it was when the link was made.
|
||||
* it was when the link was made. The sentence is the notice; the entity's id
|
||||
* goes on a second line under it.
|
||||
* @param {{kind: string, id: string}} entity
|
||||
* @param {number|null} observedAtMs
|
||||
* @param {number} [nowMs]
|
||||
* @returns {string}
|
||||
* @returns {{message: string, detail: string}}
|
||||
*/
|
||||
export function sharedFixNotice(entity, observedAtMs, nowMs = Date.now()) {
|
||||
// ICAO addresses read as they are written on the aircraft: upper case.
|
||||
const id =
|
||||
ENTITY_BY_KIND.get(entity.kind)?.idForm === 'hex24'
|
||||
? String(entity.id).toUpperCase()
|
||||
: String(entity.id);
|
||||
const detail = sharedFixDetail(entity);
|
||||
const notices = SHARED_FIX_NOTICES[entity.kind];
|
||||
if (!notices)
|
||||
return {
|
||||
message: t('Shared {subject} is unavailable', { subject: t('entity') }),
|
||||
detail,
|
||||
};
|
||||
if (!Number.isFinite(observedAtMs))
|
||||
return t("{id} isn't reporting now — showing where it was last seen", {
|
||||
id,
|
||||
});
|
||||
return { message: t(notices.lastSeen), detail };
|
||||
const time = formatDate(
|
||||
observedAtMs,
|
||||
nowMs - observedAtMs < DAY_MS
|
||||
? { hour: '2-digit', minute: '2-digit' }
|
||||
: { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' },
|
||||
);
|
||||
return t("{id} isn't reporting now — showing where it was at {time}", {
|
||||
id,
|
||||
time,
|
||||
});
|
||||
return { message: t(notices.at, { time }), detail };
|
||||
}
|
||||
|
||||
/** Own initial share restoration, durable layer state and restoration notices. */
|
||||
@@ -181,7 +235,7 @@ export class ShareRestoration {
|
||||
this.syncShareState();
|
||||
if (this.shareLinkManager?.rejectedShareCode)
|
||||
this._presentAfterStartupCover(
|
||||
t("This share link can't be opened"),
|
||||
{ message: t("This share link can't be opened") },
|
||||
++this._shareTrackingNoticeGeneration,
|
||||
);
|
||||
}
|
||||
@@ -411,7 +465,7 @@ export class ShareRestoration {
|
||||
this._presentAfterStartupCover(
|
||||
view.lastKnown
|
||||
? sharedFixNotice(view.entity, view.lastKnown.observedAtMs)
|
||||
: t('Shared vessel is unavailable'),
|
||||
: { message: t('Shared vessel is unavailable') },
|
||||
++this._shareTrackingNoticeGeneration,
|
||||
);
|
||||
return false;
|
||||
@@ -505,26 +559,36 @@ export class ShareRestoration {
|
||||
// A share link that knows where the entity was says so; the view is
|
||||
// already there.
|
||||
const fix = this._sharedThingFor(result)?.lastKnown;
|
||||
const message = fix
|
||||
const notice = fix
|
||||
? sharedFixNotice(
|
||||
this._initialShareState.shareView.entity,
|
||||
fix.observedAtMs,
|
||||
)
|
||||
: shareTrackingRestoreNotice(result);
|
||||
: { message: shareTrackingRestoreNotice(result) };
|
||||
if (this._resolveInitialShareRestore) {
|
||||
void this.initialRestorePromise.then(() =>
|
||||
this._presentAfterStartupCover(message, noticeGeneration),
|
||||
this._presentAfterStartupCover(notice, noticeGeneration),
|
||||
);
|
||||
return;
|
||||
}
|
||||
this._presentAfterStartupCover(message, noticeGeneration);
|
||||
this._presentAfterStartupCover(notice, noticeGeneration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a status notice once the start-up cover is gone, unless a newer
|
||||
* notice (generation) has taken its place.
|
||||
* notice (generation) has taken its place. A notice with a detail line is
|
||||
* a last-known one: the sentence over the entity's id.
|
||||
* @param {{message: string, detail?: string}} notice
|
||||
* @param {number} noticeGeneration
|
||||
*/
|
||||
_presentAfterStartupCover(message, noticeGeneration) {
|
||||
_presentAfterStartupCover(notice, noticeGeneration) {
|
||||
const show = () =>
|
||||
notice.detail
|
||||
? this.showStatus(notice.message, {
|
||||
state: 'last-known',
|
||||
detail: notice.detail,
|
||||
})
|
||||
: this.showStatus(notice.message);
|
||||
const showAfterStartupCover = () => {
|
||||
this._lifetime.frame(() => {
|
||||
if (
|
||||
@@ -540,7 +604,7 @@ export class ShareRestoration {
|
||||
!startupCover ||
|
||||
getComputedStyle(startupCover).visibility === 'hidden'
|
||||
) {
|
||||
this.showStatus(message);
|
||||
show();
|
||||
return;
|
||||
}
|
||||
let fallbackTimer = null;
|
||||
@@ -555,7 +619,7 @@ export class ShareRestoration {
|
||||
this._disposed,
|
||||
)
|
||||
)
|
||||
this.showStatus(message);
|
||||
show();
|
||||
};
|
||||
removeStartupListener = this._lifetime.listen(
|
||||
startupCover,
|
||||
|
||||
@@ -265,3 +265,64 @@ export function translateStatusLine(text) {
|
||||
.map(translateStatusPiece)
|
||||
.join(STATUS_SEPARATOR);
|
||||
}
|
||||
|
||||
/** Thousands separators out of an English number ("3,000" → 3000). */
|
||||
const englishNumber = (text) => Number(text.replace(/,/g, ''));
|
||||
|
||||
// Coverage notes (transit/queries.js, bikeshare/controls.js). Their " · " is
|
||||
// inside one sentence, so they match whole before the line is split.
|
||||
const COVERAGE_NOTE_PATTERNS = [
|
||||
[
|
||||
/^Fly below ([\d,]+) km to a covered region$/,
|
||||
([, km]) =>
|
||||
t('Fly below {km} km to a covered region', {
|
||||
km: formatNumber(englishNumber(km)),
|
||||
}),
|
||||
],
|
||||
[
|
||||
/^No feed here yet · ([\d,]+) regions available$/,
|
||||
([, regions]) => {
|
||||
const count = englishNumber(regions);
|
||||
return tn(
|
||||
count,
|
||||
'No feed here yet · {n} region available',
|
||||
'No feed here yet · {n} regions available',
|
||||
{ n: formatNumber(count) },
|
||||
);
|
||||
},
|
||||
],
|
||||
[
|
||||
/^Fly below ([\d,]+) km to a covered city$/,
|
||||
([, km]) =>
|
||||
t('Fly below {km} km to a covered city', {
|
||||
km: formatNumber(englishNumber(km)),
|
||||
}),
|
||||
],
|
||||
[
|
||||
/^No bike share here yet · ([\d,]+) systems available$/,
|
||||
([, systems]) => {
|
||||
const count = englishNumber(systems);
|
||||
return tn(
|
||||
count,
|
||||
'No bike share here yet · {n} system available',
|
||||
'No bike share here yet · {n} systems available',
|
||||
{ n: formatNumber(count) },
|
||||
);
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* A layer's status message in the UI language: its catalog entry, a coverage
|
||||
* note by its shape, or a status line translated piece by piece.
|
||||
*/
|
||||
export function translateStatusMessage(text) {
|
||||
if (typeof text !== 'string') return text;
|
||||
const known = translateKnown(text);
|
||||
if (known !== text) return known;
|
||||
for (const [pattern, format] of COVERAGE_NOTE_PATTERNS) {
|
||||
const match = pattern.exec(text);
|
||||
if (match) return format(match);
|
||||
}
|
||||
return translateStatusLine(text);
|
||||
}
|
||||
@@ -3,7 +3,11 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { setLocale, t } from '../i18n/index.js';
|
||||
import { translateFeedError, translateStatusLine } from './statusText.js';
|
||||
import {
|
||||
translateFeedError,
|
||||
translateStatusLine,
|
||||
translateStatusMessage,
|
||||
} from './statusText.js';
|
||||
|
||||
function inLocale(locale, run) {
|
||||
setLocale(locale);
|
||||
@@ -75,3 +79,55 @@ for (const locale of ['es', 'ru']) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// A layer's coverage note when no feed covers the view: one sentence with a
|
||||
// " · " in it (transit/queries.js, bikeshare/controls.js).
|
||||
const COVERAGE_NOTES = [
|
||||
'Fly below 2,850 km to a covered region',
|
||||
'No feed here yet · 16 regions available',
|
||||
'Fly below 48 km to a covered city',
|
||||
'No bike share here yet · 61 systems available',
|
||||
];
|
||||
|
||||
test('en: coverage notes show as they came', () => {
|
||||
setLocale('en');
|
||||
for (const text of COVERAGE_NOTES)
|
||||
assert.equal(translateStatusMessage(text), text);
|
||||
assert.equal(
|
||||
translateStatusMessage('No bike share here yet · 1 systems available'),
|
||||
'No bike share here yet · 1 system available',
|
||||
);
|
||||
});
|
||||
|
||||
for (const locale of ['es', 'ru', 'ja']) {
|
||||
test(`${locale}: a coverage note translates whole, numbers kept`, () => {
|
||||
inLocale(locale, () => {
|
||||
for (const text of COVERAGE_NOTES) {
|
||||
const shown = translateStatusMessage(text);
|
||||
assert.doesNotMatch(
|
||||
shown,
|
||||
/\b(Fly|below|covered|feed|bike share|available)\b/,
|
||||
shown,
|
||||
);
|
||||
const number = /[\d,]+(?= km| regions| systems)/.exec(text)[0];
|
||||
assert.ok(
|
||||
shown.replace(/[^\d]/g, '').includes(number.replace(/,/g, '')),
|
||||
shown,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test(`${locale}: a status message without a coverage note keeps its other forms`, () => {
|
||||
inLocale(locale, () => {
|
||||
assert.equal(
|
||||
translateStatusMessage('Upstream response too large'),
|
||||
t('Upstream response too large'),
|
||||
);
|
||||
assert.equal(
|
||||
translateStatusMessage('2 feeds live · 14 heard'),
|
||||
translateStatusLine('2 feeds live · 14 heard'),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1822,7 +1822,13 @@ html:not([lang='en']) #cockpit-brief-auto {
|
||||
letter-spacing: 0.13em;
|
||||
text-align: center;
|
||||
}
|
||||
.cockpit-brief-status[data-state='unavailable'] {
|
||||
/* `display: grid` above would otherwise beat the UA [hidden] rule and keep a
|
||||
stale banner over a populated list. */
|
||||
.cockpit-brief-status[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.cockpit-brief-status[data-state='unavailable'],
|
||||
.cockpit-brief-status[data-state='cached'] {
|
||||
color: #d5a863;
|
||||
}
|
||||
.cockpit-local-place {
|
||||
|
||||
@@ -156,9 +156,10 @@ body.mobile-shell[data-mobile-sheet='more'] #right-context-rail {
|
||||
|
||||
body.mobile-shell #left-panel-stack > *,
|
||||
body.mobile-shell #right-context-rail > *,
|
||||
/* Rail rules show expanded Weather and Recent Imagery by id; on phones they
|
||||
belong to the Context sheet only. */
|
||||
/* Rail rules show expanded Weather, News and Recent Imagery by id; on phones
|
||||
they belong to the Context sheet only. */
|
||||
body.mobile-shell #right-context-rail > #weather-panel,
|
||||
body.mobile-shell #right-context-rail > #news-panel,
|
||||
body.mobile-shell #right-context-rail > #recent-imagery-panel {
|
||||
display: none;
|
||||
}
|
||||
@@ -182,6 +183,9 @@ body.mobile-shell[data-mobile-sheet='context']
|
||||
body.mobile-shell[data-mobile-sheet='context']
|
||||
#right-context-rail
|
||||
> #weather-panel:not([hidden]),
|
||||
body.mobile-shell[data-mobile-sheet='context']
|
||||
#right-context-rail
|
||||
> #news-panel:not([hidden]),
|
||||
body.mobile-shell[data-mobile-sheet='context']
|
||||
#right-context-rail
|
||||
> #recent-imagery-panel:not([hidden]),
|
||||
@@ -195,6 +199,12 @@ body.mobile-shell[data-mobile-sheet='more'] #right-context-rail > #pp-toggles {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* The sheet scrolls: News keeps its height instead of shrinking under the
|
||||
panel below it, as the rail makes it do on a desktop. */
|
||||
body.mobile-shell #right-context-rail > #news-panel:not(.collapsed) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ── Dock: voice floats above the tab bar; search and presets are sheets ─ */
|
||||
body.mobile-shell #command-dock {
|
||||
/* The dock's tray rules size voice by this basis; a column makes it a height. */
|
||||
|
||||
@@ -0,0 +1,434 @@
|
||||
/* News rail panel (#news-panel): the last 24 hours as a doom-scroll of event
|
||||
cards drawn with GEV's own tokens. Colour is
|
||||
severity only (the layer sets --news-color per card); never a side. The
|
||||
rail owns placement and height; only the body scrolls. */
|
||||
.news-panel-inner {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
min-height: 0;
|
||||
max-height: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 14px;
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: var(--panel-radius);
|
||||
background: var(--glass-bg);
|
||||
backdrop-filter: blur(24px) saturate(1.4);
|
||||
-webkit-backdrop-filter: blur(24px) saturate(1.4);
|
||||
box-shadow:
|
||||
0 8px 32px rgba(0, 0, 0, 0.5),
|
||||
0 0 0 1px rgba(255, 255, 255, 0.03) inset,
|
||||
0 1px 0 rgba(255, 255, 255, 0.06) inset;
|
||||
}
|
||||
#news-panel .panel-glow {
|
||||
position: absolute;
|
||||
inset: -18px;
|
||||
background: radial-gradient(
|
||||
ellipse at center,
|
||||
rgba(0, 212, 255, 0.16) 0%,
|
||||
transparent 65%
|
||||
);
|
||||
filter: blur(16px);
|
||||
opacity: 0.25;
|
||||
pointer-events: none;
|
||||
}
|
||||
#news-panel .panel-header {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
#news-panel-count {
|
||||
color: var(--text-secondary);
|
||||
font: 9px var(--font-mono);
|
||||
}
|
||||
#news-panel-body {
|
||||
min-height: 0;
|
||||
max-height: calc(var(--right-stack-max-height, 50svh) - 64px);
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
#news-panel.collapsed #news-panel-body,
|
||||
#news-panel[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
#right-context-rail > #news-panel {
|
||||
position: relative;
|
||||
inset: auto;
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
max-height: 100%;
|
||||
pointer-events: auto;
|
||||
}
|
||||
#right-context-rail > #news-panel:not(.collapsed) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
#right-context-rail.layout-focus > #news-panel:not(.collapsed) {
|
||||
flex: 0 1 var(--right-panel-allocated-height);
|
||||
height: var(--right-panel-allocated-height);
|
||||
min-height: 0;
|
||||
max-height: var(--right-panel-allocated-height);
|
||||
}
|
||||
#right-context-rail.layout-focus
|
||||
> #news-panel:not(.collapsed)
|
||||
.news-panel-inner {
|
||||
height: 100%;
|
||||
}
|
||||
#right-context-rail[data-rail-measuring]
|
||||
> #news-panel:not(.collapsed)
|
||||
> .news-panel-inner {
|
||||
height: auto !important;
|
||||
}
|
||||
#right-context-rail #news-panel.collapsed {
|
||||
width: var(--right-display-collapsed-width);
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
#right-context-rail #news-panel.collapsed .news-panel-inner {
|
||||
height: 50px;
|
||||
min-height: 50px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
#right-context-rail #news-panel.collapsed {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
:root[data-ui-theme='cyber'] .news-panel-inner {
|
||||
border-radius: 0;
|
||||
clip-path: var(--cyber-panel-frame);
|
||||
box-shadow: var(--cyber-panel-shadow);
|
||||
}
|
||||
|
||||
.news-readout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
color: var(--text-primary);
|
||||
font: 11px/1.4 var(--font-sans);
|
||||
}
|
||||
.news-readout__window,
|
||||
.news-readout__head {
|
||||
margin: 0;
|
||||
color: var(--text-secondary);
|
||||
font: 600 9px var(--font-mono);
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
/* What Local reads, in the primary colour so it reads before the list. */
|
||||
.news-readout__area {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.news-readout__sections,
|
||||
.news-readout__chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
/* One select per row: at the rail's width two side by side cut off
|
||||
"Significant and above" (and longer translations). */
|
||||
.news-readout__filters {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 6px;
|
||||
}
|
||||
.news-filter {
|
||||
min-width: 0;
|
||||
}
|
||||
/* The window choice sits where the window label does, as narrow as its text. */
|
||||
.news-readout__window-choice {
|
||||
align-self: flex-start;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
.news-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.news-toggle input {
|
||||
accent-color: var(--accent);
|
||||
}
|
||||
.news-readout__section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.news-readout__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.news-readout__list.is-stale {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.news-readout__status,
|
||||
.news-readout__empty {
|
||||
color: var(--text-dim);
|
||||
font: 10px var(--font-mono);
|
||||
}
|
||||
/* A missing key's next step, under what it holds back. */
|
||||
.news-readout__empty .ui-empty__hint {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.news-readout__footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.news-card {
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 6px;
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
.news-card:hover,
|
||||
.news-card.is-open {
|
||||
border-color: var(--glass-border-hover);
|
||||
background: rgba(0, 212, 255, 0.06);
|
||||
}
|
||||
.news-card.is-open {
|
||||
border-color: rgba(0, 212, 255, 0.45);
|
||||
}
|
||||
.news-card.is-unmapped .news-card__title {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.news-card__main {
|
||||
display: grid;
|
||||
grid-template-columns: 96px 1fr;
|
||||
column-gap: 8px;
|
||||
row-gap: 3px;
|
||||
width: 100%;
|
||||
padding: 6px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
}
|
||||
.news-card__main > :not(.news-card__thumb) {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.news-card__thumb ~ * {
|
||||
grid-column: 2 !important;
|
||||
}
|
||||
.news-card__thumb {
|
||||
position: relative;
|
||||
grid-row: 1 / span 5;
|
||||
width: 96px;
|
||||
height: 64px;
|
||||
overflow: hidden;
|
||||
border-radius: 4px;
|
||||
background: var(--bg-dark);
|
||||
}
|
||||
.news-card__thumb img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
/* A clip waits behind its picture; the open card plays it. */
|
||||
.news-card__play {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: var(--text-primary);
|
||||
font-size: 14px;
|
||||
text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
|
||||
pointer-events: none;
|
||||
}
|
||||
.news-card__clip {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: 220px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 4px;
|
||||
background: #000;
|
||||
}
|
||||
.news-card__credit {
|
||||
position: absolute;
|
||||
inset-inline-end: 0;
|
||||
bottom: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
padding: 0 4px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
color: var(--text-primary);
|
||||
font-size: 8px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.news-card__title {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.news-card__note,
|
||||
.news-card__sides {
|
||||
color: var(--text-secondary);
|
||||
font-size: 10px;
|
||||
}
|
||||
.news-card__meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
color: var(--text-secondary);
|
||||
font: 10px var(--font-mono);
|
||||
}
|
||||
/* The globe's marker in small: a dark disc, rim and icon in the severity
|
||||
colour (sprites.js). */
|
||||
.news-card__marker {
|
||||
flex: none;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
box-sizing: border-box;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border: 1.5px solid var(--news-color);
|
||||
border-radius: 50%;
|
||||
background: var(--bg-dark);
|
||||
}
|
||||
.news-card__marker svg {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
fill: none;
|
||||
stroke: var(--news-color);
|
||||
stroke-width: 1.8;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.news-card__marker.solid svg {
|
||||
fill: var(--news-color);
|
||||
stroke: none;
|
||||
}
|
||||
/* The service a report came through: credited, and kept quiet. */
|
||||
.news-card__via {
|
||||
color: var(--text-dim);
|
||||
font: 9px var(--font-mono);
|
||||
}
|
||||
.news-card__severity {
|
||||
flex: none;
|
||||
color: var(--news-color);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.news-card__chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
/* GEV's read-only badge (status-badge.css), neutral unless attested. */
|
||||
.news-chip {
|
||||
padding: 2px 7px;
|
||||
border: 1px solid var(--glass-border-hover);
|
||||
border-radius: 999px;
|
||||
color: var(--text-secondary);
|
||||
font: 8px var(--font-mono);
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.news-chip--official,
|
||||
.news-chip--confirmed {
|
||||
border-color: rgba(0, 212, 255, 0.32);
|
||||
background: rgba(0, 212, 255, 0.09);
|
||||
color: #9defff;
|
||||
}
|
||||
.news-chip--claimed {
|
||||
border-style: dashed;
|
||||
}
|
||||
.news-card__open {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 0 8px 8px;
|
||||
}
|
||||
.news-card__original,
|
||||
.news-card__snippet {
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
font-size: 11px;
|
||||
}
|
||||
.news-card__original {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.news-card__others {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
font-size: 10px;
|
||||
}
|
||||
.news-card__others a,
|
||||
.news-card__link {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.news-card__others a:hover,
|
||||
.news-card__link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.news-card__side {
|
||||
margin-inline-end: 6px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.news-card__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
font: 10px var(--font-mono);
|
||||
}
|
||||
.news-legend {
|
||||
color: var(--text-secondary);
|
||||
font-size: 10px;
|
||||
}
|
||||
.news-legend summary {
|
||||
cursor: pointer;
|
||||
}
|
||||
.news-legend p {
|
||||
margin: 4px 0;
|
||||
}
|
||||
.news-legend__severity {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 10px;
|
||||
margin: 4px 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.news-legend__severity li::before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
margin-inline-end: 4px;
|
||||
border-radius: 50%;
|
||||
background: var(--news-color);
|
||||
}
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.news-card,
|
||||
.news-readout__list {
|
||||
transition:
|
||||
background var(--transition-fast),
|
||||
border-color var(--transition-fast),
|
||||
opacity var(--transition-fast);
|
||||
}
|
||||
}
|
||||
@@ -360,6 +360,31 @@ html:not([lang='en']) .radio-transport button {
|
||||
margin: 0 0 7px;
|
||||
color: #fff;
|
||||
}
|
||||
.military-awareness-photo {
|
||||
display: block;
|
||||
margin: 0 0 8px;
|
||||
color: #a9b7c7;
|
||||
text-decoration: none;
|
||||
}
|
||||
.military-awareness-photo img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border: 1px solid rgba(98, 181, 255, 0.34);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.military-awareness-photo small {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
}
|
||||
.military-awareness-photo:hover small,
|
||||
.military-awareness-photo:focus-visible small {
|
||||
color: #fff;
|
||||
}
|
||||
.military-awareness-photo:focus-visible {
|
||||
outline: 1px solid rgba(127, 200, 255, 0.85);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.military-awareness-controls {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
@@ -1067,6 +1092,43 @@ html:not([lang='en']) .data-row-list-text {
|
||||
letter-spacing: 0.8px;
|
||||
}
|
||||
|
||||
/* Optional start and end pickers on one line (e.g. a layer's period). The
|
||||
shared field style paints each select. */
|
||||
.data-toggle-range {
|
||||
flex-basis: 100%;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.data-toggle-range-ends {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.data-toggle-range-end {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.data-toggle-range-caption {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 8px;
|
||||
letter-spacing: 1.2px;
|
||||
color: var(--text-dim);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.data-toggle-range-select {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 24px;
|
||||
font: 10px/1 var(--font-mono);
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
|
||||
+31
-9
@@ -1,13 +1,15 @@
|
||||
/* Right-to-left languages (Arabic). The chrome mirrors through logical
|
||||
properties in the component sheets (inset-inline-*, margin-inline-*); this
|
||||
sheet holds only what logical properties cannot express. */
|
||||
/* Right-to-left languages (Arabic, Hebrew). The chrome mirrors through
|
||||
logical properties in the component sheets (inset-inline-*,
|
||||
margin-inline-*); this sheet holds only what logical properties cannot
|
||||
express. */
|
||||
|
||||
/* Arabic letters join: letter-spacing tears every word into separate glyphs.
|
||||
Hebrew letters do not join, but tracking only spaces their words out.
|
||||
Latin marked translate="no" and the intel HUD's Latin telemetry keep their
|
||||
tracking; the HUD's translated lines are released below. Unlike cjk.css, a
|
||||
container that merely holds a translate="no" span is not spared: its own
|
||||
Arabic text would come apart. */
|
||||
html:lang(ar)
|
||||
text would come apart. */
|
||||
html:is(:lang(ar), :lang(he))
|
||||
body
|
||||
:not(#intel-hud, #intel-hud *, [translate='no'], [translate='no'] *) {
|
||||
letter-spacing: 0 !important;
|
||||
@@ -30,8 +32,7 @@ html[dir='rtl'] #intel-hud :is(.hud-mode, .hud-summary-label, .hud-summary) {
|
||||
letter apart. Noto Sans Arabic (loaded with the other Google fonts; its
|
||||
files download only when the page shows Arabic) leads the mono stack, so
|
||||
the spaces between Arabic words come from it too and not from the
|
||||
fixed-pitch Latin face. The intel and cockpit HUDs keep JetBrains Mono for
|
||||
their Latin telemetry and column-aligned digits. */
|
||||
fixed-pitch Latin face. */
|
||||
html:lang(ar) {
|
||||
--font-mono:
|
||||
'Noto Sans Arabic', 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Geeza Pro',
|
||||
@@ -40,9 +41,23 @@ html:lang(ar) {
|
||||
'Inter', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, 'Geeza Pro',
|
||||
Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
/* Hebrew: JetBrains Mono and Inter also lack Hebrew glyphs. Noto Sans Hebrew
|
||||
(loaded with the other Google fonts; its files download only when the page
|
||||
shows Hebrew) leads the stack so the body text keeps one proportional
|
||||
Hebrew face across platforms. */
|
||||
html:lang(he) {
|
||||
--font-mono:
|
||||
'Noto Sans Hebrew', 'JetBrains Mono', 'SF Mono', 'Fira Code', Tahoma,
|
||||
monospace;
|
||||
--font-sans:
|
||||
'Inter', 'Noto Sans Hebrew', -apple-system, BlinkMacSystemFont, Tahoma,
|
||||
sans-serif;
|
||||
}
|
||||
/* The Global Context lines and their buttons set ui-monospace through the
|
||||
`font` shorthand; route them through the Arabic-aware stack too. */
|
||||
html:lang(ar)
|
||||
`font` shorthand; in both RTL languages the words come from the page's
|
||||
own font stack. */
|
||||
html:is(:lang(ar), :lang(he))
|
||||
:is(
|
||||
#military-awareness-panel,
|
||||
.military-awareness-controls button,
|
||||
@@ -54,11 +69,18 @@ html:lang(ar)
|
||||
) {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
/* The intel and cockpit HUDs keep JetBrains Mono leading for their Latin
|
||||
telemetry and column-aligned digits, with the language's face behind it. */
|
||||
html:lang(ar) :is(#intel-hud, #cockpit-hud) {
|
||||
--font-mono:
|
||||
'JetBrains Mono', 'SF Mono', 'Fira Code', 'Noto Sans Arabic', 'Geeza Pro',
|
||||
Tahoma, monospace;
|
||||
}
|
||||
html:lang(he) :is(#intel-hud, #cockpit-hud) {
|
||||
--font-mono:
|
||||
'JetBrains Mono', 'SF Mono', 'Fira Code', 'Noto Sans Hebrew', Tahoma,
|
||||
monospace;
|
||||
}
|
||||
|
||||
/* The Display/Context rail moves to the left edge. It keeps a physical
|
||||
`right` in layers.css because the attribution-clearance model
|
||||
|
||||
@@ -166,6 +166,24 @@ html:not([lang='en']) #global-loading-detail {
|
||||
#global-loading-status[data-state='cancelled'] #global-loading-detail {
|
||||
color: #ffd488;
|
||||
}
|
||||
/* A last-known notice is a sentence with the entity's id on a second line;
|
||||
the id is shown whole (a vessel UUID is 36 characters). */
|
||||
#global-loading-status[data-state='last-known'] {
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
border-color: rgba(255, 212, 136, 0.55);
|
||||
text-align: center;
|
||||
}
|
||||
#global-loading-status[data-state='last-known'] #global-loading-label {
|
||||
color: #ffd488;
|
||||
}
|
||||
#global-loading-status[data-state='last-known'] #global-loading-detail {
|
||||
max-width: none;
|
||||
color: rgba(255, 228, 176, 0.82);
|
||||
letter-spacing: 1.2px;
|
||||
text-align: center;
|
||||
text-transform: none;
|
||||
}
|
||||
#global-loading-status[data-state='acquiring'] {
|
||||
border-color: rgba(0, 212, 255, 0.42);
|
||||
box-shadow:
|
||||
|
||||
@@ -36,6 +36,10 @@ const sceneRuntime = computed(() => scenePanel.value?.runtime ?? '');
|
||||
<template #badge><span id="weather-panel-count" :aria-label="t('Active weather products')">0</span></template>
|
||||
<div id="weather-panel-body" class="ui-scroll" data-rail-scroller></div>
|
||||
</RailPanel>
|
||||
<RailPanel id="news-panel" hidden :title="t('NEWS')" sideways rail-scroller>
|
||||
<template #badge><span id="news-panel-count" :aria-label="t('News items in the feed')">0</span></template>
|
||||
<div id="news-panel-body" class="ui-scroll" data-rail-scroller></div>
|
||||
</RailPanel>
|
||||
<RailPanel id="recent-imagery-panel" hidden :title="t('RECENT IMAGERY')" sideways rail-scroller>
|
||||
<template #badge><span id="recent-imagery-panel-count" :aria-label="t('Imagery days in the box')"></span></template>
|
||||
<div id="recent-imagery-panel-body" class="ui-scroll" data-rail-scroller></div>
|
||||
|
||||
@@ -11,6 +11,13 @@ import AwarenessNames from './AwarenessNames.vue';
|
||||
const { awareness: view, awarenessLayer: layer } = storeToRefs(useContextStore());
|
||||
const user = { origin: 'user' };
|
||||
const root = ref(null);
|
||||
// A photo whose image failed to load stays hidden until another one arrives.
|
||||
// The failing image's own src is recorded, so a late error from a previous
|
||||
// photo never hides the current one.
|
||||
const failedPhoto = ref('');
|
||||
const fail = (event) => {
|
||||
failedPhoto.value = event.target.getAttribute('src');
|
||||
};
|
||||
|
||||
// A live repaint keeps focus on the same control by identity: browsers drop
|
||||
// focus from a node Vue moves, removes or disables, so the control is found
|
||||
@@ -52,6 +59,10 @@ onUpdated(() => {
|
||||
</div>
|
||||
<template v-else-if="view.kind === 'results'">
|
||||
<div class="military-awareness-subject">{{ view.subject }}</div>
|
||||
<a v-if="view.photo && view.photo.src !== failedPhoto" class="military-awareness-photo" :href="view.photo.link" target="_blank" rel="noopener">
|
||||
<img :src="view.photo.src" :width="view.photo.width ?? undefined" :height="view.photo.height ?? undefined" alt="" @error="fail" />
|
||||
<small v-if="view.photo.credit">{{ view.photo.credit }}</small>
|
||||
</a>
|
||||
<AwarenessNames v-if="view.subjectNames" :names="view.subjectNames" />
|
||||
<div class="military-awareness-controls" role="group" :aria-label="view.navigation.label">
|
||||
<button type="button" data-awareness-action="previous" :title="view.navigation.previous.title" :disabled="view.navigation.previous.disabled" @click="layer?.navigatePrevious(user)">{{ view.navigation.previous.text }}</button>
|
||||
|
||||
@@ -166,7 +166,7 @@ const frameStyle = (panel) => ({
|
||||
<button class="gev-voice-error-dismiss" type="button" @click="controls?.dismissError()">{{ t('DISMISS') }}</button>
|
||||
</div>
|
||||
<div id="gev-voice-error-detail">{{ view.error.text }}</div>
|
||||
<div class="gev-voice-error-hint" :hidden="view.error.typed">{{ t('Check microphone permission and network access, then try again.') }}</div>
|
||||
<div class="gev-voice-error-hint" :hidden="view.error.typed || view.error.hint === false">{{ t('Check microphone permission and network access, then try again.') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user